How to fill billing fields?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Using the standard checkout, how can I pre fill the billing fields ?
My code :
<script src="https://www.paypal.com/sdk/js?client-id=MY_ID¤cy=EUR"></script>
<div id="paypal-button-container"></div>
<script>
showSpinner();
const price = 123.45;
const customId = 'abcdef';
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
currency_code: "EUR",
value: price,
},
// invoice_id: invoiceId,
custom_id: customId,
}]
});
},
onApprove: function(data, actions) {
console.log('ICE ::: onApprove ::: data: ', data)
showSpinner();
const { facilitatorAccessToken, orderID, payerID } = data
// Here call server
},
onCancel: function (data) {
console.log('ICE ::: onCancel ::: data: ', data)
},
onError: function (err) {
console.log('ICE ::: onError ::: data: ', err)
},
onClick: function() {
console.log('ICE ::: onClick')
},
onInit: function(data, actions) {
console.log('ICE ::: onInit ::: data: ', data)
hideSpinner();
}
}).render('#paypal-button-container');
</script>
It gives me that :
1) As you can see (right column) I allready collected the customer's address on a previous page. So I do not really need to collect that fields again. Can I simply hide the address inputs? Or can I pre fill the inputs with the data I collected before?
2) Can I remove the delivery checkbox? I do not want the customer to specify and other address for the delivery...
- Labels:
-
PayPal HTML Buttons
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @thierryler ,
One way to prepopulate the billing fields is to add the payer -> address object
E.g.
paypal.Buttons({
// Sets up the transaction when a payment button is clicked
createOrder: function(data, actions) {
return actions.order.create({
payer: {
birth_date: '2021-01-01',
email_address: 'customer_at_emailaddress',
phone: {
phone_number: {
national_number[Removed. Phone #s not permitted],
}
},
name: {
given_name: 'Bub',
surname: 'Customer',
},
address: {
address_line_1: '33 ABC Street',
address_line_2: 'Apt 3',
admin_area_2: 'San Jose',
admin_area_1: 'CA',
postal_code: '95121',
country_code: 'US',
},
},
purchase_units: [{
amount: {
value: '33.00' // Can reference variables or functions. Example: `value: document.getElementById('...').value`
}
}]
});
},
Thank you.
Powered by Custom Software : NexWebSites.com
PayPal Developers

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- Cannot create developer account from invitation link in Braintree Client-side Integration (JS, iOS, Android SDKs)
- Why does PayPal make it difficult to send an item to a different shipping address from billing? in PayPal Upgrade Community
- Show all billing address fields when hiding shipping address fields in PayPal Payments Standard
- Enable PayPal Billing Address Request on sandbox account in REST APIs
- Is it possible to set multiple billing agreements in SetExpressCheckout? in NVP/SOAP APIs