Calculating the Grand Total Amount

Klarna requires that the grand total amount of a purchase be included in the request using the
purchaseTotals_grandTotalAmount
field. The country of the transaction and the use of coupons affect how to calculate the grand total amount.

US Grand Total with Coupons

To calculate the grand total amount for US transactions with coupons, use this formula:
sum of (unit price x quantity) for all items + item-level tax amount – sum of (
coupon
amount x quantity) for all items – item-level discount amount
This is the same formula with the respective API fields:
sum of (
item_#_unitPrice
x
item_#_quantity
) for all items +
purchaseTotals_taxAmount
– sum of coupons (
item_#_unitPrice
x
item_#_quantity
) –
purchaseTotals_discountAmount
US Grand Total Amount with Coupons
This example shows the proper syntax and calculation of a grand total amount within an API request.
<item id="0"> <unitPrice>100</unitPrice> <quantity>1</quantity> <totalAmount>100</totalAmount> </item> <item id="1"> <unitPrice>75</unitPrice> <quantity>2</quantity> <totalAmount>150</totalAmount> </item> <item id="2"> <unitPrice>30</unitPrice> <quantity>1</quantity> <productCode>coupon<productCode> <productName>first-time customer<productName> <productSKU>12345</productSKU> </item> <purchaseTotals> <taxAmount>40</taxAmount> <discountAmount>10</discountAmount> <grandTotalAmount>250</grandTotalAmount> </purchaseTotals>

US Grand Total without Coupons

To calculate the grand total amount for US transactions without coupons, use this formula:
sum of (unit price x quantity) for all items + item-level tax amount – item-level discount amount
This is the same formula with the respective API fields:
sum of (
item_#_unitPrice
x
item_#_quantity
) for all items +
purchaseTotals_taxAmount
purchaseTotals_discountAmount
Grand Total Amount
This example shows the proper syntax and calculation of a grand total amount within an API request.
<item id="0"> <unitPrice>100</unitPrice> <quantity>1</quantity> <totalAmount>100</totalAmount> </item> <item id="1"> <unitPrice>75</unitPrice> <quantity>2</quantity> <totalAmount>150</totalAmount> </item> <purchaseTotals> <discountAmount>10</discountAmount> <taxAmount>40</taxAmount> <grandTotalAmount>280</grandTotalAmount> </purchaseTotals>

Non-US Countries Grand Total with Coupons

To calculate the grand total amount for non-US transactions with coupons, use this formula:
sum of (unit price x quantity) for all items + sum of (item-level tax amount) for all items – sum of (coupon amount x quantity) for all items – item-level discount amount
This is the same formula with the respective API fields:
sum of (
item_#_unitPrice
x
item_#_quantity
) for all items + sum of (
item_#_taxAmount
) for all items – sum of coupons (
item_#_unitPrice
x
item_#_quantity
) for all times –
purchaseTotals_discountAmount
Grand Total Amount
This example shows the proper syntax and calculation of a grand total amount within an API request.
<item id="0"> <unitPrice>100</unitPrice> <quantity>1</quantity> <taxAmount>20</taxAmount> <totalAmount>120</totalAmount> </item> <item id="1"> <unitPrice>75</unitPrice> <quantity>2</quantity> <taxAmount>20</taxAmount> <totalAmount>170</totalAmount> </item> <item id="2"> <unitPrice>30</unitPrice> <quantity>1</quantity> <productCode>coupon<productCode> <productName>first-time customer<productName> <productSKU>12345</productSKU> <purchaseTotals> <discountAmount>10</discountAmount> <grandTotalAmount>290</grandTotalAmount> </purchaseTotals>

Non-US Countries Grand Total without Coupons

To calculate the grand total amount for non-US transactions without coupons, use this formula:
sum of (unit price x quantity) for all items + sum of (item-level tax amount) for all items – item-level discount amount
This is the same formula with the respective API fields:
sum of (
item_#_unitPrice
x
item_#_quantity
) for all items + sum of (
item_#_taxAmount
) for all items
Grand Total Amount
This example shows the proper syntax and calculation of a grand total amount within an API request.
<item id="0"> <unitPrice>100</unitPrice> <quantity>1</quantity> <totalAmount>120</totalAmount> </item> <item id="1"> <unitPrice>75</unitPrice> <quantity>2</quantity> <taxAmount>20</taxAmount> <totalAmount>170</totalAmount> </item> <purchaseTotals> <grandTotalAmount>280</grandTotalAmount> </purchaseTotals>