This page describes the rules applied by ChargeAfter during validation of a cart as a part of Charge Creation API.
Validation of totalAmount
totalAmount should be equal to:
SUM(Item Cost) + shippingAmount + taxAmount
Item Cost is:
item quantity * (item price - SUM(item discount amount))
Validation of taxAmount
taxAmount should be equal to:
SUM(Item Tax Amount) + shippingTaxAmount
Item Tax Amount is:
taxAmount * quantity
Additional validation
All items should have a taxAmount.
Cart level Discounts should not be allowed.
Item level Warranty should not be allowed. Any warranties should be added as separate line items.
Example of a valid cart
total amount calculation
2245 = (1000 2) - (5 2) + 205 + 50
tax amount calculation
205 = (100 * 2) + 5
{
"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
}