Add list of items to standard button for payment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feels like it should be possible to create an order with multiple items using standard buttons generated on the Paypal site. Clearly I'm missing something and would appreciate any assistance or information. Below is my page source code and the error message received when pressing the Pay button.
<div id="paypal-button-container"></div>
<!-- Include the PayPal JavaScript SDK -->
<script src="https://www.paypal.com/sdk/js?client-id=MY_SANDBOX_CLIENT_ID&enable-funding=venmo¤cy=USD&debug..."></script>
<script>
// Render the PayPal button into #paypal-button-container
paypal.Buttons({
style: {
color: 'blue',
shape: 'rect',
label: 'pay',
},
// Sets up the transaction when a payment button is clicked
createOrder: function(data, actions) {
return actions.order.create({
intent: 'CAPTURE', //capture payment from buyer
payer: {
name: {
given_name: "John",
surname: "Doe"
},
address: {
address_line_1: "<removed>",
address_line_2: "Apt 2",
admin_area_2: "Sacramento",
admin_area_1: "CA",
postal_code: "<removed>",
country_code: "US"
},
email_address: "sb_test_email_address",
phone: {
phone_type: "MOBILE",
phone_number: {
national_number[Removed. Phone #s not permitted]
}
}
},
purchase_units: [{
description: "My Purchases",
amount: {
currency_code: "USD",
value: "12.00", // Purchase Total
breakdown: {
item_total: {
currency_code: 'USD',
value: "12.00",
},
shipping: {
currency_code: 'USD',
value: "0",
},
tax_total: {
currency_code: 'USD',
value: "0",
}
}
},
items: [{
name: "Item 1",
unit_amount: {
currency_code: 'USD',
value: "6.00",
},
quantity: "1",
name: "Item 2",
unit_amount: {
currency_code: 'USD',
value: "6.00",
},
quantity: "1"
}]
}]
});
},
// Finalize the transaction after payer approval
onApprove: function(data, actions) {
return actions.order.capture().then(function(orderData) {
window.location.href = "Thanks.html";
});
},
onCancel: function(data) {
//payment cancelled
alert("Payment Cancelled");
},
onError: function(err) {
alert("Error Message: " + err);
}
}).render('#paypal-button-container');
</script>
</div>
- Labels:
-
PayPal HTML Buttons
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- recurring payments when price maybe changed and price have 2 decimal point in REST APIs
- Add Others data in SDKs
- Button in PayPal Payments Standard
- Shipping options are not appearing in my cart through link or button. in PayPal Payments Standard
- Need help to integrate PayPal Checkout with Ecwid in PayPal Upgrade Community