I try to integrate my page with paypal, and I decide to use Client Side REST, theoretical all is correct but i need add some extra variables like order number or payment description, I want ask if it's possible to do this and haw and if its possible to get back full name of country not only country code document.querySelector('#country').innerText = shipping.country_code; My full code: <!DOCTYPE html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
</head>
<body>
<div id="paypal-button-container"></div> <div id="confirm" class="hidden"> <div>Ship to:</div> <div><span id="recipient"></span>, <span id="line1"></span>, <span id="city"></span></div> <div><span id="state"></span>, <span id="zip"></span>, <span id="country"></span></div> <button id="confirmButton">Complete Payment</button> </div> <div id="thanks" class="hidden"> Thanks, <span id="thanksname"></span>! </div>
<script>
paypal.Button.render({
env: 'sandbox', // sandbox | production
client: {
sandbox: 'some id',
production: ''
},
payment: function(data, actions) {
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: '0.01', currency: 'USD' }
}
]
}
});
},
// Wait for the payment to be authorized by the customer
onAuthorize: function(data, actions) { // Get the payment details return actions.payment.get().then(function(data) { // Display the payment details and a confirmation button var shipping = data.payer.payer_info.shipping_address; document.querySelector('#recipient').innerText = shipping.recipient_name; document.querySelector('#line1').innerText = shipping.line1; document.querySelector('#city').innerText = shipping.city; document.querySelector('#state').innerText = shipping.state; document.querySelector('#zip').innerText = shipping.postal_code; document.querySelector('#country').innerText = shipping.country_code; document.querySelector('#paypal-button-container').style.display = 'none'; document.querySelector('#confirm').style.display = 'block'; // Listen for click on confirm button document.querySelector('#confirmButton').addEventListener('click', function() { // Disable the button and show a loading message document.querySelector('#confirm').innerText = 'Loading...'; document.querySelector('#confirm').disabled = true; // Execute the payment return actions.payment.execute().then(function() { // Show a thank-you note document.querySelector('#thanksname').innerText = shipping.recipient_name; document.querySelector('#confirm').style.display = 'none'; document.querySelector('#thanks').style.display = 'block'; }); }); }); } }, '#paypal-button-container');
</script>
</body>
... View more