Paypal Express Sandbox - onShippingChange returns error 400 when patching order
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've been using the sample code in the tutorial as a base to get a simple Paypal express button working, all seems to be fine until I attempt to patch the order to add shipping costs. The patch command returns an error 400
My onshippingchange code is below :
const baseOrderAmount = '15.00';
const addFloats = (...floats) => floats.reduce((v, t) => parseFloat(t) + parseFloat(v), 0).toFixed(2);
onShippingChange: function(data, actions) {
// Patch the shipping amount
const shippingAmount = '20.00';
return actions.order.patch([
{
op: 'replace',
path: '/purchase_units/@reference_id==default/amount',
value: {
currency_code: 'USD',
value: addFloats(baseOrderAmount, shippingAmount),
breakdown: {
item_total: {
currency_code: 'USD',
value: baseOrderAmount
},
shipping: {
currency_code: 'USD',
value: shippingAmount
}
}
}
}
]);
}
What am I missing here?
- Labels:
-
Express Checkout
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- Patch replace requests returns 204 but does not update next payment amount on sanbox in REST APIs
- patch payment returning validation error for field not in request in Sandbox Environment
- Can't get full shipping address from Paypal checkout buttons in PayPal Payments Standard
- Sandbox Patch 'test' requests all returning INTERNAL_SERVICE_ERROR in Sandbox Environment