Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set billing or shipping address using PayPal PHP REST API?

I am using "paypal" payment method:

$payer = new Payer();
$payer->setPaymentMethod('paypal');

I have tried the following, but it is not setting the address:

$addr = new Address();
$addr->setLine1('34/1');
$addr->setLine2('xxx');
$addr->setCity('xxxxxxx');
$addr->setCountry_code('US');
$addr->setPostal_code('43210');
$addr->setState('OH');
like image 882
vishnu Avatar asked Oct 03 '13 10:10

vishnu


1 Answers

  1. Create ShippingAddress object.
  2. ShippingAddress extends Address object. Therefore, set all of the Address object properties and ShippingAddress specific properties (RecipientName).
  3. Assign the created ShippingAddress to the ItemList using setShippingAddress method:
$shipping_address = new ShippingAddress();

$shipping_address->setCity('City');
$shipping_address->setCountryCode('AR');
$shipping_address->setPostalCode('200');
$shipping_address->setLine1('Adress Line1');
$shipping_address->setState('State');
$shipping_address->setRecipientName('Recipient Name');

$itemList->setShippingAddress($shipping_address);
like image 54
nicomonjelat Avatar answered Sep 20 '22 13:09

nicomonjelat