PayPal smart buttons code missing product details

fleurlovin
Contributor
Contributor

Hello, I Added the PayPal smart buttons code to my cart page at Shopify and everything works perfectly! but when I made the test I noted important details for the products are missing such as product titles, sizes, colors, and quantity, and without these details, I don't know what the customer bought from my store! can anyone help me to modify the code I will be soo appreciate it.

<style>
#checkout {
display: none;
}
</style>
<div id="smart-button-container">
<div style="text-align: center;">
<div id="paypal-button-container"></div>
</div>
</div>
<script src="https://www.paypal.com/sdk/js?client-id=AbFb9fGidItG9-SAHbrS7AtWtR81-F8itNxaNZoRMQVCJnVoIksREANlykEC..." data-sdk-integration-source="button-factory"></script>
<script>
function initPayPalButton() {
paypal.Buttons({
style: {
shape: 'rect',
color: 'gold',
layout: 'vertical',
label: 'paypal',

},

createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
"amount": {
"currency_code": "USD",
"value": "{{ cart.total_price | money_without_currency }}"
}
}]
});
},

onApprove: function(data, actions) {
return actions.order.capture().then(function(orderData) {

// Full available details
console.log('Capture result', orderData, JSON.stringify(orderData, null, 2));

// Show a success message within this page, e.g.
const element = document.getElementById('paypal-button-container');
element.innerHTML = '';
element.innerHTML = '<h3>Thank you for your payment!</h3>';

// Or go to another URL: actions.redirect('thank_you.html');

});
},

onError: function(err) {
console.log(err);
}
}).render('#paypal-button-container');
}
initPayPalButton();
</script>




Login to Me Too
1 REPLY 1

MTS_Chiranjeevi
Moderator
Moderator

Good day @fleurlovin,

 

Thank you for posting to the PayPal community.

 

Merchants should pass the item details(name/title, quantity, category etc.) in the Create Order API call, based on the requirement.

 

https://developer.paypal.com/docs/api/orders/v2/#definition-purchase_unit_request 

 

https://developer.paypal.com/docs/api/orders/v2/#orders_create 

 

Sincerely,

Chiranjeevi

PayPal/Braintree MTS

 

If this post or any other was helpful, please enrich the community by giving kudos or accepting it as a solution.

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.