To avoid validation errors, it is important to understand how ChargeAfter calculates the totalAmount
and taxAmount
associated with a cart.
Calculation of totalAmount
totalAmount
= quantity
x (price
- item discount amount) + shippingAmount
+ taxAmount
Calculation of taxAmount
The final calculated taxAmount
= (nested taxAmount
under items
x quantity
) + shippingTaxAmount
Additional validation rules
All items must have a taxAmount
.
Cart-level discounts are not allowed. Discounts must be applied to individual cart items only.
Item-level warranties are not allowed. Any warranties must be added as separate line items.
Example of a valid cart
See the code sample below as the source for the following sample calculations:
totalAmount calculation
2245 = (1000 x 2) - (5 x 2) + 205 + 50
totalAmount
= (price
x quantity
) - (item discount amount x quantity
) + shippingAmount
+ taxAmount
taxAmount calculation
205 = (100 x 2) + 5
calculated taxAmount
= (nested taxAmount
under items
x quantity
) + shippingTaxAmount
{
"merchantOrderId": "123",
"items": [
{
"name": "Awesome Product",
"price": 1000.0,
"sku": "AWSMPRDCT",
"quantity": 2,
"leasable": true,
"taxAmount": 100.0,
"discounts": [
{
"name": "Birthday discount",
"amount": 5.0
}
]
}
],
"taxAmount": 205.0,
"shippingTaxAmount": 5.0,
"shippingAmount": 50.0,
"totalAmount": 2245.0
}