Smart payment buttons - standard card fields

lucaAnto1981
Contributor
Contributor

Hello,

 

I'm implementing a paypal payment process using the smart payment buttons.

When I start the payment process I already have the payer's informations (name, address, phone number) but I can't get the standard card fields filled in with those informations.

I pass to paypal all the informations in the actions.order.create function as in the following sample page code:

 

<!DOCTYPE html>
<html>

<head>

<meta http-equiv="Content-Language" content="it">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="viewport" content="width=device-width, initial-scale=1"> <!-- Ensures optimal rendering on mobile devices. -->
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <!-- Optimal Internet Explorer compatibility -->

</head>

<body>
<!-- PAYPAL SCRIPT SECTION-->
<script src="https://www.paypal.com/sdk/js?client-id=Ab-iApjF2wHobvZCPkBsv2ecGsXu_VlMfh9GMLvwsIRJ6ToHkjaOoxinUN0L...>
<!-- END PAYPAL SECTION -->


<div id="paypal-button-container"></div>


<script>
paypal.Buttons({
locale: 'it_IT',
style: {
layout: 'vertical',
color: 'gold',
shape: 'pill',
label: 'pay',
height: 40
},
enableStandardCardFields: true,
createOrder: function(data, actions) {
// This function sets up the details of the transaction, including the amount and line item details.
return actions.order.create({
purchase_units: [{
amount: {
currency_code: "EUR",
description: 'Event description',
value: '10'
},
intent: 'CAPTURE',
payer: {
name: {
given_name: "PayPal",
surname: "Customer"
},
address: {
address_line_1: ' <removed>',
address_line_2: ' <removed>',
admin_area_2: ' <removed>',
admin_area_1: 'CA',
postal_code: ' <removed>',
country_code: 'US'
},
email_address: "mail_adress",
phone: {
phone_type: "MOBILE",
phone_number: {
national_number: "<removed>"
}
}
}
}]
});
},
onApprove: function(data, actions) {
// This function captures the funds from the transaction.
return actions.order.capture().then(function(details) {
// Go to the payment confirmation page
var url="www.google.it";
window.location = url;
});
}
}).render('#paypal-button-container');
</script>
</body>
</html>

 

Someone may help me?

 

Many thanks,

Luca

 

 

 

Login to Me Too
1 REPLY 1

CaliPhotography
Contributor
Contributor

I'm using Fat Fre PHP, so that's what the {{ @...}} fields are getting data from.

 

createOrder: function(data, actions) {
return actions.order.create({
payer: {
name: {
given_name: '{{ <removed>.first }}',
surname: '{{ <removed>.last }}'
},
//address: {
//address_line_1: ' <removed>',
//address_line_2: ' <removed>',
//admin_area_2: ' <removed>',
//admin_area_1: 'CA',
//postal_code: ' <removed>',
//country_code: 'US'
//},
email_address: '{{ <removed> }}',
phone: {
phone_type: 'MOBILE',
phone_number: {
national_number: '{{ <removed> }}'
}
}
},
purchase_units: [{
amount: {
value: '{{ <removed> total }}',
currency_code: 'USD'
},
shipping: {
address: {
address_line_1: ' <removed>',
address_line_2: ' <removed>',
admin_area_2: ' <removed>',
admin_area_1: 'CA',
postal_code: ' <removed>',
country_code: 'US'
}
},
}],
"application_context" : {
"shipping_preference":"NO_SHIPPING"
}
});
},

Login to Me Too

Haven't Found your Answer?

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