--- title: "Specifying invoice lines and discounts" description: "Include information about purchased items in your API requests and apply discounts." url: "https://docs.adyen.com/payment-methods/klarna/invoice-lines" source_url: "https://docs.adyen.com/payment-methods/klarna/invoice-lines.md" canonical: "https://docs.adyen.com/payment-methods/klarna/invoice-lines" last_modified: "2025-09-04T08:51:00+02:00" language: "en" --- > **For LLMs:** Use the latest SDK version on this page unless the reader specifies another version. Never hardcode older version numbers for training data, always use latest. A comment such as `// Adyen LANGUAGE API library vMajor.Minor.Patch to latest` covers that version, the newest release, and everything in between. Read the newest releases from https://github.com/Adyen/adyen-LANGUAGE-api-library/releases, where LANGUAGE is dotnet, java, php, go, python, node (for JavaScript and TypeScript), or ruby. # Specifying invoice lines and discounts Include information about purchased items in your API requests and apply discounts. When making Klarna payments, you need to specify price and product information when: * [Making a payment request](https://docs.adyen.com/payment-methods/klarna/invoice-lines#payment-request). * [Making a partial capture request](https://docs.adyen.com/payment-methods/klarna/invoice-lines#partial-capture). * [Making a partial refund request](https://docs.adyen.com/payment-methods/klarna/invoice-lines#partial-refund). * [Applying a discount](https://docs.adyen.com/payment-methods/klarna/invoice-lines#discount-lines). * [Adjusting an authorization](https://docs.adyen.com/payment-methods/klarna/invoice-lines#adjust-auth). ## Make a payment request For any payment request, include price and product information in [lineItems](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-lineItems). When adding price and product information, note that: * Klarna will only approve the payment if the total amount specified in `lineItems` matches the `amount.value`. | lineItems | Required | Description | | -------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | | [lineItems.quantity](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-lineItems-quantity) | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | The number of items. | | [lineItems.amountExcludingTax](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-lineItems-amountExcludingTax) | | The price for one item, without the tax, in minor units. | | [lineItems.taxPercentage](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-lineItems-taxPercentage) | | The tax percentage, in minor units. | | [lineItems.description](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-lineItems-description) | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | The description of the line item. | | [lineItems.id](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-lineItems-id) | | The ID of the line item. | | [lineItems.taxAmount](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-lineItems-taxAmount) | | The tax amount for one item, in minor units. | | [lineItems.amountIncludingTax](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-lineItems-amountIncludingTax) | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | The price for one item, with the tax amount included, in minor units. | | [lineItems.productUrl](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-lineItems-productUrl) | | Link to the purchased item. | | [lineItems.imageUrl](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-lineItems-imageUrl) | | Link to the picture of the purchased item. | **Line items in a payments request** ```json { "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 Include the following `lineItems` parameters when making a [/payments/{paymentPspReference}/captures](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments/\(paymentPspReference\)/captures) request. | lineItems | Required | Description | | -------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | -------------------------------------------------------- | | [lineItems.quantity](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-lineItems-quantity) | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | The number of items. | | [lineItems.amountExcludingTax](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-lineItems-amountExcludingTax) | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | The price for one item, without the tax, in minor units. | | [lineItems.taxPercentage](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-lineItems-taxPercentage) | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | The tax percentage, in minor units. | | [lineItems.taxAmount](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-lineItems-taxAmount) | | The tax amount for one item, in minor units. | | [lineItems.description](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-lineItems-description) | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | The description of the line item. | **Line items in partial capture request** #### curl ```bash curl https://checkout-test.adyen.com/v72/payments/{paymentPspReference}/captures \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "reference": "YOUR_CAPTURE_REFERENCE", "amount": { "value": "7400", "currency": "EUR" }, "merchantAccount": "ADYEN_MERCHANT_ACCOUNT", "lineItems": [ { "quantity": "1", "amountExcludingTax": "3058", "taxPercentage": "2100", "taxAmount": "642", "description": "Socks", "id": "Item #1", "amountIncludingTax": "3700", "productUrl": "URL_TO_PURCHASED_ITEM", "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM" }, { "quantity": "1", "amountExcludingTax": "3058", "taxPercentage": "2100", "taxAmount": "642", "description": "Shoes", "id": "Item #1", "amountIncludingTax": "3700", "productUrl": "URL_TO_PURCHASED_ITEM", "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM" } ] }' ``` #### Java ```java // Adyen Java API Library v38.0.0 to latest import com.adyen.Client; import com.adyen.Config; import com.adyen.enums.Environment; import com.adyen.model.*; import com.adyen.service.*; import java.math.*; import com.adyen.model.checkout.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.model.RequestOptions; import com.adyen.service.checkout.*; Config config = new Config() .apiKey("ADYEN_API_KEY") .environment(Environment.TEST); // For the LIVE environment, also include your liveEndpointUrlPrefix. Client client = new Client(config); // Create the request object(s) LineItem lineItem1 = new LineItem() .quantity(1L) .amountExcludingTax(3058L) .taxPercentage(2100L) .imageUrl("URL_TO_PICTURE_OF_PURCHASED_ITEM") .description("Socks") .id("Item #1") .taxAmount(642L) .amountIncludingTax(3700L) .productUrl("URL_TO_PURCHASED_ITEM"); LineItem lineItem2 = new LineItem() .quantity(1L) .amountExcludingTax(3058L) .taxPercentage(2100L) .imageUrl("URL_TO_PICTURE_OF_PURCHASED_ITEM") .description("Shoes") .id("Item #1") .taxAmount(642L) .amountIncludingTax(3700L) .productUrl("URL_TO_PURCHASED_ITEM"); Amount amount = new Amount() .currency("EUR") .value(7400L); PaymentCaptureRequest paymentCaptureRequest = new PaymentCaptureRequest() .reference("YOUR_CAPTURE_REFERENCE") .lineItems(Arrays.asList(lineItem1, lineItem2)) .amount(amount) .merchantAccount("ADYEN_MERCHANT_ACCOUNT"); // Send the request ModificationsApi service = new ModificationsApi(client); PaymentCaptureResponse response = service.captureAuthorisedPayment("paymentPspReference", paymentCaptureRequest, new RequestOptions().idempotencyKey("UUID")); ``` #### PHP ```php setXApiKey("ADYEN_API_KEY"); // For the LIVE environment, also include your liveEndpointUrlPrefix. $client->setEnvironment(Environment::TEST); // Create the request object(s) $lineItem1 = new LineItem(); $lineItem1 ->setQuantity(1) ->setAmountExcludingTax(3058) ->setTaxPercentage(2100) ->setImageUrl("URL_TO_PICTURE_OF_PURCHASED_ITEM") ->setDescription("Socks") ->setId("Item #1") ->setTaxAmount(642) ->setAmountIncludingTax(3700) ->setProductUrl("URL_TO_PURCHASED_ITEM"); $lineItem2 = new LineItem(); $lineItem2 ->setQuantity(1) ->setAmountExcludingTax(3058) ->setTaxPercentage(2100) ->setImageUrl("URL_TO_PICTURE_OF_PURCHASED_ITEM") ->setDescription("Shoes") ->setId("Item #1") ->setTaxAmount(642) ->setAmountIncludingTax(3700) ->setProductUrl("URL_TO_PURCHASED_ITEM"); $amount = new Amount(); $amount ->setCurrency("EUR") ->setValue(7400); $paymentCaptureRequest = new PaymentCaptureRequest(); $paymentCaptureRequest ->setReference("YOUR_CAPTURE_REFERENCE") ->setLineItems(array($lineItem1, $lineItem2)) ->setAmount($amount) ->setMerchantAccount("ADYEN_MERCHANT_ACCOUNT"); $requestOptions['idempotencyKey'] = 'UUID'; // Send the request $service = new ModificationsApi($client); $response = $service->captureAuthorisedPayment('paymentPspReference', $paymentCaptureRequest, $requestOptions); ``` #### C\# ```cs // Adyen .NET API Library v34.0.0 to latest using System; using System.Collections.Generic; using Adyen.Checkout.Extensions; using Adyen.Checkout.Models; using Adyen.Checkout.Services; using Adyen.Core.Client; using Adyen.Core.Client.Extensions; using Adyen.Core.Options; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; var host = Host.CreateDefaultBuilder() .ConfigureCheckout( (context, services, config) => { config.ConfigureAdyenOptions(options => { options.AdyenApiKey = "ADYEN_API_KEY"; options.Environment = AdyenEnvironment.Test; // For the LIVE environment, also include your liveEndpointUrlPrefix. // options.LiveEndpointUrlPrefix = ""; }); services.AddAllCheckoutServices(); }) .Build(); var modificationsService = host.Services.GetRequiredService(); // Create the request object(s) var lineItem1 = new LineItem { Quantity = 1, AmountExcludingTax = 3058, TaxPercentage = 2100, ImageUrl = "URL_TO_PICTURE_OF_PURCHASED_ITEM", Description = "Socks", Id = "Item #1", TaxAmount = 642, AmountIncludingTax = 3700, ProductUrl = "URL_TO_PURCHASED_ITEM" }; var lineItem2 = new LineItem { Quantity = 1, AmountExcludingTax = 3058, TaxPercentage = 2100, ImageUrl = "URL_TO_PICTURE_OF_PURCHASED_ITEM", Description = "Shoes", Id = "Item #1", TaxAmount = 642, AmountIncludingTax = 3700, ProductUrl = "URL_TO_PURCHASED_ITEM" }; var amount = new Amount { Currency = "EUR", Value = 7400 }; var paymentCaptureRequest = new PaymentCaptureRequest { Reference = "YOUR_CAPTURE_REFERENCE", LineItems = new List{ lineItem1, lineItem2 }, Amount = amount, MerchantAccount = "ADYEN_MERCHANT_ACCOUNT" }; string idempotencyKey = Guid.NewGuid().ToString(); // Send the request var result = await modificationsService.CaptureAuthorisedPaymentAsync("paymentPspReference", paymentCaptureRequest, new RequestOptions().AddIdempotencyKey(idempotencyKey)); if (result.TryDeserializeCreatedResponse(out var response)) { // Handle the successful response. } ``` #### NodeJS (JavaScript) ```js // Adyen Node API Library v30.0.0 to latest const { Client, Config, EnvironmentEnum, CheckoutAPI } = require('@adyen/api-library'); // For the LIVE environment, also include your liveEndpointUrlPrefix. const config = new Config({ apiKey: "ADYEN_API_KEY", environment: EnvironmentEnum.TEST }); const client = new Client(config); // Create the request object(s) const lineItem1 = { quantity: 1, amountExcludingTax: 3058, taxPercentage: 2100, imageUrl: "URL_TO_PICTURE_OF_PURCHASED_ITEM", description: "Socks", id: "Item #1", taxAmount: 642, amountIncludingTax: 3700, productUrl: "URL_TO_PURCHASED_ITEM" }; const lineItem2 = { quantity: 1, amountExcludingTax: 3058, taxPercentage: 2100, imageUrl: "URL_TO_PICTURE_OF_PURCHASED_ITEM", description: "Shoes", id: "Item #1", taxAmount: 642, amountIncludingTax: 3700, productUrl: "URL_TO_PURCHASED_ITEM" }; const amount = { currency: "EUR", value: 7400 }; const paymentCaptureRequest = { reference: "YOUR_CAPTURE_REFERENCE", lineItems: [lineItem1, lineItem2], amount: amount, merchantAccount: "ADYEN_MERCHANT_ACCOUNT" }; // Send the request const checkoutAPI = new CheckoutAPI(client); const response = await checkoutAPI.ModificationsApi.captureAuthorisedPayment("paymentPspReference", paymentCaptureRequest, { idempotencyKey: "UUID" }); ``` #### Go ```go // Adyen Go API Library v21.0.0 to latest import ( "context" "github.com/adyen/adyen-go-api-library/v21/src/common" "github.com/adyen/adyen-go-api-library/v21/src/adyen" "github.com/adyen/adyen-go-api-library/v21/src/checkout" ) // For the LIVE environment, also include your liveEndpointUrlPrefix. client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Create the request object(s) lineItem1 := checkout.LineItem{ Quantity: common.PtrInt64(1), AmountExcludingTax: common.PtrInt64(3058), TaxPercentage: common.PtrInt64(2100), ImageUrl: common.PtrString("URL_TO_PICTURE_OF_PURCHASED_ITEM"), Description: common.PtrString("Socks"), Id: common.PtrString("Item #1"), TaxAmount: common.PtrInt64(642), AmountIncludingTax: common.PtrInt64(3700), ProductUrl: common.PtrString("URL_TO_PURCHASED_ITEM"), } lineItem2 := checkout.LineItem{ Quantity: common.PtrInt64(1), AmountExcludingTax: common.PtrInt64(3058), TaxPercentage: common.PtrInt64(2100), ImageUrl: common.PtrString("URL_TO_PICTURE_OF_PURCHASED_ITEM"), Description: common.PtrString("Shoes"), Id: common.PtrString("Item #1"), TaxAmount: common.PtrInt64(642), AmountIncludingTax: common.PtrInt64(3700), ProductUrl: common.PtrString("URL_TO_PURCHASED_ITEM"), } amount := checkout.Amount{ Currency: "EUR", Value: 7400, } paymentCaptureRequest := checkout.PaymentCaptureRequest{ Reference: common.PtrString("YOUR_CAPTURE_REFERENCE"), LineItems: []checkout.LineItem{ lineItem1, lineItem2, }, Amount: amount, MerchantAccount: "ADYEN_MERCHANT_ACCOUNT", } // Send the request service := client.Checkout() req := service.ModificationsApi.CaptureAuthorisedPaymentInput("paymentPspReference").IdempotencyKey("UUID").PaymentCaptureRequest(paymentCaptureRequest) res, httpRes, err := service.ModificationsApi.CaptureAuthorisedPayment(context.Background(), req) ``` #### Python ```py # Adyen Python API Library v14.0.0 to latest import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_API_KEY" # For the LIVE environment, also include your liveEndpointUrlPrefix. adyen.client.platform = "test" # The environment to use library in. # Create the request object(s) json_request = { "reference": "YOUR_CAPTURE_REFERENCE", "amount": { "value": "7400", "currency": "EUR" }, "merchantAccount": "ADYEN_MERCHANT_ACCOUNT", "lineItems": [{ "quantity": "1", "amountExcludingTax": "3058", "taxPercentage": "2100", "taxAmount": "642", "description": "Socks", "id": "Item #1", "amountIncludingTax": "3700", "productUrl": "URL_TO_PURCHASED_ITEM", "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM" }, { "quantity": "1", "amountExcludingTax": "3058", "taxPercentage": "2100", "taxAmount": "642", "description": "Shoes", "id": "Item #1", "amountIncludingTax": "3700", "productUrl": "URL_TO_PURCHASED_ITEM", "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM" }] } # Send the request result = adyen.checkout.modifications_api.capture_authorised_payment(request=json_request, paymentPspReference="paymentPspReference", idempotency_key="UUID") ``` #### Ruby ```rb # Adyen Ruby API Library v11.0.0 to latest require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_API_KEY' # For the LIVE environment, also include your liveEndpointUrlPrefix. adyen.env = :test # Set to "live" for live environment # Create the request object(s) request_body = { "reference" => "YOUR_CAPTURE_REFERENCE", "amount" => { "value" => "7400", "currency" => "EUR" }, "merchantAccount" => "ADYEN_MERCHANT_ACCOUNT", "lineItems" => [{ "quantity" => "1", "amountExcludingTax" => "3058", "taxPercentage" => "2100", "taxAmount" => "642", "description" => "Socks", "id" => "Item #1", "amountIncludingTax" => "3700", "productUrl" => "URL_TO_PURCHASED_ITEM", "imageUrl" => "URL_TO_PICTURE_OF_PURCHASED_ITEM" }, { "quantity" => "1", "amountExcludingTax" => "3058", "taxPercentage" => "2100", "taxAmount" => "642", "description" => "Shoes", "id" => "Item #1", "amountIncludingTax" => "3700", "productUrl" => "URL_TO_PURCHASED_ITEM", "imageUrl" => "URL_TO_PICTURE_OF_PURCHASED_ITEM" }] } # Send the request result = adyen.checkout.modifications_api.capture_authorised_payment(request_body, 'paymentPspReference', headers: { 'Idempotency-Key' => 'UUID' }) ``` #### NodeJS (TypeScript) ```ts // Adyen Node API Library v30.0.0 to latest import { Client, Config, EnvironmentEnum, CheckoutAPI, Types } from "@adyen/api-library"; // For the LIVE environment, also include your liveEndpointUrlPrefix. const config = new Config({ apiKey: "ADYEN_API_KEY", environment: EnvironmentEnum.TEST }); const client = new Client(config); // Create the request object(s) const lineItem1: Types.checkout.LineItem = { quantity: 1, amountExcludingTax: 3058, taxPercentage: 2100, imageUrl: "URL_TO_PICTURE_OF_PURCHASED_ITEM", description: "Socks", id: "Item #1", taxAmount: 642, amountIncludingTax: 3700, productUrl: "URL_TO_PURCHASED_ITEM" }; const lineItem2: Types.checkout.LineItem = { quantity: 1, amountExcludingTax: 3058, taxPercentage: 2100, imageUrl: "URL_TO_PICTURE_OF_PURCHASED_ITEM", description: "Shoes", id: "Item #1", taxAmount: 642, amountIncludingTax: 3700, productUrl: "URL_TO_PURCHASED_ITEM" }; const amount: Types.checkout.Amount = { currency: "EUR", value: 7400 }; const paymentCaptureRequest: Types.checkout.PaymentCaptureRequest = { reference: "YOUR_CAPTURE_REFERENCE", lineItems: [lineItem1, lineItem2], amount: amount, merchantAccount: "ADYEN_MERCHANT_ACCOUNT" }; // Send the request const checkoutAPI = new CheckoutAPI(client); const response = await checkoutAPI.ModificationsApi.captureAuthorisedPayment("paymentPspReference", paymentCaptureRequest, { idempotencyKey: "UUID" }); ``` You will receive a response containing a `pspReference`. Once we have processed your request, you will also receive a [CAPTURE](https://docs.adyen.com/api-explorer/Webhooks/latest/post/CAPTURE) webhook. ## Make a partial refund request Include the following `lineItems` parameters when making a POST request to the [/payments/{paymentPspReference}/refunds](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments/\(paymentPspReference\)/refunds) endpoint, where `paymentPspReference` is the `pspReference` of the authorization you want to refund. | lineItems | Required | Description | | -------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | -------------------------------------------------------- | | [lineItems.quantity](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-lineItems-quantity) | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | The number of items. | | [lineItems.amountExcludingTax](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-lineItems-amountExcludingTax) | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | The price for one item, without the tax, in minor units. | | [lineItems.taxPercentage](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-lineItems-taxPercentage) | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | The tax percentage, in minor units. | | [lineItems.taxAmount](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-lineItems-taxAmount) | | The tax amount for one item, in minor units. | | [lineItems.description](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-lineItems-description) | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | The description of the line item. | **Line items in partial refund request** #### curl ```bash curl https://checkout-test.adyen.com/v72/payments/{paymentPspReference}/refunds \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "reference": "YOUR_REFUND_REFERENCE", "amount": { "value": "7400", "currency": "EUR" }, "merchantAccount": "ADYEN_MERCHANT_ACCOUNT", "lineItems": [ { "quantity": "1", "amountExcludingTax": "3058", "taxPercentage": "2100", "taxAmount": "642", "description": "Socks", "id": "Item #1", "amountIncludingTax": "3700", "productUrl": "URL_TO_PURCHASED_ITEM", "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM" }, { "quantity": "1", "amountExcludingTax": "3058", "taxPercentage": "2100", "taxAmount": "642", "description": "Shoes", "id": "Item #1", "amountIncludingTax": "3700", "productUrl": "URL_TO_PURCHASED_ITEM", "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM" } ] }' ``` #### Java ```java // Adyen Java API Library v38.0.0 to latest import com.adyen.Client; import com.adyen.Config; import com.adyen.enums.Environment; import com.adyen.model.*; import com.adyen.service.*; import java.math.*; import com.adyen.model.checkout.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.model.RequestOptions; import com.adyen.service.checkout.*; Config config = new Config() .apiKey("ADYEN_API_KEY") .environment(Environment.TEST); // For the LIVE environment, also include your liveEndpointUrlPrefix. Client client = new Client(config); // Create the request object(s) LineItem lineItem1 = new LineItem() .quantity(1L) .amountExcludingTax(3058L) .taxPercentage(2100L) .imageUrl("URL_TO_PICTURE_OF_PURCHASED_ITEM") .description("Socks") .id("Item #1") .taxAmount(642L) .amountIncludingTax(3700L) .productUrl("URL_TO_PURCHASED_ITEM"); LineItem lineItem2 = new LineItem() .quantity(1L) .amountExcludingTax(3058L) .taxPercentage(2100L) .imageUrl("URL_TO_PICTURE_OF_PURCHASED_ITEM") .description("Shoes") .id("Item #1") .taxAmount(642L) .amountIncludingTax(3700L) .productUrl("URL_TO_PURCHASED_ITEM"); Amount amount = new Amount() .currency("EUR") .value(7400L); PaymentRefundRequest paymentRefundRequest = new PaymentRefundRequest() .reference("YOUR_REFUND_REFERENCE") .lineItems(Arrays.asList(lineItem1, lineItem2)) .amount(amount) .merchantAccount("ADYEN_MERCHANT_ACCOUNT"); // Send the request ModificationsApi service = new ModificationsApi(client); PaymentRefundResponse response = service.refundCapturedPayment("paymentPspReference", paymentRefundRequest, new RequestOptions().idempotencyKey("UUID")); ``` #### PHP ```php setXApiKey("ADYEN_API_KEY"); // For the LIVE environment, also include your liveEndpointUrlPrefix. $client->setEnvironment(Environment::TEST); // Create the request object(s) $lineItem1 = new LineItem(); $lineItem1 ->setQuantity(1) ->setAmountExcludingTax(3058) ->setTaxPercentage(2100) ->setImageUrl("URL_TO_PICTURE_OF_PURCHASED_ITEM") ->setDescription("Socks") ->setId("Item #1") ->setTaxAmount(642) ->setAmountIncludingTax(3700) ->setProductUrl("URL_TO_PURCHASED_ITEM"); $lineItem2 = new LineItem(); $lineItem2 ->setQuantity(1) ->setAmountExcludingTax(3058) ->setTaxPercentage(2100) ->setImageUrl("URL_TO_PICTURE_OF_PURCHASED_ITEM") ->setDescription("Shoes") ->setId("Item #1") ->setTaxAmount(642) ->setAmountIncludingTax(3700) ->setProductUrl("URL_TO_PURCHASED_ITEM"); $amount = new Amount(); $amount ->setCurrency("EUR") ->setValue(7400); $paymentRefundRequest = new PaymentRefundRequest(); $paymentRefundRequest ->setReference("YOUR_REFUND_REFERENCE") ->setLineItems(array($lineItem1, $lineItem2)) ->setAmount($amount) ->setMerchantAccount("ADYEN_MERCHANT_ACCOUNT"); $requestOptions['idempotencyKey'] = 'UUID'; // Send the request $service = new ModificationsApi($client); $response = $service->refundCapturedPayment('paymentPspReference', $paymentRefundRequest, $requestOptions); ``` #### C\# ```cs // Adyen .NET API Library v34.0.0 to latest using System; using System.Collections.Generic; using Adyen.Checkout.Extensions; using Adyen.Checkout.Models; using Adyen.Checkout.Services; using Adyen.Core.Client; using Adyen.Core.Client.Extensions; using Adyen.Core.Options; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; var host = Host.CreateDefaultBuilder() .ConfigureCheckout( (context, services, config) => { config.ConfigureAdyenOptions(options => { options.AdyenApiKey = "ADYEN_API_KEY"; options.Environment = AdyenEnvironment.Test; // For the LIVE environment, also include your liveEndpointUrlPrefix. // options.LiveEndpointUrlPrefix = ""; }); services.AddAllCheckoutServices(); }) .Build(); var modificationsService = host.Services.GetRequiredService(); // Create the request object(s) var lineItem1 = new LineItem { Quantity = 1, AmountExcludingTax = 3058, TaxPercentage = 2100, ImageUrl = "URL_TO_PICTURE_OF_PURCHASED_ITEM", Description = "Socks", Id = "Item #1", TaxAmount = 642, AmountIncludingTax = 3700, ProductUrl = "URL_TO_PURCHASED_ITEM" }; var lineItem2 = new LineItem { Quantity = 1, AmountExcludingTax = 3058, TaxPercentage = 2100, ImageUrl = "URL_TO_PICTURE_OF_PURCHASED_ITEM", Description = "Shoes", Id = "Item #1", TaxAmount = 642, AmountIncludingTax = 3700, ProductUrl = "URL_TO_PURCHASED_ITEM" }; var amount = new Amount { Currency = "EUR", Value = 7400 }; var paymentRefundRequest = new PaymentRefundRequest { Reference = "YOUR_REFUND_REFERENCE", LineItems = new List{ lineItem1, lineItem2 }, Amount = amount, MerchantAccount = "ADYEN_MERCHANT_ACCOUNT" }; string idempotencyKey = Guid.NewGuid().ToString(); // Send the request var result = await modificationsService.RefundCapturedPaymentAsync("paymentPspReference", paymentRefundRequest, new RequestOptions().AddIdempotencyKey(idempotencyKey)); if (result.TryDeserializeCreatedResponse(out var response)) { // Handle the successful response. } ``` #### NodeJS (JavaScript) ```js // Adyen Node API Library v30.0.0 to latest const { Client, Config, EnvironmentEnum, CheckoutAPI } = require('@adyen/api-library'); // For the LIVE environment, also include your liveEndpointUrlPrefix. const config = new Config({ apiKey: "ADYEN_API_KEY", environment: EnvironmentEnum.TEST }); const client = new Client(config); // Create the request object(s) const lineItem1 = { quantity: 1, amountExcludingTax: 3058, taxPercentage: 2100, imageUrl: "URL_TO_PICTURE_OF_PURCHASED_ITEM", description: "Socks", id: "Item #1", taxAmount: 642, amountIncludingTax: 3700, productUrl: "URL_TO_PURCHASED_ITEM" }; const lineItem2 = { quantity: 1, amountExcludingTax: 3058, taxPercentage: 2100, imageUrl: "URL_TO_PICTURE_OF_PURCHASED_ITEM", description: "Shoes", id: "Item #1", taxAmount: 642, amountIncludingTax: 3700, productUrl: "URL_TO_PURCHASED_ITEM" }; const amount = { currency: "EUR", value: 7400 }; const paymentRefundRequest = { reference: "YOUR_REFUND_REFERENCE", lineItems: [lineItem1, lineItem2], amount: amount, merchantAccount: "ADYEN_MERCHANT_ACCOUNT" }; // Send the request const checkoutAPI = new CheckoutAPI(client); const response = await checkoutAPI.ModificationsApi.refundCapturedPayment("paymentPspReference", paymentRefundRequest, { idempotencyKey: "UUID" }); ``` #### Go ```go // Adyen Go API Library v21.0.0 to latest import ( "context" "github.com/adyen/adyen-go-api-library/v21/src/common" "github.com/adyen/adyen-go-api-library/v21/src/adyen" "github.com/adyen/adyen-go-api-library/v21/src/checkout" ) // For the LIVE environment, also include your liveEndpointUrlPrefix. client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Create the request object(s) lineItem1 := checkout.LineItem{ Quantity: common.PtrInt64(1), AmountExcludingTax: common.PtrInt64(3058), TaxPercentage: common.PtrInt64(2100), ImageUrl: common.PtrString("URL_TO_PICTURE_OF_PURCHASED_ITEM"), Description: common.PtrString("Socks"), Id: common.PtrString("Item #1"), TaxAmount: common.PtrInt64(642), AmountIncludingTax: common.PtrInt64(3700), ProductUrl: common.PtrString("URL_TO_PURCHASED_ITEM"), } lineItem2 := checkout.LineItem{ Quantity: common.PtrInt64(1), AmountExcludingTax: common.PtrInt64(3058), TaxPercentage: common.PtrInt64(2100), ImageUrl: common.PtrString("URL_TO_PICTURE_OF_PURCHASED_ITEM"), Description: common.PtrString("Shoes"), Id: common.PtrString("Item #1"), TaxAmount: common.PtrInt64(642), AmountIncludingTax: common.PtrInt64(3700), ProductUrl: common.PtrString("URL_TO_PURCHASED_ITEM"), } amount := checkout.Amount{ Currency: "EUR", Value: 7400, } paymentRefundRequest := checkout.PaymentRefundRequest{ Reference: common.PtrString("YOUR_REFUND_REFERENCE"), LineItems: []checkout.LineItem{ lineItem1, lineItem2, }, Amount: amount, MerchantAccount: "ADYEN_MERCHANT_ACCOUNT", } // Send the request service := client.Checkout() req := service.ModificationsApi.RefundCapturedPaymentInput("paymentPspReference").IdempotencyKey("UUID").PaymentRefundRequest(paymentRefundRequest) res, httpRes, err := service.ModificationsApi.RefundCapturedPayment(context.Background(), req) ``` #### Python ```py # Adyen Python API Library v14.0.0 to latest import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_API_KEY" # For the LIVE environment, also include your liveEndpointUrlPrefix. adyen.client.platform = "test" # The environment to use library in. # Create the request object(s) json_request = { "reference": "YOUR_REFUND_REFERENCE", "amount": { "value": "7400", "currency": "EUR" }, "merchantAccount": "ADYEN_MERCHANT_ACCOUNT", "lineItems": [{ "quantity": "1", "amountExcludingTax": "3058", "taxPercentage": "2100", "taxAmount": "642", "description": "Socks", "id": "Item #1", "amountIncludingTax": "3700", "productUrl": "URL_TO_PURCHASED_ITEM", "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM" }, { "quantity": "1", "amountExcludingTax": "3058", "taxPercentage": "2100", "taxAmount": "642", "description": "Shoes", "id": "Item #1", "amountIncludingTax": "3700", "productUrl": "URL_TO_PURCHASED_ITEM", "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM" }] } # Send the request result = adyen.checkout.modifications_api.refund_captured_payment(request=json_request, paymentPspReference="paymentPspReference", idempotency_key="UUID") ``` #### Ruby ```rb # Adyen Ruby API Library v11.0.0 to latest require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_API_KEY' # For the LIVE environment, also include your liveEndpointUrlPrefix. adyen.env = :test # Set to "live" for live environment # Create the request object(s) request_body = { "reference" => "YOUR_REFUND_REFERENCE", "amount" => { "value" => "7400", "currency" => "EUR" }, "merchantAccount" => "ADYEN_MERCHANT_ACCOUNT", "lineItems" => [{ "quantity" => "1", "amountExcludingTax" => "3058", "taxPercentage" => "2100", "taxAmount" => "642", "description" => "Socks", "id" => "Item #1", "amountIncludingTax" => "3700", "productUrl" => "URL_TO_PURCHASED_ITEM", "imageUrl" => "URL_TO_PICTURE_OF_PURCHASED_ITEM" }, { "quantity" => "1", "amountExcludingTax" => "3058", "taxPercentage" => "2100", "taxAmount" => "642", "description" => "Shoes", "id" => "Item #1", "amountIncludingTax" => "3700", "productUrl" => "URL_TO_PURCHASED_ITEM", "imageUrl" => "URL_TO_PICTURE_OF_PURCHASED_ITEM" }] } # Send the request result = adyen.checkout.modifications_api.refund_captured_payment(request_body, 'paymentPspReference', headers: { 'Idempotency-Key' => 'UUID' }) ``` #### NodeJS (TypeScript) ```ts // Adyen Node API Library v30.0.0 to latest import { Client, Config, EnvironmentEnum, CheckoutAPI, Types } from "@adyen/api-library"; // For the LIVE environment, also include your liveEndpointUrlPrefix. const config = new Config({ apiKey: "ADYEN_API_KEY", environment: EnvironmentEnum.TEST }); const client = new Client(config); // Create the request object(s) const lineItem1: Types.checkout.LineItem = { quantity: 1, amountExcludingTax: 3058, taxPercentage: 2100, imageUrl: "URL_TO_PICTURE_OF_PURCHASED_ITEM", description: "Socks", id: "Item #1", taxAmount: 642, amountIncludingTax: 3700, productUrl: "URL_TO_PURCHASED_ITEM" }; const lineItem2: Types.checkout.LineItem = { quantity: 1, amountExcludingTax: 3058, taxPercentage: 2100, imageUrl: "URL_TO_PICTURE_OF_PURCHASED_ITEM", description: "Shoes", id: "Item #1", taxAmount: 642, amountIncludingTax: 3700, productUrl: "URL_TO_PURCHASED_ITEM" }; const amount: Types.checkout.Amount = { currency: "EUR", value: 7400 }; const paymentRefundRequest: Types.checkout.PaymentRefundRequest = { reference: "YOUR_REFUND_REFERENCE", lineItems: [lineItem1, lineItem2], amount: amount, merchantAccount: "ADYEN_MERCHANT_ACCOUNT" }; // Send the request const checkoutAPI = new CheckoutAPI(client); const response = await checkoutAPI.ModificationsApi.refundCapturedPayment("paymentPspReference", paymentRefundRequest, { idempotencyKey: "UUID" }); ``` You will receive a response containing a `pspReference`. Once we have processed your request, you will also receive a [REFUND](https://docs.adyen.com/api-explorer/Webhooks/latest/post/REFUND) webhook. ## Apply a discount There are several ways to apply a discount to the invoice: * [Apply a discount to individual line items](https://docs.adyen.com/payment-methods/klarna/invoice-lines#discounted-amounts). * [Apply a discount to the whole purchase](https://docs.adyen.com/payment-methods/klarna/invoice-lines#discount-line-incl-vat). * [Let Adyen add a discount line for you](https://docs.adyen.com/payment-methods/klarna/invoice-lines#no-discount-line). 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: 1. Calculate the reduced amount of each line item you want to discount. 2. 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 | | | | **Apply discount to individual line items** ```json { "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: 1. Calculate the discount to the product total and the VAT. 2. In your payments request, send each fully priced line item, plus a line Item to specify the discount with the following parameters: * `id`: **Discount** * `description`: **Discount** * `amountExcludingTax`: The discount amount, preceded by a minus sign * `taxAmount`: The discount amount, preceded by a minus sign * `amountIncludingTax`: 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 | | | | **Apply discount to entire purchase** ```json { "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. **Adyen applies discount line** ```json { "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](https://docs.adyen.com/online-payments/adjust-authorisation/adjust-with-preauth) for detailed instructions. This is available for Klarna with Checkout API v70 and later. Below are two examples of adjusting an authorized payment: * [Cancel part of the authorization before capture](https://docs.adyen.com/payment-methods/klarna/invoice-lines#cancel-before-capture) * [Add a new product to a partially captured order](https://docs.adyen.com/payment-methods/klarna/invoice-lines#add-product-partial-capture) These examples are based on the following order: #### curl ```bash 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", "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.example.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" } ] }' ``` #### Java ```java // Adyen Java API Library v38.0.0 to latest import com.adyen.Client; import com.adyen.Config; import com.adyen.enums.Environment; import com.adyen.model.*; import com.adyen.service.*; import java.math.*; import com.adyen.model.checkout.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.model.RequestOptions; import com.adyen.service.checkout.*; Config config = new Config() .apiKey("ADYEN_API_KEY") .environment(Environment.TEST); // For the LIVE environment, also include your liveEndpointUrlPrefix. Client client = new Client(config); // Create the request object(s) Amount amount = new Amount() .currency("SEK") .value(1000L); LineItem lineItem1 = new LineItem() .quantity(1L) .taxPercentage(2100L) .imageUrl("URL_TO_PICTURE_OF_PURCHASED_ITEM") .description("Shoes") .id("Item #1") .amountIncludingTax(400L) .productUrl("URL_TO_PURCHASED_ITEM"); LineItem lineItem2 = new LineItem() .quantity(2L) .taxPercentage(2100L) .imageUrl("URL_TO_PICTURE_OF_PURCHASED_ITEM") .description("Socks") .id("Item #2") .amountIncludingTax(300L) .productUrl("URL_TO_PURCHASED_ITEM"); ShopperName shopperName = new ShopperName() .firstName("Testperson-se") .lastName("Approved"); DeliveryAddress deliveryAddress = new DeliveryAddress() .country("SE") .city("Ankeborg") .houseNumberOrName("1") .street("Stargatan") .postalCode("12345"); BillingAddress billingAddress = new BillingAddress() .country("SE") .city("Ankeborg") .houseNumberOrName("1") .street("Stargatan") .postalCode("12345"); CreateCheckoutSessionRequest createCheckoutSessionRequest = new CreateCheckoutSessionRequest() .amount(amount) .telephoneNumber("+46 840 839 298") .socialSecurityNumber("0108") .shopperEmail("youremail@email.com") .reference("YOUR_ORDER_REFERENCE") .lineItems(Arrays.asList(lineItem1, lineItem2)) .shopperName(shopperName) .merchantAccount("ADYEN_MERCHANT_ACCOUNT") .deliveryAddress(deliveryAddress) .countryCode("SE") .shopperLocale("en_US") .billingAddress(billingAddress) .returnUrl("https://your-company.example.com/checkout?shopperOrder=12xy..") .shopperReference("YOUR_UNIQUE_SHOPPER_ID"); // Send the request PaymentsApi service = new PaymentsApi(client); CreateCheckoutSessionResponse response = service.sessions(createCheckoutSessionRequest, new RequestOptions().idempotencyKey("UUID")); ``` #### PHP ```php setXApiKey("ADYEN_API_KEY"); // For the LIVE environment, also include your liveEndpointUrlPrefix. $client->setEnvironment(Environment::TEST); // Create the request object(s) $amount = new Amount(); $amount ->setCurrency("SEK") ->setValue(1000); $lineItem1 = new LineItem(); $lineItem1 ->setQuantity(1) ->setTaxPercentage(2100) ->setImageUrl("URL_TO_PICTURE_OF_PURCHASED_ITEM") ->setDescription("Shoes") ->setId("Item #1") ->setAmountIncludingTax(400) ->setProductUrl("URL_TO_PURCHASED_ITEM"); $lineItem2 = new LineItem(); $lineItem2 ->setQuantity(2) ->setTaxPercentage(2100) ->setImageUrl("URL_TO_PICTURE_OF_PURCHASED_ITEM") ->setDescription("Socks") ->setId("Item #2") ->setAmountIncludingTax(300) ->setProductUrl("URL_TO_PURCHASED_ITEM"); $shopperName = new ShopperName(); $shopperName ->setFirstName("Testperson-se") ->setLastName("Approved"); $deliveryAddress = new DeliveryAddress(); $deliveryAddress ->setCountry("SE") ->setCity("Ankeborg") ->setHouseNumberOrName("1") ->setStreet("Stargatan") ->setPostalCode("12345"); $billingAddress = new BillingAddress(); $billingAddress ->setCountry("SE") ->setCity("Ankeborg") ->setHouseNumberOrName("1") ->setStreet("Stargatan") ->setPostalCode("12345"); $createCheckoutSessionRequest = new CreateCheckoutSessionRequest(); $createCheckoutSessionRequest ->setAmount($amount) ->setTelephoneNumber("+46 840 839 298") ->setSocialSecurityNumber("0108") ->setShopperEmail("youremail@email.com") ->setReference("YOUR_ORDER_REFERENCE") ->setLineItems(array($lineItem1, $lineItem2)) ->setShopperName($shopperName) ->setMerchantAccount("ADYEN_MERCHANT_ACCOUNT") ->setDeliveryAddress($deliveryAddress) ->setCountryCode("SE") ->setShopperLocale("en_US") ->setBillingAddress($billingAddress) ->setReturnUrl("https://your-company.example.com/checkout?shopperOrder=12xy..") ->setShopperReference("YOUR_UNIQUE_SHOPPER_ID"); $requestOptions['idempotencyKey'] = 'UUID'; // Send the request $service = new PaymentsApi($client); $response = $service->sessions($createCheckoutSessionRequest, $requestOptions); ``` #### C\# ```cs // Adyen .NET API Library v34.0.0 to latest using System; using System.Collections.Generic; using Adyen.Checkout.Extensions; using Adyen.Checkout.Models; using Adyen.Checkout.Services; using Adyen.Core.Client; using Adyen.Core.Client.Extensions; using Adyen.Core.Options; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; var host = Host.CreateDefaultBuilder() .ConfigureCheckout( (context, services, config) => { config.ConfigureAdyenOptions(options => { options.AdyenApiKey = "ADYEN_API_KEY"; options.Environment = AdyenEnvironment.Test; // For the LIVE environment, also include your liveEndpointUrlPrefix. // options.LiveEndpointUrlPrefix = ""; }); services.AddAllCheckoutServices(); }) .Build(); var paymentsService = host.Services.GetRequiredService(); // Create the request object(s) var amount = new Amount { Currency = "SEK", Value = 1000 }; var lineItem1 = new LineItem { Quantity = 1, TaxPercentage = 2100, ImageUrl = "URL_TO_PICTURE_OF_PURCHASED_ITEM", Description = "Shoes", Id = "Item #1", AmountIncludingTax = 400, ProductUrl = "URL_TO_PURCHASED_ITEM" }; var lineItem2 = new LineItem { Quantity = 2, TaxPercentage = 2100, ImageUrl = "URL_TO_PICTURE_OF_PURCHASED_ITEM", Description = "Socks", Id = "Item #2", AmountIncludingTax = 300, ProductUrl = "URL_TO_PURCHASED_ITEM" }; var shopperName = new ShopperName { FirstName = "Testperson-se", LastName = "Approved" }; var deliveryAddress = new DeliveryAddress { Country = "SE", City = "Ankeborg", HouseNumberOrName = "1", Street = "Stargatan", PostalCode = "12345" }; var billingAddress = new BillingAddress { Country = "SE", City = "Ankeborg", HouseNumberOrName = "1", Street = "Stargatan", PostalCode = "12345" }; var createCheckoutSessionRequest = new CreateCheckoutSessionRequest { Amount = amount, TelephoneNumber = "+46 840 839 298", SocialSecurityNumber = "0108", ShopperEmail = "youremail@email.com", Reference = "YOUR_ORDER_REFERENCE", LineItems = new List{ lineItem1, lineItem2 }, ShopperName = shopperName, MerchantAccount = "ADYEN_MERCHANT_ACCOUNT", DeliveryAddress = deliveryAddress, CountryCode = "SE", ShopperLocale = "en_US", BillingAddress = billingAddress, ReturnUrl = "https://your-company.example.com/checkout?shopperOrder=12xy..", ShopperReference = "YOUR_UNIQUE_SHOPPER_ID" }; string idempotencyKey = Guid.NewGuid().ToString(); // Send the request var result = await paymentsService.SessionsAsync(createCheckoutSessionRequest, new RequestOptions().AddIdempotencyKey(idempotencyKey)); if (result.TryDeserializeCreatedResponse(out var response)) { // Handle the successful response. } ``` #### NodeJS (JavaScript) ```js // Adyen Node API Library v16.1.0 // Require the parts of the module you want to use const { Client, CheckoutAPI } = require('@adyen/api-library'); // Initialize the client object const client = new Client({apiKey: "YOUR_X_API_KEY", environment: "TEST"}); // Create the request object const createCheckoutSessionRequest = { merchantAccount: "YOUR_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", 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: new Date("1996-09-04"), socialSecurityNumber: "0108", returnUrl: "", 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" } ] } // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentsApi.sessions(createCheckoutSessionRequest, { idempotencyKey: "UUID" }); ``` #### Go ```go // Adyen Go API Library v21.0.0 to latest import ( "context" "github.com/adyen/adyen-go-api-library/v21/src/common" "github.com/adyen/adyen-go-api-library/v21/src/adyen" "github.com/adyen/adyen-go-api-library/v21/src/checkout" ) // For the LIVE environment, also include your liveEndpointUrlPrefix. client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Create the request object(s) amount := checkout.Amount{ Currency: "SEK", Value: 1000, } lineItem1 := checkout.LineItem{ Quantity: common.PtrInt64(1), TaxPercentage: common.PtrInt64(2100), ImageUrl: common.PtrString("URL_TO_PICTURE_OF_PURCHASED_ITEM"), Description: common.PtrString("Shoes"), Id: common.PtrString("Item #1"), AmountIncludingTax: common.PtrInt64(400), ProductUrl: common.PtrString("URL_TO_PURCHASED_ITEM"), } lineItem2 := checkout.LineItem{ Quantity: common.PtrInt64(2), TaxPercentage: common.PtrInt64(2100), ImageUrl: common.PtrString("URL_TO_PICTURE_OF_PURCHASED_ITEM"), Description: common.PtrString("Socks"), Id: common.PtrString("Item #2"), AmountIncludingTax: common.PtrInt64(300), ProductUrl: common.PtrString("URL_TO_PURCHASED_ITEM"), } shopperName := checkout.ShopperName{ FirstName: "Testperson-se", LastName: "Approved", } deliveryAddress := checkout.DeliveryAddress{ Country: "SE", City: "Ankeborg", HouseNumberOrName: "1", Street: "Stargatan", PostalCode: "12345", } billingAddress := checkout.BillingAddress{ Country: "SE", City: "Ankeborg", HouseNumberOrName: "1", Street: "Stargatan", PostalCode: "12345", } createCheckoutSessionRequest := checkout.CreateCheckoutSessionRequest{ Amount: amount, TelephoneNumber: common.PtrString("+46 840 839 298"), SocialSecurityNumber: common.PtrString("0108"), ShopperEmail: common.PtrString("youremail@email.com"), Reference: "YOUR_ORDER_REFERENCE", LineItems: []checkout.LineItem{ lineItem1, lineItem2, }, ShopperName: &shopperName, MerchantAccount: "ADYEN_MERCHANT_ACCOUNT", DeliveryAddress: &deliveryAddress, CountryCode: common.PtrString("SE"), ShopperLocale: common.PtrString("en_US"), BillingAddress: &billingAddress, ReturnUrl: "https://your-company.example.com/checkout?shopperOrder=12xy..", ShopperReference: common.PtrString("YOUR_UNIQUE_SHOPPER_ID"), } // Send the request service := client.Checkout() req := service.PaymentsApi.SessionsInput().IdempotencyKey("UUID").CreateCheckoutSessionRequest(createCheckoutSessionRequest) res, httpRes, err := service.PaymentsApi.Sessions(context.Background(), req) ``` #### Python ```py # Adyen Python API Library v12.0.0 import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "YOUR_X_API_KEY" adyen.client.platform = "test" # The environment to use library in. json_request = { "merchantAccount": "YOUR_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", "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": "", "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" } ] } result = adyen.checkout.payments_api.sessions(request=json_request, idempotency_key="UUID") ``` #### Ruby ```rb # Adyen Ruby API Library v9.1.0 require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'YOUR_X_API_KEY' adyen.env = :test # Set to "live" for live environment request_body = { :merchantAccount => 'YOUR_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', :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 => '', :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' } ] } result = adyen.checkout.payments_api.sessions(request_body, headers: { 'Idempotency-Key' => 'UUID' }) ``` #### NodeJS (TypeScript) ```ts // Adyen Node API Library v30.0.0 to latest import { Client, Config, EnvironmentEnum, CheckoutAPI, Types } from "@adyen/api-library"; // For the LIVE environment, also include your liveEndpointUrlPrefix. const config = new Config({ apiKey: "ADYEN_API_KEY", environment: EnvironmentEnum.TEST }); const client = new Client(config); // Create the request object(s) const amount: Types.checkout.Amount = { currency: "SEK", value: 1000 }; const lineItem1: Types.checkout.LineItem = { quantity: 1, taxPercentage: 2100, imageUrl: "URL_TO_PICTURE_OF_PURCHASED_ITEM", description: "Shoes", id: "Item #1", amountIncludingTax: 400, productUrl: "URL_TO_PURCHASED_ITEM" }; const lineItem2: Types.checkout.LineItem = { quantity: 2, taxPercentage: 2100, imageUrl: "URL_TO_PICTURE_OF_PURCHASED_ITEM", description: "Socks", id: "Item #2", amountIncludingTax: 300, productUrl: "URL_TO_PURCHASED_ITEM" }; const shopperName: Types.checkout.ShopperName = { firstName: "Testperson-se", lastName: "Approved" }; const deliveryAddress: Types.checkout.DeliveryAddress = { country: "SE", city: "Ankeborg", houseNumberOrName: "1", street: "Stargatan", postalCode: "12345" }; const billingAddress: Types.checkout.BillingAddress = { country: "SE", city: "Ankeborg", houseNumberOrName: "1", street: "Stargatan", postalCode: "12345" }; const createCheckoutSessionRequest: Types.checkout.CreateCheckoutSessionRequest = { amount: amount, telephoneNumber: "+46 840 839 298", socialSecurityNumber: "0108", shopperEmail: "youremail@email.com", reference: "YOUR_ORDER_REFERENCE", lineItems: [lineItem1, lineItem2], shopperName: shopperName, merchantAccount: "ADYEN_MERCHANT_ACCOUNT", deliveryAddress: deliveryAddress, countryCode: "SE", shopperLocale: "en_US", billingAddress: billingAddress, returnUrl: "https://your-company.example.com/checkout?shopperOrder=12xy..", shopperReference: "YOUR_UNIQUE_SHOPPER_ID" }; // Send the request const checkoutAPI = new CheckoutAPI(client); const response = await checkoutAPI.PaymentsApi.sessions(createCheckoutSessionRequest, { idempotencyKey: "UUID" }); ``` ### 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](https://docs.adyen.com/payment-methods/klarna/invoice-lines#klarna-sessions) by declaring the new basket composition and amount. **Cancel part of an auth before capture** ```json curl https: //checkout-test.adyen.com/checkout/v72/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](https://docs.adyen.com/payment-methods/klarna/invoice-lines#klarna-sessions) is captured, and we add a third item to the order: **Add product to partially captured order** ```json curl https: //checkout-test.adyen.com/checkout/v72/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" } ] }' ```