--- title: "Online donations using Adyen Giving" description: "Enable your users to accept online donations from shoppers using Adyen Giving." url: "https://docs.adyen.com/platforms/online-payments/donations-online" source_url: "https://docs.adyen.com/platforms/online-payments/donations-online.md" canonical: "https://docs.adyen.com/platforms/online-payments/donations-online" last_modified: "2026-10-16T14:14:34+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. # Online donations using Adyen Giving Enable your users to accept online donations from shoppers using Adyen Giving. ##### Read more ![Giving logo](https://docs.adyen.com/media/375c2c0f711e8e1121cbd8896f73158f464c25f13edbea0d3d16530b1f98cbb3.svg?decoding=auto\&fetchpriority=auto) Learn about Adyen Giving [on your payment terminals](https://docs.adyen.com/platforms/in-person-payments/donations-in-person). With Adyen Giving, your users can give shoppers the option to donate to a nonprofit organization as part of their online purchase. When a shopper chooses to donate, the donation is processed as a separate transaction. Adyen covers all fees and the donation amount is transferred to the nonprofit in full. This means you can split amounts and fees on the original transaction, but not on the donation transaction. This page describes how to implement online donations after a donation campaign has been set up. ## Requirements Before you begin, take into account the following requirements, limitations, and preparations. | Requirement | Description | | -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **Integration type** | Adyen for Platforms with a platform model, with an [API only](https://docs.adyen.com/online-payments/donations/api-only) online payments integration using Checkout API v67 or later. | | **[Webhooks](https://docs.adyen.com/development-resources/webhooks)** | Subscribe to the **[Adyen Giving merchant webhook](https://docs.adyen.com/development-resources/webhooks/webhook-types#other-webhooks)**. | | **Limitations** | Make sure that you are using [supported payment methods](https://docs.adyen.com/platforms/donations#supported-payment-methods) and [supported regions and currencies](https://docs.adyen.com/platforms/donations#supported-currencies). | | **Setup steps** | Before you begin, set up a donation campaign and learn how to activate and manage donation campaigns. See [Create and manage donation campaigns](https://docs.adyen.com/platforms/donations/create-manage-campaigns). | ## How it works To enable your users to accept donations at checkout: 1. Choose a nonprofit and set up an account holder donation campaign in your Customer Area or using API calls. For instructions, see [Create and manage donation campaigns](https://docs.adyen.com/platforms/donations/create-manage-campaigns). 2. Make sure that your integration can show the active campaign in your checkout, and make a request for the amount that the shopper wants to donate. See [Online payments flow](https://docs.adyen.com/platforms/online-payments/donations-online#online-payments-flow). 3. Make sure you have a way to [show the nonprofit's terms and conditions](https://docs.adyen.com/online-payments/donations/terms-and-conditions). 4. To inform shoppers about their donation, make sure that you can process [Giving webhook messages](https://docs.adyen.com/platforms/online-payments/donations-online#giving-webhook). 5. Start the campaign in your Customer Area, or using an API call. For instructions, see [Create and manage donation campaigns](https://docs.adyen.com/platforms/donations/create-manage-campaigns). ## Online payments flow The donation flow depends on the donation moment, pre-checkout or post-checkout: ### Tab: Pre-checkout donations When your shopper goes to the checkout page and proceeds to pay with a [payment method that supports donations](https://docs.adyen.com/platforms/donations#supported-payment-methods) : 1. From your server, make a [/donationCampaigns](https://docs.adyen.com/api-explorer/Checkout/latest/post/donationCampaigns) request to [get the details of your active donation campaigns](https://docs.adyen.com/platforms/online-payments/donations-online#get-details-of-donation-campaigns). 2. [Present the option to donate](https://docs.adyen.com/platforms/online-payments/donations-online#present-option-to-donate) in one of the following ways, depending on the donation type that is configured in the campaign: * Show the shopper a donation form with fixed amounts. * Show the shopper a round-up option that suggests making a donation by rounding up their payment to the nearest full amount. 3. From your server, make a [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) request to make the payment for the original transaction. 4. After you get the [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) response, make a [/donations](https://docs.adyen.com/api-explorer/Checkout/latest/post/donations) request to [make a donation](https://docs.adyen.com/platforms/online-payments/donations-online#make-a-donation). 5. [Get the outcome](https://docs.adyen.com/platforms/online-payments/donations-online#giving-webhook) from a webhook and show it to the shopper. The following diagram shows the donation flow for a round-up amount before the shopper pays for their original transaction: ![Flow diagram for pre-checkout donations](https://docs.adyen.com/media/58e1833d98fd35498def1706e9265522cb0346358bb7b668fe41fdce844414d7.svg?decoding=auto\&fetchpriority=auto) ### Tab: Post-checkout donations When your shopper completes their payment with a [payment method that supports donations](https://docs.adyen.com/platforms/donations#supported-payment-methods) : 1. From your server, make a [/donationCampaigns](https://docs.adyen.com/api-explorer/Checkout/latest/post/donationCampaigns) request to [get the details of your active donation campaigns](https://docs.adyen.com/platforms/online-payments/donations-online#get-details-of-donation-campaigns). 2. [Present the option to donate](https://docs.adyen.com/platforms/online-payments/donations-online#present-option-to-donate) in one of the following ways, depending on the donation type that is configured in the campaign: * Show the shopper a donation form with fixed amounts. * Show the shopper a round-up option that suggests making a donation by rounding up their payment to the nearest full amount. 3. From your server, make a [/donations](https://docs.adyen.com/api-explorer/Checkout/latest/post/donations) request to [make a donation](https://docs.adyen.com/platforms/online-payments/donations-online#make-a-donation). 4. [Get the outcome](https://docs.adyen.com/platforms/online-payments/donations-online#giving-webhook) from a webhook and show it to the shopper. The following diagram shows the donation flow for a fixed amount donation after the shopper pays for their original transaction. ![Flow diagram for post-checkout donations](https://docs.adyen.com/media/11732c8ae0daba3ec83e18f13fa287b478e9f6229ccc929b017ec7ee0a19fd8e.svg?decoding=auto\&fetchpriority=auto) ## Get details of your active donation campaigns Depending on the donation moment that you choose, get the details of your active donation campaigns at either moment: * Pre-checkout: When a shopper proceeds to pay for their original transaction with a payment method that supports donations. * Post-checkout: When a shopper completes their original transaction with a payment method that supports donations, and the [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) or [/payments/details](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments/details) (for iDEAL payments) response includes the [donationToken](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#responses-200-donationToken) field. When you make a request to get your active donation campaigns, the response you receive depends on the donation type, fixed amounts or round-up: ### Tab: Fixed amount donations 1. From your server, make a POST [/donationCampaigns](https://docs.adyen.com/api-explorer/Checkout/latest/post/donationCampaigns) request, specifying: | Field name | Required | Description | | | ----------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - | | `merchantAccount` | ![Required](https://docs.adyen.com/media/732127089c689593ccb0331d565e5773bed94e60145cae96672212374facb8c6.svg?decoding=auto\&fetchpriority=auto) | Your merchant account name. | | | `currency` | ![Required](https://docs.adyen.com/media/732127089c689593ccb0331d565e5773bed94e60145cae96672212374facb8c6.svg?decoding=auto\&fetchpriority=auto) | The three-character [ISO currency code](https://en.wikipedia.org/wiki/ISO_4217). | | | `store` | ![Required](https://docs.adyen.com/media/732127089c689593ccb0331d565e5773bed94e60145cae96672212374facb8c6.svg?decoding=auto\&fetchpriority=auto) | Your reference for the user's store. Use this to get the donation campaigns that are available for a specific store. | | | `locale` | | The language in which you want to receive the donation campaign details in the response. The default is configured by the nonprofit. Set it to the shopper's language and country code, for example, `en-US`. | | **Example POST /donationCampaigns request on a platform** #### curl ```bash curl https://checkout-test.adyen.com/v72/donationCampaigns \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -X POST \ -d '{ "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "currency": "EUR", "locale": "en-US", "store": "USER_STORE_REFERENCE" }' ``` #### 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) DonationCampaignsRequest donationCampaignsRequest = new DonationCampaignsRequest() .merchantAccount("YOUR_MERCHANT_ACCOUNT") .currency("EUR") .store("USER_STORE_REFERENCE") .locale("en-US"); // Send the request DonationsApi service = new DonationsApi(client); DonationCampaignsResponse response = service.donationCampaigns(donationCampaignsRequest, 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) $donationCampaignsRequest = new DonationCampaignsRequest(); $donationCampaignsRequest ->setMerchantAccount("YOUR_MERCHANT_ACCOUNT") ->setCurrency("EUR") ->setStore("USER_STORE_REFERENCE") ->setLocale("en-US"); $requestOptions['idempotencyKey'] = 'UUID'; // Send the request $service = new DonationsApi($client); $response = $service->donationCampaigns($donationCampaignsRequest, $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 donationsService = host.Services.GetRequiredService(); // Create the request object(s) var donationCampaignsRequest = new DonationCampaignsRequest { MerchantAccount = "YOUR_MERCHANT_ACCOUNT", Currency = "EUR", Store = "USER_STORE_REFERENCE", Locale = "en-US" }; string idempotencyKey = Guid.NewGuid().ToString(); // Send the request var result = await donationsService.DonationCampaignsAsync(donationCampaignsRequest, 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 donationCampaignsRequest = { merchantAccount: "YOUR_MERCHANT_ACCOUNT", currency: "EUR", store: "USER_STORE_REFERENCE", locale: "en-US" }; // Send the request const checkoutAPI = new CheckoutAPI(client); const response = await checkoutAPI.DonationsApi.donationCampaigns(donationCampaignsRequest, { 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) donationCampaignsRequest := checkout.DonationCampaignsRequest{ MerchantAccount: "YOUR_MERCHANT_ACCOUNT", Currency: "EUR", Store: common.PtrString("USER_STORE_REFERENCE"), Locale: common.PtrString("en-US"), } // Send the request service := client.Checkout() req := service.DonationsApi.DonationCampaignsInput().IdempotencyKey("UUID").DonationCampaignsRequest(donationCampaignsRequest) res, httpRes, err := service.DonationsApi.DonationCampaigns(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 = { "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "currency": "EUR", "locale": "en-US", "store": "USER_STORE_REFERENCE" } # Send the request result = adyen.checkout.donations_api.donation_campaigns(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 = { "merchantAccount" => "YOUR_MERCHANT_ACCOUNT", "currency" => "EUR", "locale" => "en-US", "store" => "USER_STORE_REFERENCE" } # Send the request result = adyen.checkout.donations_api.donation_campaigns(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 donationCampaignsRequest: Types.checkout.DonationCampaignsRequest = { merchantAccount: "YOUR_MERCHANT_ACCOUNT", currency: "EUR", store: "USER_STORE_REFERENCE", locale: "en-US" }; // Send the request const checkoutAPI = new CheckoutAPI(client); const response = await checkoutAPI.DonationsApi.donationCampaigns(donationCampaignsRequest, { idempotencyKey: "UUID" }); ``` 2. From the response, get the details of your active donation campaign(s). You need these details [to create the donation form that you show to the shopper](https://docs.adyen.com/platforms/online-payments/donations-online#present-option-to-donate). | Field name | Description | | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `id` | The unique campaign ID of the donation campaign. | | `campaignName` | The name of the donation campaign. | | `donation` | Specifies the details of the donation. This object has:- `type`: **fixedAmounts**. - `currency`: The three-character [ISO currency code](https://docs.adyen.com/development-resources/currency-codes/). - `values`: Specifies the fixed donation amounts the shopper can choose from. | | `causeName` | The cause of the nonprofit. | | `logoUrl` | The URL for the logo of the nonprofit. | | `bannerUrl` | The URL for the banner of the nonprofit or campaign. | | `nonprofitName` | The name of the nonprofit. | | `nonprofitDescription` | The description of the nonprofit. | | `nonprofitUrl` | The website URL of the nonprofit. | | `termsAndConditionsUrl` | The URL of the terms and conditions page of the nonprofit. | **Example POST /donationCampaigns response for a fixed amount donation** ```bash { "donationCampaigns": [ { "id": "DONATION_CAMPAIGN_ID", "campaignName": "DONATION_CAMPAIGN_NAME", "donation": { "currency": "EUR", "type": "fixedAmounts", "values": [100, 200, 300] }, "nonprofitName": "NONPROFIT_NAME", "causeName": "NONPROFIT_CAUSE", "nonprofitDescription": "NONPROFIT_DESCRIPTION.", "nonprofitUrl": "NONPROFIT_WEBSITE_URL", "logoUrl": "NONPROFIT_LOGO_URL", "bannerUrl": "NONPROFIT_BANNER_URL", "termsAndConditionsUrl": "NONPROFIT_TERMS_AND_CONDITIONS_URL" } ] } ``` ### Tab: Round-up donations 1. From your server, make a POST [/donationCampaigns](https://docs.adyen.com/api-explorer/Checkout/latest/post/donationCampaigns) request, specifying: | Field name | Required | Description | | | ----------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - | | `merchantAccount` | ![Required](https://docs.adyen.com/media/732127089c689593ccb0331d565e5773bed94e60145cae96672212374facb8c6.svg?decoding=auto\&fetchpriority=auto) | Your merchant account name. | | | `currency` | ![Required](https://docs.adyen.com/media/732127089c689593ccb0331d565e5773bed94e60145cae96672212374facb8c6.svg?decoding=auto\&fetchpriority=auto) | The three-character [ISO currency code](https://en.wikipedia.org/wiki/ISO_4217). | | | `store` | ![Required](https://docs.adyen.com/media/732127089c689593ccb0331d565e5773bed94e60145cae96672212374facb8c6.svg?decoding=auto\&fetchpriority=auto) | Your reference for the user's store. Use this to get the donation campaigns that are available for a specific store. | | | `locale` | | The language in which you want to receive the donation campaign details in the response. The default is configured by the nonprofit. Set it to the shopper's language and country code, for example, `en-US`. | | **Example POST /donationCampaigns request on a platform** #### curl ```bash curl https://checkout-test.adyen.com/v72/donationCampaigns \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -X POST \ -d '{ "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "currency": "EUR", "locale": "en-US", "store": "USER_STORE_REFERENCE" }' ``` #### 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) DonationCampaignsRequest donationCampaignsRequest = new DonationCampaignsRequest() .merchantAccount("YOUR_MERCHANT_ACCOUNT") .currency("EUR") .store("USER_STORE_REFERENCE") .locale("en-US"); // Send the request DonationsApi service = new DonationsApi(client); DonationCampaignsResponse response = service.donationCampaigns(donationCampaignsRequest, 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) $donationCampaignsRequest = new DonationCampaignsRequest(); $donationCampaignsRequest ->setMerchantAccount("YOUR_MERCHANT_ACCOUNT") ->setCurrency("EUR") ->setStore("USER_STORE_REFERENCE") ->setLocale("en-US"); $requestOptions['idempotencyKey'] = 'UUID'; // Send the request $service = new DonationsApi($client); $response = $service->donationCampaigns($donationCampaignsRequest, $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 donationsService = host.Services.GetRequiredService(); // Create the request object(s) var donationCampaignsRequest = new DonationCampaignsRequest { MerchantAccount = "YOUR_MERCHANT_ACCOUNT", Currency = "EUR", Store = "USER_STORE_REFERENCE", Locale = "en-US" }; string idempotencyKey = Guid.NewGuid().ToString(); // Send the request var result = await donationsService.DonationCampaignsAsync(donationCampaignsRequest, 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 donationCampaignsRequest = { merchantAccount: "YOUR_MERCHANT_ACCOUNT", currency: "EUR", store: "USER_STORE_REFERENCE", locale: "en-US" }; // Send the request const checkoutAPI = new CheckoutAPI(client); const response = await checkoutAPI.DonationsApi.donationCampaigns(donationCampaignsRequest, { 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) donationCampaignsRequest := checkout.DonationCampaignsRequest{ MerchantAccount: "YOUR_MERCHANT_ACCOUNT", Currency: "EUR", Store: common.PtrString("USER_STORE_REFERENCE"), Locale: common.PtrString("en-US"), } // Send the request service := client.Checkout() req := service.DonationsApi.DonationCampaignsInput().IdempotencyKey("UUID").DonationCampaignsRequest(donationCampaignsRequest) res, httpRes, err := service.DonationsApi.DonationCampaigns(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 = { "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "currency": "EUR", "locale": "en-US", "store": "USER_STORE_REFERENCE" } # Send the request result = adyen.checkout.donations_api.donation_campaigns(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 = { "merchantAccount" => "YOUR_MERCHANT_ACCOUNT", "currency" => "EUR", "locale" => "en-US", "store" => "USER_STORE_REFERENCE" } # Send the request result = adyen.checkout.donations_api.donation_campaigns(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 donationCampaignsRequest: Types.checkout.DonationCampaignsRequest = { merchantAccount: "YOUR_MERCHANT_ACCOUNT", currency: "EUR", store: "USER_STORE_REFERENCE", locale: "en-US" }; // Send the request const checkoutAPI = new CheckoutAPI(client); const response = await checkoutAPI.DonationsApi.donationCampaigns(donationCampaignsRequest, { idempotencyKey: "UUID" }); ``` 2. From the response, get the details of your active donation campaign(s). You need these details [to display a checkbox suggesting to round up the order amount as a donation](https://docs.adyen.com/platforms/online-payments/donations-online#present-option-to-donate). | Field name | Description | | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `id` | The unique campaign ID of the donation campaign. | | `campaignName` | The name of the donation campaign. | | `donation` | Specifies the details of the donation. This object has:- `type`: **roundup**. - `currency`: The three-character [ISO currency code](https://docs.adyen.com/development-resources/currency-codes/). - `maxRoundupAmount`: Specifies the maximum amount a transaction can be rounded up to make a donation. | | `causeName` | The cause of the nonprofit. | | `logoUrl` | The URL for the logo of the nonprofit. | | `bannerUrl` | The URL for the banner of the nonprofit or campaign. | | `nonprofitName` | The name of the nonprofit. | | `nonprofitDescription` | The description of the nonprofit. | | `nonprofitUrl` | The website URL of the nonprofit. | | `termsAndConditionsUrl` | The URL of the terms and conditions page of the nonprofit. | **Example POST /donationCampaigns response for a round-up donation** ```bash { "donationCampaigns": [ { "id": "DONATION_CAMPAIGN_ID", "campaignName": "DONATION_CAMPAIGN_NAME", "donation": { "currency": "EUR", "type": "roundup", "maxRoundupAmount": 100 }, "nonprofitName": "NONPROFIT_NAME", "causeName": "NONPROFIT_CAUSE", "nonprofitDescription": "NONPROFIT_DESCRIPTION.", "nonprofitUrl": "NONPROFIT_WEBSITE_URL", "logoUrl": "NONPROFIT_LOGO_URL", "bannerUrl": "NONPROFIT_BANNER_URL", "termsAndConditionsUrl": "NONPROFIT_TERMS_AND_CONDITIONS_URL" } ] } ``` ## Present the option to donate ### Tab: Fixed amount donations Use the values you received in the [/donationCampaigns](https://docs.adyen.com/api-explorer/Checkout/latest/post/donationCampaigns) response to show a donation form with one or more buttons for the shopper to select a donation amount. For example, **Donate EUR 3**, **Donate EUR 5**, and **Donate EUR 10**. The donation form must: * Show the name and description of the nonprofit. * Link to the nonprofit's [Terms & Conditions](https://docs.adyen.com/online-payments/donations/terms-and-conditions). * Show the campaign banner and logo. * Have the option for the shopper to decline to donate. For example, a **Not now** button. The donation form can optionally include the cause of the nonprofit. If the shopper paid with iDEAL, tell the shopper that the donation transaction will show up in their bank statement a day or more later. ### Tab: Round-up donations Use the values you received in the [/donationCampaigns](https://docs.adyen.com/api-explorer/Checkout/latest/post/donationCampaigns) response to show a checkbox that suggests to round up the shopper's payment amount as a donation. Use the following formula to calculate the round-up amount: ```text roundupAmount = maxRoundupAmount - (commercialTxAmount % maxRoundupAmount) ``` * `maxRoundupAmount`: The maximum amount the transaction can be rounded up, received in the `/donationCampaigns` response. * `commercialTxAmount`: The original transaction amount for the shopper's order. This excludes the donation amount. The checkout page must: * Show the name of the nonprofit. * Link to the nonprofit's website. * Link to the nonprofit's [Terms & Conditions](https://docs.adyen.com/online-payments/donations/terms-and-conditions). If the shopper is paying with iDEAL, tell the shopper that the donation transaction will show up in their bank statement a day or more later. ## Make a donation Depending on the [interaction flow](https://docs.adyen.com/platforms/online-payments/donations-online#interaction-flow) for the campaign, you make a donation request at either time: * **Pre-checkout donation**: you first make a [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) request. If the payment is authorized, and the [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) or [/payments/details](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments/details) (for iDEAL payments) response includes the [donationToken](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#responses-200-donationToken) field, you make a donation request. * **Post-checkout donation**: you present the option to donate after the shopper completes the payment for their original transaction, you make a donation request and use the [donationToken](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#responses-200-donationToken) you received in the [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) or [/payments/details](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments/details) (for iDEAL payments) response. ### Tab: Fixed amount donations 1. Make a POST [/donations](https://docs.adyen.com/api-explorer/Checkout/latest/post/donations) request, specifying the following fields: | Field name | Required | Description | | | --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | - | | [amount](https://docs.adyen.com/api-explorer/Checkout/latest/post/donations#request-amount) | ![Required](https://docs.adyen.com/media/732127089c689593ccb0331d565e5773bed94e60145cae96672212374facb8c6.svg?decoding=auto\&fetchpriority=auto) | The `currency` and `value` of the donation. | | | [donationCampaignId](https://docs.adyen.com/api-explorer/Checkout/latest/post/donations#request-donationCampaignId) | ![Required](https://docs.adyen.com/media/732127089c689593ccb0331d565e5773bed94e60145cae96672212374facb8c6.svg?decoding=auto\&fetchpriority=auto) | The unique campaign ID from the `/donationCampaigns` response `id` field. | | | [paymentMethod](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-paymentMethod) | ![Required](https://docs.adyen.com/media/732127089c689593ccb0331d565e5773bed94e60145cae96672212374facb8c6.svg?decoding=auto\&fetchpriority=auto) | For cards, Apple Pay, or Google Pay: `type`: **scheme** For iDEAL: `type`: **sepadirectdebit** | | | [donationOriginalPspReference](https://docs.adyen.com/api-explorer/Checkout/latest/post/donations#request-donationOriginalPspReference) | ![Required](https://docs.adyen.com/media/732127089c689593ccb0331d565e5773bed94e60145cae96672212374facb8c6.svg?decoding=auto\&fetchpriority=auto) | The PSP reference of the original payment. | | | [donationToken](https://docs.adyen.com/api-explorer/Checkout/latest/post/donations#request-donationOriginalPspReference) | ![Required](https://docs.adyen.com/media/732127089c689593ccb0331d565e5773bed94e60145cae96672212374facb8c6.svg?decoding=auto\&fetchpriority=auto) | For cards, the `donationToken` from the [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments), or [/payments/details](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments/details) response. For iDEAL, the `donationToken` from the [/payments/details](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments/details) response. | | | [reference](https://docs.adyen.com/api-explorer/Checkout/latest/post/donations#request-reference) | ![Required](https://docs.adyen.com/media/732127089c689593ccb0331d565e5773bed94e60145cae96672212374facb8c6.svg?decoding=auto\&fetchpriority=auto) | The reference to uniquely identify a payment. This reference is used in all communication with you about the payment status. We recommend using a unique value per payment; however, it is not a requirement. If you need to provide multiple references for a transaction, separate them with hyphens ("-"). Maximum length: 80 characters. | | | [merchantAccount](https://docs.adyen.com/api-explorer/Checkout/latest/post/donations#request-merchantAccount) | ![Required](https://docs.adyen.com/media/732127089c689593ccb0331d565e5773bed94e60145cae96672212374facb8c6.svg?decoding=auto\&fetchpriority=auto) | The merchant account identifier, with which you want to process the transaction. | | | [store](https://docs.adyen.com/api-explorer/Checkout/latest/post/donations#request-store) | ![Required](https://docs.adyen.com/media/732127089c689593ccb0331d565e5773bed94e60145cae96672212374facb8c6.svg?decoding=auto\&fetchpriority=auto) | Your reference for the user's store. | | **Example POST /donations request on a platform** #### curl ```bash curl https://checkout-test.adyen.com/v72/donations \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -X POST \ -d '{ "amount": { "currency": "EUR", "value": 500 }, "donationCampaignId": "DONATION_CAMPAIGN_ID", "paymentMethod": { "type": "scheme" }, "donationOriginalPspReference": "ORIGINAL_PAYMENT_PSP_REFERENCE", "donationToken": "DONATION_TOKEN", "reference": "YOUR_DONATION_REFERENCE", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "store": "USER_STORE_REFERENCE" }' ``` #### 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("EUR") .value(500L); CardDonations cardDonations = new CardDonations() .type(CardDonations.TypeEnum.SCHEME); DonationPaymentRequest donationPaymentRequest = new DonationPaymentRequest() .reference("YOUR_DONATION_REFERENCE") .amount(amount) .merchantAccount("YOUR_MERCHANT_ACCOUNT") .donationCampaignId("DONATION_CAMPAIGN_ID") .donationOriginalPspReference("ORIGINAL_PAYMENT_PSP_REFERENCE") .paymentMethod(new DonationPaymentMethod(cardDonations)) .store("USER_STORE_REFERENCE") .donationToken("DONATION_TOKEN"); // Send the request DonationsApi service = new DonationsApi(client); DonationPaymentResponse response = service.donations(donationPaymentRequest, 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(500); $donationPaymentMethod = new DonationPaymentMethod(); $donationPaymentMethod ->setType("scheme"); $donationPaymentRequest = new DonationPaymentRequest(); $donationPaymentRequest ->setReference("YOUR_DONATION_REFERENCE") ->setAmount($amount) ->setMerchantAccount("YOUR_MERCHANT_ACCOUNT") ->setDonationCampaignId("DONATION_CAMPAIGN_ID") ->setDonationOriginalPspReference("ORIGINAL_PAYMENT_PSP_REFERENCE") ->setPaymentMethod($donationPaymentMethod) ->setStore("USER_STORE_REFERENCE") ->setDonationToken("DONATION_TOKEN"); $requestOptions['idempotencyKey'] = 'UUID'; // Send the request $service = new DonationsApi($client); $response = $service->donations($donationPaymentRequest, $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 donationsService = host.Services.GetRequiredService(); // Create the request object(s) var amount = new Amount { Currency = "EUR", Value = 500 }; var cardDonations = new CardDonations { Type = CardDonations.TypeEnum.Scheme }; var donationPaymentRequest = new DonationPaymentRequest { Reference = "YOUR_DONATION_REFERENCE", Amount = amount, MerchantAccount = "YOUR_MERCHANT_ACCOUNT", DonationCampaignId = "DONATION_CAMPAIGN_ID", DonationOriginalPspReference = "ORIGINAL_PAYMENT_PSP_REFERENCE", PaymentMethod = new DonationPaymentMethod(cardDonations), Store = "USER_STORE_REFERENCE", DonationToken = "DONATION_TOKEN" }; string idempotencyKey = Guid.NewGuid().ToString(); // Send the request var result = await donationsService.DonationsAsync(donationPaymentRequest, 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: "EUR", value: 500 }; const cardDonations = { type: "scheme" }; const donationPaymentRequest = { reference: "YOUR_DONATION_REFERENCE", amount: amount, merchantAccount: "YOUR_MERCHANT_ACCOUNT", donationCampaignId: "DONATION_CAMPAIGN_ID", donationOriginalPspReference: "ORIGINAL_PAYMENT_PSP_REFERENCE", paymentMethod: cardDonations, store: "USER_STORE_REFERENCE", donationToken: "DONATION_TOKEN" }; // Send the request const checkoutAPI = new CheckoutAPI(client); const response = await checkoutAPI.DonationsApi.donations(donationPaymentRequest, { 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: "EUR", Value: 500, } cardDonations := checkout.CardDonations{ Type: common.PtrString("scheme"), } donationPaymentRequest := checkout.DonationPaymentRequest{ Reference: "YOUR_DONATION_REFERENCE", Amount: amount, MerchantAccount: "YOUR_MERCHANT_ACCOUNT", DonationCampaignId: common.PtrString("DONATION_CAMPAIGN_ID"), DonationOriginalPspReference: common.PtrString("ORIGINAL_PAYMENT_PSP_REFERENCE"), PaymentMethod: func() *checkout.DonationPaymentMethod { v := checkout.CardDonationsAsDonationPaymentMethod(&cardDonations); return &v }(), Store: common.PtrString("USER_STORE_REFERENCE"), DonationToken: common.PtrString("DONATION_TOKEN"), } // Send the request service := client.Checkout() req := service.DonationsApi.DonationsInput().IdempotencyKey("UUID").DonationPaymentRequest(donationPaymentRequest) res, httpRes, err := service.DonationsApi.Donations(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": "EUR", "value": 500 }, "donationCampaignId": "DONATION_CAMPAIGN_ID", "paymentMethod": { "type": "scheme" }, "donationOriginalPspReference": "ORIGINAL_PAYMENT_PSP_REFERENCE", "donationToken": "DONATION_TOKEN", "reference": "YOUR_DONATION_REFERENCE", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "store": "USER_STORE_REFERENCE" } # Send the request result = adyen.checkout.donations_api.donations(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" => "EUR", "value" => 500 }, "donationCampaignId" => "DONATION_CAMPAIGN_ID", "paymentMethod" => { "type" => "scheme" }, "donationOriginalPspReference" => "ORIGINAL_PAYMENT_PSP_REFERENCE", "donationToken" => "DONATION_TOKEN", "reference" => "YOUR_DONATION_REFERENCE", "merchantAccount" => "YOUR_MERCHANT_ACCOUNT", "store" => "USER_STORE_REFERENCE" } # Send the request result = adyen.checkout.donations_api.donations(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: "EUR", value: 500 }; const cardDonations: Types.checkout.CardDonations = { type: Types.checkout.CardDonations.TypeEnum.Scheme }; const donationPaymentRequest = { reference: "YOUR_DONATION_REFERENCE", amount: amount, merchantAccount: "YOUR_MERCHANT_ACCOUNT", donationCampaignId: "DONATION_CAMPAIGN_ID", donationOriginalPspReference: "ORIGINAL_PAYMENT_PSP_REFERENCE", paymentMethod: cardDonations, store: "USER_STORE_REFERENCE", donationToken: "DONATION_TOKEN" } as unknown as Types.checkout.DonationPaymentRequest; // Send the request const checkoutAPI = new CheckoutAPI(client); const response = await checkoutAPI.DonationsApi.donations(donationPaymentRequest, { idempotencyKey: "UUID" }); ``` 2. In the response, note the following: * `id`: a unique resource identifier. * `status`: the status of the donation. Possible values: **completed**, **pending**, or **refused**. * `payment`: object that contains the [result code](https://docs.adyen.com/online-payments/build-your-integration/payment-result-codes/#final-payment-status), and the `pspReference` for the donation transaction. ### Tab: Round-up donations 1. Make a POST [/donations](https://docs.adyen.com/api-explorer/Checkout/latest/post/donations) request, specifying the following fields: | Field name | Required | Description | | | --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - | | [amount](https://docs.adyen.com/api-explorer/Checkout/latest/post/donations#request-amount) | ![Required](https://docs.adyen.com/media/732127089c689593ccb0331d565e5773bed94e60145cae96672212374facb8c6.svg?decoding=auto\&fetchpriority=auto) | The `currency` and `value` of the donation. | | | [donationCampaignId](https://docs.adyen.com/api-explorer/Checkout/latest/post/donations#request-donationCampaignId) | ![Required](https://docs.adyen.com/media/732127089c689593ccb0331d565e5773bed94e60145cae96672212374facb8c6.svg?decoding=auto\&fetchpriority=auto) | The unique campaign ID from the `/donationCampaigns` response `id` field. | | | [paymentMethod](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-paymentMethod) | ![Required](https://docs.adyen.com/media/732127089c689593ccb0331d565e5773bed94e60145cae96672212374facb8c6.svg?decoding=auto\&fetchpriority=auto) | For cards, Apple Pay, or Google Pay: `type`: **scheme** For iDeal: `type`: **sepadirectdebit** | | | [donationOriginalPspReference](https://docs.adyen.com/api-explorer/Checkout/latest/post/donations#request-donationOriginalPspReference) | ![Required](https://docs.adyen.com/media/732127089c689593ccb0331d565e5773bed94e60145cae96672212374facb8c6.svg?decoding=auto\&fetchpriority=auto) | The PSP reference of the original payment. | | | [donationToken](https://docs.adyen.com/api-explorer/Checkout/latest/post/donations#request-donationOriginalPspReference) | ![Required](https://docs.adyen.com/media/732127089c689593ccb0331d565e5773bed94e60145cae96672212374facb8c6.svg?decoding=auto\&fetchpriority=auto) | For cards, the `donationToken` from the [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) response. For iDeal, the `donationToken` from the [/payments/details](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments/details) response. | | | [reference](https://docs.adyen.com/api-explorer/Checkout/latest/post/donations#request-reference) | ![Required](https://docs.adyen.com/media/732127089c689593ccb0331d565e5773bed94e60145cae96672212374facb8c6.svg?decoding=auto\&fetchpriority=auto) | The reference to uniquely identify a payment. This reference is used in all communication with you about the payment status. We recommend using a unique value per payment; however, it is not a requirement. If you need to provide multiple references for a transaction, separate them with hyphens ("-"). Maximum length: 80 characters. | | | [merchantAccount](https://docs.adyen.com/api-explorer/Checkout/latest/post/donations#request-merchantAccount) | ![Required](https://docs.adyen.com/media/732127089c689593ccb0331d565e5773bed94e60145cae96672212374facb8c6.svg?decoding=auto\&fetchpriority=auto) | The merchant account identifier, with which you want to process the transaction. | | | [store](https://docs.adyen.com/api-explorer/Checkout/latest/post/donations#request-store) | ![Required](https://docs.adyen.com/media/732127089c689593ccb0331d565e5773bed94e60145cae96672212374facb8c6.svg?decoding=auto\&fetchpriority=auto) | Your reference for the user's store. | | **Example POST /donations request on a platform** #### curl ```bash curl https://checkout-test.adyen.com/v72/donations \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -X POST \ -d '{ "amount": { "currency": "EUR", "value": 99 }, "donationCampaignId": "DONATION_CAMPAIGN_ID", "paymentMethod": { "type": "scheme" }, "donationOriginalPspReference": "ORIGINAL_PAYMENT_PSP_REFERENCE", "donationToken": "DONATION_TOKEN", "reference": "YOUR_DONATION_REFERENCE" "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "store": "USER_STORE_REFERENCE" }' ``` #### 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("EUR") .value(99L); CardDonations cardDonations = new CardDonations() .type(CardDonations.TypeEnum.SCHEME); DonationPaymentRequest donationPaymentRequest = new DonationPaymentRequest() .reference("YOUR_DONATION_REFERENCE") .amount(amount) .merchantAccount("YOUR_MERCHANT_ACCOUNT") .donationCampaignId("DONATION_CAMPAIGN_ID") .donationOriginalPspReference("ORIGINAL_PAYMENT_PSP_REFERENCE") .paymentMethod(new DonationPaymentMethod(cardDonations)) .store("USER_STORE_REFERENCE") .donationToken("DONATION_TOKEN"); // Send the request DonationsApi service = new DonationsApi(client); DonationPaymentResponse response = service.donations(donationPaymentRequest, 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(99); $donationPaymentMethod = new DonationPaymentMethod(); $donationPaymentMethod ->setType("scheme"); $donationPaymentRequest = new DonationPaymentRequest(); $donationPaymentRequest ->setReference("YOUR_DONATION_REFERENCE") ->setAmount($amount) ->setMerchantAccount("YOUR_MERCHANT_ACCOUNT") ->setDonationCampaignId("DONATION_CAMPAIGN_ID") ->setDonationOriginalPspReference("ORIGINAL_PAYMENT_PSP_REFERENCE") ->setPaymentMethod($donationPaymentMethod) ->setStore("USER_STORE_REFERENCE") ->setDonationToken("DONATION_TOKEN"); $requestOptions['idempotencyKey'] = 'UUID'; // Send the request $service = new DonationsApi($client); $response = $service->donations($donationPaymentRequest, $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 donationsService = host.Services.GetRequiredService(); // Create the request object(s) var amount = new Amount { Currency = "EUR", Value = 99 }; var cardDonations = new CardDonations { Type = CardDonations.TypeEnum.Scheme }; var donationPaymentRequest = new DonationPaymentRequest { Reference = "YOUR_DONATION_REFERENCE", Amount = amount, MerchantAccount = "YOUR_MERCHANT_ACCOUNT", DonationCampaignId = "DONATION_CAMPAIGN_ID", DonationOriginalPspReference = "ORIGINAL_PAYMENT_PSP_REFERENCE", PaymentMethod = new DonationPaymentMethod(cardDonations), Store = "USER_STORE_REFERENCE", DonationToken = "DONATION_TOKEN" }; string idempotencyKey = Guid.NewGuid().ToString(); // Send the request var result = await donationsService.DonationsAsync(donationPaymentRequest, 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: "EUR", value: 99 }; const cardDonations = { type: "scheme" }; const donationPaymentRequest = { reference: "YOUR_DONATION_REFERENCE", amount: amount, merchantAccount: "YOUR_MERCHANT_ACCOUNT", donationCampaignId: "DONATION_CAMPAIGN_ID", donationOriginalPspReference: "ORIGINAL_PAYMENT_PSP_REFERENCE", paymentMethod: cardDonations, store: "USER_STORE_REFERENCE", donationToken: "DONATION_TOKEN" }; // Send the request const checkoutAPI = new CheckoutAPI(client); const response = await checkoutAPI.DonationsApi.donations(donationPaymentRequest, { 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: "EUR", Value: 99, } cardDonations := checkout.CardDonations{ Type: common.PtrString("scheme"), } donationPaymentRequest := checkout.DonationPaymentRequest{ Reference: "YOUR_DONATION_REFERENCE", Amount: amount, MerchantAccount: "YOUR_MERCHANT_ACCOUNT", DonationCampaignId: common.PtrString("DONATION_CAMPAIGN_ID"), DonationOriginalPspReference: common.PtrString("ORIGINAL_PAYMENT_PSP_REFERENCE"), PaymentMethod: func() *checkout.DonationPaymentMethod { v := checkout.CardDonationsAsDonationPaymentMethod(&cardDonations); return &v }(), Store: common.PtrString("USER_STORE_REFERENCE"), DonationToken: common.PtrString("DONATION_TOKEN"), } // Send the request service := client.Checkout() req := service.DonationsApi.DonationsInput().IdempotencyKey("UUID").DonationPaymentRequest(donationPaymentRequest) res, httpRes, err := service.DonationsApi.Donations(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": "EUR", "value": 99 }, "donationCampaignId": "DONATION_CAMPAIGN_ID", "paymentMethod": { "type": "scheme" }, "donationOriginalPspReference": "ORIGINAL_PAYMENT_PSP_REFERENCE", "donationToken": "DONATION_TOKEN", "reference": "YOUR_DONATION_REFERENCE", "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "store": "USER_STORE_REFERENCE" } # Send the request result = adyen.checkout.donations_api.donations(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" => "EUR", "value" => 99 }, "donationCampaignId" => "DONATION_CAMPAIGN_ID", "paymentMethod" => { "type" => "scheme" }, "donationOriginalPspReference" => "ORIGINAL_PAYMENT_PSP_REFERENCE", "donationToken" => "DONATION_TOKEN", "reference" => "YOUR_DONATION_REFERENCE", "merchantAccount" => "YOUR_MERCHANT_ACCOUNT", "store" => "USER_STORE_REFERENCE" } # Send the request result = adyen.checkout.donations_api.donations(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: "EUR", value: 99 }; const cardDonations: Types.checkout.CardDonations = { type: Types.checkout.CardDonations.TypeEnum.Scheme }; const donationPaymentRequest = { reference: "YOUR_DONATION_REFERENCE", amount: amount, merchantAccount: "YOUR_MERCHANT_ACCOUNT", donationCampaignId: "DONATION_CAMPAIGN_ID", donationOriginalPspReference: "ORIGINAL_PAYMENT_PSP_REFERENCE", paymentMethod: cardDonations, store: "USER_STORE_REFERENCE", donationToken: "DONATION_TOKEN" } as unknown as Types.checkout.DonationPaymentRequest; // Send the request const checkoutAPI = new CheckoutAPI(client); const response = await checkoutAPI.DonationsApi.donations(donationPaymentRequest, { idempotencyKey: "UUID" }); ``` 2. In the response, note the following: * `id`: a unique resource identifier. * `status`: the status of the donation. Possible values: **completed**, **pending**, or **refused**. * `payment`: object that contains the [result code](https://docs.adyen.com/online-payments/build-your-integration/payment-result-codes/#final-payment-status), and the `pspReference` for the donation transaction. ## Get the donation outcome You get the outcome of each donation in a webhook message. For cards, you can show the shopper if their donation is successful after you get the webhook message. For iDEAL, you get the webhook event a day or more later. You can send the outcome to the shopper using email or mobile messaging. To receive these webhook messages, enable the [Adyen Giving merchant webhook](https://docs.adyen.com/development-resources/webhooks/webhook-types#other-webhooks), which includes `eventCode`: **DONATION**. For a successful donation, the event contains: * `success`: **true**. * `originalReference`: use this value to associate the donation with the shopper's original transaction. **Successful donation webhook event** ```json { "live": "false", "notificationItems": [ { "NotificationRequestItem": { "additionalData": { "originalMerchantAccountCode": "YOUR_MERCHANT_ACCOUNT" }, "amount": { "currency": "EUR", "value": 500 }, "originalReference": "V4HZ4RBFJGXXGN82", "eventCode": "DONATION", "eventDate": "2022-07-07T13:18:13+02:00", "merchantAccountCode": "CHARITY_DONATION_ACCOUNT", "merchantReference": "YOUR_DONATION_REFERENCE", "paymentMethod": "visa", "pspReference": "Z58FGTKBRCQ2WN27", "reason": "033899:1111:03/2030", "success": "true" } } ] } ``` ## Test and go live Before going live with your integration, [use our test cards to test your integration](https://docs.adyen.com/online-payments/donations/testing). ## See also * [Adyen Giving donation campaigns](https://docs.adyen.com/platforms/donations) * [Create and manage donation campaigns](https://docs.adyen.com/platforms/donations/create-manage-campaigns) * [Donations with in-person platform payments](https://docs.adyen.com/platforms/in-person-payments/donations) * [API-only integration](https://docs.adyen.com/online-payments/donations/api-only) * [Reports and dashboard](https://docs.adyen.com/reporting/donation-campaigns)