3
votes

I am using the Paypal Rest API. I have succesfully managed to submit the shipping address via the ItemList. However I can't manage to submit the billing address, so it will be prefilled for users without a Paypal Account. The billing address is always filled with the shipping address.

I have tried it according to the documentation here with the address object but I can't get it to work:

"Base Address object used as billing address in a payment or extended for Shipping Address." https://developer.paypal.com/docs/api/#address-object

$billing_address = new Address();
$billing_address->setLine1('Street Name');
$billing_address->setCity('city name');
$billing_address->setPostalCode('12345');
$billing_address->setCountryCode('DE');

Then I pass the $billing_address into the $payer_info along with the other payer information.

$payer_info->setBillingAddress($billing_address);
$payer->setPayer_info($payer_info) ;

However it seems that is not the correct way. How do I pass the billing address to Paypal.

1
What is the payment method you are using, is it PayPal payment method? Are you able to see any error? Can you please share the above info? Please note that you cannot set billing address when using 'PayPal' as the payment method. - Mithun
I am trying to do the same thing, only has error if i try and set payer info email address. PayPal seems to just clobber the address with what ever the Payer's shipping address is set to. - Chris Seufert

1 Answers

0
votes

If you're attempting to submit a credit card payment to the API, you'd add the $billing_address object to the $card object:

<?php $billing_address = new Address();
$billing_address->setLine1('Street Name');
$billing_address->setCity('city name');
$billing_address->setState('city name');
$billing_address->setPostalCode('12345');
$billing_address->setCountryCode('US');

$card = new CreditCard();
$card->setType("visa")
    ->setNumber("4148529247832259")
    ->setExpireMonth("11")
    ->setExpireYear("2019")
    ->setCvv2("012")
    ->setFirstName("Joe")
    ->setLastName("Shopper")
    ->setBillingAddress($billing_address); ?>

I'm not 100% on where you'd add it to for a PayPal payment, however.