Reputation: 81
I am creating a PayPal Checkout button, is there any way to auto fill the billing address in the Debit or Credit Card form?
My current code:
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: '1'
}
}],
});
}
}).render('#paypal-button-container');
Upvotes: 6
Views: 2282
Reputation: 30457
The way to do this used to involve a payer
object, and still works:
paypal.Buttons({
enableStandardCardFields: true,
createOrder: function(data, actions) {
return actions.order.create({
intent: 'CAPTURE',
payer: {
name: {
given_name: "Firstname",
surname: "Lastname"
},
address: {
address_line_1: '123 ABC Street',
address_line_2: 'Apt 2',
admin_area_2: 'San Jose',
admin_area_1: 'CA',
postal_code: '95121',
country_code: 'US'
},
email_address: "[email protected]",
phone: {
phone_type: "MOBILE",
phone_number: {
national_number: "14082508100"
}
}
},
purchase_units: [
{
amount: {
value: '15.00',
currency_code: 'USD'
},
shipping: {
address: {
address_line_1: '2211 N First Street',
address_line_2: 'Building 17',
admin_area_2: 'San Jose',
admin_area_1: 'CA',
postal_code: '95131',
country_code: 'US'
}
},
}
]
});
}
}).render("body");
That payer
parameter of the v2/checkout/orders API has been deprecated recently, though; seems the replacements will be in payment_source.paypal
Upvotes: 2