如何使用PayPal PHP REST API设置账单或送货地址?

时间:2013-10-03 10:11:13

标签: paypal paypal-rest-sdk

我使用“paypal”付款方式:

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

我尝试过以下操作,但没有设置地址:

$addr = new Address();
$addr->setLine1('34/1');
$addr->setLine2('xxx');
$addr->setCity('xxxxxxx');
$addr->setCountry_code('US');
$addr->setPostal_code('43210');
$addr->setState('OH');

1 个答案:

答案 0 :(得分:9)

  1. 创建ShippingAddress对象。
  2. ShippingAddress扩展了Address个对象。因此,请设置所有Address对象属性和ShippingAddress特定属性(RecipientName)。
  3. 使用ShippingAddress方法将创建的setShippingAddress分配给ItemList
  4. $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);