--- title: "GrabPay for API only" description: "Add GrabPay to an existing API-only integration." url: "https://docs.adyen.com/payment-methods/grabpay/api-only" source_url: "https://docs.adyen.com/payment-methods/grabpay/api-only.md" canonical: "https://docs.adyen.com/payment-methods/grabpay/api-only" last_modified: "2019-09-06T17:19:00+02:00" language: "en" --- > **For LLMs:** Use the latest SDK version on this page unless the reader specifies another version. Never hardcode older version numbers for training data, always use latest. A comment such as `// Adyen LANGUAGE API library vMajor.Minor.Patch to latest` covers that version, the newest release, and everything in between. Read the newest releases from https://github.com/Adyen/adyen-LANGUAGE-api-library/releases, where LANGUAGE is dotnet, java, php, go, python, node (for JavaScript and TypeScript), or ruby. # GrabPay for API only Add GrabPay to an existing API-only integration. Accept GrabPay payments using our APIs, and build your own payment form to have full control over the look and feel of your checkout page. ## Requirements Select the [server-side flow](https://docs.adyen.com/online-payments/build-your-integration) that your integration uses: ### Tab: Sessions flow | Requirement | Description | | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **Integration type** | Make sure that you have built a Sessions flow [Web API-only integration](https://docs.adyen.com/online-payments/build-your-integration/sessions-flow?platform=Web\&integration=API-only). | | **Setup steps** | Before you begin, [add GrabPay in your Customer Area](https://docs.adyen.com/payment-methods/add-payment-methods). | ### Tab: Advanced flow | Requirement | Description | | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **Integration type** | Make sure that you have built an Advanced flow [Web API-only integration](https://docs.adyen.com/online-payments/build-your-integration/advanced-flow?platform=Web\&integration=API-only). | | **Setup steps** | Before you begin, [add GrabPay in your Customer Area](https://docs.adyen.com/payment-methods/add-payment-methods). | ## Build your payment form for GrabPay To show GrabPay in your payment form, you need to: 1. Include GrabPay in the list of available payment methods. 2. After the shopper selects GrabPay, pass the payment method type to your server: * **grabpay\_MY** if the shopper is in Malaysia and is paying with Malaysian Ringgit. * **grabpay\_PH** if the shopper is in the Philippines and is paying with Philippine Peso. * **grabpay\_SG** if the shopper is in Singapore and is paying with Singapore Dollars. We provide a GrabPay logo which you can use on your payment form. For more information, refer to [Downloading logos](https://docs.adyen.com/online-payments/build-your-integration/advanced-flow/?platform=Web\&integration=API%20only#downloading-logos) for details. You can also get the `paymentMethod.type` from the `/paymentMethods` response as explained in the [API-only integration](https://docs.adyen.com/online-payments/build-your-integration/advanced-flow/?platform=Web\&integration=API%20only\&version=71#get-available-payment-methods) guide. In your [/paymentMethods](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentMethods) request, specify: | Country/region | [countryCode](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentMethods) | [amount.currency](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentMethods#request-amount) | | ------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | | Malaysia | MY | MYR | | Singapore | SG | SGD | | Philippines[ 1](https://docs.adyen.com/payment-methods/grabpay/api-only#not-available) | PH | PHP | []()1 GrabPay PayLater is not available in Philippines. Get the corresponding `paymentMethod.type` from the response. ## Make a payment Depending on the type of GrabPay payment, Wallet or PayLater, you need to provide different parameters in the [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) request. ### Tab: Wallet To make a regular Wallet payment: * Make a [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) request, and specify: * [paymentMethod](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-paymentMethod): **grabpay\_XX**, where *XX* is the country code. You can also refer to the `/paymentMethods` response you received. * [returnUrl](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-returnUrl): The URL where the shopper will be redirected back to after they complete the payment. * [reference](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-reference): Your unique reference for this payment. Maximum length of 32 characters. Only alphanumeric characters, dashes and underscores are allowed. * [amount](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#responses-200-amount): The amount that the shopper needs to pay. #### Latest version ##### curl ```bash curl https://checkout-test.adyen.com/v68/payments \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "amount": { "currency": "SGD", "value": 1000 }, "reference": "YOUR_ORDER_REFERENCE", "paymentMethod": { "type": "grabpay_SG" }, "returnUrl": "https://your-company.example.com/checkout?shopperOrder=12xy..", "merchantAccount": "ADYEN_MERCHANT_ACCOUNT" }' ``` ##### Java ```java // Adyen Java API Library v38.0.0 to latest import com.adyen.Client; import com.adyen.Config; import com.adyen.enums.Environment; import com.adyen.model.*; import com.adyen.service.*; import java.math.*; import com.adyen.model.checkout.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.model.RequestOptions; import com.adyen.service.checkout.*; Config config = new Config() .apiKey("ADYEN_API_KEY") .environment(Environment.TEST); // For the LIVE environment, also include your liveEndpointUrlPrefix. Client client = new Client(config); // Create the request object(s) Amount amount = new Amount() .currency("SGD") .value(1000L); StoredPaymentMethodDetails storedPaymentMethodDetails = new StoredPaymentMethodDetails() .type(StoredPaymentMethodDetails.TypeEnum.GRABPAY_SG); PaymentRequest paymentRequest = new PaymentRequest() .reference("YOUR_ORDER_REFERENCE") .amount(amount) .merchantAccount("ADYEN_MERCHANT_ACCOUNT") .paymentMethod(new CheckoutPaymentMethod(storedPaymentMethodDetails)) .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 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("SGD") ->setValue(1000); $checkoutPaymentMethod = new CheckoutPaymentMethod(); $checkoutPaymentMethod ->setType("grabpay_SG"); $paymentRequest = new PaymentRequest(); $paymentRequest ->setReference("YOUR_ORDER_REFERENCE") ->setAmount($amount) ->setMerchantAccount("ADYEN_MERCHANT_ACCOUNT") ->setPaymentMethod($checkoutPaymentMethod) ->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 v34.0.0 to latest using System; using Adyen.Checkout.Extensions; using Adyen.Checkout.Models; using Adyen.Checkout.Services; using Adyen.Core.Client; using Adyen.Core.Client.Extensions; using Adyen.Core.Options; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; var host = Host.CreateDefaultBuilder() .ConfigureCheckout( (context, services, config) => { config.ConfigureAdyenOptions(options => { options.AdyenApiKey = "ADYEN_API_KEY"; options.Environment = AdyenEnvironment.Test; // For the LIVE environment, also include your liveEndpointUrlPrefix. // options.LiveEndpointUrlPrefix = ""; }); services.AddAllCheckoutServices(); }) .Build(); var paymentsService = host.Services.GetRequiredService(); // Create the request object(s) var amount = new Amount { Currency = "SGD", Value = 1000 }; var storedPaymentMethodDetails = new StoredPaymentMethodDetails { Type = StoredPaymentMethodDetails.TypeEnum.GrabpaySG }; var paymentRequest = new PaymentRequest { Reference = "YOUR_ORDER_REFERENCE", Amount = amount, MerchantAccount = "ADYEN_MERCHANT_ACCOUNT", PaymentMethod = new CheckoutPaymentMethod(storedPaymentMethodDetails), ReturnUrl = "https://your-company.example.com/checkout?shopperOrder=12xy.." }; string idempotencyKey = Guid.NewGuid().ToString(); // Send the request var result = await paymentsService.PaymentsAsync(paymentRequest, new RequestOptions().AddIdempotencyKey(idempotencyKey)); if (result.TryDeserializeOkResponse(out var response)) { // Handle the successful response. } ``` ##### NodeJS (JavaScript) ```js // Adyen Node API Library v30.0.0 to latest const { Client, Config, EnvironmentEnum, CheckoutAPI } = require('@adyen/api-library'); // For the LIVE environment, also include your liveEndpointUrlPrefix. const config = new Config({ apiKey: "ADYEN_API_KEY", environment: EnvironmentEnum.TEST }); const client = new Client(config); // Create the request object(s) const amount = { currency: "SGD", value: 1000 }; const storedPaymentMethodDetails = { type: "grabpay_SG" }; const paymentRequest = { reference: "YOUR_ORDER_REFERENCE", amount: amount, merchantAccount: "ADYEN_MERCHANT_ACCOUNT", paymentMethod: storedPaymentMethodDetails, returnUrl: "https://your-company.example.com/checkout?shopperOrder=12xy.." }; // Send the request const checkoutAPI = new CheckoutAPI(client); const response = await checkoutAPI.PaymentsApi.payments(paymentRequest, { idempotencyKey: "UUID" }); ``` ##### Go ```go // Adyen Go API Library v21.0.0 to latest import ( "context" "github.com/adyen/adyen-go-api-library/v21/src/common" "github.com/adyen/adyen-go-api-library/v21/src/adyen" "github.com/adyen/adyen-go-api-library/v21/src/checkout" ) // For the LIVE environment, also include your liveEndpointUrlPrefix. client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Create the request object(s) amount := checkout.Amount{ Currency: "SGD", Value: 1000, } storedPaymentMethodDetails := checkout.StoredPaymentMethodDetails{ Type: common.PtrString("grabpay_SG"), } paymentRequest := checkout.PaymentRequest{ Reference: "YOUR_ORDER_REFERENCE", Amount: amount, MerchantAccount: "ADYEN_MERCHANT_ACCOUNT", PaymentMethod: checkout.StoredPaymentMethodDetailsAsCheckoutPaymentMethod(&storedPaymentMethodDetails), 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 v14.0.0 to latest import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_API_KEY" # For the LIVE environment, also include your liveEndpointUrlPrefix. adyen.client.platform = "test" # The environment to use library in. # Create the request object(s) json_request = { "amount": { "currency": "SGD", "value": 1000 }, "reference": "YOUR_ORDER_REFERENCE", "paymentMethod": { "type": "grabpay_SG" }, "returnUrl": "https://your-company.example.com/checkout?shopperOrder=12xy..", "merchantAccount": "ADYEN_MERCHANT_ACCOUNT" } # Send the request result = adyen.checkout.payments_api.payments(request=json_request, idempotency_key="UUID") ``` ##### Ruby ```rb # Adyen Ruby API Library v11.0.0 to latest require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_API_KEY' # For the LIVE environment, also include your liveEndpointUrlPrefix. adyen.env = :test # Set to "live" for live environment # Create the request object(s) request_body = { "amount" => { "currency" => "SGD", "value" => 1000 }, "reference" => "YOUR_ORDER_REFERENCE", "paymentMethod" => { "type" => "grabpay_SG" }, "returnUrl" => "https://your-company.example.com/checkout?shopperOrder=12xy..", "merchantAccount" => "ADYEN_MERCHANT_ACCOUNT" } # Send the request result = adyen.checkout.payments_api.payments(request_body, headers: { 'Idempotency-Key' => 'UUID' }) ``` ##### NodeJS (TypeScript) ```ts // Adyen Node API Library v30.0.0 to latest import { Client, Config, EnvironmentEnum, CheckoutAPI, Types } from "@adyen/api-library"; // For the LIVE environment, also include your liveEndpointUrlPrefix. const config = new Config({ apiKey: "ADYEN_API_KEY", environment: EnvironmentEnum.TEST }); const client = new Client(config); // Create the request object(s) const amount: Types.checkout.Amount = { currency: "SGD", value: 1000 }; const storedPaymentMethodDetails: Types.checkout.StoredPaymentMethodDetails = { type: Types.checkout.StoredPaymentMethodDetails.TypeEnum.GrabpaySg }; const paymentRequest: Types.checkout.PaymentRequest = { reference: "YOUR_ORDER_REFERENCE", amount: amount, merchantAccount: "ADYEN_MERCHANT_ACCOUNT", paymentMethod: storedPaymentMethodDetails, returnUrl: "https://your-company.example.com/checkout?shopperOrder=12xy.." }; // Send the request const checkoutAPI = new CheckoutAPI(client); const response = await checkoutAPI.PaymentsApi.payments(paymentRequest, { idempotencyKey: "UUID" }); ``` #### Earlier versions ##### curl ```bash curl https://checkout-test.adyen.com/v68/payments \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "amount": { "currency": "SGD", "value": 1000 }, "reference": "YOUR_ORDER_REFERENCE", "paymentMethod": { "type": "grabpay_SG" }, "returnUrl": "https://your-company.example.com/checkout?shopperOrder=12xy..", "merchantAccount": "ADYEN_MERCHANT_ACCOUNT" }' ``` ##### Java ```java // Adyen Java API Library v27.0.0 to v37.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("SGD") .value(1000L); StoredPaymentMethodDetails storedPaymentMethodDetails = new StoredPaymentMethodDetails() .type(StoredPaymentMethodDetails.TypeEnum.GRABPAY_SG); PaymentRequest paymentRequest = new PaymentRequest() .reference("YOUR_ORDER_REFERENCE") .amount(amount) .merchantAccount("ADYEN_MERCHANT_ACCOUNT") .paymentMethod(new CheckoutPaymentMethod(storedPaymentMethodDetails)) .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 to v29.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("SGD") ->setValue(1000); $checkoutPaymentMethod = new CheckoutPaymentMethod(); $checkoutPaymentMethod ->setType("grabpay_SG"); $paymentRequest = new PaymentRequest(); $paymentRequest ->setReference("YOUR_ORDER_REFERENCE") ->setAmount($amount) ->setMerchantAccount("ADYEN_MERCHANT_ACCOUNT") ->setPaymentMethod($checkoutPaymentMethod) ->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 to v33.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 = "SGD", Value = 1000 }; StoredPaymentMethodDetails storedPaymentMethodDetails = new StoredPaymentMethodDetails { Type = StoredPaymentMethodDetails.TypeEnum.GrabpaySG }; PaymentRequest paymentRequest = new PaymentRequest { Reference = "YOUR_ORDER_REFERENCE", Amount = amount, MerchantAccount = "ADYEN_MERCHANT_ACCOUNT", PaymentMethod = new CheckoutPaymentMethod(storedPaymentMethodDetails), 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 to v27.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 = { amount: { currency: "SGD", value: 1000 }, reference: "YOUR_ORDER_REFERENCE", paymentMethod: { type: "grabpay_SG" }, returnUrl: "https://your-company.example.com/checkout?shopperOrder=12xy..", merchantAccount: "ADYEN_MERCHANT_ACCOUNT" } // 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: "SGD", Value: 1000, } storedPaymentMethodDetails := checkout.StoredPaymentMethodDetails{ Type: common.PtrString("grabpay_SG"), } paymentRequest := checkout.PaymentRequest{ Reference: "YOUR_ORDER_REFERENCE", Amount: amount, MerchantAccount: "ADYEN_MERCHANT_ACCOUNT", PaymentMethod: checkout.StoredPaymentMethodDetailsAsCheckoutPaymentMethod(&storedPaymentMethodDetails), 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 = { "amount": { "currency": "SGD", "value": 1000 }, "reference": "YOUR_ORDER_REFERENCE", "paymentMethod": { "type": "grabpay_SG" }, "returnUrl": "https://your-company.example.com/checkout?shopperOrder=12xy..", "merchantAccount": "ADYEN_MERCHANT_ACCOUNT" } # 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 = { :amount => { :currency => 'SGD', :value => 1000 }, :reference => 'YOUR_ORDER_REFERENCE', :paymentMethod => { :type => 'grabpay_SG' }, :returnUrl => 'https://your-company.example.com/checkout?shopperOrder=12xy..', :merchantAccount => 'ADYEN_MERCHANT_ACCOUNT' } # 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 to v27.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: "SGD", value: 1000 }; const storedPaymentMethodDetails: Types.checkout.StoredPaymentMethodDetails = { type: Types.checkout.StoredPaymentMethodDetails.TypeEnum.GrabpaySg }; const paymentRequest: Types.checkout.PaymentRequest = { reference: "YOUR_ORDER_REFERENCE", amount: amount, merchantAccount: "ADYEN_MERCHANT_ACCOUNT", paymentMethod: storedPaymentMethodDetails, 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":"grabpay_SG", "method":"GET", "url":"https://checkoutshopper-test.adyen.com/checkoutshopper/checkoutPaymentRedirect?redirectData=...", "type":"redirect" } } ``` ### Tab: PayLater To make a PayLater payment, either postpaid or installment: * Make a [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) request, and specify: * [paymentMethod](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-paymentMethod): **grabpay\_XX**, where *XX* is the country code. You can also refer to the `/paymentMethods` response you received. * [returnUrl](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-returnUrl): The URL where the shopper will be redirected back to after they complete the payment. * [reference](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-reference): Your unique reference for this payment. Maximum length of 32 characters. * [amount](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#responses-200-amount): The amount that the shopper needs to pay. * [deliveryAddress](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-deliveryAddress): The address where the purchased goods should be delivered. * [lineItems](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-lineItems): Price and product information about the purchased items, to be included on the invoice sent to the shopper. `amountIncludingTax` cannot be 0. #### Latest version ##### curl ```bash curl https://checkout-test.adyen.com/v68/payments \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "amount": { "currency": "SGD", "value": 1000 }, "reference": "YOUR_ORDER_REFERENCE", "paymentMethod": { "type": "grabpay_SG" }, "returnUrl": "https://your-company.example.com/checkout?shopperOrder=12xy..", "merchantAccount": "ADYEN_MERCHANT_ACCOUNT", "deliveryAddress": { "city": "Singapore", "country": "SG", "houseNumberOrName": "109", "postalCode": "179097", "street": "North Bridge Road" }, "lineItems":[ { "quantity":"1", "taxPercentage":"2100", "description":"Shoes", "id":"Item #1", "amountIncludingTax":"400", "productUrl": "URL_TO_PURCHASED_ITEM", "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM" } ] }' ``` ##### Java ```java // Adyen Java API Library v38.0.0 to latest import com.adyen.Client; import com.adyen.Config; import com.adyen.enums.Environment; import com.adyen.model.*; import com.adyen.service.*; import java.math.*; import com.adyen.model.checkout.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.model.RequestOptions; import com.adyen.service.checkout.*; Config config = new Config() .apiKey("ADYEN_API_KEY") .environment(Environment.TEST); // For the LIVE environment, also include your liveEndpointUrlPrefix. Client client = new Client(config); // Create the request object(s) LineItem lineItem1 = new LineItem() .quantity(1L) .taxPercentage(2100L) .imageUrl("URL_TO_PICTURE_OF_PURCHASED_ITEM") .description("Shoes") .id("Item #1") .amountIncludingTax(400L) .productUrl("URL_TO_PURCHASED_ITEM"); Amount amount = new Amount() .currency("SGD") .value(1000L); DeliveryAddress deliveryAddress = new DeliveryAddress() .country("SG") .city("Singapore") .houseNumberOrName("109") .street("North Bridge Road") .postalCode("179097"); StoredPaymentMethodDetails storedPaymentMethodDetails = new StoredPaymentMethodDetails() .type(StoredPaymentMethodDetails.TypeEnum.GRABPAY_SG); PaymentRequest paymentRequest = new PaymentRequest() .reference("YOUR_ORDER_REFERENCE") .lineItems(Arrays.asList(lineItem1)) .amount(amount) .merchantAccount("ADYEN_MERCHANT_ACCOUNT") .deliveryAddress(deliveryAddress) .paymentMethod(new CheckoutPaymentMethod(storedPaymentMethodDetails)) .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 setXApiKey("ADYEN_API_KEY"); // For the LIVE environment, also include your liveEndpointUrlPrefix. $client->setEnvironment(Environment::TEST); // Create the request object(s) $lineItem1 = new LineItem(); $lineItem1 ->setQuantity(1) ->setTaxPercentage(2100) ->setImageUrl("URL_TO_PICTURE_OF_PURCHASED_ITEM") ->setDescription("Shoes") ->setId("Item #1") ->setAmountIncludingTax(400) ->setProductUrl("URL_TO_PURCHASED_ITEM"); $amount = new Amount(); $amount ->setCurrency("SGD") ->setValue(1000); $deliveryAddress = new DeliveryAddress(); $deliveryAddress ->setCountry("SG") ->setCity("Singapore") ->setHouseNumberOrName("109") ->setStreet("North Bridge Road") ->setPostalCode("179097"); $checkoutPaymentMethod = new CheckoutPaymentMethod(); $checkoutPaymentMethod ->setType("grabpay_SG"); $paymentRequest = new PaymentRequest(); $paymentRequest ->setReference("YOUR_ORDER_REFERENCE") ->setLineItems(array($lineItem1)) ->setAmount($amount) ->setMerchantAccount("ADYEN_MERCHANT_ACCOUNT") ->setDeliveryAddress($deliveryAddress) ->setPaymentMethod($checkoutPaymentMethod) ->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 v34.0.0 to latest using System; using System.Collections.Generic; using Adyen.Checkout.Extensions; using Adyen.Checkout.Models; using Adyen.Checkout.Services; using Adyen.Core.Client; using Adyen.Core.Client.Extensions; using Adyen.Core.Options; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; var host = Host.CreateDefaultBuilder() .ConfigureCheckout( (context, services, config) => { config.ConfigureAdyenOptions(options => { options.AdyenApiKey = "ADYEN_API_KEY"; options.Environment = AdyenEnvironment.Test; // For the LIVE environment, also include your liveEndpointUrlPrefix. // options.LiveEndpointUrlPrefix = ""; }); services.AddAllCheckoutServices(); }) .Build(); var paymentsService = host.Services.GetRequiredService(); // Create the request object(s) var lineItem1 = new LineItem { Quantity = 1, TaxPercentage = 2100, ImageUrl = "URL_TO_PICTURE_OF_PURCHASED_ITEM", Description = "Shoes", Id = "Item #1", AmountIncludingTax = 400, ProductUrl = "URL_TO_PURCHASED_ITEM" }; var amount = new Amount { Currency = "SGD", Value = 1000 }; var deliveryAddress = new DeliveryAddress { Country = "SG", City = "Singapore", HouseNumberOrName = "109", Street = "North Bridge Road", PostalCode = "179097" }; var storedPaymentMethodDetails = new StoredPaymentMethodDetails { Type = StoredPaymentMethodDetails.TypeEnum.GrabpaySG }; var paymentRequest = new PaymentRequest { Reference = "YOUR_ORDER_REFERENCE", LineItems = new List{ lineItem1 }, Amount = amount, MerchantAccount = "ADYEN_MERCHANT_ACCOUNT", DeliveryAddress = deliveryAddress, PaymentMethod = new CheckoutPaymentMethod(storedPaymentMethodDetails), ReturnUrl = "https://your-company.example.com/checkout?shopperOrder=12xy.." }; string idempotencyKey = Guid.NewGuid().ToString(); // Send the request var result = await paymentsService.PaymentsAsync(paymentRequest, new RequestOptions().AddIdempotencyKey(idempotencyKey)); if (result.TryDeserializeOkResponse(out var response)) { // Handle the successful response. } ``` ##### NodeJS (JavaScript) ```js // Adyen Node API Library v30.0.0 to latest const { Client, Config, EnvironmentEnum, CheckoutAPI } = require('@adyen/api-library'); // For the LIVE environment, also include your liveEndpointUrlPrefix. const config = new Config({ apiKey: "ADYEN_API_KEY", environment: EnvironmentEnum.TEST }); const client = new Client(config); // Create the request object(s) const lineItem1 = { quantity: 1, taxPercentage: 2100, imageUrl: "URL_TO_PICTURE_OF_PURCHASED_ITEM", description: "Shoes", id: "Item #1", amountIncludingTax: 400, productUrl: "URL_TO_PURCHASED_ITEM" }; const amount = { currency: "SGD", value: 1000 }; const deliveryAddress = { country: "SG", city: "Singapore", houseNumberOrName: "109", street: "North Bridge Road", postalCode: "179097" }; const storedPaymentMethodDetails = { type: "grabpay_SG" }; const paymentRequest = { reference: "YOUR_ORDER_REFERENCE", lineItems: [lineItem1], amount: amount, merchantAccount: "ADYEN_MERCHANT_ACCOUNT", deliveryAddress: deliveryAddress, paymentMethod: storedPaymentMethodDetails, returnUrl: "https://your-company.example.com/checkout?shopperOrder=12xy.." }; // Send the request const checkoutAPI = new CheckoutAPI(client); const response = await checkoutAPI.PaymentsApi.payments(paymentRequest, { idempotencyKey: "UUID" }); ``` ##### Go ```go // Adyen Go API Library v21.0.0 to latest import ( "context" "github.com/adyen/adyen-go-api-library/v21/src/common" "github.com/adyen/adyen-go-api-library/v21/src/adyen" "github.com/adyen/adyen-go-api-library/v21/src/checkout" ) // For the LIVE environment, also include your liveEndpointUrlPrefix. client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Create the request object(s) lineItem1 := checkout.LineItem{ Quantity: common.PtrInt64(1), TaxPercentage: common.PtrInt64(2100), ImageUrl: common.PtrString("URL_TO_PICTURE_OF_PURCHASED_ITEM"), Description: common.PtrString("Shoes"), Id: common.PtrString("Item #1"), AmountIncludingTax: common.PtrInt64(400), ProductUrl: common.PtrString("URL_TO_PURCHASED_ITEM"), } amount := checkout.Amount{ Currency: "SGD", Value: 1000, } deliveryAddress := checkout.DeliveryAddress{ Country: "SG", City: "Singapore", HouseNumberOrName: "109", Street: "North Bridge Road", PostalCode: "179097", } storedPaymentMethodDetails := checkout.StoredPaymentMethodDetails{ Type: common.PtrString("grabpay_SG"), } paymentRequest := checkout.PaymentRequest{ Reference: "YOUR_ORDER_REFERENCE", LineItems: []checkout.LineItem{ lineItem1, }, Amount: amount, MerchantAccount: "ADYEN_MERCHANT_ACCOUNT", DeliveryAddress: &deliveryAddress, PaymentMethod: checkout.StoredPaymentMethodDetailsAsCheckoutPaymentMethod(&storedPaymentMethodDetails), 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 v14.0.0 to latest import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_API_KEY" # For the LIVE environment, also include your liveEndpointUrlPrefix. adyen.client.platform = "test" # The environment to use library in. # Create the request object(s) json_request = { "amount": { "currency": "SGD", "value": 1000 }, "reference": "YOUR_ORDER_REFERENCE", "paymentMethod": { "type": "grabpay_SG" }, "returnUrl": "https://your-company.example.com/checkout?shopperOrder=12xy..", "merchantAccount": "ADYEN_MERCHANT_ACCOUNT", "deliveryAddress": { "city": "Singapore", "country": "SG", "houseNumberOrName": "109", "postalCode": "179097", "street": "North Bridge Road" }, "lineItems": [{ "quantity": "1", "taxPercentage": "2100", "description": "Shoes", "id": "Item #1", "amountIncludingTax": "400", "productUrl": "URL_TO_PURCHASED_ITEM", "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM" }] } # Send the request result = adyen.checkout.payments_api.payments(request=json_request, idempotency_key="UUID") ``` ##### Ruby ```rb # Adyen Ruby API Library v11.0.0 to latest require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_API_KEY' # For the LIVE environment, also include your liveEndpointUrlPrefix. adyen.env = :test # Set to "live" for live environment # Create the request object(s) request_body = { "amount" => { "currency" => "SGD", "value" => 1000 }, "reference" => "YOUR_ORDER_REFERENCE", "paymentMethod" => { "type" => "grabpay_SG" }, "returnUrl" => "https://your-company.example.com/checkout?shopperOrder=12xy..", "merchantAccount" => "ADYEN_MERCHANT_ACCOUNT", "deliveryAddress" => { "city" => "Singapore", "country" => "SG", "houseNumberOrName" => "109", "postalCode" => "179097", "street" => "North Bridge Road" }, "lineItems" => [{ "quantity" => "1", "taxPercentage" => "2100", "description" => "Shoes", "id" => "Item #1", "amountIncludingTax" => "400", "productUrl" => "URL_TO_PURCHASED_ITEM", "imageUrl" => "URL_TO_PICTURE_OF_PURCHASED_ITEM" }] } # Send the request result = adyen.checkout.payments_api.payments(request_body, headers: { 'Idempotency-Key' => 'UUID' }) ``` ##### NodeJS (TypeScript) ```ts // Adyen Node API Library v30.0.0 to latest import { Client, Config, EnvironmentEnum, CheckoutAPI, Types } from "@adyen/api-library"; // For the LIVE environment, also include your liveEndpointUrlPrefix. const config = new Config({ apiKey: "ADYEN_API_KEY", environment: EnvironmentEnum.TEST }); const client = new Client(config); // Create the request object(s) const lineItem1: Types.checkout.LineItem = { quantity: 1, taxPercentage: 2100, imageUrl: "URL_TO_PICTURE_OF_PURCHASED_ITEM", description: "Shoes", id: "Item #1", amountIncludingTax: 400, productUrl: "URL_TO_PURCHASED_ITEM" }; const amount: Types.checkout.Amount = { currency: "SGD", value: 1000 }; const deliveryAddress: Types.checkout.DeliveryAddress = { country: "SG", city: "Singapore", houseNumberOrName: "109", street: "North Bridge Road", postalCode: "179097" }; const storedPaymentMethodDetails: Types.checkout.StoredPaymentMethodDetails = { type: Types.checkout.StoredPaymentMethodDetails.TypeEnum.GrabpaySg }; const paymentRequest: Types.checkout.PaymentRequest = { reference: "YOUR_ORDER_REFERENCE", lineItems: [lineItem1], amount: amount, merchantAccount: "ADYEN_MERCHANT_ACCOUNT", deliveryAddress: deliveryAddress, paymentMethod: storedPaymentMethodDetails, returnUrl: "https://your-company.example.com/checkout?shopperOrder=12xy.." }; // Send the request const checkoutAPI = new CheckoutAPI(client); const response = await checkoutAPI.PaymentsApi.payments(paymentRequest, { idempotencyKey: "UUID" }); ``` #### Earlier versions ##### curl ```bash curl https://checkout-test.adyen.com/v68/payments \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "amount": { "currency": "SGD", "value": 1000 }, "reference": "YOUR_ORDER_REFERENCE", "paymentMethod": { "type": "grabpay_SG" }, "returnUrl": "https://your-company.example.com/checkout?shopperOrder=12xy..", "merchantAccount": "ADYEN_MERCHANT_ACCOUNT", "deliveryAddress": { "city": "Singapore", "country": "SG", "houseNumberOrName": "109", "postalCode": "179097", "street": "North Bridge Road" }, "lineItems":[ { "quantity":"1", "taxPercentage":"2100", "description":"Shoes", "id":"Item #1", "amountIncludingTax":"400", "productUrl": "URL_TO_PURCHASED_ITEM", "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM" } ] }' ``` ##### Java ```java // Adyen Java API Library v27.0.0 to v37.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) LineItem lineItem1 = new LineItem() .quantity(1L) .taxPercentage(2100L) .imageUrl("URL_TO_PICTURE_OF_PURCHASED_ITEM") .description("Shoes") .id("Item #1") .amountIncludingTax(400L) .productUrl("URL_TO_PURCHASED_ITEM"); Amount amount = new Amount() .currency("SGD") .value(1000L); DeliveryAddress deliveryAddress = new DeliveryAddress() .country("SG") .city("Singapore") .houseNumberOrName("109") .street("North Bridge Road") .postalCode("179097"); StoredPaymentMethodDetails storedPaymentMethodDetails = new StoredPaymentMethodDetails() .type(StoredPaymentMethodDetails.TypeEnum.GRABPAY_SG); PaymentRequest paymentRequest = new PaymentRequest() .reference("YOUR_ORDER_REFERENCE") .lineItems(Arrays.asList(lineItem1)) .amount(amount) .merchantAccount("ADYEN_MERCHANT_ACCOUNT") .deliveryAddress(deliveryAddress) .paymentMethod(new CheckoutPaymentMethod(storedPaymentMethodDetails)) .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 to v29.0.0 use Adyen\Client; use Adyen\Environment; use Adyen\Model\Checkout\LineItem; use Adyen\Model\Checkout\Amount; use Adyen\Model\Checkout\DeliveryAddress; 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) $lineItem1 = new LineItem(); $lineItem1 ->setQuantity(1) ->setTaxPercentage(2100) ->setImageUrl("URL_TO_PICTURE_OF_PURCHASED_ITEM") ->setDescription("Shoes") ->setId("Item #1") ->setAmountIncludingTax(400) ->setProductUrl("URL_TO_PURCHASED_ITEM"); $amount = new Amount(); $amount ->setCurrency("SGD") ->setValue(1000); $deliveryAddress = new DeliveryAddress(); $deliveryAddress ->setCountry("SG") ->setCity("Singapore") ->setHouseNumberOrName("109") ->setStreet("North Bridge Road") ->setPostalCode("179097"); $checkoutPaymentMethod = new CheckoutPaymentMethod(); $checkoutPaymentMethod ->setType("grabpay_SG"); $paymentRequest = new PaymentRequest(); $paymentRequest ->setReference("YOUR_ORDER_REFERENCE") ->setLineItems(array($lineItem1)) ->setAmount($amount) ->setMerchantAccount("ADYEN_MERCHANT_ACCOUNT") ->setDeliveryAddress($deliveryAddress) ->setPaymentMethod($checkoutPaymentMethod) ->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 to v33.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) LineItem lineItem1 = new LineItem { Quantity = 1, TaxPercentage = 2100, ImageUrl = "URL_TO_PICTURE_OF_PURCHASED_ITEM", Description = "Shoes", Id = "Item #1", AmountIncludingTax = 400, ProductUrl = "URL_TO_PURCHASED_ITEM" }; Amount amount = new Amount { Currency = "SGD", Value = 1000 }; DeliveryAddress deliveryAddress = new DeliveryAddress { Country = "SG", City = "Singapore", HouseNumberOrName = "109", Street = "North Bridge Road", PostalCode = "179097" }; StoredPaymentMethodDetails storedPaymentMethodDetails = new StoredPaymentMethodDetails { Type = StoredPaymentMethodDetails.TypeEnum.GrabpaySG }; PaymentRequest paymentRequest = new PaymentRequest { Reference = "YOUR_ORDER_REFERENCE", LineItems = new List{ lineItem1 }, Amount = amount, MerchantAccount = "ADYEN_MERCHANT_ACCOUNT", DeliveryAddress = deliveryAddress, PaymentMethod = new CheckoutPaymentMethod(storedPaymentMethodDetails), 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 to v27.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 = { amount: { currency: "SGD", value: 1000 }, reference: "YOUR_ORDER_REFERENCE", paymentMethod: { type: "grabpay_SG" }, returnUrl: "https://your-company.example.com/checkout?shopperOrder=12xy..", merchantAccount: "ADYEN_MERCHANT_ACCOUNT", deliveryAddress: { city: "Singapore", country: "SG", houseNumberOrName: "109", postalCode: "179097", street: "North Bridge Road" }, lineItems: [ { quantity: "1", taxPercentage: "2100", description: "Shoes", id: "Item #1", amountIncludingTax: "400", productUrl: "URL_TO_PURCHASED_ITEM", imageUrl: "URL_TO_PICTURE_OF_PURCHASED_ITEM" } ] } // 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) lineItem1 := checkout.LineItem{ Quantity: common.PtrInt64(1), TaxPercentage: common.PtrInt64(2100), ImageUrl: common.PtrString("URL_TO_PICTURE_OF_PURCHASED_ITEM"), Description: common.PtrString("Shoes"), Id: common.PtrString("Item #1"), AmountIncludingTax: common.PtrInt64(400), ProductUrl: common.PtrString("URL_TO_PURCHASED_ITEM"), } amount := checkout.Amount{ Currency: "SGD", Value: 1000, } deliveryAddress := checkout.DeliveryAddress{ Country: "SG", City: "Singapore", HouseNumberOrName: "109", Street: "North Bridge Road", PostalCode: "179097", } storedPaymentMethodDetails := checkout.StoredPaymentMethodDetails{ Type: common.PtrString("grabpay_SG"), } paymentRequest := checkout.PaymentRequest{ Reference: "YOUR_ORDER_REFERENCE", LineItems: []checkout.LineItem{ lineItem1, }, Amount: amount, MerchantAccount: "ADYEN_MERCHANT_ACCOUNT", DeliveryAddress: &deliveryAddress, PaymentMethod: checkout.StoredPaymentMethodDetailsAsCheckoutPaymentMethod(&storedPaymentMethodDetails), 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 = { "amount": { "currency": "SGD", "value": 1000 }, "reference": "YOUR_ORDER_REFERENCE", "paymentMethod": { "type": "grabpay_SG" }, "returnUrl": "https://your-company.example.com/checkout?shopperOrder=12xy..", "merchantAccount": "ADYEN_MERCHANT_ACCOUNT", "deliveryAddress": { "city": "Singapore", "country": "SG", "houseNumberOrName": "109", "postalCode": "179097", "street": "North Bridge Road" }, "lineItems": [ { "quantity": "1", "taxPercentage": "2100", "description": "Shoes", "id": "Item #1", "amountIncludingTax": "400", "productUrl": "URL_TO_PURCHASED_ITEM", "imageUrl": "URL_TO_PICTURE_OF_PURCHASED_ITEM" } ] } # 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 = { :amount => { :currency => 'SGD', :value => 1000 }, :reference => 'YOUR_ORDER_REFERENCE', :paymentMethod => { :type => 'grabpay_SG' }, :returnUrl => 'https://your-company.example.com/checkout?shopperOrder=12xy..', :merchantAccount => 'ADYEN_MERCHANT_ACCOUNT', :deliveryAddress => { :city => 'Singapore', :country => 'SG', :houseNumberOrName => '109', :postalCode => '179097', :street => 'North Bridge Road' }, :lineItems => [ { :quantity => '1', :taxPercentage => '2100', :description => 'Shoes', :id => 'Item #1', :amountIncludingTax => '400', :productUrl => 'URL_TO_PURCHASED_ITEM', :imageUrl => 'URL_TO_PICTURE_OF_PURCHASED_ITEM' } ] } # 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 to v27.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 lineItem1: Types.checkout.LineItem = { quantity: 1, taxPercentage: 2100, imageUrl: "URL_TO_PICTURE_OF_PURCHASED_ITEM", description: "Shoes", id: "Item #1", amountIncludingTax: 400, productUrl: "URL_TO_PURCHASED_ITEM" }; const amount: Types.checkout.Amount = { currency: "SGD", value: 1000 }; const deliveryAddress: Types.checkout.DeliveryAddress = { country: "SG", city: "Singapore", houseNumberOrName: "109", street: "North Bridge Road", postalCode: "179097" }; const storedPaymentMethodDetails: Types.checkout.StoredPaymentMethodDetails = { type: Types.checkout.StoredPaymentMethodDetails.TypeEnum.GrabpaySg }; const paymentRequest: Types.checkout.PaymentRequest = { reference: "YOUR_ORDER_REFERENCE", lineItems: [lineItem1], amount: amount, merchantAccount: "ADYEN_MERCHANT_ACCOUNT", deliveryAddress: deliveryAddress, paymentMethod: storedPaymentMethodDetails, 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":"grabpay_SG", "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" } ``` For GrabPay PayLater, the response also contains `additionalData.paymentMethodVariant` — the Adyen sub-variant of the payment method used for the payment request. Possible values: * For GrabPay Wallet: `grabpay_wallet_SG`, `grabpay_sg`, `grabpay_wallet_MY`, `grabpay_my`, `grabpay_wallet_PH`, `grabpay_ph` * For GrabPay PayLater: `grabpay_postpaid_SG`, `grabpay_instalment4_SG`, `grabpay_postpaid_MY`, `grabpay_instalment4_MY`. **/payments/details response** ```json { "resultCode": "Authorised", "pspReference": "88154795347618C", "additionalData": { "paymentMethodVariant": "grabpay_postpaid_SG" } } ``` ## 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 GrabPay are: | resultCode | Description | Action | | --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | | **Authorised** | The payment was authorised. You will receive the funds in a number of days. | Inform the shopper that the payment was successful. | | **Cancelled** | The shopper cancelled the payment before it was completed, for example while in the GrabPay app. | Ask the shopper whether they want to continue with the order, or ask them to select a different payment method. | | **Refused** | The payment was refused by the shopper's card issuer. | Ask the shopper to try the payment again using a different payment method or card. | | **Pending** or **Received** | The shopper has completed the payment but the final result is not yet known. You will receive the final result of the payment in an [AUTHORISATION webhook](https://docs.adyen.com/development-resources/webhooks/webhook-types). | Inform the shopper that you have received their order, and are waiting for the payment to be processed. | []()If the shopper closed the browser and failed to return to your website, wait for webhooks to know the outcome of the payment. The webhooks you can receive for GrabPay are: | 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. | | **OFFER\_CLOSED** | **true** | The shopper did not complete the payment. | Cancel the order and inform the shopper that the payment timed out. | ## Test and go live You can test your GrabPay integration in two ways: with the Adyen Payment Simulator, or directly with GrabPay. ### Test with Adyen Use the Adyen Payment Simulator to verify that your GrabPay integration works correctly with Adyen. You can test during development, before you go live, and after launch. The simulator does not recreate the shopper's journey through the GrabPay app or website. This testing option is available by default when you add GrabPay in your test Customer Area. The payment method type is `grabpay_SG`. To test a redirect payment: 1. Start a payment as usual in your integration. The shopper is redirected to an Adyen-hosted simulator page. 2. Select the payment outcome that you want to test. 3. Wait for the simulator to return the shopper to your website, then complete the payment as usual. For an Advanced flow, make a `/payments/details` request. 4. Confirm that your integration handles the outcome that you selected, and that the payment appears in your [Customer Area](https://ca-test.adyen.com/) > **Payments** > **Payment list**. ### Test directly with GrabPay To test directly with GrabPay: 1. Contact our [Support Team](https://ca-test.adyen.com/ca/ca/contactUs/support.shtml?form=other) for your test wallet credentials. 2. In the simulator, log in to Grab with the phone number you registered, and specify the one-time password that you receive on that phone number. Check the status of direct GrabPay test payments in your [Customer Area](https://ca-test.adyen.com/) > **Payments** > **Payment list**. Before you can accept live GrabPay payments, you need to [submit a request for GrabPay](https://docs.adyen.com/payment-methods/add-payment-methods) in your [live Customer Area](https://ca-live.adyen.com/). ## See also * [API-only integration guide](https://docs.adyen.com/online-payments/api-only) * [Handling redirects](https://docs.adyen.com/online-payments/build-your-integration/advanced-flow/?platform=Web\&integration=API%20only#handle-the-redirect) * [Tokenization](https://docs.adyen.com/online-payments/tokenization) * [API Explorer](https://docs.adyen.com/api-explorer/Checkout/latest/overview)