Problem with creating an order with tax
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am attempting to create an order with items that have tax but the following code is causing an exception. I can't see any useful error messages so can anyone spot what I am doing wrong. There seem to be very few examples out there apart from simplistic ones.
<script>
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [
{
reference_id: "ref",
custom_id: "123456",
amount: {
currency_code: "EUR",
value: "2.40",
},
amount_breakdown: {
item_total: {
currency_code: 'EUR',
value: '2.00'
},
tax_total: {
currency_code: 'EUR',
value: '0.40'
},
},
items: [
{
name: "Item 1",
description: "Description of item 1",
sku: "id1",
unit_amount: {
currency_code: "EUR",
value: "1.00"
},
tax: {
currency_code: "EUR",
value: "0.20"
},
quantity: "1"
},
{
name: "Item 2",
description: "Description of item 2",
sku: "id2",
unit_amount: {
currency_code: "EUR",
value: "1.00"
},
tax: {
currency_code: "EUR",
value: "0.20"
},
quantity: "1"
}
],
}
],
});
},
onApprove: function(data, actions) {
// Capture the funds from the transaction
return actions.order.capture().then(function(details) {
// Show a success message to your buyer
alert('Transaction completed by ' + details.payer.name.given_name);
});
},
onError: function (err) {
alert(err);
}
}).render('#paypal-button-container');
</script>
- Labels:
-
Payments REST APIs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In case anyone else needs this I found the solution.
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [
{
reference_id: "ref",
custom_id: "123456",
amount: {
currency_code: "EUR",
value: "2.40",
breakdown: {
item_total: {
currency_code: 'EUR',
value: '2.00'
},
tax_total: {
currency_code: 'EUR',
value: '0.40'
},
}
},
items: [
{
name: "Item 1",
description: "Description of item 1",
sku: "id1",
unit_amount: {
currency_code: "EUR",
value: "1.00"
},
tax: {
currency_code: "EUR",
value: "0.20"
},
quantity: "1"
},
{
name: "Item 2",
description: "Description of item 2",
sku: "id2",
unit_amount: {
currency_code: "EUR",
value: "1.00"
},
tax: {
currency_code: "EUR",
value: "0.20"
},
quantity: "1"
}
],
}
],
});
},
onApprove: function(data, actions) {
// Capture the funds from the transaction
return actions.order.capture().then(function(details) {
// Show a success message to your buyer
alert('Transaction completed by ' + details.payer.name.given_name);
});
},
onError: function (err) {
alert(err);
}
}).render('#paypal-button-container');

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- Assistance Needed: Passing and Retrieving Custom Data in PayPal Webhook Payload in PayPal Payments Standard
- Advance checkout in Braintree Server-side Integration (PHP, Java, .NET, Ruby, Python, NodeJS SDKs)
- CHECKOUT.ORDER.APPROVED webhook event not triggered if payment_source is passed in in REST APIs
- A gateway error log add to get detailed information response from paypal. in PayPal Payments Standard
- Spain in PayPal Payments Standard