--- title: "Pay by Link through the API" description: "Learn how to create payment links through the API." url: "https://docs.adyen.com/unified-commerce/pay-by-link/create-payment-links/api" source_url: "https://docs.adyen.com/unified-commerce/pay-by-link/create-payment-links/api.md" canonical: "https://docs.adyen.com/unified-commerce/pay-by-link/create-payment-links/api" last_modified: "2026-05-24T12:54:31+02:00" language: "en" --- # Pay by Link through the API Learn how to create payment links through the API. [View source](/unified-commerce/pay-by-link/create-payment-links/api.md) ![](/user/pages/reuse/development-resources/additional-info-resources/postman-logo-vertical-orange-2021.svg?decoding=auto\&fetchpriority=auto)  [Postman collection](https://www.postman.com/adyendev/workspace/adyen-apis/collection/25716737-46ad970e-dc9e-4246-bac2-769c6083e7b5) **Implementation examples**\ ![](/user/pages/reuse/development-resources/additional-info-resources/java-original.svg?decoding=auto\&fetchpriority=auto)  [Java Spring](https://github.com/adyen-examples/adyen-java-spring-online-payments/tree/main/paybylink-example)\ ![](/user/pages/reuse/development-resources/additional-info-resources/dot-net-original.svg?decoding=auto\&fetchpriority=auto)  [.NET](https://github.com/adyen-examples/adyen-dotnet-online-payments/tree/main/paybylink-example)\ ![](/user/pages/reuse/development-resources/additional-info-resources/nodejs-original.svg?decoding=auto\&fetchpriority=auto)  [Node.js](https://github.com/adyen-examples/adyen-node-online-payments/tree/main/paybylink-example) Creating payment links through the API allows you to accept [most payment methods](/unified-commerce/pay-by-link/supported-payment-methods), including buy now, pay later payment methods such as Klarna and Afterpay. Using payment links to accept payments works as follows: 1. [Create a payment link](#create). 2. [Send the payment link to your shopper](#send). 3. [Get updates about the payment](#get-updates). On this page, you'll also learn how to implement additional use cases such as: * [Create a reusable payment link](#reusable-payment-links). * Tokenize your shopper's payment details for future [one-off payments](#tokenize-future-payments) or for [subscription payments](#tokenize-subscriptions). * Provide [additional information](#provide-additional-information) about the product or the shopper. This is required for some payment methods, for example buy now, pay later payment methods. * [Force the expiry of a payment link](#force-expiry), for example if you sent a new payment link to your shopper. * [Customize](#customize) the payment methods, style, and language shown on the payment page. ## Requirements Before you begin to integrate, make sure you have followed the [Get started with Adyen guide](/get-started-with-adyen) to: * Get an overview of the steps needed to accept live payments. * Create your test account. After you have created your test account: * [Add your terms and conditions](/unified-commerce/pay-by-link#add-your-terms-and-conditions) to the Pay by Link payment page. * [Generate your API key](#api-key) for creating payment links. * [Set up webhooks](#webhooks) to keep track of the payment result. * [Add payment methods](#add-payment-methods) to your account. ### Generate your API key 1. Log in to your [Customer Area](https://ca-test.adyen.com/) and select your **Company** account. 2. Go to **Developers** > **API credentials**. 3. Select the **Payments** or **Platforms** tab, depending on your integration type. 4. Select the credential username. 5. Under **Server settings** > **Authentication** select the **API key** tab. 6. Select **Generate API key**. 7. Select the copy icon **and store your API key securely in your system. You cannot copy the API key again after you leave the page. 8. Select **Save changes**. ### Set up webhooks Webhooks allow you to get updates about the payment after you have sent the payment link to your shopper. If you haven't done so already, [set up webhooks](/development-resources/webhooks), and make sure that your server can process and accept webhooks. ### Add payment methods to your account If you haven't done so already, add payment methods to your merchant account. To see which payment methods are supported for Pay by Link, refer to [Supported payment methods](/unified-commerce/pay-by-link/supported-payment-methods). 1. Log in to your [Customer Area](https://ca-test.adyen.com/). 2. Switch to your merchant account. 3. Go to **Settings** > **Payment methods**. 4. Select **Add payment methods**. 5. Start entering the name of the payment method, then select it from the drop-down list. 6. Select **Submit**. ## Step 1: Create a payment link Make a POST [/paymentLinks](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks) request specifying the following: * [merchantAccount](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/paymentLinks__resParam_merchantAccount): the name of your merchant account. * [reference](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-reference): your identifier for the transaction. * [amount](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-amount): the `currency` and `value` in [minor units](/development-resources/currency-codes). You can also include other parameters, for example [`shopperLocale` ](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/paymentLinks__reqParam_shopperLocale)to specify the language of the payment page, [`expiresAt` ](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/paymentLinks__resParam_expiresAt)to change the expiry date of the payment link, or [`description` ](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/paymentLinks__reqParam_description)to add a description for the product. If these are not provided, the payment page will be rendered in the language of the shopper's browser locale, without a description, and with a 24-hour expiry. In this example, we'll show you how you can create a payment link for a shopper in the **Netherlands** for a purchase amount of **EUR 42**: #### curl ```bash curl https://checkout-test.adyen.com/v72/paymentLinks \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "reference": "YOUR_PAYMENT_REFERENCE", "amount": { "value": 4200, "currency": "EUR" }, "shopperReference": "YOUR_SHOPPER_REFERENCE", "description": "Blue Bag - ModelM671", "countryCode": "NL", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "shopperLocale": "nl-NL" }' ``` #### Java ```java // Adyen Java API Library v25.0.0 import com.adyen.Client; import com.adyen.enums.Environment; import com.adyen.model.checkout.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.model.RequestOptions; import com.adyen.service.checkout.*; Client client = new Client("ADYEN_API_KEY", Environment.TEST); // Request objects Amount amount = new Amount() .currency("EUR") .value(4200L); PaymentLinkRequest paymentLinkRequest = new PaymentLinkRequest() .reference("YOUR_PAYMENT_REFERENCE") .amount(amount) .merchantAccount("YOUR_MERCHANT_ACCOUNT") .countryCode("NL") .description("Blue Bag - ModelM671") .shopperLocale("nl-NL") .shopperReference("YOUR_SHOPPER_REFERENCE"); // Make the request PaymentLinksApi service = new PaymentLinksApi(client); PaymentLinkResponse response = service.paymentLinks(paymentLinkRequest, new RequestOptions().idempotencyKey("UUID")); ``` #### PHP ```php // Adyen PHP API Library v17.4.0 use Adyen\Client; use Adyen\Environment; use Adyen\Model\Checkout\Amount; use Adyen\Model\Checkout\PaymentLinkRequest; use Adyen\Service\Checkout\PaymentLinksApi; $client = new Client(); $client->setXApiKey("ADYEN_API_KEY"); $client->setEnvironment(Environment::TEST); // Request objects $amount = new Amount(); $amount ->setCurrency("EUR") ->setValue(4200); $paymentLinkRequest = new PaymentLinkRequest(); $paymentLinkRequest ->setReference("YOUR_PAYMENT_REFERENCE") ->setAmount($amount) ->setMerchantAccount("YOUR_MERCHANT_ACCOUNT") ->setCountryCode("NL") ->setDescription("Blue Bag - ModelM671") ->setShopperLocale("nl-NL") ->setShopperReference("YOUR_SHOPPER_REFERENCE"); $requestOptions['idempotencyKey'] = 'UUID'; // Make the request $service = new PaymentLinksApi($client); $response = $service->paymentLinks($paymentLinkRequest, $requestOptions); ``` #### C\# ```cs // Adyen .net API Library v14.3.0 using Adyen; using Environment = Adyen.Model.Environment; using Adyen.Model; using Adyen.Model.Checkout; using Adyen.Service.Checkout; var config = new Config() { XApiKey = "ADYEN_API_KEY", Environment = Environment.Test }; var client = new Client(config); // Fill in your request objects Amount amount = new Amount { Currency = "EUR", Value = 4200 }; PaymentLinkRequest paymentLinkRequest = new PaymentLinkRequest { Reference = "YOUR_PAYMENT_REFERENCE", Amount = amount, MerchantAccount = "YOUR_MERCHANT_ACCOUNT", CountryCode = "NL", Description = "Blue Bag - ModelM671", ShopperLocale = "nl-NL", ShopperReference = "YOUR_SHOPPER_REFERENCE" }; // Make the request var service = new PaymentLinksService(client); var response = service.PaymentLinks(paymentLinkRequest, requestOptions: new RequestOptions { IdempotencyKey = "UUID"}); ``` #### NodeJS (JavaScript) ```js // Adyen Node API Library v16.2.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: "ADYEN_API_KEY", environment: "TEST"}); // Create the request object const paymentLinkRequest = { reference: "YOUR_PAYMENT_REFERENCE", amount: { value: 4200, currency: "EUR" }, shopperReference: "YOUR_SHOPPER_REFERENCE", description: "Blue Bag - ModelM671", countryCode: "NL", merchantAccount: "YOUR_MERCHANT_ACCOUNT", shopperLocale: "nl-NL" } // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentLinksApi.paymentLinks(paymentLinkRequest, { idempotencyKey: "UUID" }); ``` #### Go ```go // Adyen Go API Library v9.2.0 import ( "context" "github.com/adyen/adyen-go-api-library/v9/src/common" "github.com/adyen/adyen-go-api-library/v9/src/adyen" "github.com/adyen/adyen-go-api-library/v9/src/checkout" ) client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Fill in your request objects amount := checkout.Amount{ Currency: "EUR", Value: 4200, } paymentLinkRequest := checkout.PaymentLinkRequest{ Reference: "YOUR_PAYMENT_REFERENCE", Amount: amount, MerchantAccount: "YOUR_MERCHANT_ACCOUNT", CountryCode: common.PtrString("NL"), Description: common.PtrString("Blue Bag - ModelM671"), ShopperLocale: common.PtrString("nl-NL"), ShopperReference: common.PtrString("YOUR_SHOPPER_REFERENCE"), } // Make the request service := client.Checkout() req := service.PaymentLinksApi.PaymentLinksInput().IdempotencyKey("UUID").PaymentLinkRequest(paymentLinkRequest) res, httpRes, err := service.PaymentLinksApi.PaymentLinks(context.Background(), req) ``` #### Python ```py # Adyen Python API Library v12.2.0 import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_API_KEY" adyen.client.platform = "test" # The environment to use library in. json_request = { "reference": "YOUR_PAYMENT_REFERENCE", "amount": { "value": 4200, "currency": "EUR" }, "shopperReference": "YOUR_SHOPPER_REFERENCE", "description": "Blue Bag - ModelM671", "countryCode": "NL", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "shopperLocale": "nl-NL" } result = adyen.checkout.payment_links_api.payment_links(request=json_request, idempotency_key="UUID") ``` #### Ruby ```rb # Adyen Ruby API Library v9.2.0 require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_API_KEY' adyen.env = :test # Set to "live" for live environment request_body = { :reference => 'YOUR_PAYMENT_REFERENCE', :amount => { :value => 4200, :currency => 'EUR' }, :shopperReference => 'YOUR_SHOPPER_REFERENCE', :description => 'Blue Bag - ModelM671', :countryCode => 'NL', :merchantAccount => 'YOUR_MERCHANT_ACCOUNT', :shopperLocale => 'nl-NL' } result = adyen.checkout.payment_links_api.payment_links(request_body, headers: { 'Idempotency-Key' => 'UUID' }) ``` #### NodeJS (TypeScript) ```ts // Adyen Node API Library v16.2.0 // Require the parts of the module you want to use import { Client, CheckoutAPI, Types } from "@adyen/api-library"; // Initialize the client object const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"}); // Create the request objects const amount: Types.checkout.Amount = { currency: "EUR", value: 4200 }; const paymentLinkRequest: Types.checkout.PaymentLinkRequest = { reference: "YOUR_PAYMENT_REFERENCE", amount: amount, merchantAccount: "YOUR_MERCHANT_ACCOUNT", countryCode: "NL", description: "Blue Bag - ModelM671", shopperLocale: "nl-NL", shopperReference: "YOUR_SHOPPER_REFERENCE" }; // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentLinksApi.paymentLinks(paymentLinkRequest, { idempotencyKey: "UUID" }); ``` You receive a response containing the following: * [id](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/paymentLinks__resParam_id): the payment link ID. * [url](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#responses-201-url): the payment link that you should send to your shopper. * [expiresAt](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/paymentLinks__reqParam_expiresAt): date and time when the payment link expires. **Response** ```json { "amount": { "currency": "EUR", "value": 4200 }, "countryCode": "NL", "description": "Blue Bag - ModelM671", "expiresAt": "2020-07-25T11:32:20Z", "id": "PL50C5F751CED39G71", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "reference": "YOUR_PAYMENT_REFERENCE", "shopperLocale": "nl-NL", "shopperReference": "YOUR_SHOPPER_REFERENCE", "url": "https://test.adyen.link/PL50C5F751CED39G71" } ``` ## Step 2: Send the payment link to your shopper Use the `url` from the [/paymentLinks](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks) response to redirect your shopper to the payment link. Starting November 1, 2025, you cannot embed payment links in an iframe. If you are currently using payment links in an iframe, update your integration to comply. Send the `url` to your shopper. When the shopper selects the link, they are redirected to an Adyen-hosted payment page. The shopper is presented with the payment methods available for the `amount` and `countryCode` specified in the request. ## Step 3: Get updates about the payment First, wait for the [AUTHORISATION](#notification) webhook to receive the result of the payment, as well as the payment link ID. When you have the payment link ID, you can [make a GET `/paymentLinks/{linkId}` request](#get-details) to get details about the payment link. You can also [view payment links in your Customer Area](/unified-commerce/pay-by-link/create-payment-links/customer-area#view-links). Currently, the **Payment Links** page in the Customer Area only shows links that are created in the EU. For links created in other regions, you can use the [id](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#responses-201-id) you received in the [/paymentLinks](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks) response to navigate to the payment link details page, with the following format: ```text https://ca-live.adyen.com/ca/ca/transactions/payment-link-details.shtml?d=PAYMENT_LINK_ID ``` We keep payment link details for three months. If it was more than three months ago that a payment link was created, the details are no longer available. ### AUTHORISATION webhook The **AUTHORISATION** webhook contains: * `additionalData.paymentLinkId`: Use this to match the payment to the payment link. For our example, this matches the payment link ID **PL50C5F751CED39G71**. * `pspReference`: Unique identifier for the payment. * `success`: The result of the transaction. | `success` | Description | Action to take | | --------- | -------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **true** | The shopper successfully completed the payment. | Inform the shopper that the payment has been successful, and proceed with the order. If you have enabled [manual capture](/online-payments/capture#manual-capture), you also need to capture the payment. | | **false** | The shopper attempted to pay but the transaction failed. | The payment page informs the shopper that the payment was unsuccessful, and prompts them to try again. If the shopper still doesn't make a successful payment, you may want to reach out to them to follow up. | **AUTHORISATION webhook** ```json { "notificationItems":[ { "NotificationRequestItem":{ "additionalData":{ ... "paymentLinkId":"PL50C5F751CED39G71" }, "amount":{ "currency":"EUR", "value":4200 }, ... "eventCode":"AUTHORISATION", "merchantAccountCode":"YOUR_MERCHANT_ACCOUNT", "merchantReference":"YOUR_ORDER_NUMBER", "pspReference":"852593065346377D", "success":"true" } } ] } ``` ### Get details about a payment link To get the details of a specific payment link, send a GET [/paymentLinks/{linkId}](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/get/paymentLinks/{linkId}) request. Let's use our example from the previous section for a payment link with ID **PL50C5F751CED39G71**. **Get payment link details** ```bash curl https://checkout-test.adyen.com/v68/paymentLinks/PL50C5F751CED39G71 \ -X GET \ -H'x-api-key: ADYEN_API_KEY' ``` The response returns the payment link details, including the `amount` and the `status`. If the link is not expired and has not been paid, the status is **active**. Else, the status is **completed** or **expired**. The status can also be **paymentPending** if the payment has an asynchronous flow and the shopper hasn't yet completed the payment. **Response** ```json { "amount": { "currency": "EUR", "value": 4200 }, "countryCode": "NL", "expiresAt": "2020-06-23T12:25:28Z", "id": "PL50C5F751CED39G71", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "reference": "YOUR_PAYMENT_REFERENCE", "shopperLocale": "nl-NL", "status": "active", "url": "https://test.adyen.link/PL50C5F751CED39G71" } ``` ## Create a reusable payment link In some cases, you may want to create a reusable link. For example, if you want to accept donations for a fixed amount from multiple shoppers, or sell event tickets. To do this, set [reusable](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/paymentLinks__resParam_reusable) to **true** in your POST [/paymentLinks](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks) request. The following example shows how to create a *reusable* payment link to accept donations for the amount of **USD 8.50** from shoppers in the **United States**: **Create a reusable payment link** #### curl ```bash curl https://checkout-test.adyen.com/v68/paymentLinks \ -H'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "reference": "YOUR_PAYMENT_REFERENCE", "amount": { "value": 850, "currency": "USD" }, "description": "Donation", "countryCode": "US", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "shopperLocale": "en-US", "reusable" : true }' ``` #### Java ```java // Adyen Java API Library v25.0.0 import com.adyen.Client; import com.adyen.enums.Environment; import com.adyen.model.checkout.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.model.RequestOptions; import com.adyen.service.checkout.*; Client client = new Client("ADYEN_API_KEY", Environment.TEST); // Request objects Amount amount = new Amount() .currency("USD") .value(850L); PaymentLinkRequest paymentLinkRequest = new PaymentLinkRequest() .reference("YOUR_PAYMENT_REFERENCE") .amount(amount) .merchantAccount("YOUR_MERCHANT_ACCOUNT") .countryCode("US") .description("Donation") .shopperLocale("en-US") .reusable(true); // Make the request PaymentLinksApi service = new PaymentLinksApi(client); PaymentLinkResponse response = service.paymentLinks(paymentLinkRequest, new RequestOptions().idempotencyKey("UUID")); ``` #### PHP ```php // Adyen PHP API Library v17.4.0 use Adyen\Client; use Adyen\Environment; use Adyen\Model\Checkout\Amount; use Adyen\Model\Checkout\PaymentLinkRequest; use Adyen\Service\Checkout\PaymentLinksApi; $client = new Client(); $client->setXApiKey("ADYEN_API_KEY"); $client->setEnvironment(Environment::TEST); // Request objects $amount = new Amount(); $amount ->setCurrency("USD") ->setValue(850); $paymentLinkRequest = new PaymentLinkRequest(); $paymentLinkRequest ->setReference("YOUR_PAYMENT_REFERENCE") ->setAmount($amount) ->setMerchantAccount("YOUR_MERCHANT_ACCOUNT") ->setCountryCode("US") ->setDescription("Donation") ->setShopperLocale("en-US") ->setReusable(true); $requestOptions['idempotencyKey'] = 'UUID'; // Make the request $service = new PaymentLinksApi($client); $response = $service->paymentLinks($paymentLinkRequest, $requestOptions); ``` #### C\# ```cs // Adyen .net API Library v14.3.0 using Adyen; using Environment = Adyen.Model.Environment; using Adyen.Model; using Adyen.Model.Checkout; using Adyen.Service.Checkout; var config = new Config() { XApiKey = "ADYEN_API_KEY", Environment = Environment.Test }; var client = new Client(config); // Fill in your request objects Amount amount = new Amount { Currency = "USD", Value = 850 }; PaymentLinkRequest paymentLinkRequest = new PaymentLinkRequest { Reference = "YOUR_PAYMENT_REFERENCE", Amount = amount, MerchantAccount = "YOUR_MERCHANT_ACCOUNT", CountryCode = "US", Description = "Donation", ShopperLocale = "en-US", Reusable = true }; // Make the request var service = new PaymentLinksService(client); var response = service.PaymentLinks(paymentLinkRequest, requestOptions: new RequestOptions { IdempotencyKey = "UUID"}); ``` #### NodeJS (JavaScript) ```js // Adyen Node API Library v16.2.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: "ADYEN_API_KEY", environment: "TEST"}); // Create the request object const paymentLinkRequest = { reference: "YOUR_PAYMENT_REFERENCE", amount: { value: 850, currency: "USD" }, description: "Donation", countryCode: "US", merchantAccount: "YOUR_MERCHANT_ACCOUNT", shopperLocale: "en-US", reusable: true } // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentLinksApi.paymentLinks(paymentLinkRequest, { idempotencyKey: "UUID" }); ``` #### Go ```go // Adyen Go API Library v9.2.0 import ( "context" "github.com/adyen/adyen-go-api-library/v9/src/common" "github.com/adyen/adyen-go-api-library/v9/src/adyen" "github.com/adyen/adyen-go-api-library/v9/src/checkout" ) client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Fill in your request objects amount := checkout.Amount{ Currency: "USD", Value: 850, } paymentLinkRequest := checkout.PaymentLinkRequest{ Reference: "YOUR_PAYMENT_REFERENCE", Amount: amount, MerchantAccount: "YOUR_MERCHANT_ACCOUNT", CountryCode: common.PtrString("US"), Description: common.PtrString("Donation"), ShopperLocale: common.PtrString("en-US"), Reusable: common.PtrBool(true), } // Make the request service := client.Checkout() req := service.PaymentLinksApi.PaymentLinksInput().IdempotencyKey("UUID").PaymentLinkRequest(paymentLinkRequest) res, httpRes, err := service.PaymentLinksApi.PaymentLinks(context.Background(), req) ``` #### Python ```py # Adyen Python API Library v12.2.0 import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_API_KEY" adyen.client.platform = "test" # The environment to use library in. json_request = { "reference": "YOUR_PAYMENT_REFERENCE", "amount": { "value": 850, "currency": "USD" }, "description": "Donation", "countryCode": "US", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "shopperLocale": "en-US", "reusable": True } result = adyen.checkout.payment_links_api.payment_links(request=json_request, idempotency_key="UUID") ``` #### Ruby ```rb # Adyen Ruby API Library v9.2.0 require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_API_KEY' adyen.env = :test # Set to "live" for live environment request_body = { :reference => 'YOUR_PAYMENT_REFERENCE', :amount => { :value => 850, :currency => 'USD' }, :description => 'Donation', :countryCode => 'US', :merchantAccount => 'YOUR_MERCHANT_ACCOUNT', :shopperLocale => 'en-US', :reusable => true } result = adyen.checkout.payment_links_api.payment_links(request_body, headers: { 'Idempotency-Key' => 'UUID' }) ``` #### NodeJS (TypeScript) ```ts // Adyen Node API Library v16.2.0 // Require the parts of the module you want to use import { Client, CheckoutAPI, Types } from "@adyen/api-library"; // Initialize the client object const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"}); // Create the request objects const amount: Types.checkout.Amount = { currency: "USD", value: 850 }; const paymentLinkRequest: Types.checkout.PaymentLinkRequest = { reference: "YOUR_PAYMENT_REFERENCE", amount: amount, merchantAccount: "YOUR_MERCHANT_ACCOUNT", countryCode: "US", description: "Donation", shopperLocale: "en-US", reusable: true }; // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentLinksApi.paymentLinks(paymentLinkRequest, { idempotencyKey: "UUID" }); ``` ## Tokenize your shopper's payment details You can use the Pay by Link API to create a payment link that will tokenize and store your shopper's card details. Your `/paymentLinks` request must include a `recurringProcessingModel` to indicate how you want to use the token: | Business model | `recurringProcessingModel` | Description | | ------------------------------------------------------- | -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [One-off payments](#tokenize-future-payments) | **CardOnFile** | Tokenize the customer's card details, and with future payment links present the customer's stored card on the payment page. | | [Subscription payments](#tokenize-subscriptions) | **Subscription** | Tokenize the customer's card for recurring payments that occur at regular intervals without the customer being present. | | [Unscheduled recurring payments](#tokenize-unscheduled) | **UnscheduledCardOnFile** | Tokenize the customer's card for recurring payments that occur on a non-fixed schedule without the customer being present. This includes automatic top-ups when the cardholder's balance drops below a certain amount. | ### Tokenize for future one-off payments You should always ask for your customer's consent before tokenizing their card for future payments. You can use the Pay by Link API to create a payment link that will tokenize and store your shopper's card details for future one-off payments. The next time the same shopper makes a purchase, their stored card details will be presented on the payment page. 1. Send the following in your POST [/paymentLinks](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks) request: * A unique [shopperReference](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-shopperReference) of at least three characters. Your reference must not include personally identifiable information (PII), like name or email address. * [storePaymentMethodMode](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-storePaymentMethodMode) set to **askForConsent** to allow the shopper to decide whether to store the details. If you already have the shopper's consent, set this parameter to **enabled**. * [recurringProcessingModel](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#responses-200-recurringProcessingModel) set to **CardOnFile**. Here's an example of how you can create a payment link for a shopper with `shopperReference` **ShopperID-A16728**. **Create a payment link to save card details** #### curl ```bash curl https://checkout-test.adyen.com/v68/paymentLinks \ -H'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "reference": "YOUR_PAYMENT_REFERENCE", "amount": { "value": 4250, "currency": "EUR" }, "description": "Black sneakers - X51", "countryCode": "NL", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "shopperLocale": "nl-NL", "shopperReference": "ShopperID-A16728", "storePaymentMethodMode": "askForConsent", "recurringProcessingModel": "CardOnFile" }' ``` #### Java ```java // Adyen Java API Library v25.0.0 import com.adyen.Client; import com.adyen.enums.Environment; import com.adyen.model.checkout.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.model.RequestOptions; import com.adyen.service.checkout.*; Client client = new Client("ADYEN_API_KEY", Environment.TEST); // Request objects Amount amount = new Amount() .currency("EUR") .value(4250L); PaymentLinkRequest paymentLinkRequest = new PaymentLinkRequest() .reference("YOUR_PAYMENT_REFERENCE") .storePaymentMethodMode(PaymentLinkRequest.StorePaymentMethodModeEnum.ASKFORCONSENT) .amount(amount) .merchantAccount("YOUR_MERCHANT_ACCOUNT") .countryCode("NL") .recurringProcessingModel(PaymentLinkRequest.RecurringProcessingModelEnum.CARDONFILE) .description("Black sneakers - X51") .shopperLocale("nl-NL") .shopperReference("ShopperID-A16728"); // Make the request PaymentLinksApi service = new PaymentLinksApi(client); PaymentLinkResponse response = service.paymentLinks(paymentLinkRequest, new RequestOptions().idempotencyKey("UUID")); ``` #### PHP ```php // Adyen PHP API Library v17.4.0 use Adyen\Client; use Adyen\Environment; use Adyen\Model\Checkout\Amount; use Adyen\Model\Checkout\PaymentLinkRequest; use Adyen\Service\Checkout\PaymentLinksApi; $client = new Client(); $client->setXApiKey("ADYEN_API_KEY"); $client->setEnvironment(Environment::TEST); // Request objects $amount = new Amount(); $amount ->setCurrency("EUR") ->setValue(4250); $paymentLinkRequest = new PaymentLinkRequest(); $paymentLinkRequest ->setReference("YOUR_PAYMENT_REFERENCE") ->setStorePaymentMethodMode("askForConsent") ->setAmount($amount) ->setMerchantAccount("YOUR_MERCHANT_ACCOUNT") ->setCountryCode("NL") ->setRecurringProcessingModel("CardOnFile") ->setDescription("Black sneakers - X51") ->setShopperLocale("nl-NL") ->setShopperReference("ShopperID-A16728"); $requestOptions['idempotencyKey'] = 'UUID'; // Make the request $service = new PaymentLinksApi($client); $response = $service->paymentLinks($paymentLinkRequest, $requestOptions); ``` #### C\# ```cs // Adyen .net API Library v14.3.0 using Adyen; using Environment = Adyen.Model.Environment; using Adyen.Model; using Adyen.Model.Checkout; using Adyen.Service.Checkout; var config = new Config() { XApiKey = "ADYEN_API_KEY", Environment = Environment.Test }; var client = new Client(config); // Fill in your request objects Amount amount = new Amount { Currency = "EUR", Value = 4250 }; PaymentLinkRequest paymentLinkRequest = new PaymentLinkRequest { Reference = "YOUR_PAYMENT_REFERENCE", StorePaymentMethodMode = PaymentLinkRequest.StorePaymentMethodModeEnum.AskForConsent, Amount = amount, MerchantAccount = "YOUR_MERCHANT_ACCOUNT", CountryCode = "NL", RecurringProcessingModel = PaymentLinkRequest.RecurringProcessingModelEnum.CardOnFile, Description = "Black sneakers - X51", ShopperLocale = "nl-NL", ShopperReference = "ShopperID-A16728" }; // Make the request var service = new PaymentLinksService(client); var response = service.PaymentLinks(paymentLinkRequest, requestOptions: new RequestOptions { IdempotencyKey = "UUID"}); ``` #### NodeJS (JavaScript) ```js // Adyen Node API Library v16.2.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: "ADYEN_API_KEY", environment: "TEST"}); // Create the request object const paymentLinkRequest = { reference: "YOUR_PAYMENT_REFERENCE", amount: { value: 4250, currency: "EUR" }, description: "Black sneakers - X51", countryCode: "NL", merchantAccount: "YOUR_MERCHANT_ACCOUNT", shopperLocale: "nl-NL", shopperReference: "ShopperID-A16728", storePaymentMethodMode: "askForConsent", recurringProcessingModel: "CardOnFile" } // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentLinksApi.paymentLinks(paymentLinkRequest, { idempotencyKey: "UUID" }); ``` #### Go ```go // Adyen Go API Library v9.2.0 import ( "context" "github.com/adyen/adyen-go-api-library/v9/src/common" "github.com/adyen/adyen-go-api-library/v9/src/adyen" "github.com/adyen/adyen-go-api-library/v9/src/checkout" ) client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Fill in your request objects amount := checkout.Amount{ Currency: "EUR", Value: 4250, } paymentLinkRequest := checkout.PaymentLinkRequest{ Reference: "YOUR_PAYMENT_REFERENCE", StorePaymentMethodMode: common.PtrString("askForConsent"), Amount: amount, MerchantAccount: "YOUR_MERCHANT_ACCOUNT", CountryCode: common.PtrString("NL"), RecurringProcessingModel: common.PtrString("CardOnFile"), Description: common.PtrString("Black sneakers - X51"), ShopperLocale: common.PtrString("nl-NL"), ShopperReference: common.PtrString("ShopperID-A16728"), } // Make the request service := client.Checkout() req := service.PaymentLinksApi.PaymentLinksInput().IdempotencyKey("UUID").PaymentLinkRequest(paymentLinkRequest) res, httpRes, err := service.PaymentLinksApi.PaymentLinks(context.Background(), req) ``` #### Python ```py # Adyen Python API Library v12.2.0 import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_API_KEY" adyen.client.platform = "test" # The environment to use library in. json_request = { "reference": "YOUR_PAYMENT_REFERENCE", "amount": { "value": 4250, "currency": "EUR" }, "description": "Black sneakers - X51", "countryCode": "NL", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "shopperLocale": "nl-NL", "shopperReference": "ShopperID-A16728", "storePaymentMethodMode": "askForConsent", "recurringProcessingModel": "CardOnFile" } result = adyen.checkout.payment_links_api.payment_links(request=json_request, idempotency_key="UUID") ``` #### Ruby ```rb # Adyen Ruby API Library v9.2.0 require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_API_KEY' adyen.env = :test # Set to "live" for live environment request_body = { :reference => 'YOUR_PAYMENT_REFERENCE', :amount => { :value => 4250, :currency => 'EUR' }, :description => 'Black sneakers - X51', :countryCode => 'NL', :merchantAccount => 'YOUR_MERCHANT_ACCOUNT', :shopperLocale => 'nl-NL', :shopperReference => 'ShopperID-A16728', :storePaymentMethodMode => 'askForConsent', :recurringProcessingModel => 'CardOnFile' } result = adyen.checkout.payment_links_api.payment_links(request_body, headers: { 'Idempotency-Key' => 'UUID' }) ``` #### NodeJS (TypeScript) ```ts // Adyen Node API Library v16.2.0 // Require the parts of the module you want to use import { Client, CheckoutAPI, Types } from "@adyen/api-library"; // Initialize the client object const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"}); // Create the request objects const amount: Types.checkout.Amount = { currency: "EUR", value: 4250 }; const paymentLinkRequest: Types.checkout.PaymentLinkRequest = { reference: "YOUR_PAYMENT_REFERENCE", storePaymentMethodMode: Types.checkout.PaymentLinkRequest.StorePaymentMethodModeEnum.AskForConsent, amount: amount, merchantAccount: "YOUR_MERCHANT_ACCOUNT", countryCode: "NL", recurringProcessingModel: Types.checkout.PaymentLinkRequest.RecurringProcessingModelEnum.CardOnFile, description: "Black sneakers - X51", shopperLocale: "nl-NL", shopperReference: "ShopperID-A16728" }; // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentLinksApi.paymentLinks(paymentLinkRequest, { idempotencyKey: "UUID" }); ``` The shopper's card details will be tokenized after they make a successful payment.\ []() 2. When the shopper returns for their next purchase, send the same [shopperReference](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-shopperReference) from the first request, and set [recurringProcessingModel](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/paymentLinks) to **CardOnFile** in your POST [/paymentLinks](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks) request. Here's an example of how you can create a payment link for the same shopper with `shopperReference` **ShopperID-A16728**. **Create a payment link that shows stored card details** #### curl ```bash curl https://checkout-test.adyen.com/v68/paymentLinks \ -H'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "reference": "YOUR_PAYMENT_REFERENCE", "amount": { "value": 4250, "currency": "EUR" }, "description": "Blue backpack - BK11", "countryCode": "NL", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "shopperLocale": "nl-NL", "shopperReference": "ShopperID-A16728", "recurringProcessingModel": "CardOnFile" }' ``` #### Java ```java // Adyen Java API Library v25.0.0 import com.adyen.Client; import com.adyen.enums.Environment; import com.adyen.model.checkout.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.model.RequestOptions; import com.adyen.service.checkout.*; Client client = new Client("ADYEN_API_KEY", Environment.TEST); // Request objects Amount amount = new Amount() .currency("EUR") .value(4250L); PaymentLinkRequest paymentLinkRequest = new PaymentLinkRequest() .reference("YOUR_PAYMENT_REFERENCE") .amount(amount) .merchantAccount("YOUR_MERCHANT_ACCOUNT") .countryCode("NL") .recurringProcessingModel(PaymentLinkRequest.RecurringProcessingModelEnum.CARDONFILE) .description("Blue backpack - BK11") .shopperLocale("nl-NL") .shopperReference("ShopperID-A16728"); // Make the request PaymentLinksApi service = new PaymentLinksApi(client); PaymentLinkResponse response = service.paymentLinks(paymentLinkRequest, new RequestOptions().idempotencyKey("UUID")); ``` #### PHP ```php // Adyen PHP API Library v17.4.0 use Adyen\Client; use Adyen\Environment; use Adyen\Model\Checkout\Amount; use Adyen\Model\Checkout\PaymentLinkRequest; use Adyen\Service\Checkout\PaymentLinksApi; $client = new Client(); $client->setXApiKey("ADYEN_API_KEY"); $client->setEnvironment(Environment::TEST); // Request objects $amount = new Amount(); $amount ->setCurrency("EUR") ->setValue(4250); $paymentLinkRequest = new PaymentLinkRequest(); $paymentLinkRequest ->setReference("YOUR_PAYMENT_REFERENCE") ->setAmount($amount) ->setMerchantAccount("YOUR_MERCHANT_ACCOUNT") ->setCountryCode("NL") ->setRecurringProcessingModel("CardOnFile") ->setDescription("Blue backpack - BK11") ->setShopperLocale("nl-NL") ->setShopperReference("ShopperID-A16728"); $requestOptions['idempotencyKey'] = 'UUID'; // Make the request $service = new PaymentLinksApi($client); $response = $service->paymentLinks($paymentLinkRequest, $requestOptions); ``` #### C\# ```cs // Adyen .net API Library v14.3.0 using Adyen; using Environment = Adyen.Model.Environment; using Adyen.Model; using Adyen.Model.Checkout; using Adyen.Service.Checkout; var config = new Config() { XApiKey = "ADYEN_API_KEY", Environment = Environment.Test }; var client = new Client(config); // Fill in your request objects Amount amount = new Amount { Currency = "EUR", Value = 4250 }; PaymentLinkRequest paymentLinkRequest = new PaymentLinkRequest { Reference = "YOUR_PAYMENT_REFERENCE", Amount = amount, MerchantAccount = "YOUR_MERCHANT_ACCOUNT", CountryCode = "NL", RecurringProcessingModel = PaymentLinkRequest.RecurringProcessingModelEnum.CardOnFile, Description = "Blue backpack - BK11", ShopperLocale = "nl-NL", ShopperReference = "ShopperID-A16728" }; // Make the request var service = new PaymentLinksService(client); var response = service.PaymentLinks(paymentLinkRequest, requestOptions: new RequestOptions { IdempotencyKey = "UUID"}); ``` #### NodeJS (JavaScript) ```js // Adyen Node API Library v16.2.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: "ADYEN_API_KEY", environment: "TEST"}); // Create the request object const paymentLinkRequest = { reference: "YOUR_PAYMENT_REFERENCE", amount: { value: 4250, currency: "EUR" }, description: "Blue backpack - BK11", countryCode: "NL", merchantAccount: "YOUR_MERCHANT_ACCOUNT", shopperLocale: "nl-NL", shopperReference: "ShopperID-A16728", recurringProcessingModel: "CardOnFile" } // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentLinksApi.paymentLinks(paymentLinkRequest, { idempotencyKey: "UUID" }); ``` #### Go ```go // Adyen Go API Library v9.2.0 import ( "context" "github.com/adyen/adyen-go-api-library/v9/src/common" "github.com/adyen/adyen-go-api-library/v9/src/adyen" "github.com/adyen/adyen-go-api-library/v9/src/checkout" ) client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Fill in your request objects amount := checkout.Amount{ Currency: "EUR", Value: 4250, } paymentLinkRequest := checkout.PaymentLinkRequest{ Reference: "YOUR_PAYMENT_REFERENCE", Amount: amount, MerchantAccount: "YOUR_MERCHANT_ACCOUNT", CountryCode: common.PtrString("NL"), RecurringProcessingModel: common.PtrString("CardOnFile"), Description: common.PtrString("Blue backpack - BK11"), ShopperLocale: common.PtrString("nl-NL"), ShopperReference: common.PtrString("ShopperID-A16728"), } // Make the request service := client.Checkout() req := service.PaymentLinksApi.PaymentLinksInput().IdempotencyKey("UUID").PaymentLinkRequest(paymentLinkRequest) res, httpRes, err := service.PaymentLinksApi.PaymentLinks(context.Background(), req) ``` #### Python ```py # Adyen Python API Library v12.2.0 import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_API_KEY" adyen.client.platform = "test" # The environment to use library in. json_request = { "reference": "YOUR_PAYMENT_REFERENCE", "amount": { "value": 4250, "currency": "EUR" }, "description": "Blue backpack - BK11", "countryCode": "NL", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "shopperLocale": "nl-NL", "shopperReference": "ShopperID-A16728", "recurringProcessingModel": "CardOnFile" } result = adyen.checkout.payment_links_api.payment_links(request=json_request, idempotency_key="UUID") ``` #### Ruby ```rb # Adyen Ruby API Library v9.2.0 require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_API_KEY' adyen.env = :test # Set to "live" for live environment request_body = { :reference => 'YOUR_PAYMENT_REFERENCE', :amount => { :value => 4250, :currency => 'EUR' }, :description => 'Blue backpack - BK11', :countryCode => 'NL', :merchantAccount => 'YOUR_MERCHANT_ACCOUNT', :shopperLocale => 'nl-NL', :shopperReference => 'ShopperID-A16728', :recurringProcessingModel => 'CardOnFile' } result = adyen.checkout.payment_links_api.payment_links(request_body, headers: { 'Idempotency-Key' => 'UUID' }) ``` #### NodeJS (TypeScript) ```ts // Adyen Node API Library v16.2.0 // Require the parts of the module you want to use import { Client, CheckoutAPI, Types } from "@adyen/api-library"; // Initialize the client object const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"}); // Create the request objects const amount: Types.checkout.Amount = { currency: "EUR", value: 4250 }; const paymentLinkRequest: Types.checkout.PaymentLinkRequest = { reference: "YOUR_PAYMENT_REFERENCE", amount: amount, merchantAccount: "YOUR_MERCHANT_ACCOUNT", countryCode: "NL", recurringProcessingModel: Types.checkout.PaymentLinkRequest.RecurringProcessingModelEnum.CardOnFile, description: "Blue backpack - BK11", shopperLocale: "nl-NL", shopperReference: "ShopperID-A16728" }; // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentLinksApi.paymentLinks(paymentLinkRequest, { idempotencyKey: "UUID" }); ``` ### Tokenize for subscriptions You should always ask for your customer's consent before tokenizing their card for future payments. You can use the Pay by Link API to create a payment link that will tokenize and store your shopper's card details for recurring payments. 1. Send the following in your POST [/paymentLinks](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks) request: * A unique [shopperReference](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-shopperReference) of at least three characters. Your reference must not include personally identifiable information (PII), like name or email address. * [storePaymentMethodMode](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-storePaymentMethodMode) set to **askForConsent** to allow the shopper to decide whether to store the details. If you already have the shopper's consent, set this parameter to **enabled**. * [recurringProcessingModel](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#responses-200-recurringProcessingModel) set to **Subscription**. * The payment `amount`, or if you only want to tokenize the shopper's payment details without charging them, set the [amount.value](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/paymentLinks__resParam_amount-value) to **0**. This is called a *zero-value authorisation*. Instead of a **Pay** button, your shoppers will see a **Confirm preauthorization** button on the payment page. Here is an example of how you can create a payment link to tokenize and store payment details for a subscription, for a shopper with `shopperReference` **Shopper-B7183**. **Create a payment link to tokenize for subscription** #### curl ```bash curl https://checkout-test.adyen.com/v68/paymentLinks \ -H'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "reference": "YOUR_PAYMENT_REFERENCE", "amount": { "value": 0, "currency": "EUR" }, "description": "Coffee Subscription", "countryCode": "NL", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "shopperLocale": "nl-NL", "shopperReference": "Shopper-B7183", "storePaymentMethodMode": "askForConsent", "recurringProcessingModel": "Subscription" }' ``` #### Java ```java // Adyen Java API Library v25.0.0 import com.adyen.Client; import com.adyen.enums.Environment; import com.adyen.model.checkout.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.model.RequestOptions; import com.adyen.service.checkout.*; Client client = new Client("ADYEN_API_KEY", Environment.TEST); // Request objects Amount amount = new Amount() .currency("EUR") .value(0L); PaymentLinkRequest paymentLinkRequest = new PaymentLinkRequest() .reference("YOUR_PAYMENT_REFERENCE") .storePaymentMethodMode(PaymentLinkRequest.StorePaymentMethodModeEnum.ASKFORCONSENT) .amount(amount) .merchantAccount("YOUR_MERCHANT_ACCOUNT") .countryCode("NL") .recurringProcessingModel(PaymentLinkRequest.RecurringProcessingModelEnum.SUBSCRIPTION) .description("Coffee Subscription") .shopperLocale("nl-NL") .shopperReference("Shopper-B7183"); // Make the request PaymentLinksApi service = new PaymentLinksApi(client); PaymentLinkResponse response = service.paymentLinks(paymentLinkRequest, new RequestOptions().idempotencyKey("UUID")); ``` #### PHP ```php // Adyen PHP API Library v17.4.0 use Adyen\Client; use Adyen\Environment; use Adyen\Model\Checkout\Amount; use Adyen\Model\Checkout\PaymentLinkRequest; use Adyen\Service\Checkout\PaymentLinksApi; $client = new Client(); $client->setXApiKey("ADYEN_API_KEY"); $client->setEnvironment(Environment::TEST); // Request objects $amount = new Amount(); $amount ->setCurrency("EUR") ->setValue(0); $paymentLinkRequest = new PaymentLinkRequest(); $paymentLinkRequest ->setReference("YOUR_PAYMENT_REFERENCE") ->setStorePaymentMethodMode("askForConsent") ->setAmount($amount) ->setMerchantAccount("YOUR_MERCHANT_ACCOUNT") ->setCountryCode("NL") ->setRecurringProcessingModel("Subscription") ->setDescription("Coffee Subscription") ->setShopperLocale("nl-NL") ->setShopperReference("Shopper-B7183"); $requestOptions['idempotencyKey'] = 'UUID'; // Make the request $service = new PaymentLinksApi($client); $response = $service->paymentLinks($paymentLinkRequest, $requestOptions); ``` #### C\# ```cs // Adyen .net API Library v14.3.0 using Adyen; using Environment = Adyen.Model.Environment; using Adyen.Model; using Adyen.Model.Checkout; using Adyen.Service.Checkout; var config = new Config() { XApiKey = "ADYEN_API_KEY", Environment = Environment.Test }; var client = new Client(config); // Fill in your request objects Amount amount = new Amount { Currency = "EUR", Value = 0 }; PaymentLinkRequest paymentLinkRequest = new PaymentLinkRequest { Reference = "YOUR_PAYMENT_REFERENCE", StorePaymentMethodMode = PaymentLinkRequest.StorePaymentMethodModeEnum.AskForConsent, Amount = amount, MerchantAccount = "YOUR_MERCHANT_ACCOUNT", CountryCode = "NL", RecurringProcessingModel = PaymentLinkRequest.RecurringProcessingModelEnum.Subscription, Description = "Coffee Subscription", ShopperLocale = "nl-NL", ShopperReference = "Shopper-B7183" }; // Make the request var service = new PaymentLinksService(client); var response = service.PaymentLinks(paymentLinkRequest, requestOptions: new RequestOptions { IdempotencyKey = "UUID"}); ``` #### NodeJS (JavaScript) ```js // Adyen Node API Library v16.2.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: "ADYEN_API_KEY", environment: "TEST"}); // Create the request object const paymentLinkRequest = { reference: "YOUR_PAYMENT_REFERENCE", amount: { value: 0, currency: "EUR" }, description: "Coffee Subscription", countryCode: "NL", merchantAccount: "YOUR_MERCHANT_ACCOUNT", shopperLocale: "nl-NL", shopperReference: "Shopper-B7183", storePaymentMethodMode: "askForConsent", recurringProcessingModel: "Subscription" } // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentLinksApi.paymentLinks(paymentLinkRequest, { idempotencyKey: "UUID" }); ``` #### Go ```go // Adyen Go API Library v9.2.0 import ( "context" "github.com/adyen/adyen-go-api-library/v9/src/common" "github.com/adyen/adyen-go-api-library/v9/src/adyen" "github.com/adyen/adyen-go-api-library/v9/src/checkout" ) client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Fill in your request objects amount := checkout.Amount{ Currency: "EUR", Value: 0, } paymentLinkRequest := checkout.PaymentLinkRequest{ Reference: "YOUR_PAYMENT_REFERENCE", StorePaymentMethodMode: common.PtrString("askForConsent"), Amount: amount, MerchantAccount: "YOUR_MERCHANT_ACCOUNT", CountryCode: common.PtrString("NL"), RecurringProcessingModel: common.PtrString("Subscription"), Description: common.PtrString("Coffee Subscription"), ShopperLocale: common.PtrString("nl-NL"), ShopperReference: common.PtrString("Shopper-B7183"), } // Make the request service := client.Checkout() req := service.PaymentLinksApi.PaymentLinksInput().IdempotencyKey("UUID").PaymentLinkRequest(paymentLinkRequest) res, httpRes, err := service.PaymentLinksApi.PaymentLinks(context.Background(), req) ``` #### Python ```py # Adyen Python API Library v12.2.0 import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_API_KEY" adyen.client.platform = "test" # The environment to use library in. json_request = { "reference": "YOUR_PAYMENT_REFERENCE", "amount": { "value": 0, "currency": "EUR" }, "description": "Coffee Subscription", "countryCode": "NL", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "shopperLocale": "nl-NL", "shopperReference": "Shopper-B7183", "storePaymentMethodMode": "askForConsent", "recurringProcessingModel": "Subscription" } result = adyen.checkout.payment_links_api.payment_links(request=json_request, idempotency_key="UUID") ``` #### Ruby ```rb # Adyen Ruby API Library v9.2.0 require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_API_KEY' adyen.env = :test # Set to "live" for live environment request_body = { :reference => 'YOUR_PAYMENT_REFERENCE', :amount => { :value => 0, :currency => 'EUR' }, :description => 'Coffee Subscription', :countryCode => 'NL', :merchantAccount => 'YOUR_MERCHANT_ACCOUNT', :shopperLocale => 'nl-NL', :shopperReference => 'Shopper-B7183', :storePaymentMethodMode => 'askForConsent', :recurringProcessingModel => 'Subscription' } result = adyen.checkout.payment_links_api.payment_links(request_body, headers: { 'Idempotency-Key' => 'UUID' }) ``` #### NodeJS (TypeScript) ```ts // Adyen Node API Library v16.2.0 // Require the parts of the module you want to use import { Client, CheckoutAPI, Types } from "@adyen/api-library"; // Initialize the client object const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"}); // Create the request objects const amount: Types.checkout.Amount = { currency: "EUR", value: 0 }; const paymentLinkRequest: Types.checkout.PaymentLinkRequest = { reference: "YOUR_PAYMENT_REFERENCE", storePaymentMethodMode: Types.checkout.PaymentLinkRequest.StorePaymentMethodModeEnum.AskForConsent, amount: amount, merchantAccount: "YOUR_MERCHANT_ACCOUNT", countryCode: "NL", recurringProcessingModel: Types.checkout.PaymentLinkRequest.RecurringProcessingModelEnum.Subscription, description: "Coffee Subscription", shopperLocale: "nl-NL", shopperReference: "Shopper-B7183" }; // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentLinksApi.paymentLinks(paymentLinkRequest, { idempotencyKey: "UUID" }); ``` 2. After the shopper completes the payment or the preauthorization, make a POST [/paymentMethods](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentMethods) request to [get the shopper's tokenized payment details](/online-payments/tokenization/managing-tokens#list-stored-details). 3. Send the token when you [make subsequent subscription payments](/online-payments/tokenization/make-token-payments#make-a-subscription-or-unscheduled-card-on-file-payment) with a POST [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) request. ### Tokenize for unscheduled recurring payments You should always ask for your customer's consent before tokenizing their card for future payments. You can use the Pay by Link API to create a payment link that will tokenize and store your shopper's card details for recurring payments on a non-fixed schedule. 1. Send the following in your POST [/paymentLinks](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks) request: * A unique [shopperReference](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-shopperReference) of at least three characters. Your reference must not include personally identifiable information (PII), like name or email address. * [storePaymentMethodMode](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-storePaymentMethodMode) set to **askForConsent** to allow the shopper to decide whether to store the details. If you already have the shopper's consent, set this parameter to **enabled**. * [recurringProcessingModel](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#responses-200-recurringProcessingModel) set to **UnscheduledCardOnFile**. * The payment `amount`, or if you only want to tokenize the shopper's payment details without charging them, set the [amount.value](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/paymentLinks__resParam_amount-value) to **0**. This is called a *zero-value authorisation*. Instead of a **Pay** button, your shoppers will see a **Confirm preauthorization** button on the payment page. Here is an example of how you can create a payment link to tokenize and store payment details for automatic top-ups, for a shopper with `shopperReference` **Shopper-C5250**. **Create a payment link to tokenize for automatic top-ups** #### curl ```bash curl https://checkout-test.adyen.com/v68/paymentLinks \ -H'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "reference": "YOUR_PAYMENT_REFERENCE", "amount": { "value": 0, "currency": "EUR" }, "description": "Account top-up agreement", "countryCode": "NL", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "shopperLocale": "nl-NL", "shopperReference": "Shopper-C5250", "storePaymentMethodMode": "askForConsent", "recurringProcessingModel": "UnscheduledCardOnFile" }' ``` #### Java ```java // Adyen Java API Library v25.0.0 import com.adyen.Client; import com.adyen.enums.Environment; import com.adyen.model.checkout.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.model.RequestOptions; import com.adyen.service.checkout.*; Client client = new Client("ADYEN_API_KEY", Environment.TEST); // Request objects Amount amount = new Amount() .currency("EUR") .value(0L); PaymentLinkRequest paymentLinkRequest = new PaymentLinkRequest() .reference("YOUR_PAYMENT_REFERENCE") .storePaymentMethodMode(PaymentLinkRequest.StorePaymentMethodModeEnum.ASKFORCONSENT) .amount(amount) .merchantAccount("YOUR_MERCHANT_ACCOUNT") .countryCode("NL") .recurringProcessingModel(PaymentLinkRequest.RecurringProcessingModelEnum.UNSCHEDULEDCARDONFILE) .description("Account top-up agreement") .shopperLocale("nl-NL") .shopperReference("Shopper-C5250"); // Make the request PaymentLinksApi service = new PaymentLinksApi(client); PaymentLinkResponse response = service.paymentLinks(paymentLinkRequest, new RequestOptions().idempotencyKey("UUID")); ``` #### PHP ```php // Adyen PHP API Library v17.4.0 use Adyen\Client; use Adyen\Environment; use Adyen\Model\Checkout\Amount; use Adyen\Model\Checkout\PaymentLinkRequest; use Adyen\Service\Checkout\PaymentLinksApi; $client = new Client(); $client->setXApiKey("ADYEN_API_KEY"); $client->setEnvironment(Environment::TEST); // Request objects $amount = new Amount(); $amount ->setCurrency("EUR") ->setValue(0); $paymentLinkRequest = new PaymentLinkRequest(); $paymentLinkRequest ->setReference("YOUR_PAYMENT_REFERENCE") ->setStorePaymentMethodMode("askForConsent") ->setAmount($amount) ->setMerchantAccount("YOUR_MERCHANT_ACCOUNT") ->setCountryCode("NL") ->setRecurringProcessingModel("UnscheduledCardOnFile") ->setDescription("Account top-up agreement") ->setShopperLocale("nl-NL") ->setShopperReference("Shopper-C5250"); $requestOptions['idempotencyKey'] = 'UUID'; // Make the request $service = new PaymentLinksApi($client); $response = $service->paymentLinks($paymentLinkRequest, $requestOptions); ``` #### C\# ```cs // Adyen .net API Library v14.3.0 using Adyen; using Environment = Adyen.Model.Environment; using Adyen.Model; using Adyen.Model.Checkout; using Adyen.Service.Checkout; var config = new Config() { XApiKey = "ADYEN_API_KEY", Environment = Environment.Test }; var client = new Client(config); // Fill in your request objects Amount amount = new Amount { Currency = "EUR", Value = 0 }; PaymentLinkRequest paymentLinkRequest = new PaymentLinkRequest { Reference = "YOUR_PAYMENT_REFERENCE", StorePaymentMethodMode = PaymentLinkRequest.StorePaymentMethodModeEnum.AskForConsent, Amount = amount, MerchantAccount = "YOUR_MERCHANT_ACCOUNT", CountryCode = "NL", RecurringProcessingModel = PaymentLinkRequest.RecurringProcessingModelEnum.UnscheduledCardOnFile, Description = "Account top-up agreement", ShopperLocale = "nl-NL", ShopperReference = "Shopper-C5250" }; // Make the request var service = new PaymentLinksService(client); var response = service.PaymentLinks(paymentLinkRequest, requestOptions: new RequestOptions { IdempotencyKey = "UUID"}); ``` #### NodeJS (JavaScript) ```js // Adyen Node API Library v16.2.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: "ADYEN_API_KEY", environment: "TEST"}); // Create the request object const paymentLinkRequest = { reference: "YOUR_PAYMENT_REFERENCE", amount: { value: 0, currency: "EUR" }, description: "Account top-up agreement", countryCode: "NL", merchantAccount: "YOUR_MERCHANT_ACCOUNT", shopperLocale: "nl-NL", shopperReference: "Shopper-C5250", storePaymentMethodMode: "askForConsent", recurringProcessingModel: "UnscheduledCardOnFile" } // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentLinksApi.paymentLinks(paymentLinkRequest, { idempotencyKey: "UUID" }); ``` #### Go ```go // Adyen Go API Library v9.2.0 import ( "context" "github.com/adyen/adyen-go-api-library/v9/src/common" "github.com/adyen/adyen-go-api-library/v9/src/adyen" "github.com/adyen/adyen-go-api-library/v9/src/checkout" ) client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Fill in your request objects amount := checkout.Amount{ Currency: "EUR", Value: 0, } paymentLinkRequest := checkout.PaymentLinkRequest{ Reference: "YOUR_PAYMENT_REFERENCE", StorePaymentMethodMode: common.PtrString("askForConsent"), Amount: amount, MerchantAccount: "YOUR_MERCHANT_ACCOUNT", CountryCode: common.PtrString("NL"), RecurringProcessingModel: common.PtrString("UnscheduledCardOnFile"), Description: common.PtrString("Account top-up agreement"), ShopperLocale: common.PtrString("nl-NL"), ShopperReference: common.PtrString("Shopper-C5250"), } // Make the request service := client.Checkout() req := service.PaymentLinksApi.PaymentLinksInput().IdempotencyKey("UUID").PaymentLinkRequest(paymentLinkRequest) res, httpRes, err := service.PaymentLinksApi.PaymentLinks(context.Background(), req) ``` #### Python ```py # Adyen Python API Library v12.2.0 import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_API_KEY" adyen.client.platform = "test" # The environment to use library in. json_request = { "reference": "YOUR_PAYMENT_REFERENCE", "amount": { "value": 0, "currency": "EUR" }, "description": "Account top-up agreement", "countryCode": "NL", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "shopperLocale": "nl-NL", "shopperReference": "Shopper-C5250", "storePaymentMethodMode": "askForConsent", "recurringProcessingModel": "UnscheduledCardOnFile" } result = adyen.checkout.payment_links_api.payment_links(request=json_request, idempotency_key="UUID") ``` #### Ruby ```rb # Adyen Ruby API Library v9.2.0 require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_API_KEY' adyen.env = :test # Set to "live" for live environment request_body = { :reference => 'YOUR_PAYMENT_REFERENCE', :amount => { :value => 0, :currency => 'EUR' }, :description => 'Account top-up agreement', :countryCode => 'NL', :merchantAccount => 'YOUR_MERCHANT_ACCOUNT', :shopperLocale => 'nl-NL', :shopperReference => 'Shopper-C5250', :storePaymentMethodMode => 'askForConsent', :recurringProcessingModel => 'UnscheduledCardOnFile' } result = adyen.checkout.payment_links_api.payment_links(request_body, headers: { 'Idempotency-Key' => 'UUID' }) ``` #### NodeJS (TypeScript) ```ts // Adyen Node API Library v16.2.0 // Require the parts of the module you want to use import { Client, CheckoutAPI, Types } from "@adyen/api-library"; // Initialize the client object const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"}); // Create the request objects const amount: Types.checkout.Amount = { currency: "EUR", value: 0 }; const paymentLinkRequest: Types.checkout.PaymentLinkRequest = { reference: "YOUR_PAYMENT_REFERENCE", storePaymentMethodMode: Types.checkout.PaymentLinkRequest.StorePaymentMethodModeEnum.AskForConsent, amount: amount, merchantAccount: "YOUR_MERCHANT_ACCOUNT", countryCode: "NL", recurringProcessingModel: Types.checkout.PaymentLinkRequest.RecurringProcessingModelEnum.UnscheduledCardOnFile, description: "Account top-up agreement", shopperLocale: "nl-NL", shopperReference: "Shopper-C5250" }; // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentLinksApi.paymentLinks(paymentLinkRequest, { idempotencyKey: "UUID" }); ``` 2. After the shopper completes the payment or the preauthorization, make a POST [/paymentMethods](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentMethods) request to [get the shopper's tokenized payment details](/online-payments/tokenization/managing-tokens#list-stored-details). 3. Send the token when you [make subsequent recurring payments](/online-payments/tokenization/make-token-payments#make-a-subscription-or-unscheduled-card-on-file-payment) with a POST [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) request. ## Provide additional information Some payment methods, such as buy now, pay later payment methods, require additional information about the purchased product (`lineItems`) or the shopper (for example, `shopperEmail`). If you want to create a payment link that can support these payment methods, you need to make sure that you provide this information. | Payment method | Required objects | | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | 3x 4x Oney (FR, ES) | [lineItems](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-lineItems)Note: Other shopper information such as shopper name and email are collected on the payment page. | | Afterpay (AU, NZ) | [lineItems](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-lineItems), [shopperEmail](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-shopperEmail), [shopperName](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-shopperName), [deliveryAddress](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-deliveryAddress), [billingAddress](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-billingAddress) | | Klarna (AT, DK, FI, DE, NO, SE, CH, NL, GB, US) | [lineItems](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-lineItems) , [shopperEmail](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-shopperEmail) | | PayBright (CA) | [lineItems](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-lineItems), [shopperEmail](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-shopperEmail), [shopperName](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-shopperName), [deliveryAddress](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-deliveryAddress), [billingAddress](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-billingAddress) | | Zip (AU) | [lineItems](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-lineItems), [shopperEmail](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-shopperEmail), [shopperName](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-shopperName), [deliveryAddress](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-deliveryAddress), [billingAddress](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-billingAddress) | ### Provide product information If a payment method requires [lineItems](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks#request-lineItems), you will need to collect this information, and include it in your POST [/paymentLinks](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks) request. The following example shows how to create a payment link that can support **3x 4x Oney (FR, ES)** . **Create payment link with lineItems** #### curl ```bash curl https://checkout-test.adyen.com/v68/paymentLinks \ -H'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "reference": "YOUR_ORDER_NUMBER", "amount": { "value": 1000, "currency": "EUR" }, "description": "Shoes and socks", "countryCode": "FR", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "shopperReference": "YOUR_SHOPPER_REFERENCE", "shopperLocale": "en-US", "lineItems":[ { "quantity":"1", "amountExcludingTax":"331", "taxPercentage":"2100", "description":"Shoes", "id":"Item #1", "taxAmount":"69", "amountIncludingTax":"400" }, { "quantity":"2", "amountExcludingTax":"248", "taxPercentage":"2100", "description":"Socks", "id":"Item #2", "taxAmount":"52", "amountIncludingTax":"300" } ] }' ``` #### Java ```java // Adyen Java API Library v25.0.0 import com.adyen.Client; import com.adyen.enums.Environment; import com.adyen.model.checkout.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.model.RequestOptions; import com.adyen.service.checkout.*; Client client = new Client("ADYEN_API_KEY", Environment.TEST); // Request objects LineItem lineItem1 = new LineItem() .quantity(1L) .amountExcludingTax(331L) .taxPercentage(2100L) .description("Shoes") .id("Item #1") .taxAmount(69L) .amountIncludingTax(400L); LineItem lineItem2 = new LineItem() .quantity(2L) .amountExcludingTax(248L) .taxPercentage(2100L) .description("Socks") .id("Item #2") .taxAmount(52L) .amountIncludingTax(300L); Amount amount = new Amount() .currency("EUR") .value(1000L); PaymentLinkRequest paymentLinkRequest = new PaymentLinkRequest() .reference("YOUR_ORDER_NUMBER") .lineItems(Arrays.asList(lineItem1, lineItem2)) .amount(amount) .merchantAccount("YOUR_MERCHANT_ACCOUNT") .countryCode("FR") .description("Shoes and socks") .shopperLocale("en-US") .shopperReference("YOUR_SHOPPER_REFERENCE"); // Make the request PaymentLinksApi service = new PaymentLinksApi(client); PaymentLinkResponse response = service.paymentLinks(paymentLinkRequest, new RequestOptions().idempotencyKey("UUID")); ``` #### PHP ```php // Adyen PHP API Library v17.4.0 use Adyen\Client; use Adyen\Environment; use Adyen\Model\Checkout\LineItem; use Adyen\Model\Checkout\Amount; use Adyen\Model\Checkout\PaymentLinkRequest; use Adyen\Service\Checkout\PaymentLinksApi; $client = new Client(); $client->setXApiKey("ADYEN_API_KEY"); $client->setEnvironment(Environment::TEST); // Request objects $lineItem1 = new LineItem(); $lineItem1 ->setQuantity(1) ->setAmountExcludingTax(331) ->setTaxPercentage(2100) ->setDescription("Shoes") ->setId("Item #1") ->setTaxAmount(69) ->setAmountIncludingTax(400); $lineItem2 = new LineItem(); $lineItem2 ->setQuantity(2) ->setAmountExcludingTax(248) ->setTaxPercentage(2100) ->setDescription("Socks") ->setId("Item #2") ->setTaxAmount(52) ->setAmountIncludingTax(300); $amount = new Amount(); $amount ->setCurrency("EUR") ->setValue(1000); $paymentLinkRequest = new PaymentLinkRequest(); $paymentLinkRequest ->setReference("YOUR_ORDER_NUMBER") ->setLineItems(array($lineItem1, $lineItem2)) ->setAmount($amount) ->setMerchantAccount("YOUR_MERCHANT_ACCOUNT") ->setCountryCode("FR") ->setDescription("Shoes and socks") ->setShopperLocale("en-US") ->setShopperReference("YOUR_SHOPPER_REFERENCE"); $requestOptions['idempotencyKey'] = 'UUID'; // Make the request $service = new PaymentLinksApi($client); $response = $service->paymentLinks($paymentLinkRequest, $requestOptions); ``` #### C\# ```cs // Adyen .net API Library v14.3.0 using Adyen; using Environment = Adyen.Model.Environment; using Adyen.Model; using Adyen.Model.Checkout; using Adyen.Service.Checkout; var config = new Config() { XApiKey = "ADYEN_API_KEY", Environment = Environment.Test }; var client = new Client(config); // Fill in your request objects LineItem lineItem1 = new LineItem { Quantity = 1, AmountExcludingTax = 331, TaxPercentage = 2100, Description = "Shoes", Id = "Item #1", TaxAmount = 69, AmountIncludingTax = 400 }; LineItem lineItem2 = new LineItem { Quantity = 2, AmountExcludingTax = 248, TaxPercentage = 2100, Description = "Socks", Id = "Item #2", TaxAmount = 52, AmountIncludingTax = 300 }; Amount amount = new Amount { Currency = "EUR", Value = 1000 }; PaymentLinkRequest paymentLinkRequest = new PaymentLinkRequest { Reference = "YOUR_ORDER_NUMBER", LineItems = new List{ lineItem1, lineItem2 }, Amount = amount, MerchantAccount = "YOUR_MERCHANT_ACCOUNT", CountryCode = "FR", Description = "Shoes and socks", ShopperLocale = "en-US", ShopperReference = "YOUR_SHOPPER_REFERENCE" }; // Make the request var service = new PaymentLinksService(client); var response = service.PaymentLinks(paymentLinkRequest, requestOptions: new RequestOptions { IdempotencyKey = "UUID"}); ``` #### NodeJS (JavaScript) ```js // Adyen Node API Library v16.2.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: "ADYEN_API_KEY", environment: "TEST"}); // Create the request object const paymentLinkRequest = { reference: "YOUR_ORDER_NUMBER", amount: { value: 1000, currency: "EUR" }, description: "Shoes and socks", countryCode: "FR", merchantAccount: "YOUR_MERCHANT_ACCOUNT", shopperReference: "YOUR_SHOPPER_REFERENCE", shopperLocale: "en-US", lineItems: [ { quantity: "1", amountExcludingTax: "331", taxPercentage: "2100", description: "Shoes", id: "Item #1", taxAmount: "69", amountIncludingTax: "400" }, { quantity: "2", amountExcludingTax: "248", taxPercentage: "2100", description: "Socks", id: "Item #2", taxAmount: "52", amountIncludingTax: "300" } ] } // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentLinksApi.paymentLinks(paymentLinkRequest, { idempotencyKey: "UUID" }); ``` #### Go ```go // Adyen Go API Library v9.2.0 import ( "context" "github.com/adyen/adyen-go-api-library/v9/src/common" "github.com/adyen/adyen-go-api-library/v9/src/adyen" "github.com/adyen/adyen-go-api-library/v9/src/checkout" ) client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Fill in your request objects lineItem1 := checkout.LineItem{ Quantity: common.PtrInt64(1), AmountExcludingTax: common.PtrInt64(331), TaxPercentage: common.PtrInt64(2100), Description: common.PtrString("Shoes"), Id: common.PtrString("Item #1"), TaxAmount: common.PtrInt64(69), AmountIncludingTax: common.PtrInt64(400), } lineItem2 := checkout.LineItem{ Quantity: common.PtrInt64(2), AmountExcludingTax: common.PtrInt64(248), TaxPercentage: common.PtrInt64(2100), Description: common.PtrString("Socks"), Id: common.PtrString("Item #2"), TaxAmount: common.PtrInt64(52), AmountIncludingTax: common.PtrInt64(300), } amount := checkout.Amount{ Currency: "EUR", Value: 1000, } paymentLinkRequest := checkout.PaymentLinkRequest{ Reference: "YOUR_ORDER_NUMBER", LineItems: []checkout.LineItem{ lineItem1, lineItem2, }, Amount: amount, MerchantAccount: "YOUR_MERCHANT_ACCOUNT", CountryCode: common.PtrString("FR"), Description: common.PtrString("Shoes and socks"), ShopperLocale: common.PtrString("en-US"), ShopperReference: common.PtrString("YOUR_SHOPPER_REFERENCE"), } // Make the request service := client.Checkout() req := service.PaymentLinksApi.PaymentLinksInput().IdempotencyKey("UUID").PaymentLinkRequest(paymentLinkRequest) res, httpRes, err := service.PaymentLinksApi.PaymentLinks(context.Background(), req) ``` #### Python ```py # Adyen Python API Library v12.2.0 import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_API_KEY" adyen.client.platform = "test" # The environment to use library in. json_request = { "reference": "YOUR_ORDER_NUMBER", "amount": { "value": 1000, "currency": "EUR" }, "description": "Shoes and socks", "countryCode": "FR", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "shopperReference": "YOUR_SHOPPER_REFERENCE", "shopperLocale": "en-US", "lineItems": [ { "quantity": "1", "amountExcludingTax": "331", "taxPercentage": "2100", "description": "Shoes", "id": "Item #1", "taxAmount": "69", "amountIncludingTax": "400" }, { "quantity": "2", "amountExcludingTax": "248", "taxPercentage": "2100", "description": "Socks", "id": "Item #2", "taxAmount": "52", "amountIncludingTax": "300" } ] } result = adyen.checkout.payment_links_api.payment_links(request=json_request, idempotency_key="UUID") ``` #### Ruby ```rb # Adyen Ruby API Library v9.2.0 require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_API_KEY' adyen.env = :test # Set to "live" for live environment request_body = { :reference => 'YOUR_ORDER_NUMBER', :amount => { :value => 1000, :currency => 'EUR' }, :description => 'Shoes and socks', :countryCode => 'FR', :merchantAccount => 'YOUR_MERCHANT_ACCOUNT', :shopperReference => 'YOUR_SHOPPER_REFERENCE', :shopperLocale => 'en-US', :lineItems => [ { :quantity => '1', :amountExcludingTax => '331', :taxPercentage => '2100', :description => 'Shoes', :id => 'Item #1', :taxAmount => '69', :amountIncludingTax => '400' }, { :quantity => '2', :amountExcludingTax => '248', :taxPercentage => '2100', :description => 'Socks', :id => 'Item #2', :taxAmount => '52', :amountIncludingTax => '300' } ] } result = adyen.checkout.payment_links_api.payment_links(request_body, headers: { 'Idempotency-Key' => 'UUID' }) ``` #### NodeJS (TypeScript) ```ts // Adyen Node API Library v16.2.0 // Require the parts of the module you want to use import { Client, CheckoutAPI, Types } from "@adyen/api-library"; // Initialize the client object const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"}); // Create the request objects const lineItem1: Types.checkout.LineItem = { quantity: 1, amountExcludingTax: 331, taxPercentage: 2100, description: "Shoes", id: "Item #1", taxAmount: 69, amountIncludingTax: 400 }; const lineItem2: Types.checkout.LineItem = { quantity: 2, amountExcludingTax: 248, taxPercentage: 2100, description: "Socks", id: "Item #2", taxAmount: 52, amountIncludingTax: 300 }; const amount: Types.checkout.Amount = { currency: "EUR", value: 1000 }; const paymentLinkRequest: Types.checkout.PaymentLinkRequest = { reference: "YOUR_ORDER_NUMBER", lineItems: [lineItem1, lineItem2], amount: amount, merchantAccount: "YOUR_MERCHANT_ACCOUNT", countryCode: "FR", description: "Shoes and socks", shopperLocale: "en-US", shopperReference: "YOUR_SHOPPER_REFERENCE" }; // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentLinksApi.paymentLinks(paymentLinkRequest, { idempotencyKey: "UUID" }); ``` ### Provide shopper information For shopper information such as name, email, or address, you can either: * If using [API version v67](/online-payments/release-notes/?integration_type=api\&version%5B0%5D=67#releaseNote=2021-03-01-checkout-api-67) or later, ask the shopper to fill in this information before they complete the payment, by including [requiredShopperFields](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/paymentLinks__reqParam_requiredShopperFields) in your POST [/paymentLinks](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks) request. * Collect this information yourself, and include it in your POST [/paymentLinks](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks) request. ### Tab: Ask shopper to provide information The following example shows how to create a payment link that can support **Klarna**, and ask the shopper to fill in the required information themselves: **Create payment link with required shopper fields** #### curl ```bash curl https://checkout-test.adyen.com/v68/paymentLinks \ -H'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "reference": "YOUR_ORDER_NUMBER", "amount": { "value": 1000, "currency": "SEK" }, "description": "Shoes and socks", "countryCode": "SE", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "shopperReference": "YOUR_SHOPPER_REFERENCE", "requiredShopperFields": ["shopperName", "shopperEmail", "billingAddress"], "shopperLocale": "en-US", "lineItems":[ { "quantity":"1", "amountExcludingTax":"331", "taxPercentage":"2100", "description":"Shoes", "id":"Item #1", "taxAmount":"69", "amountIncludingTax":"400" }, { "quantity":"2", "amountExcludingTax":"248", "taxPercentage":"2100", "description":"Socks", "id":"Item #2", "taxAmount":"52", "amountIncludingTax":"300" } ] }' ``` #### Java ```java // Adyen Java API Library v25.0.0 import com.adyen.Client; import com.adyen.enums.Environment; import com.adyen.model.checkout.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.model.RequestOptions; import com.adyen.service.checkout.*; Client client = new Client("ADYEN_API_KEY", Environment.TEST); // Request objects LineItem lineItem1 = new LineItem() .quantity(1L) .amountExcludingTax(331L) .taxPercentage(2100L) .description("Shoes") .id("Item #1") .taxAmount(69L) .amountIncludingTax(400L); LineItem lineItem2 = new LineItem() .quantity(2L) .amountExcludingTax(248L) .taxPercentage(2100L) .description("Socks") .id("Item #2") .taxAmount(52L) .amountIncludingTax(300L); Amount amount = new Amount() .currency("SEK") .value(1000L); PaymentLinkRequest paymentLinkRequest = new PaymentLinkRequest() .reference("YOUR_ORDER_NUMBER") .lineItems(Arrays.asList(lineItem1, lineItem2)) .amount(amount) .merchantAccount("YOUR_MERCHANT_ACCOUNT") .countryCode("SE") .requiredShopperFields(Arrays.asList(Amount.RequiredShopperFieldsEnum.SHOPPERNAME, Amount.RequiredShopperFieldsEnum.SHOPPEREMAIL, Amount.RequiredShopperFieldsEnum.BILLINGADDRESS)) .description("Shoes and socks") .shopperLocale("en-US") .shopperReference("YOUR_SHOPPER_REFERENCE"); // Make the request PaymentLinksApi service = new PaymentLinksApi(client); PaymentLinkResponse response = service.paymentLinks(paymentLinkRequest, new RequestOptions().idempotencyKey("UUID")); ``` #### PHP ```php // Adyen PHP API Library v17.4.0 use Adyen\Client; use Adyen\Environment; use Adyen\Model\Checkout\LineItem; use Adyen\Model\Checkout\Amount; use Adyen\Model\Checkout\PaymentLinkRequest; use Adyen\Service\Checkout\PaymentLinksApi; $client = new Client(); $client->setXApiKey("ADYEN_API_KEY"); $client->setEnvironment(Environment::TEST); // Request objects $lineItem1 = new LineItem(); $lineItem1 ->setQuantity(1) ->setAmountExcludingTax(331) ->setTaxPercentage(2100) ->setDescription("Shoes") ->setId("Item #1") ->setTaxAmount(69) ->setAmountIncludingTax(400); $lineItem2 = new LineItem(); $lineItem2 ->setQuantity(2) ->setAmountExcludingTax(248) ->setTaxPercentage(2100) ->setDescription("Socks") ->setId("Item #2") ->setTaxAmount(52) ->setAmountIncludingTax(300); $amount = new Amount(); $amount ->setCurrency("SEK") ->setValue(1000); $paymentLinkRequest = new PaymentLinkRequest(); $paymentLinkRequest ->setReference("YOUR_ORDER_NUMBER") ->setLineItems(array($lineItem1, $lineItem2)) ->setAmount($amount) ->setMerchantAccount("YOUR_MERCHANT_ACCOUNT") ->setCountryCode("SE") ->setRequiredShopperFields(array("shopperName", "shopperEmail", "billingAddress")) ->setDescription("Shoes and socks") ->setShopperLocale("en-US") ->setShopperReference("YOUR_SHOPPER_REFERENCE"); $requestOptions['idempotencyKey'] = 'UUID'; // Make the request $service = new PaymentLinksApi($client); $response = $service->paymentLinks($paymentLinkRequest, $requestOptions); ``` #### C\# ```cs // Adyen .net API Library v14.3.0 using Adyen; using Environment = Adyen.Model.Environment; using Adyen.Model; using Adyen.Model.Checkout; using Adyen.Service.Checkout; var config = new Config() { XApiKey = "ADYEN_API_KEY", Environment = Environment.Test }; var client = new Client(config); // Fill in your request objects LineItem lineItem1 = new LineItem { Quantity = 1, AmountExcludingTax = 331, TaxPercentage = 2100, Description = "Shoes", Id = "Item #1", TaxAmount = 69, AmountIncludingTax = 400 }; LineItem lineItem2 = new LineItem { Quantity = 2, AmountExcludingTax = 248, TaxPercentage = 2100, Description = "Socks", Id = "Item #2", TaxAmount = 52, AmountIncludingTax = 300 }; Amount amount = new Amount { Currency = "SEK", Value = 1000 }; PaymentLinkRequest paymentLinkRequest = new PaymentLinkRequest { Reference = "YOUR_ORDER_NUMBER", LineItems = new List{ lineItem1, lineItem2 }, Amount = amount, MerchantAccount = "YOUR_MERCHANT_ACCOUNT", CountryCode = "SE", RequiredShopperFields = { PaymentLinkRequest.RequiredShopperFieldsEnum.ShopperName, PaymentLinkRequest.RequiredShopperFieldsEnum.ShopperEmail, PaymentLinkRequest.RequiredShopperFieldsEnum.BillingAddress }, Description = "Shoes and socks", ShopperLocale = "en-US", ShopperReference = "YOUR_SHOPPER_REFERENCE" }; // Make the request var service = new PaymentLinksService(client); var response = service.PaymentLinks(paymentLinkRequest, requestOptions: new RequestOptions { IdempotencyKey = "UUID"}); ``` #### NodeJS (JavaScript) ```js // Adyen Node API Library v16.2.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: "ADYEN_API_KEY", environment: "TEST"}); // Create the request object const paymentLinkRequest = { reference: "YOUR_ORDER_NUMBER", amount: { value: 1000, currency: "SEK" }, description: "Shoes and socks", countryCode: "SE", merchantAccount: "YOUR_MERCHANT_ACCOUNT", shopperReference: "YOUR_SHOPPER_REFERENCE", requiredShopperFields: [ "shopperName", "shopperEmail", "billingAddress" ], shopperLocale: "en-US", lineItems: [ { quantity: "1", amountExcludingTax: "331", taxPercentage: "2100", description: "Shoes", id: "Item #1", taxAmount: "69", amountIncludingTax: "400" }, { quantity: "2", amountExcludingTax: "248", taxPercentage: "2100", description: "Socks", id: "Item #2", taxAmount: "52", amountIncludingTax: "300" } ] } // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentLinksApi.paymentLinks(paymentLinkRequest, { idempotencyKey: "UUID" }); ``` #### Go ```go // Adyen Go API Library v9.2.0 import ( "context" "github.com/adyen/adyen-go-api-library/v9/src/common" "github.com/adyen/adyen-go-api-library/v9/src/adyen" "github.com/adyen/adyen-go-api-library/v9/src/checkout" ) client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Fill in your request objects lineItem1 := checkout.LineItem{ Quantity: common.PtrInt64(1), AmountExcludingTax: common.PtrInt64(331), TaxPercentage: common.PtrInt64(2100), Description: common.PtrString("Shoes"), Id: common.PtrString("Item #1"), TaxAmount: common.PtrInt64(69), AmountIncludingTax: common.PtrInt64(400), } lineItem2 := checkout.LineItem{ Quantity: common.PtrInt64(2), AmountExcludingTax: common.PtrInt64(248), TaxPercentage: common.PtrInt64(2100), Description: common.PtrString("Socks"), Id: common.PtrString("Item #2"), TaxAmount: common.PtrInt64(52), AmountIncludingTax: common.PtrInt64(300), } amount := checkout.Amount{ Currency: "SEK", Value: 1000, } paymentLinkRequest := checkout.PaymentLinkRequest{ Reference: "YOUR_ORDER_NUMBER", LineItems: []checkout.LineItem{ lineItem1, lineItem2, }, Amount: amount, MerchantAccount: "YOUR_MERCHANT_ACCOUNT", CountryCode: common.PtrString("SE"), RequiredShopperFields: []string{ "shopperName", "shopperEmail", "billingAddress", }, Description: common.PtrString("Shoes and socks"), ShopperLocale: common.PtrString("en-US"), ShopperReference: common.PtrString("YOUR_SHOPPER_REFERENCE"), } // Make the request service := client.Checkout() req := service.PaymentLinksApi.PaymentLinksInput().IdempotencyKey("UUID").PaymentLinkRequest(paymentLinkRequest) res, httpRes, err := service.PaymentLinksApi.PaymentLinks(context.Background(), req) ``` #### Python ```py # Adyen Python API Library v12.2.0 import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_API_KEY" adyen.client.platform = "test" # The environment to use library in. json_request = { "reference": "YOUR_ORDER_NUMBER", "amount": { "value": 1000, "currency": "SEK" }, "description": "Shoes and socks", "countryCode": "SE", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "shopperReference": "YOUR_SHOPPER_REFERENCE", "requiredShopperFields": [ "shopperName", "shopperEmail", "billingAddress" ], "shopperLocale": "en-US", "lineItems": [ { "quantity": "1", "amountExcludingTax": "331", "taxPercentage": "2100", "description": "Shoes", "id": "Item #1", "taxAmount": "69", "amountIncludingTax": "400" }, { "quantity": "2", "amountExcludingTax": "248", "taxPercentage": "2100", "description": "Socks", "id": "Item #2", "taxAmount": "52", "amountIncludingTax": "300" } ] } result = adyen.checkout.payment_links_api.payment_links(request=json_request, idempotency_key="UUID") ``` #### Ruby ```rb # Adyen Ruby API Library v9.2.0 require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_API_KEY' adyen.env = :test # Set to "live" for live environment request_body = { :reference => 'YOUR_ORDER_NUMBER', :amount => { :value => 1000, :currency => 'SEK' }, :description => 'Shoes and socks', :countryCode => 'SE', :merchantAccount => 'YOUR_MERCHANT_ACCOUNT', :shopperReference => 'YOUR_SHOPPER_REFERENCE', :requiredShopperFields => [ 'shopperName', 'shopperEmail', 'billingAddress' ], :shopperLocale => 'en-US', :lineItems => [ { :quantity => '1', :amountExcludingTax => '331', :taxPercentage => '2100', :description => 'Shoes', :id => 'Item #1', :taxAmount => '69', :amountIncludingTax => '400' }, { :quantity => '2', :amountExcludingTax => '248', :taxPercentage => '2100', :description => 'Socks', :id => 'Item #2', :taxAmount => '52', :amountIncludingTax => '300' } ] } result = adyen.checkout.payment_links_api.payment_links(request_body, headers: { 'Idempotency-Key' => 'UUID' }) ``` #### NodeJS (TypeScript) ```ts // Adyen Node API Library v16.2.0 // Require the parts of the module you want to use import { Client, CheckoutAPI, Types } from "@adyen/api-library"; // Initialize the client object const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"}); // Create the request objects const lineItem1: Types.checkout.LineItem = { quantity: 1, amountExcludingTax: 331, taxPercentage: 2100, description: "Shoes", id: "Item #1", taxAmount: 69, amountIncludingTax: 400 }; const lineItem2: Types.checkout.LineItem = { quantity: 2, amountExcludingTax: 248, taxPercentage: 2100, description: "Socks", id: "Item #2", taxAmount: 52, amountIncludingTax: 300 }; const amount: Types.checkout.Amount = { currency: "SEK", value: 1000 }; const paymentLinkRequest: Types.checkout.PaymentLinkRequest = { reference: "YOUR_ORDER_NUMBER", lineItems: [lineItem1, lineItem2], amount: amount, merchantAccount: "YOUR_MERCHANT_ACCOUNT", countryCode: "SE", requiredShopperFields: [ Types.checkout.PaymentLinkRequest.RequiredShopperFieldsEnum.ShopperName, Types.checkout.PaymentLinkRequest.RequiredShopperFieldsEnum.ShopperEmail, Types.checkout.PaymentLinkRequest.RequiredShopperFieldsEnum.BillingAddress ], description: "Shoes and socks", shopperLocale: "en-US", shopperReference: "YOUR_SHOPPER_REFERENCE" }; // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentLinksApi.paymentLinks(paymentLinkRequest, { idempotencyKey: "UUID" }); ``` ### Tab: Include shopper information The following example shows how to create a payment link that can support **Klarna** if you have already collected the shopper's email, name, and address: **Create payment link with additional shopper information** #### curl ```bash curl https://checkout-test.adyen.com/v68/paymentLinks \ -H'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "reference": "YOUR_ORDER_NUMBER", "amount": { "value": 1000, "currency": "SEK" }, "description": "Shoes and socks", "countryCode": "SE", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "shopperReference": "YOUR_SHOPPER_REFERENCE", "shopperName":{ "firstName":"Testperson-se", "lastName":"Approved" }, "shopperEmail": "s.hopper@example.com", "shopperLocale": "en-US", "billingAddress":{ "city":"Ankeborg", "country":"SE", "houseNumberOrName":"1", "postalCode":"12345", "street":"Stargatan" }, "lineItems":[ { "quantity":"1", "amountExcludingTax":"331", "taxPercentage":"2100", "description":"Shoes", "id":"Item #1", "taxAmount":"69", "amountIncludingTax":"400" }, { "quantity":"2", "amountExcludingTax":"248", "taxPercentage":"2100", "description":"Socks", "id":"Item #2", "taxAmount":"52", "amountIncludingTax":"300" } ] }' ``` #### Java ```java // Adyen Java API Library v25.0.0 import com.adyen.Client; import com.adyen.enums.Environment; import com.adyen.model.checkout.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.model.RequestOptions; import com.adyen.service.checkout.*; Client client = new Client("ADYEN_API_KEY", Environment.TEST); // Request objects LineItem lineItem1 = new LineItem() .quantity(1L) .amountExcludingTax(331L) .taxPercentage(2100L) .description("Shoes") .id("Item #1") .taxAmount(69L) .amountIncludingTax(400L); LineItem lineItem2 = new LineItem() .quantity(2L) .amountExcludingTax(248L) .taxPercentage(2100L) .description("Socks") .id("Item #2") .taxAmount(52L) .amountIncludingTax(300L); Amount amount = new Amount() .currency("SEK") .value(1000L); Name name = new Name() .firstName("Testperson-se") .lastName("Approved"); Address address = new Address() .country("SE") .city("Ankeborg") .houseNumberOrName("1") .street("Stargatan") .postalCode("12345"); PaymentLinkRequest paymentLinkRequest = new PaymentLinkRequest() .reference("YOUR_ORDER_NUMBER") .lineItems(Arrays.asList(lineItem1, lineItem2)) .amount(amount) .shopperName(name) .merchantAccount("YOUR_MERCHANT_ACCOUNT") .countryCode("SE") .description("Shoes and socks") .shopperEmail("s.hopper@example.com") .shopperLocale("en-US") .billingAddress(address) .shopperReference("YOUR_SHOPPER_REFERENCE"); // Make the request PaymentLinksApi service = new PaymentLinksApi(client); PaymentLinkResponse response = service.paymentLinks(paymentLinkRequest, new RequestOptions().idempotencyKey("UUID")); ``` #### PHP ```php // Adyen PHP API Library v17.4.0 use Adyen\Client; use Adyen\Environment; use Adyen\Model\Checkout\LineItem; use Adyen\Model\Checkout\Amount; use Adyen\Model\Checkout\Name; use Adyen\Model\Checkout\Address; use Adyen\Model\Checkout\PaymentLinkRequest; use Adyen\Service\Checkout\PaymentLinksApi; $client = new Client(); $client->setXApiKey("ADYEN_API_KEY"); $client->setEnvironment(Environment::TEST); // Request objects $lineItem1 = new LineItem(); $lineItem1 ->setQuantity(1) ->setAmountExcludingTax(331) ->setTaxPercentage(2100) ->setDescription("Shoes") ->setId("Item #1") ->setTaxAmount(69) ->setAmountIncludingTax(400); $lineItem2 = new LineItem(); $lineItem2 ->setQuantity(2) ->setAmountExcludingTax(248) ->setTaxPercentage(2100) ->setDescription("Socks") ->setId("Item #2") ->setTaxAmount(52) ->setAmountIncludingTax(300); $amount = new Amount(); $amount ->setCurrency("SEK") ->setValue(1000); $name = new Name(); $name ->setFirstName("Testperson-se") ->setLastName("Approved"); $address = new Address(); $address ->setCountry("SE") ->setCity("Ankeborg") ->setHouseNumberOrName("1") ->setStreet("Stargatan") ->setPostalCode("12345"); $paymentLinkRequest = new PaymentLinkRequest(); $paymentLinkRequest ->setReference("YOUR_ORDER_NUMBER") ->setLineItems(array($lineItem1, $lineItem2)) ->setAmount($amount) ->setShopperName($name) ->setMerchantAccount("YOUR_MERCHANT_ACCOUNT") ->setCountryCode("SE") ->setDescription("Shoes and socks") ->setShopperEmail("s.hopper@example.com") ->setShopperLocale("en-US") ->setBillingAddress($address) ->setShopperReference("YOUR_SHOPPER_REFERENCE"); $requestOptions['idempotencyKey'] = 'UUID'; // Make the request $service = new PaymentLinksApi($client); $response = $service->paymentLinks($paymentLinkRequest, $requestOptions); ``` #### C\# ```cs // Adyen .net API Library v14.3.0 using Adyen; using Environment = Adyen.Model.Environment; using Adyen.Model; using Adyen.Model.Checkout; using Adyen.Service.Checkout; var config = new Config() { XApiKey = "ADYEN_API_KEY", Environment = Environment.Test }; var client = new Client(config); // Fill in your request objects LineItem lineItem1 = new LineItem { Quantity = 1, AmountExcludingTax = 331, TaxPercentage = 2100, Description = "Shoes", Id = "Item #1", TaxAmount = 69, AmountIncludingTax = 400 }; LineItem lineItem2 = new LineItem { Quantity = 2, AmountExcludingTax = 248, TaxPercentage = 2100, Description = "Socks", Id = "Item #2", TaxAmount = 52, AmountIncludingTax = 300 }; Amount amount = new Amount { Currency = "SEK", Value = 1000 }; Name name = new Name { FirstName = "Testperson-se", LastName = "Approved" }; Address address = new Address { Country = "SE", City = "Ankeborg", HouseNumberOrName = "1", Street = "Stargatan", PostalCode = "12345" }; PaymentLinkRequest paymentLinkRequest = new PaymentLinkRequest { Reference = "YOUR_ORDER_NUMBER", LineItems = new List{ lineItem1, lineItem2 }, Amount = amount, ShopperName = name, MerchantAccount = "YOUR_MERCHANT_ACCOUNT", CountryCode = "SE", Description = "Shoes and socks", ShopperEmail = "s.hopper@example.com", ShopperLocale = "en-US", BillingAddress = address, ShopperReference = "YOUR_SHOPPER_REFERENCE" }; // Make the request var service = new PaymentLinksService(client); var response = service.PaymentLinks(paymentLinkRequest, requestOptions: new RequestOptions { IdempotencyKey = "UUID"}); ``` #### NodeJS (JavaScript) ```js // Adyen Node API Library v16.2.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: "ADYEN_API_KEY", environment: "TEST"}); // Create the request object const paymentLinkRequest = { reference: "YOUR_ORDER_NUMBER", amount: { value: 1000, currency: "SEK" }, description: "Shoes and socks", countryCode: "SE", merchantAccount: "YOUR_MERCHANT_ACCOUNT", shopperReference: "YOUR_SHOPPER_REFERENCE", shopperName: { firstName: "Testperson-se", lastName: "Approved" }, shopperEmail: "s.hopper@example.com", shopperLocale: "en-US", billingAddress: { city: "Ankeborg", country: "SE", houseNumberOrName: "1", postalCode: "12345", street: "Stargatan" }, lineItems: [ { quantity: "1", amountExcludingTax: "331", taxPercentage: "2100", description: "Shoes", id: "Item #1", taxAmount: "69", amountIncludingTax: "400" }, { quantity: "2", amountExcludingTax: "248", taxPercentage: "2100", description: "Socks", id: "Item #2", taxAmount: "52", amountIncludingTax: "300" } ] } // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentLinksApi.paymentLinks(paymentLinkRequest, { idempotencyKey: "UUID" }); ``` #### Go ```go // Adyen Go API Library v9.2.0 import ( "context" "github.com/adyen/adyen-go-api-library/v9/src/common" "github.com/adyen/adyen-go-api-library/v9/src/adyen" "github.com/adyen/adyen-go-api-library/v9/src/checkout" ) client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Fill in your request objects lineItem1 := checkout.LineItem{ Quantity: common.PtrInt64(1), AmountExcludingTax: common.PtrInt64(331), TaxPercentage: common.PtrInt64(2100), Description: common.PtrString("Shoes"), Id: common.PtrString("Item #1"), TaxAmount: common.PtrInt64(69), AmountIncludingTax: common.PtrInt64(400), } lineItem2 := checkout.LineItem{ Quantity: common.PtrInt64(2), AmountExcludingTax: common.PtrInt64(248), TaxPercentage: common.PtrInt64(2100), Description: common.PtrString("Socks"), Id: common.PtrString("Item #2"), TaxAmount: common.PtrInt64(52), AmountIncludingTax: common.PtrInt64(300), } amount := checkout.Amount{ Currency: "SEK", Value: 1000, } name := checkout.Name{ FirstName: "Testperson-se", LastName: "Approved", } address := checkout.Address{ Country: "SE", City: "Ankeborg", HouseNumberOrName: "1", Street: "Stargatan", PostalCode: "12345", } paymentLinkRequest := checkout.PaymentLinkRequest{ Reference: "YOUR_ORDER_NUMBER", LineItems: []checkout.LineItem{ lineItem1, lineItem2, }, Amount: amount, ShopperName: &name, MerchantAccount: "YOUR_MERCHANT_ACCOUNT", CountryCode: common.PtrString("SE"), Description: common.PtrString("Shoes and socks"), ShopperEmail: common.PtrString("s.hopper@example.com"), ShopperLocale: common.PtrString("en-US"), BillingAddress: &address, ShopperReference: common.PtrString("YOUR_SHOPPER_REFERENCE"), } // Make the request service := client.Checkout() req := service.PaymentLinksApi.PaymentLinksInput().IdempotencyKey("UUID").PaymentLinkRequest(paymentLinkRequest) res, httpRes, err := service.PaymentLinksApi.PaymentLinks(context.Background(), req) ``` #### Python ```py # Adyen Python API Library v12.2.0 import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_API_KEY" adyen.client.platform = "test" # The environment to use library in. json_request = { "reference": "YOUR_ORDER_NUMBER", "amount": { "value": 1000, "currency": "SEK" }, "description": "Shoes and socks", "countryCode": "SE", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "shopperReference": "YOUR_SHOPPER_REFERENCE", "shopperName": { "firstName": "Testperson-se", "lastName": "Approved" }, "shopperEmail": "s.hopper@example.com", "shopperLocale": "en-US", "billingAddress": { "city": "Ankeborg", "country": "SE", "houseNumberOrName": "1", "postalCode": "12345", "street": "Stargatan" }, "lineItems": [ { "quantity": "1", "amountExcludingTax": "331", "taxPercentage": "2100", "description": "Shoes", "id": "Item #1", "taxAmount": "69", "amountIncludingTax": "400" }, { "quantity": "2", "amountExcludingTax": "248", "taxPercentage": "2100", "description": "Socks", "id": "Item #2", "taxAmount": "52", "amountIncludingTax": "300" } ] } result = adyen.checkout.payment_links_api.payment_links(request=json_request, idempotency_key="UUID") ``` #### Ruby ```rb # Adyen Ruby API Library v9.2.0 require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_API_KEY' adyen.env = :test # Set to "live" for live environment request_body = { :reference => 'YOUR_ORDER_NUMBER', :amount => { :value => 1000, :currency => 'SEK' }, :description => 'Shoes and socks', :countryCode => 'SE', :merchantAccount => 'YOUR_MERCHANT_ACCOUNT', :shopperReference => 'YOUR_SHOPPER_REFERENCE', :shopperName => { :firstName => 'Testperson-se', :lastName => 'Approved' }, :shopperEmail => 's.hopper@example.com', :shopperLocale => 'en-US', :billingAddress => { :city => 'Ankeborg', :country => 'SE', :houseNumberOrName => '1', :postalCode => '12345', :street => 'Stargatan' }, :lineItems => [ { :quantity => '1', :amountExcludingTax => '331', :taxPercentage => '2100', :description => 'Shoes', :id => 'Item #1', :taxAmount => '69', :amountIncludingTax => '400' }, { :quantity => '2', :amountExcludingTax => '248', :taxPercentage => '2100', :description => 'Socks', :id => 'Item #2', :taxAmount => '52', :amountIncludingTax => '300' } ] } result = adyen.checkout.payment_links_api.payment_links(request_body, headers: { 'Idempotency-Key' => 'UUID' }) ``` #### NodeJS (TypeScript) ```ts // Adyen Node API Library v16.2.0 // Require the parts of the module you want to use import { Client, CheckoutAPI, Types } from "@adyen/api-library"; // Initialize the client object const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"}); // Create the request objects const lineItem1: Types.checkout.LineItem = { quantity: 1, amountExcludingTax: 331, taxPercentage: 2100, description: "Shoes", id: "Item #1", taxAmount: 69, amountIncludingTax: 400 }; const lineItem2: Types.checkout.LineItem = { quantity: 2, amountExcludingTax: 248, taxPercentage: 2100, description: "Socks", id: "Item #2", taxAmount: 52, amountIncludingTax: 300 }; const amount: Types.checkout.Amount = { currency: "SEK", value: 1000 }; const name: Types.checkout.Name = { firstName: "Testperson-se", lastName: "Approved" }; const address: Types.checkout.Address = { country: "SE", city: "Ankeborg", houseNumberOrName: "1", street: "Stargatan", postalCode: "12345" }; const paymentLinkRequest: Types.checkout.PaymentLinkRequest = { reference: "YOUR_ORDER_NUMBER", lineItems: [lineItem1, lineItem2], amount: amount, shopperName: name, merchantAccount: "YOUR_MERCHANT_ACCOUNT", countryCode: "SE", description: "Shoes and socks", shopperEmail: "s.hopper@example.com", shopperLocale: "en-US", billingAddress: address, shopperReference: "YOUR_SHOPPER_REFERENCE" }; // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentLinksApi.paymentLinks(paymentLinkRequest, { idempotencyKey: "UUID" }); ``` ## Force the expiry of a payment link In some scenarios, you may want to force the expiry of a payment link. For example, if a shopper updates their order after you have sent them a payment link, you may want to create a new payment link with the updated amount. To avoid confusion with two payment links, set the `status` of the previous payment link to **expired**. Changing the status to **expired** also changes the payment link's expiry date to the current date and time. To force the expiry, make a PATCH [/paymentLinks/{linkId}](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/patch/paymentLinks/{linkId}) request and update the `status`. **Force the expiry of a payment link** #### curl ```bash curl https://checkout-test.adyen.com/v68/paymentLinks/PL50C5F751CED39G71 \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -X PATCH \ -d '{ "status": "expired" }' ``` #### Java ```java // Adyen Java API Library v25.0.0 import com.adyen.Client; import com.adyen.enums.Environment; import com.adyen.model.checkout.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.service.checkout.*; Client client = new Client("ADYEN_API_KEY", Environment.TEST); // Request objects UpdatePaymentLinkRequest updatePaymentLinkRequest = new UpdatePaymentLinkRequest() .status(UpdatePaymentLinkRequest.StatusEnum.EXPIRED); // Make the request PaymentLinksApi service = new PaymentLinksApi(client); PaymentLinkResponse response = service.updatePaymentLink("linkId", updatePaymentLinkRequest, null); ``` #### PHP ```php // Adyen PHP API Library v17.4.0 use Adyen\Client; use Adyen\Environment; use Adyen\Model\Checkout\UpdatePaymentLinkRequest; use Adyen\Service\Checkout\PaymentLinksApi; $client = new Client(); $client->setXApiKey("ADYEN_API_KEY"); $client->setEnvironment(Environment::TEST); // Request objects $updatePaymentLinkRequest = new UpdatePaymentLinkRequest(); $updatePaymentLinkRequest ->setStatus("expired"); // Make the request $service = new PaymentLinksApi($client); $response = $service->updatePaymentLink('linkId', $updatePaymentLinkRequest); ``` #### C\# ```cs // Adyen .net API Library v14.3.0 using Adyen; using Environment = Adyen.Model.Environment; using Adyen.Model; using Adyen.Model.Checkout; using Adyen.Service.Checkout; var config = new Config() { XApiKey = "ADYEN_API_KEY", Environment = Environment.Test }; var client = new Client(config); // Fill in your request objects UpdatePaymentLinkRequest updatePaymentLinkRequest = new UpdatePaymentLinkRequest { Status = UpdatePaymentLinkRequest.StatusEnum.Expired }; // Make the request var service = new PaymentLinksService(client); var response = service.UpdatePaymentLink("linkId", updatePaymentLinkRequest); ``` #### NodeJS (JavaScript) ```js // Adyen Node API Library v16.2.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: "ADYEN_API_KEY", environment: "TEST"}); // Create the request object const updatePaymentLinkRequest = { status: "expired" } // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentLinksApi.updatePaymentLink("linkId", updatePaymentLinkRequest); ``` #### Go ```go // Adyen Go API Library v9.2.0 import ( "context" "github.com/adyen/adyen-go-api-library/v9/src/common" "github.com/adyen/adyen-go-api-library/v9/src/adyen" "github.com/adyen/adyen-go-api-library/v9/src/checkout" ) client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Fill in your request objects updatePaymentLinkRequest := checkout.UpdatePaymentLinkRequest{ Status: "expired", } // Make the request service := client.Checkout() req := service.PaymentLinksApi.UpdatePaymentLinkInput("linkId").UpdatePaymentLinkRequest(updatePaymentLinkRequest) res, httpRes, err := service.PaymentLinksApi.UpdatePaymentLink(context.Background(), req) ``` #### Python ```py # Adyen Python API Library v12.2.0 import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_API_KEY" adyen.client.platform = "test" # The environment to use library in. json_request = { "status": "expired" } result = adyen.checkout.payment_links_api.update_payment_link(request=json_request, linkId="linkId") ``` #### Ruby ```rb # Adyen Ruby API Library v9.2.0 require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_API_KEY' adyen.env = :test # Set to "live" for live environment request_body = { :status => 'expired' } result = adyen.checkout.payment_links_api.update_payment_link(request_body, 'linkId') ``` #### NodeJS (TypeScript) ```ts // Adyen Node API Library v16.2.0 // Require the parts of the module you want to use import { Client, CheckoutAPI, Types } from "@adyen/api-library"; // Initialize the client object const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"}); // Create the request objects const updatePaymentLinkRequest: Types.checkout.UpdatePaymentLinkRequest = { status: Types.checkout.UpdatePaymentLinkRequest.StatusEnum.Expired }; // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentLinksApi.updatePaymentLink("linkId", updatePaymentLinkRequest); ``` The response returns the payment link details with the updated `status` and `expiresAt` parameters. **Response** ```json { "amount": { "currency": "EUR", "value": 4200 }, "countryCode": "NL", "expiresAt": "2020-06-23T13:10:33Z", "id": "PL50C5F751CED39G71", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "reference": "YOUR_PAYMENT_REFERENCE", "shopperLocale": "nl-NL", "status": "expired", "url": "https://test.adyen.link/PL50C5F751CED39G71" } ``` ## Customize the payment page Learn how to customize: * Which [payment methods](#payment-methods) are shown on the payment page, and in which order. * The appearance of the payment page, using [themes](#themes). * The [language](#language) shown on the payment page. ### Payment methods The payment methods are ordered by popularity, the most popular payment methods in the shopper's country/region appearing at the top. In your [Customer Area](https://ca-test.adyen.com/), you can configure which payment methods are rendered [based on the shopper's country/region](#customize-based-on-shoppers-country). If you want to [customize payment methods for specific transactions](#specific-transactions), you can do this by including additional parameters in your API request. #### Customize based on shopper's country/region To configure payment methods in your Customer Area, you must have the **Change payment methods** [user role](/account/user-roles#account). To configure which payment methods are rendered (and in which order) based on the shopper's country/region: 1. Log in to your [Customer Area](https://ca-test.adyen.com/). 2. Go to **Settings** > **Checkout settings**. 3. Select a **Shopper country/region**. 4. Drag the payment methods into the order you want them to appear to shoppers in this country/region. 5. To hide a payment method from shoppers in this country/region, drag it to the **Other configured payment methods** box. #### Customize for specific transactions When making a POST [/paymentLinks](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks) request, you can include one of the following parameters: * [allowedPaymentMethods](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/paymentLinks__reqParam_allowedPaymentMethods): only payment methods that you specify here will be rendered on the payment page. * [blockedPaymentMethods](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/paymentLinks__reqParam_blockedPaymentMethods): payment methods that you specify here will not be rendered on the payment page. To refer to payment methods, use their [`paymentMethodVariant` ](/development-resources/paymentmethodvariant). Here is an example of how you can create a payment link that only allows the shopper to pay with iDEAL or card: **Create a payment link with customized list of payment methods** #### curl ```bash curl https://checkout-test.adyen.com/v68/paymentLinks \ -H'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "allowedPaymentMethods": ["ideal","scheme"], "reference": "YOUR_PAYMENT_REFERENCE", "amount": { "value": 1000, "currency": "EUR" }, "countryCode": "NL", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "shopperLocale": "nl-NL" }' ``` #### Java ```java // Adyen Java API Library v25.0.0 import com.adyen.Client; import com.adyen.enums.Environment; import com.adyen.model.checkout.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.model.RequestOptions; import com.adyen.service.checkout.*; Client client = new Client("ADYEN_API_KEY", Environment.TEST); // Request objects Amount amount = new Amount() .currency("EUR") .value(1000L); PaymentLinkRequest paymentLinkRequest = new PaymentLinkRequest() .reference("YOUR_PAYMENT_REFERENCE") .amount(amount) .merchantAccount("YOUR_MERCHANT_ACCOUNT") .countryCode("NL") .shopperLocale("nl-NL") .allowedPaymentMethods(Arrays.asList("ideal", "scheme")); // Make the request PaymentLinksApi service = new PaymentLinksApi(client); PaymentLinkResponse response = service.paymentLinks(paymentLinkRequest, new RequestOptions().idempotencyKey("UUID")); ``` #### PHP ```php // Adyen PHP API Library v17.4.0 use Adyen\Client; use Adyen\Environment; use Adyen\Model\Checkout\Amount; use Adyen\Model\Checkout\PaymentLinkRequest; use Adyen\Service\Checkout\PaymentLinksApi; $client = new Client(); $client->setXApiKey("ADYEN_API_KEY"); $client->setEnvironment(Environment::TEST); // Request objects $amount = new Amount(); $amount ->setCurrency("EUR") ->setValue(1000); $paymentLinkRequest = new PaymentLinkRequest(); $paymentLinkRequest ->setReference("YOUR_PAYMENT_REFERENCE") ->setAmount($amount) ->setMerchantAccount("YOUR_MERCHANT_ACCOUNT") ->setCountryCode("NL") ->setShopperLocale("nl-NL") ->setAllowedPaymentMethods(array("ideal", "scheme")); $requestOptions['idempotencyKey'] = 'UUID'; // Make the request $service = new PaymentLinksApi($client); $response = $service->paymentLinks($paymentLinkRequest, $requestOptions); ``` #### C\# ```cs // Adyen .net API Library v14.3.0 using Adyen; using Environment = Adyen.Model.Environment; using Adyen.Model; using Adyen.Model.Checkout; using Adyen.Service.Checkout; var config = new Config() { XApiKey = "ADYEN_API_KEY", Environment = Environment.Test }; var client = new Client(config); // Fill in your request objects Amount amount = new Amount { Currency = "EUR", Value = 1000 }; PaymentLinkRequest paymentLinkRequest = new PaymentLinkRequest { Reference = "YOUR_PAYMENT_REFERENCE", Amount = amount, MerchantAccount = "YOUR_MERCHANT_ACCOUNT", CountryCode = "NL", ShopperLocale = "nl-NL", AllowedPaymentMethods = { "ideal", "scheme" } }; // Make the request var service = new PaymentLinksService(client); var response = service.PaymentLinks(paymentLinkRequest, requestOptions: new RequestOptions { IdempotencyKey = "UUID"}); ``` #### NodeJS (JavaScript) ```js // Adyen Node API Library v16.2.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: "ADYEN_API_KEY", environment: "TEST"}); // Create the request object const paymentLinkRequest = { allowedPaymentMethods: [ "ideal", "scheme" ], reference: "YOUR_PAYMENT_REFERENCE", amount: { value: 1000, currency: "EUR" }, countryCode: "NL", merchantAccount: "YOUR_MERCHANT_ACCOUNT", shopperLocale: "nl-NL" } // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentLinksApi.paymentLinks(paymentLinkRequest, { idempotencyKey: "UUID" }); ``` #### Go ```go // Adyen Go API Library v9.2.0 import ( "context" "github.com/adyen/adyen-go-api-library/v9/src/common" "github.com/adyen/adyen-go-api-library/v9/src/adyen" "github.com/adyen/adyen-go-api-library/v9/src/checkout" ) client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Fill in your request objects amount := checkout.Amount{ Currency: "EUR", Value: 1000, } paymentLinkRequest := checkout.PaymentLinkRequest{ Reference: "YOUR_PAYMENT_REFERENCE", Amount: amount, MerchantAccount: "YOUR_MERCHANT_ACCOUNT", CountryCode: common.PtrString("NL"), ShopperLocale: common.PtrString("nl-NL"), AllowedPaymentMethods: []string{ "ideal", "scheme", }, } // Make the request service := client.Checkout() req := service.PaymentLinksApi.PaymentLinksInput().IdempotencyKey("UUID").PaymentLinkRequest(paymentLinkRequest) res, httpRes, err := service.PaymentLinksApi.PaymentLinks(context.Background(), req) ``` #### Python ```py # Adyen Python API Library v12.2.0 import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_API_KEY" adyen.client.platform = "test" # The environment to use library in. json_request = { "allowedPaymentMethods": [ "ideal", "scheme" ], "reference": "YOUR_PAYMENT_REFERENCE", "amount": { "value": 1000, "currency": "EUR" }, "countryCode": "NL", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "shopperLocale": "nl-NL" } result = adyen.checkout.payment_links_api.payment_links(request=json_request, idempotency_key="UUID") ``` #### Ruby ```rb # Adyen Ruby API Library v9.2.0 require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_API_KEY' adyen.env = :test # Set to "live" for live environment request_body = { :allowedPaymentMethods => [ 'ideal', 'scheme' ], :reference => 'YOUR_PAYMENT_REFERENCE', :amount => { :value => 1000, :currency => 'EUR' }, :countryCode => 'NL', :merchantAccount => 'YOUR_MERCHANT_ACCOUNT', :shopperLocale => 'nl-NL' } result = adyen.checkout.payment_links_api.payment_links(request_body, headers: { 'Idempotency-Key' => 'UUID' }) ``` #### NodeJS (TypeScript) ```ts // Adyen Node API Library v16.2.0 // Require the parts of the module you want to use import { Client, CheckoutAPI, Types } from "@adyen/api-library"; // Initialize the client object const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"}); // Create the request objects const amount: Types.checkout.Amount = { currency: "EUR", value: 1000 }; const paymentLinkRequest: Types.checkout.PaymentLinkRequest = { reference: "YOUR_PAYMENT_REFERENCE", amount: amount, merchantAccount: "YOUR_MERCHANT_ACCOUNT", countryCode: "NL", shopperLocale: "nl-NL", allowedPaymentMethods: ["ideal", "scheme"] }; // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentLinksApi.paymentLinks(paymentLinkRequest, { idempotencyKey: "UUID" }); ``` ### Themes Themes allow you to specify a background image and a brand logo to customize the appearance of the payment page. If you create several themes, you can choose a theme when you create the payment link. #### Create a new theme To create a theme, you must have one of the following [user roles](/account/user-roles#account): * Merchant admin * Pay by Link Settings To create a new theme: 1. Log in to your [Customer Area](https://ca-test.adyen.com/) and switch to your merchant account if necessary. 2. Go to **Pay by Link** > **Themes**. 3. Select **Create a new theme**. 4. Enter a **Theme name**. This name is visible to the user creating the payment link in the Customer Area. 5. Enter a **Display name**. This name is visible to the shopper. 6. Upload a favicon. 7. Upload a brand logo. 8. If you want this theme to be the default theme for all payment links, select **Set as default**. Available only on the merchant account. 9. Select **Create**. #### Create a payment link with a specific theme After the theme has been created, you see a **Theme ID** on the Customer Area page for that theme. To use the theme for a new payment link, include the `themeId` in your POST [/paymentLinks](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks) request. Here is an example of how you can create a payment link with a theme: **Create a payment link with a theme** #### curl ```bash curl https://checkout-test.adyen.com/v68/paymentLinks \ -H'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "themeId": "eccbbbc3-b880-430a-8093-6685aba887cf", "reference": "YOUR_PAYMENT_REFERENCE", "amount": { "value": 1000, "currency": "EUR" }, "countryCode": "NL", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "shopperLocale": "nl-NL" }' ``` #### Java ```java // Adyen Java API Library v25.0.0 import com.adyen.Client; import com.adyen.enums.Environment; import com.adyen.model.checkout.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.model.RequestOptions; import com.adyen.service.checkout.*; Client client = new Client("ADYEN_API_KEY", Environment.TEST); // Request objects Amount amount = new Amount() .currency("EUR") .value(1000L); PaymentLinkRequest paymentLinkRequest = new PaymentLinkRequest() .reference("YOUR_PAYMENT_REFERENCE") .amount(amount) .merchantAccount("YOUR_MERCHANT_ACCOUNT") .countryCode("NL") .themeId("eccbbbc3-b880-430a-8093-6685aba887cf") .shopperLocale("nl-NL"); // Make the request PaymentLinksApi service = new PaymentLinksApi(client); PaymentLinkResponse response = service.paymentLinks(paymentLinkRequest, new RequestOptions().idempotencyKey("UUID")); ``` #### PHP ```php // Adyen PHP API Library v17.4.0 use Adyen\Client; use Adyen\Environment; use Adyen\Model\Checkout\Amount; use Adyen\Model\Checkout\PaymentLinkRequest; use Adyen\Service\Checkout\PaymentLinksApi; $client = new Client(); $client->setXApiKey("ADYEN_API_KEY"); $client->setEnvironment(Environment::TEST); // Request objects $amount = new Amount(); $amount ->setCurrency("EUR") ->setValue(1000); $paymentLinkRequest = new PaymentLinkRequest(); $paymentLinkRequest ->setReference("YOUR_PAYMENT_REFERENCE") ->setAmount($amount) ->setMerchantAccount("YOUR_MERCHANT_ACCOUNT") ->setCountryCode("NL") ->setThemeId("eccbbbc3-b880-430a-8093-6685aba887cf") ->setShopperLocale("nl-NL"); $requestOptions['idempotencyKey'] = 'UUID'; // Make the request $service = new PaymentLinksApi($client); $response = $service->paymentLinks($paymentLinkRequest, $requestOptions); ``` #### C\# ```cs // Adyen .net API Library v14.3.0 using Adyen; using Environment = Adyen.Model.Environment; using Adyen.Model; using Adyen.Model.Checkout; using Adyen.Service.Checkout; var config = new Config() { XApiKey = "ADYEN_API_KEY", Environment = Environment.Test }; var client = new Client(config); // Fill in your request objects Amount amount = new Amount { Currency = "EUR", Value = 1000 }; PaymentLinkRequest paymentLinkRequest = new PaymentLinkRequest { Reference = "YOUR_PAYMENT_REFERENCE", Amount = amount, MerchantAccount = "YOUR_MERCHANT_ACCOUNT", CountryCode = "NL", ThemeId = "eccbbbc3-b880-430a-8093-6685aba887cf", ShopperLocale = "nl-NL" }; // Make the request var service = new PaymentLinksService(client); var response = service.PaymentLinks(paymentLinkRequest, requestOptions: new RequestOptions { IdempotencyKey = "UUID"}); ``` #### NodeJS (JavaScript) ```js // Adyen Node API Library v16.2.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: "ADYEN_API_KEY", environment: "TEST"}); // Create the request object const paymentLinkRequest = { themeId: "eccbbbc3-b880-430a-8093-6685aba887cf", reference: "YOUR_PAYMENT_REFERENCE", amount: { value: 1000, currency: "EUR" }, countryCode: "NL", merchantAccount: "YOUR_MERCHANT_ACCOUNT", shopperLocale: "nl-NL" } // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentLinksApi.paymentLinks(paymentLinkRequest, { idempotencyKey: "UUID" }); ``` #### Go ```go // Adyen Go API Library v9.2.0 import ( "context" "github.com/adyen/adyen-go-api-library/v9/src/common" "github.com/adyen/adyen-go-api-library/v9/src/adyen" "github.com/adyen/adyen-go-api-library/v9/src/checkout" ) client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Fill in your request objects amount := checkout.Amount{ Currency: "EUR", Value: 1000, } paymentLinkRequest := checkout.PaymentLinkRequest{ Reference: "YOUR_PAYMENT_REFERENCE", Amount: amount, MerchantAccount: "YOUR_MERCHANT_ACCOUNT", CountryCode: common.PtrString("NL"), ThemeId: common.PtrString("eccbbbc3-b880-430a-8093-6685aba887cf"), ShopperLocale: common.PtrString("nl-NL"), } // Make the request service := client.Checkout() req := service.PaymentLinksApi.PaymentLinksInput().IdempotencyKey("UUID").PaymentLinkRequest(paymentLinkRequest) res, httpRes, err := service.PaymentLinksApi.PaymentLinks(context.Background(), req) ``` #### Python ```py # Adyen Python API Library v12.2.0 import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_API_KEY" adyen.client.platform = "test" # The environment to use library in. json_request = { "themeId": "eccbbbc3-b880-430a-8093-6685aba887cf", "reference": "YOUR_PAYMENT_REFERENCE", "amount": { "value": 1000, "currency": "EUR" }, "countryCode": "NL", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "shopperLocale": "nl-NL" } result = adyen.checkout.payment_links_api.payment_links(request=json_request, idempotency_key="UUID") ``` #### Ruby ```rb # Adyen Ruby API Library v9.2.0 require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_API_KEY' adyen.env = :test # Set to "live" for live environment request_body = { :themeId => 'eccbbbc3-b880-430a-8093-6685aba887cf', :reference => 'YOUR_PAYMENT_REFERENCE', :amount => { :value => 1000, :currency => 'EUR' }, :countryCode => 'NL', :merchantAccount => 'YOUR_MERCHANT_ACCOUNT', :shopperLocale => 'nl-NL' } result = adyen.checkout.payment_links_api.payment_links(request_body, headers: { 'Idempotency-Key' => 'UUID' }) ``` #### NodeJS (TypeScript) ```ts // Adyen Node API Library v16.2.0 // Require the parts of the module you want to use import { Client, CheckoutAPI, Types } from "@adyen/api-library"; // Initialize the client object const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"}); // Create the request objects const amount: Types.checkout.Amount = { currency: "EUR", value: 1000 }; const paymentLinkRequest: Types.checkout.PaymentLinkRequest = { reference: "YOUR_PAYMENT_REFERENCE", amount: amount, merchantAccount: "YOUR_MERCHANT_ACCOUNT", countryCode: "NL", themeId: "eccbbbc3-b880-430a-8093-6685aba887cf", shopperLocale: "nl-NL" }; // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentLinksApi.paymentLinks(paymentLinkRequest, { idempotencyKey: "UUID" }); ``` ### Language and localization The default language of the payment page is the language of the shopper's browser locale. To change the language of payment page, send the `shopperLocale` parameter in your POST [/paymentLinks](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentLinks) request. Pay by Link supports the following languages: | Language | `shopperLocale` | | ---------------------- | --------------- | | Arabic - International | **ar** | | Chinese - Simplified | **zh-CN** | | Chinese - Traditional | **zh-TW** | | Croatian | **hr-HR** | | Czech | **cs-CZ** | | Danish | **da-DK** | | Dutch | **nl-NL** | | English - US | **en-US** | | Finnish | **fi-FI** | | French | **fr-FR** | | German | **de-DE** | | Greek | **el-GR** | | Hungarian | **hu-HU** | | Italian | **it-IT** | | Japanese | **ja-JP** | | Korean | **ko-KR** | | Norwegian | **no-NO** | | Polish | **pl-PL** | | Portuguese - Brazil | **pt-BR** | | Portuguese - Portugal | **pt-PT** | | Romanian | **ro-RO** | | Russian | **ru-RU** | | Slovak | **sk-SK** | | Slovenian | **sl-SI** | | Spanish | **es-ES** | | Swedish | **sv-SE** | ## Test and go live Before going live, use our list of [test cards and other payment methods](/development-resources/test-cards-and-credentials/test-card-numbers) to test your integration. We recommend testing each payment method that you intend to offer to your shoppers. You can check the test payments in your [Customer Area](https://ca-test.adyen.com/), under **Transactions** > **Payments**. When you are ready to go live, you need to: 1. [Apply for a live account](/get-started-with-adyen/application-requirements). 2. [Configure your live account](/online-payments/go-live-checklist). 3. Submit a request to add payment methods in your [live Customer Area](https://ca-live.adyen.com/) . 4. Switch from test to our [live endpoints](/development-resources/live-endpoints#checkout-endpoints). 5. [Add your terms and conditions](/unified-commerce/pay-by-link#add-your-terms-and-conditions) to your live Customer Area. ## See also * [Payment methods](/unified-commerce/pay-by-link/supported-payment-methods) * [Tokenization](/online-payments/tokenization) * [Webhooks](/development-resources/webhooks)