Smart Buttons - Include Item details
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have achieved this button script so far (below), but need to add an item ID number and description (or name) of the item which will be included in the order details for myself and the customer's receipt. I have tried various things but none work. Can anyone help please?
<script>
paypal.Buttons({
style: {
shape: 'rect',
color: 'blue',
layout: 'vertical',
label: 'pay',
},
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: '18.00',
currency: 'GBP',
}
}],
application_context: {
shipping_preference: 'NO_SHIPPING'
}
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
alert('Thank you ' + details.payer.name.given_name + ', please click OK to continue'),
window.location.href = 'https://www.my-domain-name.com/thankyou';
});
}
}).render('#paypal-button-container'); // Display payment options on your web page
</script>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It looks like you're missing your Client ID?
Here's a copy of mine as an example:
<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=AZXJHo2Qp14Diln5yFwIbYGV7gydOBtTzLJVX0ow2yzANTUbqSAgCdFI4jEV..." data-sdk-integration-source="button-factory"></script>
<script>
function initPayPalButton() {
paypal.Buttons({
style: {
shape: 'pill',
color: 'gold',
layout: 'vertical',
label: 'buynow',
},
Also, your original question as to the product information, here's a copy of mine as an example:
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{"description":"Cartoons","amount":{"currency_code":"GBP","value":3}}]
});
},
This may be of help, I'm no techie, but sometimes examples can help? Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @SteveStuartDJ ,
Hoping you can assist me as well.
The problem I am having is now that I have installed the smart buttons; I am no longer receiving notifications to my shopify store. The payment is going to my PayPal but I am then having to email the customer to find out what they ordered because of the different variants.
I believe this is the section that is messed up 😞
// Finalize the transaction
onApprove: function(data, actions) {
return actions.order.capture().then(function(orderData) {
// Successful capture! For demo purposes:
console.log('Capture result', orderData, JSON.stringify(orderData, null, 2));
var transaction = orderData.purchase_units[0].payments.captures[0];
alert('Transaction '+ transaction.status + ': ' + transaction.id + '\n\nSee console for all available details');
// Replace the above to 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');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Further to Steve's reply, I did a little experimenting with inverted commas "" or not, and this did work, so kudos to Steve:
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
description:"Cartoons",
amount: {
value: '18.00',
currency: 'GBP',
}
}]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- Change the button from Sandbox to Production in REST APIs
- Need help to integrate PayPal Checkout Advanced (PPCP) with WooCommerce in PayPal Upgrade Community
- Show all billing address fields when hiding shipping address fields in PayPal Payments Standard
- When I do PayPal capture Order, I keep on getting Invalid Request Connection in REST APIs
- Seller "Buy now" button - unable to edit a button in PayPal Payments Standard