PayPal Smart button: display credit card fields

alexci
New Community Member

Dear all,

 

I am trying to display pre-filled credit card fields, however, then I define the payer's information in the script, the fields don't get displayed.

Please let me know if you know how to fix this.

 

Thanks!

 

Aleksandar

 

 

Here is the code I am using:

 

<script>

paypal.Buttons({
commit: false,
createOrder: function(data, actions) {
// This function sets up the details of the transaction, including the amount and line item details
return actions.order.create({
payer: {
name: {
given_name: "PayPal",
surname: "Customer"
},
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: "emailatdomain.com",
phone: {
phone_type: "MOBILE",
phone_number: {
national_number: "14082508100"
}
}
},

purchase_units: [{
amount: { value: '20' }
}],


application_context : {
shipping_preference: "NO_SHIPPING"
},


});

},
onCancel: function (data) {
// Show a cancel page, or return to cart
},
onApprove: function(data, actions) {
// This function captures the funds from the transaction
return actions.order.capture().then(function(details) {
// This function shows a transaction success message to your buyer
alert('Thanks for your purchase!');
});
},

style: {
layout: 'vertical',
color: 'black',
shape: 'rect'
}

}).render('#paypal-button-container');

 

</script>

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.