I'm trying to integrate with PayPay Express Checkout while calculating sales tax with external service(TaxJar). I'm working inside a VueJS project.
Everything was fine... unit it wasn't. I recall everything working fine last time I checked (a few months back)
But in recent weeks, issues arose.
First, their checkout breakdown and numbers don't match with what was patched in the onShippingChange callback. If we patch to a static value, PayPal display updates on the 2nd patch and not the first one. (2nd patch for example being you changing shipping address to a different one) On the 2nd patch/redraw it will update.
I made sure patch got correct data on the first pass as well:
return actions.order.patch([{
op: "replace",
path: "/purchase_units/@reference_id=='default'/amount",
value: {
currency_code: "USD",
value: this.totalPrice,
breakdown: {
item_total: {
currency_code: "USD",
value: this.subtotalPrice
},
shipping: {
currency_code: "USD",
value: this.shippingPrice
},
tax_total: {
currency_code: "USD",
value: this.calculatedTax
}
}
}
}])
Example:
If we set shippingPrice to 0 while creating the order, than update shippingPrice before running the above code, it will not update in the PayPal UI. If you than change the address again inside the PayPal UI, it runs the onShippingChange again and after that, the UI changes as well.
This isn't an issue for the UI only. It also affects the amount charged to the customer(as in not enough)
Why would this happen? Thank you for all the help!
P.S.: Same but in worse shape happens to tax breakdown. It's not the same for each state so number never updates.
createOrder
return actions.order.create({
purchase_units: [{
items: [
{
name: this.productTitle,
quantity: this.state.quantity,
unit_amount: {
currency_code: "USD",
value: this.itemPrice
},
tax: {
currency_code: "USD",
value: this.calculatedTax
}
}
],
description: this.productTitle,
amount: {
value: this.totalPrice,
currency: "USD",
breakdown: {
item_total: {
currency_code: "USD",
value: this.subtotalPrice
},
shipping: {
currency_code:"USD",
value: this.shippingPrice
},
tax_total: {
currency_code: "USD",
value: this.calculatedTax
}
}
}
}]
})