When making Klarna payments, you need to specify price and product information when:
- Making a payment request.
- Making a partial capture request.
- Making a partial refund request.
- Applying a discount.
- Adjusting an authorization.
Make a payment request
For any payment request, include price and product information in lineItems.
When adding price and product information, note that:
- Klarna will only approve the payment if the total amount specified in
lineItems
matches theamount.value
. productUrl
andimageUrl
are optional fields.
{ "amount":{ "currency":"EUR", "value":"1000" }, "lineItems":[ { "quantity":"1", "amountExcludingTax":"331", "taxPercentage":"2100", "description":"Shoes", "id":"Item #1", "taxAmount":"69", "amountIncludingTax":"400", "productUrl": "URL_TO_PURCHASED_ITEM", "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM" }, { "quantity":"2", "amountExcludingTax":"248", "taxPercentage":"2100", "description":"Socks", "id":"Item #2", "taxAmount":"52", "amountIncludingTax":"300", "productUrl": "URL_TO_PURCHASED_ITEM", "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM" } ] ... }
Make a partial capture request
For a partial capture request, include the price and product information in
additionalData.openinvoicedata
.
Although the field names are different, the information in additionalData.openinvoicedata
is the same as what you provided in lineItems
when making a payment request. The following table shows the corresponding fields.
openinvoicedata | lineItems | Required | Description |
---|---|---|---|
itemAmount |
amountExcludingTax |
The price for one item, without the tax, in minor units. | |
itemVatPercentage |
taxPercentage |
The tax percentage, in minor units. | |
itemVatAmount |
taxAmount |
The tax amount for one item, in minor units. |
For Klarna to approve a partial capture, the value
specified in the modificationAmount
has to match the total amount calculated from the invoice lines.
Below is an example of how you can make a partial capture if the shopper only kept one pair of socks from the two included in the original payment request.
curl https://pal-test.adyen.com/pal/servlet/Payment/v68/capture \ -u "ws@Company.YourCompany":"YourWsPassword" \ -H 'content-type: application/json' \ -d '{ "originalReference":"COPY_PSP_REFERENCE_FROM_PAYMENT_RESPONSE", "merchantAccount":"ADYEN_MERCHANT_ACCOUNT", "modificationAmount":{ "currency":"EUR", "value":700 }, "additionalData":{ "openinvoicedata.numberOfLines":"2", "openinvoicedata.line1.currencyCode":"EUR", "openinvoicedata.line1.description":"Shoes", "openinvoicedata.line1.itemAmount":"331", "openinvoicedata.line1.itemVatAmount":"69", "openinvoicedata.line1.itemVatPercentage":"2100", "openinvoicedata.line1.numberOfItems":"1", "openinvoicedata.line1.productUrl":"URL_TO_PURCHASED_ITEM", "openinvoicedata.line1.imageUrl":"URL_TO_PICTURE_OF_PURCHASED_ITEM", "openinvoicedata.line2.currencyCode":"EUR", "openinvoicedata.line2.description":"Socks", "openinvoicedata.line2.itemAmount":"248", "openinvoicedata.line2.itemVatAmount":"52", "openinvoicedata.line2.itemVatPercentage":"2100", "openinvoicedata.line2.numberOfItems":"1", "openinvoicedata.line2.productUrl":"URL_TO_PURCHASED_ITEM", "openinvoicedata.line2.imageUrl":"URL_TO_PICTURE_OF_PURCHASED_ITEM" }, "reference":"YOUR_CAPTURE_REFERENCE" }'
You will receive a response containing a pspReference
. Once we have processed your request, you will also receive a CAPTURE webhook.
Make a partial refund request
For a partial refund request, include the price and product information in
additionalData.openinvoicedata
.
Although the field names are different, the information in additionalData.openinvoicedata
is the same as what you provided in lineItems
when making a payment request. The following table shows the corresponding fields.
openinvoicedata | lineItems | Required | Description |
---|---|---|---|
itemAmount |
amountExcludingTax |
The price for one item, without the tax, in minor units. | |
itemVatPercentage |
taxPercentage |
The tax percentage, in minor units. | |
itemVatAmount |
taxAmount |
The tax amount for one item, in minor units. |
Below is an example of how you can partially refund a pair of socks from the original payment request.
curl https://pal-test.adyen.com/pal/servlet/Payment/v68/refund \ -u "ws@Company.YourCompany":"YourWsPassword" \ -H 'content-type: application/json' \ -d '{ "merchantAccount":"ADYEN_MERCHANT_ACCOUNT", "modificationAmount":{ "currency":"EUR", "value":300 }, "originalReference":"COPY_PSP_REFERENCE_FROM_PAYMENT_RESPONSE", "reference":"YOUR_REFUND_REFERENCE", "additionalData":{ "openinvoicedata.numberOfLines":"1", "openinvoicedata.line1.currencyCode":"EUR", "openinvoicedata.line1.description":"Socks", "openinvoicedata.line1.itemAmount":"248", "openinvoicedata.line1.itemVatAmount":"52", "openinvoicedata.line1.itemVatPercentage":"2100", "openinvoicedata.line1.numberOfItems":"1", "openinvoicedata.line1.productUrl":"URL_TO_PURCHASED_ITEM", "openinvoicedata.line1.imageUrl":"URL_TO_PICTURE_OF_PURCHASED_ITEM" } }'
You will receive a response containing a pspReference
. Once we have processed your request, you will also receive a REFUND webhook.
Apply a discount
There are several ways to apply a discount to the invoice:
- Apply a discount to individual line items.
- Apply a discount to the whole purchase.
- Let Adyen add a discount line for you. This is the fallback option in case the other methods do not work for you.
The examples below apply a 30% discount to the shopper's basket, which contains:
- One pair of shoes, original price EUR 12.00 including 20% VAT
- Two pairs of socks, original price EUR 4.50 including 20% VAT
Apply a discount to individual line items
With this method of applying a discount, you reduce the cost of the applicable line items instead of discounting the basket as a whole. To apply a discount to individual line items:
- Calculate the reduced amount of each line item you want to discount.
- Send a payment request in which each line item specifies the discounted amounts:
amountExcludingTax
taxAmount
amountIncludingTax
Product | Quantity | Item Price (EUR) | VAT (EUR) | Total price (EUR) |
---|---|---|---|---|
Shoes (with 30% discount) | 1 | 7,00 | 1,40 | 8,40 |
Socks (with 30% discount) | 2 | 2,63 | 0,52 | 6,30 |
Purchase amount | 12,26 | |||
VAT | 2,44 | |||
TOTAL | 14,70 |
{ "amount" : { "currency" : "EUR", "value" : "1470" }, "lineItems" : [ { "quantity" : "1", "amountExcludingTax" : "700", "taxPercentage" : "2000", "description" : "Shoes (with discount)", "id" : "Item #1", "taxAmount" : "140", "amountIncludingTax" : "840" }, { "quantity" : "2", "amountExcludingTax" : "263", "taxPercentage" : "2000", "description" : "Socks (with discount)", "id" : "Item #2", "taxAmount" : "52", "amountIncludingTax" : "315" } ] }
Apply a discount to the whole purchase
With this method of applying a discount, you specify the line items with their original price and then apply a discount to the basket as a whole by adding a discount line.
To apply a discount to the entire basket:
- Calculate the discount to the product total and the VAT.
- In your payments request, send each fully priced line item, plus a line Item to specify the discount with the following parameters:
id
: Discountdescription
: DiscountamountExcludingTax
: The discount amount, preceded by a minus signtaxAmount
: The discount amount, preceded by a minus signamountIncludingTax
: The discount amount, preceded by a minus sign
Product | Quantity | Item Price (EUR) | VAT (EUR) | Total price (EUR) |
---|---|---|---|---|
Shoes | 1 | 10,00 | 2,00 | 12,00 |
Socks | 2 | 3,75 | 0,75 | 9,00 |
Total before discount | 21,00 | |||
Product discount | 5,25 | |||
VAT discount | 1,05 | |||
Total discount (30%) | 6,30 | |||
TOTAL | 14,70 |
{ "amount" : { "currency" : "EUR", "value" : "1470" }, "lineItems" : [ { "quantity" : "1", "amountExcludingTax" : "1000", "taxPercentage" : "2000", "description" : "Shoes", "id" : "Item #1", "taxAmount" : "200", "amountIncludingTax" : "1200" }, { "quantity" : "2", "amountExcludingTax" : "375", "taxPercentage" : "2000", "description" : "Socks", "id" : "Item #2", "taxAmount" : "75", "amountIncludingTax" : "450" }, // The following line item specifies the discount { "quantity" : "1", "amountExcludingTax" : "-525", "taxPercentage" : "2000", "description" : "Discount", "id" : "Discount", "taxAmount" : "-105", "amountIncludingTax" : "-630" } ] }
Let Adyen add a discount line for you
With this method of applying a discount, Adyen calculates that amount.value
is less than the total value of the line items, so a discount must have been applied. In this case, Adyen adds a line item for the discount before sending to Klarna.
{ "amount" : { "currency" : "EUR", "value" : "1470" }, "lineItems" : [ { "quantity" : "1", "amountExcludingTax" : "1000", "taxPercentage" : "2000", "description" : "Shoes", "id" : "Item #1", "taxAmount" : "200", "amountIncludingTax" : "1200" }, { "quantity" : "2", "amountExcludingTax" : "375", "taxPercentage" : "2000", "description" : "Socks", "id" : "Item #2", "taxAmount" : "75", "amountIncludingTax" : "450" } ] }
Adjust an authorization
If you want to adjust an authorized payment that has not yet been fully captured, your API request must specify all captured and refunded lineItems
. See Adjust an authorization for detailed instructions. This is available for Klarna with Checkout API v70 and later.
Below are two examples of adjusting an authorized payment:
These examples are based on the following order:
curl https://checkout-test.adyen.com/v70/sessions \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "merchantAccount": "ADYEN_MERCHANT_ACCOUNT", "reference": "YOUR_ORDER_REFERENCE", "amount": { "currency": "SEK", "value": 1000 }, "shopperLocale": "en_US", "countryCode": "SE", "telephoneNumber": "+46 840 839 298", "shopperEmail": "youremail@email.com", "shopperName": { "firstName": "Testperson-se", "gender": "UNKNOWN", "lastName": "Approved" }, "shopperReference": "YOUR_UNIQUE_SHOPPER_ID", "billingAddress": { "city": "Ankeborg", "country": "SE", "houseNumberOrName": "1", "postalCode": "12345", "street": "Stargatan" }, "deliveryAddress": { "city": "Ankeborg", "country": "SE", "houseNumberOrName": "1", "postalCode": "12345", "street": "Stargatan" }, "dateOfBirth": "1996-09-04", "socialSecurityNumber": "0108", "returnUrl": "https://your-company.com/checkout?shopperOrder=12xy..", "lineItems": [ { "quantity": "1", "taxPercentage": "2100", "description": "Shoes", "id": "Item #1", "amountIncludingTax": "400", "productUrl": "URL_TO_PURCHASED_ITEM", "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM" }, { "quantity": "2", "taxPercentage": "2100", "description": "Socks", "id": "Item #2", "amountIncludingTax": "300", "productUrl": "URL_TO_PURCHASED_ITEM", "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM" } ], "additionalData" : { "openinvoicedata.merchantData" : "eyJjdXN0b21lcl9hY ... " } }'
Cancel part of the authorization before capture
If you want to cancel or adjust the authorization before capturing, you can declare the new amount and associated lineitems
.
The following example removes Item #2 from the above order by declaring the new basket composition and amount.
curl https: //checkout-test.adyen.com/v70/payments/{paymentPspReference}/amountUpdates \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "merchantAccount": "ADYEN_MERCHANT_ACCOUNT", "amount": { "currency": "EUR", "value": 400 }, "lineItems": [ { "quantity": "1", "taxPercentage": "2100", "description": "Shoes", "id": "Item #1", "amountIncludingTax": "400", "productUrl": "URL_TO_PURCHASED_ITEM", "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM" } ] }'
Add a product from a partially captured order
If you want to add products to a partially captured or refunded order, you must include the already captured or refunded lineItems
in the update request, in addition to the new order content.
In the following example, Item #1 from the above order is captured, and we add a third item to the order:
curl https: //checkout-test.adyen.com/v70/payments/{paymentPspReference}/amountUpdates \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "merchantAccount": "ADYEN_MERCHANT_ACCOUNT", "amount": { "currency": "EUR", "value": 1300 }, "lineItems": [ { "quantity": "1", "taxPercentage": "2100", "description": "Shoes", "id": "Item #1", "amountIncludingTax": "400", "productUrl": "URL_TO_PURCHASED_ITEM", "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM" }, { "quantity": "2", "taxPercentage": "2100", "description": "Socks", "id": "Item #2", "amountIncludingTax": "300", "productUrl": "URL_TO_PURCHASED_ITEM", "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM" }, { "quantity": "1", "taxPercentage": "2100", "description": "Hat", "id": "Item #3", "amountIncludingTax": "300", "productUrl": "URL_TO_PURCHASED_ITEM", "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM" } ] }'