--- title: "Sofort for API only" description: "Add Sofort to an existing API-only integration." url: "https://docs.adyen.com/payment-methods/sofort/api-only" source_url: "https://docs.adyen.com/payment-methods/sofort/api-only.md" canonical: "https://docs.adyen.com/payment-methods/sofort/api-only" last_modified: "2019-09-06T17:19:00+02:00" language: "en" --- # Sofort for API only Add Sofort to an existing API-only integration. Accept Sofort payments using our APIs, and build your own payment form to have full control over the look and feel of your checkout page. ## Requirements | Requirement | Description | | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | | **Integration type** | Make sure that you have built an [API-only integration](/online-payments/build-your-integration/advanced-flow?platform=Web\&integration=API%20only). | | **Setup steps** | Before you begin, [add Sofort in your test Customer Area](/payment-methods/add-payment-methods). | ## Build your payment form for Sofort Include Sofort in the list of available payment methods. You do not need to collect any information from the shopper in your payment form. We provide logos for Sofort which you can use on your payment form. For more information, refer to [Downloading logos](/online-payments/build-your-integration/advanced-flow/?platform=Web\&integration=API%20only#downloading-logos). If you are using the [/paymentMethods](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentMethods) request to show available payment methods to the shopper, specify in your request one of the following combinations of [countryCode](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentMethods) and [amount.currency](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentMethods#request-amount): | Country/region | `countryCode` | `amount.currency` | | --------------- | ------------- | ----------------- | | Austria | AT | EUR | | Belgium | BE | EUR | | Germany | DE | EUR | | Spain | ES | EUR | | Switzerland | CH | CHF | | The Netherlands | NL | EUR | The [/paymentMethods](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentMethods) response contains `paymentMethod.type`: **directEbanking**. We provide logos for Sofort which you can use on your payment form. For more information, refer to [Downloading logos](/online-payments/build-your-integration/advanced-flow/?platform=Web\&integration=API%20only#downloading-logos). ## Make a payment In your [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) request, specify: | Parameter | Required | Description | | -------------------- | ------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `paymentMethod.type` | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | Set this to **directEbanking**. | | `returnUrl` | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | URL to where the shopper should be redirected back to after they complete the payment. | | `countryCode` | | The shopper's country/region. Format: the two-letter [ISO-3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code. Exception: **QZ** (Kosovo). Include this in the request for a better shopper experience. When the shopper is redirected to Sofort's website, the country/region will be automatically selected from the dropdown list. | | `shopperLocale` | | The language that the Sofort page should be rendered in. The page can be the local language (for example, **nl-NL** for the Netherlands) or in **en-US**. | The following example shows how to make a payment request for **10 EUR** for a shopper in the Netherlands, with the Sofort page rendered in US English. #### curl ```bash curl https://checkout-test.adyen.com/v68/payments \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "merchantAccount":"ADYEN_MERCHANT_ACCOUNT", "reference":"YOUR_ORDER_NUMBER", "amount":{ "currency":"EUR", "value":1000 }, "paymentMethod":{ "type":"directEbanking" }, "{hint:Optional}countryCode{/hint}": "NL", "{hint:Optional}shopperLocale{/hint}": "en-US", "returnUrl":"https://your-company.example.com/checkout?shopperOrder=12xy.." }' ``` #### Java ```java // Adyen Java API Library v27.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.*; // For the live environment, additionally include your liveEndpointUrlPrefix. Client client = new Client("ADYEN_API_KEY", Environment.TEST); // Create the request object(s) Amount amount = new Amount() .currency("EUR") .value(1000L); PaymentDetails paymentDetails = new PaymentDetails() .type(PaymentDetails.TypeEnum.DIRECTEBANKING); PaymentRequest paymentRequest = new PaymentRequest() .reference("YOUR_ORDER_NUMBER") .amount(amount) .merchantAccount("ADYEN_MERCHANT_ACCOUNT") .countryCode("NL") .paymentMethod(new CheckoutPaymentMethod(paymentDetails)) .shopperLocale("en-US") .returnUrl("https://your-company.example.com/checkout?shopperOrder=12xy.."); // Send the request PaymentsApi service = new PaymentsApi(client); PaymentResponse response = service.payments(paymentRequest, new RequestOptions().idempotencyKey("UUID")); ``` #### PHP ```php // Adyen PHP API Library v19.0.0 use Adyen\Client; use Adyen\Environment; use Adyen\Model\Checkout\Amount; use Adyen\Model\Checkout\CheckoutPaymentMethod; use Adyen\Model\Checkout\PaymentRequest; use Adyen\Service\Checkout\PaymentsApi; $client = new Client(); $client->setXApiKey("ADYEN_API_KEY"); // For the live environment, additionally include your liveEndpointUrlPrefix. $client->setEnvironment(Environment::TEST); // Create the request object(s) $amount = new Amount(); $amount ->setCurrency("EUR") ->setValue(1000); $checkoutPaymentMethod = new CheckoutPaymentMethod(); $checkoutPaymentMethod ->setType("directEbanking"); $paymentRequest = new PaymentRequest(); $paymentRequest ->setReference("YOUR_ORDER_NUMBER") ->setAmount($amount) ->setMerchantAccount("ADYEN_MERCHANT_ACCOUNT") ->setCountryCode("NL") ->setPaymentMethod($checkoutPaymentMethod) ->setShopperLocale("en-US") ->setReturnUrl("https://your-company.example.com/checkout?shopperOrder=12xy.."); $requestOptions['idempotencyKey'] = 'UUID'; // Send the request $service = new PaymentsApi($client); $response = $service->payments($paymentRequest, $requestOptions); ``` #### C\# ```cs // Adyen .net API Library v17.0.0 using Adyen; using Environment = Adyen.Model.Environment; using Adyen.Model; using Adyen.Model.Checkout; using Adyen.Service.Checkout; // For the live environment, additionally include your liveEndpointUrlPrefix. var config = new Config() { XApiKey = "ADYEN_API_KEY", Environment = Environment.Test }; var client = new Client(config); // Create the request object(s) Amount amount = new Amount { Currency = "EUR", Value = 1000 }; PaymentDetails paymentDetails = new PaymentDetails { Type = PaymentDetails.TypeEnum.DirectEbanking }; PaymentRequest paymentRequest = new PaymentRequest { Reference = "YOUR_ORDER_NUMBER", Amount = amount, MerchantAccount = "ADYEN_MERCHANT_ACCOUNT", CountryCode = "NL", PaymentMethod = new CheckoutPaymentMethod(paymentDetails), ShopperLocale = "en-US", ReturnUrl = "https://your-company.example.com/checkout?shopperOrder=12xy.." }; // Send the request var service = new PaymentsService(client); var response = service.Payments(paymentRequest, requestOptions: new RequestOptions { IdempotencyKey = "UUID"}); ``` #### NodeJS (JavaScript) ```js // Adyen Node API Library v18.0.0 // Require the parts of the module you want to use const { Client, CheckoutAPI } = require('@adyen/api-library'); // Initialize the client object // For the live environment, additionally include your liveEndpointUrlPrefix. const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"}); // Create the request object(s) const paymentRequest = { merchantAccount: "ADYEN_MERCHANT_ACCOUNT", reference: "YOUR_ORDER_NUMBER", amount: { currency: "EUR", value: 1000 }, paymentMethod: { type: "directEbanking" }, countryCode: "NL", shopperLocale: "en-US", returnUrl: "https://your-company.example.com/checkout?shopperOrder=12xy.." } // Send the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentsApi.payments(paymentRequest, { idempotencyKey: "UUID" }); ``` #### Go ```go // Adyen Go API Library v10.4.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" ) // For the live environment, additionally include your liveEndpointUrlPrefix. client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Create the request object(s) amount := checkout.Amount{ Currency: "EUR", Value: 1000, } paymentDetails := checkout.PaymentDetails{ Type: common.PtrString("directEbanking"), } paymentRequest := checkout.PaymentRequest{ Reference: "YOUR_ORDER_NUMBER", Amount: amount, MerchantAccount: "ADYEN_MERCHANT_ACCOUNT", CountryCode: common.PtrString("NL"), PaymentMethod: checkout.PaymentDetailsAsCheckoutPaymentMethod(&paymentDetails), ShopperLocale: common.PtrString("en-US"), ReturnUrl: "https://your-company.example.com/checkout?shopperOrder=12xy..", } // Send the request service := client.Checkout() req := service.PaymentsApi.PaymentsInput().IdempotencyKey("UUID").PaymentRequest(paymentRequest) res, httpRes, err := service.PaymentsApi.Payments(context.Background(), req) ``` #### Python ```py # Adyen Python API Library v12.5.1 import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_API_KEY" # For the live environment, additionally include your liveEndpointUrlPrefix. adyen.client.platform = "test" # The environment to use library in. # Create the request object(s) json_request = { "merchantAccount": "ADYEN_MERCHANT_ACCOUNT", "reference": "YOUR_ORDER_NUMBER", "amount": { "currency": "EUR", "value": 1000 }, "paymentMethod": { "type": "directEbanking" }, "countryCode": "NL", "shopperLocale": "en-US", "returnUrl": "https://your-company.example.com/checkout?shopperOrder=12xy.." } # Send the request result = adyen.checkout.payments_api.payments(request=json_request, idempotency_key="UUID") ``` #### Ruby ```rb # Adyen Ruby API Library v9.5.1 require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_API_KEY' # For the live environment, additionally include your liveEndpointUrlPrefix. adyen.env = :test # Set to "live" for live environment # Create the request object(s) request_body = { :merchantAccount => 'ADYEN_MERCHANT_ACCOUNT', :reference => 'YOUR_ORDER_NUMBER', :amount => { :currency => 'EUR', :value => 1000 }, :paymentMethod => { :type => 'directEbanking' }, :countryCode => 'NL', :shopperLocale => 'en-US', :returnUrl => 'https://your-company.example.com/checkout?shopperOrder=12xy..' } # Send the request result = adyen.checkout.payments_api.payments(request_body, headers: { 'Idempotency-Key' => 'UUID' }) ``` #### NodeJS (TypeScript) ```ts // Adyen Node API Library v18.0.0 // Require the parts of the module you want to use import { Client, CheckoutAPI, Types } from "@adyen/api-library"; // Initialize the client object // For the live environment, additionally include your liveEndpointUrlPrefix. const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"}); // Create the request object(s) const amount: Types.checkout.Amount = { currency: "EUR", value: 1000 }; const paymentDetails: Types.checkout.PaymentDetails = { type: Types.checkout.PaymentDetails.TypeEnum.DirectEbanking }; const paymentRequest: Types.checkout.PaymentRequest = { reference: "YOUR_ORDER_NUMBER", amount: amount, merchantAccount: "ADYEN_MERCHANT_ACCOUNT", countryCode: "NL", paymentMethod: paymentDetails, shopperLocale: "en-US", returnUrl: "https://your-company.example.com/checkout?shopperOrder=12xy.." }; // Send the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentsApi.payments(paymentRequest, { idempotencyKey: "UUID" }); ``` In the [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) response, check the `action` object for the information that you must use to redirect the shopper. **/payments response** ```json { "resultCode":"RedirectShopper", "action":{ "paymentMethodType":"directEbanking", "method":"GET", "url":"https://checkoutshopper-test.adyen.com/checkoutshopper/checkoutPaymentRedirect?redirectData=...", "type":"redirect" } } ``` ## Handle the redirect 1. To complete the payment, redirect the shopper to the `action.url` returned in the [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) response, taking into account the following recommendations: * **When using the HTTP GET method:**\ For security reasons, when showing the redirect in the app, we recommend that you use [SFSafariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller) for iOS or [Chrome Custom Tabs](https://developer.chrome.com/multidevice/android/customtabs) for Android, instead of WebView objects. Also refer to the [security best practices](https://developer.android.com/topic/security/best-practices#webview) for WebView. * **Redirection for mobile integrations:**\ For mobile integrations, we strongly recommended that you redirect the shopper to the default browser of their device. Redirecting to the default browser ensures the best compatibility, handling of multi-factor authentication, app-to-app redirection, and error handling. 2. After the shopper is redirected back to your website, check the payment result by making a POST [/payments/details](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments/details) request, specifying: * `details`: object that contains the URL-decoded `redirectResult` returned when the shopper was redirected back to your site. **/payments/details request** ```bash curl https://checkout-test.adyen.com/v72/payments/details \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "details": { "redirectResult": "eyJ0cmFuc1N0YXR1cyI6IlkifQ==" } }' ``` 3. In the response note the following: * `resultCode`: use this to present the result to your shopper. * `pspReference`: our unique identifier for the transaction. **/payments/details response** ```json { "resultCode": "Authorised", "pspReference": "V4HZ4RBFJGXXGN82" } ``` ## Present the payment result Use the  [resultCode](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments/details#responses-200-resultCode) that you received in the [/payments/details](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments/details) response to present the payment result to your shopper. The `resultCode` values you can receive for Sofort are: | resultCode | Description | Action to take | | --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **Authorised** | The shopper completed their payment, and it has been sent to the bank for processing. In most cases, this means that you will receive the funds. For information on exceptions, refer to [Chargebacks](/payment-methods/sofort#chargebacks). | Inform the shopper that the payment has been successful. | | **Cancelled** | The shopper cancelled the payment while on their bank's website. | Ask the shopper whether they want to continue with the order, or ask them to select a different payment method. | | **Error** | There was an error when the payment was being processed. | Inform the shopper that there was an error processing their payment. The response contains a `refusalReason`, indicating the cause of the error. | | **Pending** or **Received** | The shopper has completed the payment but the final result is not yet known. | Inform the shopper that you have received their order, and are waiting for the payment to be completed. You will receive the final result of the payment in an [AUTHORISATION webhook](/development-resources/webhooks/webhook-types). | | **Refused** | The payment was refused by the shopper's bank. | Ask the shopper to try the payment again using a different payment method. | []()If the shopper failed to return to your website or app, wait for webhooks to know the outcome of the payment: | eventCode | success field | Description | Action to take | | ----------------- | ------------- | ----------------------------------------------- | ----------------------------------------------------------------------------------- | | **AUTHORISATION** | **false** | The transaction failed. | Cancel the order and inform the shopper that the payment failed. | | **AUTHORISATION** | **true** | The shopper successfully completed the payment. | Inform the shopper that the payment has been successful and proceed with the order. | ## Recurring payments We support recurring transactions for Sofort through [SEPA Direct Debit](/payment-methods/sepa-direct-debit). To make recurring payments, you need to: 1. [Create a shopper token](#create-a-token). 2. [Use the token to make future payments for the shopper](#make-payment-with-token). ### Create a token We strongly recommend that you request explicit permission from the shopper if you intend to make recurring SEPA payments. Being transparent about the payment schedule and the charged amount reduces the risk of [chargebacks](/payment-methods/sofort#chargebacks). To create a token, include in your [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) request: * `storePaymentMethod`: **true** * [shopperReference](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-shopperReference): Your unique identifier for the shopper (minimum length three characters). When the payment has been settled, you receive a [recurring.token.created](https://docs.adyen.com/api-explorer/Tokenization-webhooks/latest/post/recurring.token.created) [webhook](/development-resources/webhooks) containing: * `type`: **recurring.token.created** * `shopperReference`: your unique identifier for the shopper. * `eventId`: the `pspReference` of the initial payment. * `storedPaymentMethodId`: the token that you need to make recurring payments for this shopper. Make sure that your server is able to receive the [Recurring tokens life cycle events](/development-resources/webhooks/webhook-types/#other-webhooks) webhook. You can [set up this webhook in your Customer Area](/development-resources/webhooks/#set-up-webhooks-in-your-customer-area). ### Make a payment with a token To make a payment with the token, include in your [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) request: * `paymentMethod.storedPaymentMethodId`: The `storedPaymentMethodId` from the [recurring.token.created](https://docs.adyen.com/api-explorer/Tokenization-webhooks/latest/post/recurring.token.created) webhook. You can also get this value using the [/listRecurringDetails](https://docs.adyen.com/api-explorer/Recurring/latest/post/listRecurringDetails) endpoint. * `shopperReference`: The unique shopper identifier that you specified when creating the token. * `shopperInteraction`: **ContAuth**. * `recurringProcessingModel`: **Subscription** or **UnscheduledCardOnFile**. For more information about the `shopperInteraction` and `recurringProcessingModel` fields, refer to [Tokenization](/online-payments/tokenization/). #### curl ```bash curl https://checkout-test.adyen.com/v68/payments \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "amount":{ "value":1000, "currency":"EUR" }, "paymentMethod":{ "type":"sepadirectdebit", "recurringDetailReference":"7219687191761347" }, "reference":"YOUR_ORDER_NUMBER", "merchantAccount":"YOUR_MERCHANT_ACCOUNT", "shopperReference":"YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j", "shopperInteraction":"ContAuth", "recurringProcessingModel": "Subscription" }' ``` #### Java ```java // Adyen Java API Library v39.3.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.*; // For the LIVE environment, also include your liveEndpointUrlPrefix. Client client = new Client("ADYEN_API_KEY", Environment.TEST); // Create the request object(s) Amount amount = new Amount() .currency("EUR") .value(1000L); SepaDirectDebitDetails sepaDirectDebitDetails = new SepaDirectDebitDetails() .recurringDetailReference("7219687191761347") .type(SepaDirectDebitDetails.TypeEnum.SEPADIRECTDEBIT); PaymentRequest paymentRequest = new PaymentRequest() .reference("YOUR_ORDER_NUMBER") .amount(amount) .merchantAccount("YOUR_MERCHANT_ACCOUNT") .recurringProcessingModel(PaymentRequest.RecurringProcessingModelEnum.SUBSCRIPTION) .paymentMethod(new CheckoutPaymentMethod(sepaDirectDebitDetails)) .shopperInteraction(PaymentRequest.ShopperInteractionEnum.CONTAUTH) .shopperReference("YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j"); // Send the request PaymentsApi service = new PaymentsApi(client); PaymentResponse response = service.payments(paymentRequest, new RequestOptions().idempotencyKey("UUID")); ``` #### PHP ```php setXApiKey("ADYEN_API_KEY"); // For the LIVE environment, also include your liveEndpointUrlPrefix. $client->setEnvironment(Environment::TEST); // Create the request object(s) $amount = new Amount(); $amount ->setCurrency("EUR") ->setValue(1000); $checkoutPaymentMethod = new CheckoutPaymentMethod(); $checkoutPaymentMethod ->setRecurringDetailReference("7219687191761347") ->setType("sepadirectdebit"); $paymentRequest = new PaymentRequest(); $paymentRequest ->setReference("YOUR_ORDER_NUMBER") ->setAmount($amount) ->setMerchantAccount("YOUR_MERCHANT_ACCOUNT") ->setRecurringProcessingModel("Subscription") ->setPaymentMethod($checkoutPaymentMethod) ->setShopperInteraction("ContAuth") ->setShopperReference("YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j"); $requestOptions['idempotencyKey'] = 'UUID'; // Send the request $service = new PaymentsApi($client); $response = $service->payments($paymentRequest, $requestOptions); ``` #### C\# ```cs // Set your X-API-KEY with the API key from the Customer Area. var client = new Client ("ADYEN_API_KEY", Environment.Test); var checkout = new Checkout(client); var amount = new Adyen.Model.Checkout.Amount("EUR", 1000); var details = new Adyen.Model.Checkout.DefaultPaymentMethodDetails{ Type = "sepadirectdebit", StoredPaymentMethodId = "7219687191761347" }; var paymentsRequest = new Adyen.Model.Checkout.PaymentRequest { Reference = "YOUR_ORDER_NUMBER", Amount = amount, ReturnUrl = @"https://your-company.example.com/checkout?shopperOrder=12xy..", MerchantAccount = "YOUR_MERCHANT_ACCOUNT", ShopperReference = "YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j", RecurringProcessingModel = Adyen.Model.Checkout.PaymentRequest.RecurringProcessingModelEnum.Subscription, ShopperInteraction = Adyen.Model.Checkout.PaymentRequest.ShopperInteractionEnum.ContAuth, PaymentMethod = details }; var paymentResponse = checkout.Payments(paymentsRequest); ``` #### NodeJS (JavaScript) ```js // Adyen Node API Library v29.0.0 const { Client, CheckoutAPI } = require('@adyen/api-library'); // For the LIVE environment, also include your liveEndpointUrlPrefix. const config = new Config({ apiKey: "ADYEN_API_KEY", environment: EnvironmentEnum.TEST }); const client = new Client(config); // Create the request object(s) const paymentRequest = { amount: { value: 1000, currency: "EUR" }, paymentMethod: { type: "sepadirectdebit", recurringDetailReference: "7219687191761347" }, reference: "YOUR_ORDER_NUMBER", merchantAccount: "YOUR_MERCHANT_ACCOUNT", shopperReference: "YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j", shopperInteraction: "ContAuth", recurringProcessingModel: "Subscription" } // Send the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentsApi.payments(paymentRequest, { idempotencyKey: "UUID" }); ``` #### Go ```go // Adyen Go API Library v21.0.0 import ( "context" "github.com/adyen/adyen-go-api-library/v21/src/common" "github.com/adyen/adyen-go-api-library/v21/src/adyen" "github.com/adyen/adyen-go-api-library/v21/src/checkout" ) // For the LIVE environment, also include your liveEndpointUrlPrefix. client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Create the request object(s) amount := checkout.Amount{ Currency: "EUR", Value: 1000, } sepaDirectDebitDetails := checkout.SepaDirectDebitDetails{ RecurringDetailReference: common.PtrString("7219687191761347"), Type: common.PtrString("sepadirectdebit"), } paymentRequest := checkout.PaymentRequest{ Reference: "YOUR_ORDER_NUMBER", Amount: amount, MerchantAccount: "YOUR_MERCHANT_ACCOUNT", RecurringProcessingModel: common.PtrString("Subscription"), PaymentMethod: checkout.SepaDirectDebitDetailsAsCheckoutPaymentMethod(&sepaDirectDebitDetails), ShopperInteraction: common.PtrString("ContAuth"), ShopperReference: common.PtrString("YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j"), } // Send the request service := client.Checkout() req := service.PaymentsApi.PaymentsInput().IdempotencyKey("UUID").PaymentRequest(paymentRequest) res, httpRes, err := service.PaymentsApi.Payments(context.Background(), req) ``` #### Python ```py # Adyen Python API Library v13.6.0 import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_API_KEY" # For the LIVE environment, also include your liveEndpointUrlPrefix. adyen.client.platform = "test" # The environment to use library in. # Create the request object(s) json_request = { "amount": { "value": 1000, "currency": "EUR" }, "paymentMethod": { "type": "sepadirectdebit", "recurringDetailReference": "7219687191761347" }, "reference": "YOUR_ORDER_NUMBER", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "shopperReference": "YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j", "shopperInteraction": "ContAuth", "recurringProcessingModel": "Subscription" } # Send the request result = adyen.checkout.payments_api.payments(request=json_request, idempotency_key="UUID") ``` #### Ruby ```rb # Adyen Ruby API Library v10.4.0 require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_API_KEY' # For the LIVE environment, also include your liveEndpointUrlPrefix. adyen.env = :test # Set to "live" for live environment # Create the request object(s) request_body = { :amount => { :value => 1000, :currency => 'EUR' }, :paymentMethod => { :type => 'sepadirectdebit', :recurringDetailReference => '7219687191761347' }, :reference => 'YOUR_ORDER_NUMBER', :merchantAccount => 'YOUR_MERCHANT_ACCOUNT', :shopperReference => 'YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j', :shopperInteraction => 'ContAuth', :recurringProcessingModel => 'Subscription' } # Send the request result = adyen.checkout.payments_api.payments(request_body, headers: { 'Idempotency-Key' => 'UUID' }) ``` #### NodeJS (TypeScript) ```ts // Adyen Node API Library v29.0.0 import { Client, CheckoutAPI, Types } from "@adyen/api-library"; // For the LIVE environment, also include your liveEndpointUrlPrefix. const config = new Config({ apiKey: "ADYEN_API_KEY", environment: EnvironmentEnum.TEST }); const client = new Client(config); // Create the request object(s) const amount: Types.checkout.Amount = { currency: "EUR", value: 1000 }; const sepaDirectDebitDetails: Types.checkout.SepaDirectDebitDetails = { recurringDetailReference: "7219687191761347", type: Types.checkout.SepaDirectDebitDetails.TypeEnum.Sepadirectdebit }; const paymentRequest: Types.checkout.PaymentRequest = { reference: "YOUR_ORDER_NUMBER", amount: amount, merchantAccount: "YOUR_MERCHANT_ACCOUNT", recurringProcessingModel: Types.checkout.PaymentRequest.RecurringProcessingModelEnum.Subscription, paymentMethod: sepaDirectDebitDetails, shopperInteraction: Types.checkout.PaymentRequest.ShopperInteractionEnum.ContAuth, shopperReference: "YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j" }; // Send the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentsApi.payments(paymentRequest, { idempotencyKey: "UUID" }); ``` ## Test and go live Sofort does not have a specialized test environment. This means that you are redirected to the Sofort live environment even when making a payment from the Adyen test environment. You can test successful and cancelled payments in EUR for Sofort. For other scenarios, use real payment details and small amounts in your live environment. ### Test a successful payment To test your integration, use the following details:  | Bank Name | Account Number | Country/region | PIN | TAN | | --------- | --------------- | -------------- | --------------- | ------------------------- | | DemoBank | *Use any value* | **DE** | *Use any value* | *Follow the instructions* | Using a different bank name (live data) will initiate a real payment. This payment will not be transferred to your account, and is therefore lost. It is not possible to reverse or refund this payment. 1. Set the `paymentMethod` `type` to **directEbanking**. This redirects you to the Sofort page. 2. Under Bank name, select **Demo Bank**, then **Next**. 3. Enter any test login details for **Account number** and **PIN**, and select **Next**. 4. Select an account, then **Next**. 5. Enter any test **TAN** and select **Next**. 6. To check the status of your test payment, go to your [test Customer Area](https://ca-test.adyen.com/) > **Transactions** > **Payments**. ### Test a cancelled payment 1. Set the `paymentMethod` `type` to **directEbanking**. This redirects you to the Sofort page. 2. Under Bank name, select **Demo Bank**. 3. Select **Next**. 4. Select the **icon. 5. Select **Cancel payment**. 6. To check the status of your test payment, go to your [test Customer Area](https://ca-test.adyen.com/) > **Transactions** > **Payments**. ### Go live To accept live Sofort payments, you must [submit a request for Sofort](/payment-methods/add-payment-methods) in your [live Customer Area](https://ca-live.adyen.com/). ## See also * [API only integration](/online-payments/build-your-integration/advanced-flow?platform=Web\&integration=API%20only) * [Webhooks](/development-resources/webhooks) * [API Explorer](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/overview)