--- title: "Affirm Drop-in integration" description: "Add Affirm to an existing Drop-in integration." url: "https://docs.adyen.com/payment-methods/affirm/web-drop-in" source_url: "https://docs.adyen.com/payment-methods/affirm/web-drop-in.md" canonical: "https://docs.adyen.com/payment-methods/affirm/web-drop-in" last_modified: "2026-05-24T12:54:31+02:00" language: "en" --- # Affirm Drop-in integration Add Affirm to an existing Drop-in integration. [View source](/payment-methods/affirm/web-drop-in.md) This page explains how to add Affirm to your existing Web Drop-in integration. ## Requirements Select the [server-side flow](/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 Drop-in integration](/online-payments/build-your-integration/sessions-flow?platform=Web\&integration=Drop-in). | | **Setup steps** | Before you begin, [add Affirm in your Customer Area](/payment-methods/add-payment-methods). | ### Tab: Advanced flow | Requirement | Description | | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | **Integration type** | Make sure that you have built an Advanced flow [Web Drop-in integration](/online-payments/build-your-integration/advanced-flow?platform=Web\&integration=Drop-in). | | **Setup steps** | Before you begin, [add Affirm in your Customer Area](/payment-methods/add-payment-methods). | ## Import resources for v6 If you are using Web Drop-in v6, import the resources you need for Affirm: ```js import { AdyenCheckout, Affirm} from '@adyen/adyen-web' ``` ## API reference Select which endpoint you are using: ### Tab: `/sessions` This is the default with [Drop-in v5.0.0](/online-payments/build-your-integration/sessions-flow?platform=Web\&integration=Drop-in) or later. | Parameter name | Required | Description | | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [shopperName](https://docs.adyen.com/api-explorer/Checkout/latest/post/sessions#request-shopperName) | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | Shopper's first name and last name. | | [telephoneNumber](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/sessions__resParam_telephoneNumber) | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | The shopper's phone number. | | [shopperEmail](https://docs.adyen.com/api-explorer/Checkout/latest/post/sessions#request-shopperEmail) | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | The shopper's email address. | | [shopperReference](https://docs.adyen.com/api-explorer/#/CheckoutService/latest/post/sessions__reqParam_shopperReference) | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | A unique reference to identify the shopper (minimum length three characters). | | [countryCode](https://docs.adyen.com/api-explorer/Checkout/latest/post/sessions#request-countryCode) | | The shopper's country in two-letter [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format.Required when transacting in Canada or the UK, because the default **US** is used if you omit this parameter. | | [billingAddress](https://docs.adyen.com/api-explorer/Checkout/latest/post/sessions#request-billingAddress) | | The address where to send the invoice. The `stateOrProvince` address field is required for Canada and the US, and optional for the UK. | | [deliveryAddress](https://docs.adyen.com/api-explorer/Checkout/latest/post/sessions#request-deliveryAddress) | | The address where the purchased goods should be delivered. The `stateOrProvince` address field is required for Canada and the US, and optional for the UK. If blank or missing, `billingAddress` is used by default. | | [lineItems](https://docs.adyen.com/api-explorer/Checkout/latest/post/sessions#request-lineItems) | | Price and product information about the purchased items. This is optional, but we recommend to include this data to improve approval rates. | #### curl ```bash curl https://checkout-test.adyen.com/v69/sessions \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "merchantAccount":"YOUR_MERCHANT_ACCOUNT", "countryCode":"US", "amount":{ "currency":"USD", "value":5000 }, "shopperReference":"YOUR_UNIQUE_SHOPPER_ID", "reference":"YOUR_ORDER_NUMBER", "shopperName":{ "firstName":"Simon", "lastName":"Hopper" }, "telephoneNumber":"+1612345678", "shopperEmail":"s.hopper@example.com", "{hint:state.data.billingAddress from onSubmit}billingAddress{/hint}":{ "city":"San Francisco", "country":"US", "houseNumberOrName":"274", "postalCode":"94107", "stateOrProvince":"CA", "street":"Brannan St." }, "{hint:state.data.deliveryAddress from onSubmit}deliveryAddress{/hint}":{ "city":"San Francisco", "country":"US", "houseNumberOrName":"274", "postalCode":"94107", "stateOrProvince":"CA", "street":"Brannan St." }, "returnUrl":"https://your-company.example.com/checkout?shopperOrder=12xy..", "lineItems":[ { "quantity":"1", "amountExcludingTax":"331", "description":"Shoes", "id":"Item #1", "taxAmount":"69", "productUrl":"https://your-company.example.com/item1/", "imageUrl":"https://your-company.example.com/item1.jpg" }, { "quantity":"2", "amountExcludingTax":"248", "description":"Socks", "id":"Item #2", "taxAmount":"52", "productUrl":"https://your-company.example.com/item2/", "imageUrl":"https://your-company.example.com/item2.jpg" } ] }' ``` #### Java ```java // Adyen Java API Library v39.3.0 import com.adyen.Client; import com.adyen.enums.Environment; import com.adyen.model.checkout.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.model.RequestOptions; import com.adyen.service.checkout.*; // For the LIVE environment, also include your liveEndpointUrlPrefix. Client client = new Client("ADYEN_API_KEY", Environment.TEST); // Create the request object(s) LineItem lineItem1 = new LineItem() .quantity(1L) .amountExcludingTax(331L) .imageUrl("https://your-company.example.com/item1.jpg") .description("Shoes") .id("Item #1") .taxAmount(69L) .productUrl("https://your-company.example.com/item1/"); LineItem lineItem2 = new LineItem() .quantity(2L) .amountExcludingTax(248L) .imageUrl("https://your-company.example.com/item2.jpg") .description("Socks") .id("Item #2") .taxAmount(52L) .productUrl("https://your-company.example.com/item2/"); Amount amount = new Amount() .currency("USD") .value(5000L); Name name = new Name() .firstName("Simon") .lastName("Hopper"); DeliveryAddress deliveryAddress = new DeliveryAddress() .country("US") .stateOrProvince("CA") .city("San Francisco") .houseNumberOrName("274") .street("Brannan St.") .postalCode("94107"); BillingAddress billingAddress = new BillingAddress() .country("US") .stateOrProvince("CA") .city("San Francisco") .houseNumberOrName("274") .street("Brannan St.") .postalCode("94107"); CreateCheckoutSessionRequest createCheckoutSessionRequest = new CreateCheckoutSessionRequest() .reference("YOUR_ORDER_NUMBER") .lineItems(Arrays.asList(lineItem1, lineItem2)) .amount(amount) .shopperName(name) .telephoneNumber("+1612345678") .merchantAccount("YOUR_MERCHANT_ACCOUNT") .deliveryAddress(deliveryAddress) .countryCode("US") .shopperEmail("s.hopper@example.com") .billingAddress(billingAddress) .returnUrl("https://your-company.example.com/checkout?shopperOrder=12xy..") .shopperReference("YOUR_UNIQUE_SHOPPER_ID"); // Send the request PaymentsApi service = new PaymentsApi(client); CreateCheckoutSessionResponse response = service.sessions(createCheckoutSessionRequest, new RequestOptions().idempotencyKey("UUID")); ``` #### PHP ```php setXApiKey("ADYEN_API_KEY"); // For the LIVE environment, also include your liveEndpointUrlPrefix. $client->setEnvironment(Environment::TEST); // Create the request object(s) $lineItem1 = new LineItem(); $lineItem1 ->setQuantity(1) ->setAmountExcludingTax(331) ->setImageUrl("https://your-company.example.com/item1.jpg") ->setDescription("Shoes") ->setId("Item #1") ->setTaxAmount(69) ->setProductUrl("https://your-company.example.com/item1/"); $lineItem2 = new LineItem(); $lineItem2 ->setQuantity(2) ->setAmountExcludingTax(248) ->setImageUrl("https://your-company.example.com/item2.jpg") ->setDescription("Socks") ->setId("Item #2") ->setTaxAmount(52) ->setProductUrl("https://your-company.example.com/item2/"); $amount = new Amount(); $amount ->setCurrency("USD") ->setValue(5000); $name = new Name(); $name ->setFirstName("Simon") ->setLastName("Hopper"); $deliveryAddress = new DeliveryAddress(); $deliveryAddress ->setCountry("US") ->setStateOrProvince("CA") ->setCity("San Francisco") ->setHouseNumberOrName("274") ->setStreet("Brannan St.") ->setPostalCode("94107"); $billingAddress = new BillingAddress(); $billingAddress ->setCountry("US") ->setStateOrProvince("CA") ->setCity("San Francisco") ->setHouseNumberOrName("274") ->setStreet("Brannan St.") ->setPostalCode("94107"); $createCheckoutSessionRequest = new CreateCheckoutSessionRequest(); $createCheckoutSessionRequest ->setReference("YOUR_ORDER_NUMBER") ->setLineItems(array($lineItem1, $lineItem2)) ->setAmount($amount) ->setShopperName($name) ->setTelephoneNumber("+1612345678") ->setMerchantAccount("YOUR_MERCHANT_ACCOUNT") ->setDeliveryAddress($deliveryAddress) ->setCountryCode("US") ->setShopperEmail("s.hopper@example.com") ->setBillingAddress($billingAddress) ->setReturnUrl("https://your-company.example.com/checkout?shopperOrder=12xy..") ->setShopperReference("YOUR_UNIQUE_SHOPPER_ID"); $requestOptions['idempotencyKey'] = 'UUID'; // Send the request $service = new PaymentsApi($client); $response = $service->sessions($createCheckoutSessionRequest, $requestOptions); ``` #### C\# ```cs // Adyen .net API Library v32.1.1 using Adyen; using Environment = Adyen.Model.Environment; using Adyen.Model; using Adyen.Model.Checkout; using Adyen.Service.Checkout; // For the LIVE environment, also 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, AmountExcludingTax = 331, ImageUrl = "https://your-company.example.com/item1.jpg", Description = "Shoes", Id = "Item #1", TaxAmount = 69, ProductUrl = "https://your-company.example.com/item1/" }; LineItem lineItem2 = new LineItem { Quantity = 2, AmountExcludingTax = 248, ImageUrl = "https://your-company.example.com/item2.jpg", Description = "Socks", Id = "Item #2", TaxAmount = 52, ProductUrl = "https://your-company.example.com/item2/" }; Amount amount = new Amount { Currency = "USD", Value = 5000 }; Name name = new Name { FirstName = "Simon", LastName = "Hopper" }; DeliveryAddress deliveryAddress = new DeliveryAddress { Country = "US", StateOrProvince = "CA", City = "San Francisco", HouseNumberOrName = "274", Street = "Brannan St.", PostalCode = "94107" }; BillingAddress billingAddress = new BillingAddress { Country = "US", StateOrProvince = "CA", City = "San Francisco", HouseNumberOrName = "274", Street = "Brannan St.", PostalCode = "94107" }; CreateCheckoutSessionRequest createCheckoutSessionRequest = new CreateCheckoutSessionRequest { Reference = "YOUR_ORDER_NUMBER", LineItems = new List{ lineItem1, lineItem2 }, Amount = amount, ShopperName = name, TelephoneNumber = "+1612345678", MerchantAccount = "YOUR_MERCHANT_ACCOUNT", DeliveryAddress = deliveryAddress, CountryCode = "US", ShopperEmail = "s.hopper@example.com", BillingAddress = billingAddress, ReturnUrl = "https://your-company.example.com/checkout?shopperOrder=12xy..", ShopperReference = "YOUR_UNIQUE_SHOPPER_ID" }; // Send the request var service = new PaymentsService(client); var response = service.Sessions(createCheckoutSessionRequest, requestOptions: new RequestOptions { IdempotencyKey = "UUID"}); ``` #### NodeJS (JavaScript) ```js // Adyen Node API Library v29.0.0 const { Client, CheckoutAPI } = require('@adyen/api-library'); // For the LIVE environment, also include your liveEndpointUrlPrefix. const config = new Config({ apiKey: "ADYEN_API_KEY", environment: EnvironmentEnum.TEST }); const client = new Client(config); // Create the request object(s) const createCheckoutSessionRequest = { merchantAccount: "YOUR_MERCHANT_ACCOUNT", countryCode: "US", amount: { currency: "USD", value: 5000 }, shopperReference: "YOUR_UNIQUE_SHOPPER_ID", reference: "YOUR_ORDER_NUMBER", shopperName: { firstName: "Simon", lastName: "Hopper" }, telephoneNumber: "+1612345678", shopperEmail: "s.hopper@example.com", billingAddress: { city: "San Francisco", country: "US", houseNumberOrName: "274", postalCode: "94107", stateOrProvince: "CA", street: "Brannan St." }, deliveryAddress: { city: "San Francisco", country: "US", houseNumberOrName: "274", postalCode: "94107", stateOrProvince: "CA", street: "Brannan St." }, returnUrl: "https://your-company.example.com/checkout?shopperOrder=12xy..", lineItems: [ { quantity: "1", amountExcludingTax: "331", description: "Shoes", id: "Item #1", taxAmount: "69", productUrl: "https://your-company.example.com/item1/", imageUrl: "https://your-company.example.com/item1.jpg" }, { quantity: "2", amountExcludingTax: "248", description: "Socks", id: "Item #2", taxAmount: "52", productUrl: "https://your-company.example.com/item2/", imageUrl: "https://your-company.example.com/item2.jpg" } ] } // Send the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentsApi.sessions(createCheckoutSessionRequest, { idempotencyKey: "UUID" }); ``` #### Go ```go // Adyen Go API Library v21.0.0 import ( "context" "github.com/adyen/adyen-go-api-library/v21/src/common" "github.com/adyen/adyen-go-api-library/v21/src/adyen" "github.com/adyen/adyen-go-api-library/v21/src/checkout" ) // For the LIVE environment, also include your liveEndpointUrlPrefix. client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Create the request object(s) lineItem1 := checkout.LineItem{ Quantity: common.PtrInt64(1), AmountExcludingTax: common.PtrInt64(331), ImageUrl: common.PtrString("https://your-company.example.com/item1.jpg"), Description: common.PtrString("Shoes"), Id: common.PtrString("Item #1"), TaxAmount: common.PtrInt64(69), ProductUrl: common.PtrString("https://your-company.example.com/item1/"), } lineItem2 := checkout.LineItem{ Quantity: common.PtrInt64(2), AmountExcludingTax: common.PtrInt64(248), ImageUrl: common.PtrString("https://your-company.example.com/item2.jpg"), Description: common.PtrString("Socks"), Id: common.PtrString("Item #2"), TaxAmount: common.PtrInt64(52), ProductUrl: common.PtrString("https://your-company.example.com/item2/"), } amount := checkout.Amount{ Currency: "USD", Value: 5000, } name := checkout.Name{ FirstName: "Simon", LastName: "Hopper", } deliveryAddress := checkout.DeliveryAddress{ Country: "US", StateOrProvince: common.PtrString("CA"), City: "San Francisco", HouseNumberOrName: "274", Street: "Brannan St.", PostalCode: "94107", } billingAddress := checkout.BillingAddress{ Country: "US", StateOrProvince: common.PtrString("CA"), City: "San Francisco", HouseNumberOrName: "274", Street: "Brannan St.", PostalCode: "94107", } createCheckoutSessionRequest := checkout.CreateCheckoutSessionRequest{ Reference: "YOUR_ORDER_NUMBER", LineItems: []checkout.LineItem{ lineItem1, lineItem2, }, Amount: amount, ShopperName: &name, TelephoneNumber: common.PtrString("+1612345678"), MerchantAccount: "YOUR_MERCHANT_ACCOUNT", DeliveryAddress: &deliveryAddress, CountryCode: common.PtrString("US"), ShopperEmail: common.PtrString("s.hopper@example.com"), BillingAddress: &billingAddress, ReturnUrl: "https://your-company.example.com/checkout?shopperOrder=12xy..", ShopperReference: common.PtrString("YOUR_UNIQUE_SHOPPER_ID"), } // Send the request service := client.Checkout() req := service.PaymentsApi.SessionsInput().IdempotencyKey("UUID").CreateCheckoutSessionRequest(createCheckoutSessionRequest) res, httpRes, err := service.PaymentsApi.Sessions(context.Background(), req) ``` #### Python ```py # Adyen Python API Library v13.6.0 import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_API_KEY" # For the LIVE environment, also include your liveEndpointUrlPrefix. adyen.client.platform = "test" # The environment to use library in. # Create the request object(s) json_request = { "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "countryCode": "US", "amount": { "currency": "USD", "value": 5000 }, "shopperReference": "YOUR_UNIQUE_SHOPPER_ID", "reference": "YOUR_ORDER_NUMBER", "shopperName": { "firstName": "Simon", "lastName": "Hopper" }, "telephoneNumber": "+1612345678", "shopperEmail": "s.hopper@example.com", "billingAddress": { "city": "San Francisco", "country": "US", "houseNumberOrName": "274", "postalCode": "94107", "stateOrProvince": "CA", "street": "Brannan St." }, "deliveryAddress": { "city": "San Francisco", "country": "US", "houseNumberOrName": "274", "postalCode": "94107", "stateOrProvince": "CA", "street": "Brannan St." }, "returnUrl": "https://your-company.example.com/checkout?shopperOrder=12xy..", "lineItems": [ { "quantity": "1", "amountExcludingTax": "331", "description": "Shoes", "id": "Item #1", "taxAmount": "69", "productUrl": "https://your-company.example.com/item1/", "imageUrl": "https://your-company.example.com/item1.jpg" }, { "quantity": "2", "amountExcludingTax": "248", "description": "Socks", "id": "Item #2", "taxAmount": "52", "productUrl": "https://your-company.example.com/item2/", "imageUrl": "https://your-company.example.com/item2.jpg" } ] } # Send the request result = adyen.checkout.payments_api.sessions(request=json_request, idempotency_key="UUID") ``` #### Ruby ```rb # Adyen Ruby API Library v10.4.0 require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_API_KEY' # For the LIVE environment, also include your liveEndpointUrlPrefix. adyen.env = :test # Set to "live" for live environment # Create the request object(s) request_body = { :merchantAccount => 'YOUR_MERCHANT_ACCOUNT', :countryCode => 'US', :amount => { :currency => 'USD', :value => 5000 }, :shopperReference => 'YOUR_UNIQUE_SHOPPER_ID', :reference => 'YOUR_ORDER_NUMBER', :shopperName => { :firstName => 'Simon', :lastName => 'Hopper' }, :telephoneNumber => '+1612345678', :shopperEmail => 's.hopper@example.com', :billingAddress => { :city => 'San Francisco', :country => 'US', :houseNumberOrName => '274', :postalCode => '94107', :stateOrProvince => 'CA', :street => 'Brannan St.' }, :deliveryAddress => { :city => 'San Francisco', :country => 'US', :houseNumberOrName => '274', :postalCode => '94107', :stateOrProvince => 'CA', :street => 'Brannan St.' }, :returnUrl => 'https://your-company.example.com/checkout?shopperOrder=12xy..', :lineItems => [ { :quantity => '1', :amountExcludingTax => '331', :description => 'Shoes', :id => 'Item #1', :taxAmount => '69', :productUrl => 'https://your-company.example.com/item1/', :imageUrl => 'https://your-company.example.com/item1.jpg' }, { :quantity => '2', :amountExcludingTax => '248', :description => 'Socks', :id => 'Item #2', :taxAmount => '52', :productUrl => 'https://your-company.example.com/item2/', :imageUrl => 'https://your-company.example.com/item2.jpg' } ] } # Send the request result = adyen.checkout.payments_api.sessions(request_body, headers: { 'Idempotency-Key' => 'UUID' }) ``` #### NodeJS (TypeScript) ```ts // Adyen Node API Library v29.0.0 import { Client, CheckoutAPI, Types } from "@adyen/api-library"; // For the LIVE environment, also include your liveEndpointUrlPrefix. const config = new Config({ apiKey: "ADYEN_API_KEY", environment: EnvironmentEnum.TEST }); const client = new Client(config); // Create the request object(s) const lineItem1: Types.checkout.LineItem = { quantity: 1, amountExcludingTax: 331, imageUrl: "https://your-company.example.com/item1.jpg", description: "Shoes", id: "Item #1", taxAmount: 69, productUrl: "https://your-company.example.com/item1/" }; const lineItem2: Types.checkout.LineItem = { quantity: 2, amountExcludingTax: 248, imageUrl: "https://your-company.example.com/item2.jpg", description: "Socks", id: "Item #2", taxAmount: 52, productUrl: "https://your-company.example.com/item2/" }; const amount: Types.checkout.Amount = { currency: "USD", value: 5000 }; const name: Types.checkout.Name = { firstName: "Simon", lastName: "Hopper" }; const deliveryAddress: Types.checkout.DeliveryAddress = { country: "US", stateOrProvince: "CA", city: "San Francisco", houseNumberOrName: "274", street: "Brannan St.", postalCode: "94107" }; const billingAddress: Types.checkout.BillingAddress = { country: "US", stateOrProvince: "CA", city: "San Francisco", houseNumberOrName: "274", street: "Brannan St.", postalCode: "94107" }; const createCheckoutSessionRequest: Types.checkout.CreateCheckoutSessionRequest = { reference: "YOUR_ORDER_NUMBER", lineItems: [lineItem1, lineItem2], amount: amount, shopperName: name, telephoneNumber: "+1612345678", merchantAccount: "YOUR_MERCHANT_ACCOUNT", deliveryAddress: deliveryAddress, countryCode: "US", shopperEmail: "s.hopper@example.com", billingAddress: billingAddress, returnUrl: "https://your-company.example.com/checkout?shopperOrder=12xy..", shopperReference: "YOUR_UNIQUE_SHOPPER_ID" }; // Send the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentsApi.sessions(createCheckoutSessionRequest, { idempotencyKey: "UUID" }); ``` ### Tab: `/payments` If you implemented an [additional use case](/online-payments/build-your-integration). | Parameter name | Required | Description | | -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | [shopperName](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-shopperName) | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | Shopper's first name and last name. | | [telephoneNumber](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-telephoneNumber) | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | The shopper's phone number. | | [shopperEmail](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-shopperEmail) | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | The shopper's email address. | | [shopperReference](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-shopperReference) | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | A unique reference to identify the shopper (minimum length three characters). | | [countryCode](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-countryCode) | | The shopper's country in two-letter [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format.Required when transacting in Canada or the UK because the default **US** is used if you omit this parameter. | | [billingAddress](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-billingAddress) | | The address where to send the invoice. The `stateOrProvince` address field is required for Canada and the US, and optional for the UK. | | [deliveryAddress](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-deliveryAddress) | | The address where the purchased goods should be delivered. The `stateOrProvince` address field is required for Canada and the US, and optional for the UK. If blank or missing, `billingAddress` is used by default. | | [lineItems](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments#request-lineItems) | | Price and product information about the purchased items. This is optional, but we recommend to include this data to improve approval rates. | #### curl ```bash curl https://checkout-test.adyen.com/v72/payments \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "merchantAccount":"YOUR_MERCHANT_ACCOUNT", "countryCode":"US", "amount":{ "currency":"USD", "value":5000 }, "shopperReference":"YOUR_UNIQUE_SHOPPER_ID", "reference":"YOUR_ORDER_NUMBER", "paymentMethod":{ "type":"affirm" }, "shopperName":{ "firstName":"Simon", "lastName":"Hopper" }, "telephoneNumber":"+1612345678", "shopperEmail":"s.hopper@example.com", "{hint:state.data.billingAddress from onSubmit}billingAddress{/hint}":{ "city":"San Francisco", "country":"US", "houseNumberOrName":"274", "postalCode":"94107", "stateOrProvince":"CA", "street":"Brannan St." }, "{hint:state.data.deliveryAddress from onSubmit}deliveryAddress{/hint}":{ "city":"San Francisco", "country":"US", "houseNumberOrName":"274", "postalCode":"94107", "stateOrProvince":"CA", "street":"Brannan St." }, "returnUrl":"https://your-company.example.com/checkout?shopperOrder=12xy..", "lineItems":[ { "quantity":"1", "amountExcludingTax":"331", "description":"Shoes", "id":"Item #1", "taxAmount":"69", "productUrl":"https://your-company.example.com/item1/", "imageUrl":"https://your-company.example.com/item1.jpg" }, { "quantity":"2", "amountExcludingTax":"248", "description":"Socks", "id":"Item #2", "taxAmount":"52", "productUrl":"https://your-company.example.com/item2/", "imageUrl":"https://your-company.example.com/item2.jpg" } ] }' ``` #### Java ```java Client client = new Client("ADYEN_API_KEY", Environment.TEST); Checkout checkout = new Checkout(client); PaymentsRequest paymentsRequest = new PaymentsRequest(); paymentsRequest.setMerchantAccount("YOUR_MERCHANT_ACCOUNT"); paymentsRequest.setCountryCode("US"); Amount amount = new Amount(); amount.setCurrency("USD"); amount.setValue(5000L); paymentsRequest.setAmount(amount); paymentsRequest.setShopperReference("YOUR_UNIQUE_SHOPPER_ID"); paymentsRequest.setReference("YOUR_ORDER_NUMBER"); paymentsRequest.setChannel(PaymentsRequest.ChannelEnum.WEB); DefaultPaymentMethodDetails defaultPaymentMethodDetails = new DefaultPaymentMethodDetails(); defaultPaymentMethodDetails.setType("affirm"); paymentsRequest.setPaymentMethod(defaultPaymentMethodDetails); Name shopperName = new Name(); shopperName.setFirstName("Simon"); shopperName.setLastName("Hopper"); paymentsRequest.setTelephoneNumber("+1612345678"); paymentsRequest.setShopperEmail("s.hopper@example.com"); Address billingAddress = new Address(); billingAddress.setStreet("Brannan St."); billingAddress.setHouseNumberOrName("274"); billingAddress.setCity("San Francisco"); billingAddress.setPostalCode("94107"); billingAddress.setStateOrProvince("CA"); billingAddress.setCountry("US"); paymentsRequest.setBillingAddress(billingAddress); Address deliveryAddress = new Address(); deliveryAddress.setStreet("Brannan St."); deliveryAddress.setHouseNumberOrName("274"); deliveryAddress.setCity("San Francisco"); deliveryAddress.setPostalCode("94107"); deliveryAddress.setStateOrProvince("CA"); deliveryAddress.setCountry("US"); paymentsRequest.setDeliveryAddress(deliveryAddress); paymentsRequest.setReturnUrl("https://your-company.example.com/checkout?shopperOrder=12xy.."); List lineItems = new ArrayList<>(); lineItems.add( new LineItem() .quantity(1L) .amountExcludingTax(331L) .description("Shoes") .id("Item #1") .taxAmount(69L) .productUrl("https://your-company.example.com/item1/") .imageUrl("https://your-company.example.com/item1.jpg") ); lineItems.add( new LineItem() .quantity(2L) .amountExcludingTax(248L) .description("Socks") .id("Item #2") .taxAmount(52L) .productUrl("https://your-company.example.com/item2/") .imageUrl("https://your-company.example.com/item2.jpg") ); paymentsRequest.setLineItems(lineItems); PaymentsResponse paymentsResponse = checkout.payments(paymentsRequest); ``` #### PHP ```php // Set your X-API-KEY with the API key from the Customer Area. $client = new \Adyen\Client(); $client->setXApiKey("ADYEN_API_KEY"); $service = new \Adyen\Service\Checkout($client); $params = [ "merchantAccount" => "YOUR_MERCHANT_ACCOUNT", "countryCode" => "US", "amount" => [ "currency" => "USD", "value" => 5000 ], "shopperReference" => "YOUR_UNIQUE_SHOPPER_ID", "reference" => "YOUR_ORDER_NUMBER", "channel" => "Web", "paymentMethod" => [ "type" => "affirm" ], "shopperName" => [ "firstName" => "Simon", "lastName" => "Hopper" ], "telephoneNumber" => "+1612345678", "shopperEmail" => "s.hopper@example.com", "billingAddress" => [ "city" => "San Francisco", "country" => "US", "houseNumberOrName" => "274", "postalCode" => "94107", "stateOrProvince" => "CA", "street" => "Brannan St." ], "deliveryAddress" => [ "city" => "San Francisco", "country" => "US", "houseNumberOrName" => "274", "postalCode" => "94107", "stateOrProvince" => "CA", "street" => "Brannan St." ], "returnUrl" => "https://your-company.example.com/checkout?shopperOrder=12xy..", "lineItems" => [ [ "quantity" => "1", "amountExcludingTax" => "331", "description" => "Shoes", "id" => "Item #1", "taxAmount" => "69", "productUrl" => "https://your-company.example.com/item1/", "imageUrl" => "https://your-company.example.com/item1.jpg" ], [ "quantity" => "2", "amountExcludingTax" => "248", "description" => "Socks", "id" => "Item #2", "taxAmount" => "52", "productUrl" => "https://your-company.example.com/item2/", "imageUrl" => "https://your-company.example.com/item2.jpg" ] ] ]; $result = $service->payments($params); // Check if further action is needed if (array_key_exists("action", $result)){ // Pass the action object to your frontend. // $result["action"] } else { // No further action needed, pass the resultCode to your front end // $result['resultCode'] } ``` #### C\# ```cs var paymentsRequest = new Adyen.Model.Checkout.PaymentRequest { MerchantAccount = "YOUR_MERCHANT_ACCOUNT", CountryCode = "US", Amount = new Adyen.Model.Checkout.Amount("USD", 5000), ShopperReference = "YOUR_UNIQUE_SHOPPER_ID", Reference = "YOUR_ORDER_NUMBER", Channel = Adyen.Model.Checkout.PaymentRequest.ChannelEnum.Web, TelephoneNumber = "+1612345678", ShopperEmail= "s.hopper@example.com", ReturnUrl = "https://your-company.example.com/checkout?shopperOrder=12xy..", LineItems = new List { new LineItem(amountExcludingTax: 248, quantity: 2, id: "Item #1", taxAmount: 69, description: "Shoes", productUrl: "https://your-company.example.com/item1/", imageUrl: "https://your-company.example.com/item1.jpg"), new LineItem(amountExcludingTax: 248, quantity: 2, id: "Item #2", taxAmount: 52, description: "Socks", productUrl: "https://your-company.example.com/item2/", imageUrl: "https://your-company.example.com/item2.jpg") }, PaymentMethod = new DefaultPaymentMethodDetails { Type = "affirm", BillingAddress = new Adyen.Model.Checkout.Address(country: "US") { City = "San Francisco", HouseNumberOrName = "274", PostalCode = "94107", StateOrProvince = "CA", Street = "Brannan St." }, DeliveryAddress = new Adyen.Model.Checkout.Address { City = "San Francisco", HouseNumberOrName = "274", PostalCode = "94107", StateOrProvince = "CA", Street = "Brannan St." }, }, ShopperName = new Adyen.Model.Checkout.Name { FirstName = "Simon", LastName = "Hopper" } }; ``` #### NodeJS (JavaScript) ```js // Adyen Node API Library v16.1.0 // Require the parts of the module you want to use const { Client, CheckoutAPI } = require('@adyen/api-library'); // Initialize the client object const client = new Client({apiKey: "YOUR_X_API_KEY", environment: "TEST"}); // Create the request object const paymentRequest = { merchantAccount: "YOUR_MERCHANT_ACCOUNT", countryCode: "US", amount: { currency: "USD", value: 5000 }, shopperReference: "YOUR_UNIQUE_SHOPPER_ID", reference: "YOUR_ORDER_NUMBER", paymentMethod: { type: "affirm" }, shopperName: { firstName: "Simon", lastName: "Hopper" }, telephoneNumber: "+1612345678", shopperEmail: "s.hopper@example.com", billingAddress: { city: "San Francisco", country: "US", houseNumberOrName: "274", postalCode: "94107", stateOrProvince: "CA", street: "Brannan St." }, deliveryAddress: { city: "San Francisco", country: "US", houseNumberOrName: "274", postalCode: "94107", stateOrProvince: "CA", street: "Brannan St." }, returnUrl: "https://your-company.example.com/checkout?shopperOrder=12xy..", lineItems: [ { quantity: "1", amountExcludingTax: "331", description: "Shoes", id: "Item #1", taxAmount: "69", productUrl: "https://your-company.example.com/item1/", imageUrl: "https://your-company.example.com/item1.jpg" }, { quantity: "2", amountExcludingTax: "248", description: "Socks", id: "Item #2", taxAmount: "52", productUrl: "https://your-company.example.com/item2/", imageUrl: "https://your-company.example.com/item2.jpg" } ] } // Make the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentsApi.payments(paymentRequest, { idempotencyKey: "UUID" }); ``` #### Python ```py # Adyen Python API Library v12.0.0 import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "YOUR_X_API_KEY" adyen.client.platform = "test" # The environment to use library in. json_request = { "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "countryCode": "US", "amount": { "currency": "USD", "value": 5000 }, "shopperReference": "YOUR_UNIQUE_SHOPPER_ID", "reference": "YOUR_ORDER_NUMBER", "paymentMethod": { "type": "affirm" }, "shopperName": { "firstName": "Simon", "lastName": "Hopper" }, "telephoneNumber": "+1612345678", "shopperEmail": "s.hopper@example.com", "billingAddress": { "city": "San Francisco", "country": "US", "houseNumberOrName": "274", "postalCode": "94107", "stateOrProvince": "CA", "street": "Brannan St." }, "deliveryAddress": { "city": "San Francisco", "country": "US", "houseNumberOrName": "274", "postalCode": "94107", "stateOrProvince": "CA", "street": "Brannan St." }, "returnUrl": "https://your-company.example.com/checkout?shopperOrder=12xy..", "lineItems": [ { "quantity": "1", "amountExcludingTax": "331", "description": "Shoes", "id": "Item #1", "taxAmount": "69", "productUrl": "https://your-company.example.com/item1/", "imageUrl": "https://your-company.example.com/item1.jpg" }, { "quantity": "2", "amountExcludingTax": "248", "description": "Socks", "id": "Item #2", "taxAmount": "52", "productUrl": "https://your-company.example.com/item2/", "imageUrl": "https://your-company.example.com/item2.jpg" } ] } result = adyen.checkout.payments_api.payments(request=json_request, idempotency_key="UUID") ``` #### Ruby ```rb # Adyen Ruby API Library v9.1.0 require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'YOUR_X_API_KEY' adyen.env = :test # Set to "live" for live environment request_body = { :merchantAccount => 'YOUR_MERCHANT_ACCOUNT', :countryCode => 'US', :amount => { :currency => 'USD', :value => 5000 }, :shopperReference => 'YOUR_UNIQUE_SHOPPER_ID', :reference => 'YOUR_ORDER_NUMBER', :paymentMethod => { :type => 'affirm' }, :shopperName => { :firstName => 'Simon', :lastName => 'Hopper' }, :telephoneNumber => '+1612345678', :shopperEmail => 's.hopper@example.com', :billingAddress => { :city => 'San Francisco', :country => 'US', :houseNumberOrName => '274', :postalCode => '94107', :stateOrProvince => 'CA', :street => 'Brannan St.' }, :deliveryAddress => { :city => 'San Francisco', :country => 'US', :houseNumberOrName => '274', :postalCode => '94107', :stateOrProvince => 'CA', :street => 'Brannan St.' }, :returnUrl => 'https://your-company.example.com/checkout?shopperOrder=12xy..', :lineItems => [ { :quantity => '1', :amountExcludingTax => '331', :description => 'Shoes', :id => 'Item #1', :taxAmount => '69', :productUrl => 'https://your-company.example.com/item1/', :imageUrl => 'https://your-company.example.com/item1.jpg' }, { :quantity => '2', :amountExcludingTax => '248', :description => 'Socks', :id => 'Item #2', :taxAmount => '52', :productUrl => 'https://your-company.example.com/item2/', :imageUrl => 'https://your-company.example.com/item2.jpg' } ] } result = adyen.checkout.payments_api.payments(request_body, headers: { 'Idempotency-Key' => 'UUID' }) ``` ## Optional Drop-in configuration When you [configure Drop-in](/online-payments/build-your-integration/sessions-flow?platform=Web\&integration=Drop-in#id1031863926), you can add optional configuration for Affirm. ### Pre-filled shopper data You can add configuration with the shopper's information, so that you can pre-fill the payment form. The `data` property includes the following information that you can pre-fill: | Property | Description | Data type | | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | --------- | | `personalDetails.firstName` | The shopper's first name. | String | | `personalDetails.lastName` | The shopper's last name. | String | | `personalDetails.dateOfBirth` | The shopper's date of birth. Format: `YYYY-MM-DD`. | String | | `personalDetails.shopperEmail` | The shoppers' email address. | String | | `personalDetails.telephoneNumber` | The shopper's telephone number. | String | | `billingAddress.street` | The street name for the billing address. | String | | `billingAddress.houseNumberOrName` | The house number or name for the billing address. | String | | `billingAddress.postalCode` | The postal code for the billing address. | String | | `billingAddress.city` | The city for the billing address. | String | | `billingAddress.stateOrProvince` | The state, province, or region for the billing address. | String | | `billingAddress.country` | The two-character [ISO 3166-1 alpha-2 country code](https://www.iso.org/iso-3166-country-codes.html) for the billing address. | String | | `deliveryAddress.street` | The street name for the delivery address. | String | | `deliveryAddress.houseNumberOrName` | The house number or building name for the delivery address. | String | | `deliveryAddress.postalCode` | The postal code for the delivery address. | String | | `deliveryAddress.city` | The city for the delivery address. | String | | `deliveryAddress.stateOrProvince` | The state, province, or region for the delivery address. | String | | `deliveryAddress.country` | The two-character [ISO 3166-1 alpha-2 country code](https://www.iso.org/iso-3166-country-codes.html) for the delivery address. | String | **Example of pre-filled data for Affirm** ```ts const preFilledData = { personalDetails: { firstName: "John", lastName: "Smith", shopperEmail: "johnsmith@example.com", telephoneNumber: "2025550123", }, billingAddress: { street: "Main St", houseNumberOrName: "123", postalCode: "90210", city: "Beverly Hills", stateOrProvince: "CA", country: "US", }, deliveryAddress: { street: "Main St", houseNumberOrName: "123", postalCode: "90210", city: "Beverly Hills", stateOrProvince: "CA", country: "US", } } ``` ### Payment form fields configuration In the payment form, you can configure if groups of fields are visible or can be edited by the shopper. Use the `visibility` property to configure groups of fields with the possible values: * **hidden**: The fields do not show up in the payment form. * **readOnly**: The fields show up in the payment form with the pre-filled values. The shopper cannot change the values. If you set any group of fields with this value, you must provide the corresponding information in the pre-filled object. * **editable**: The fields show up in the payment form with the pre-filled values. The shopper can change the values. | Fields | Default value | | ----------------- | ------------- | | `companyDetails` | **hidden** | | `personalDetails` | **editable** | | `billingAddress` | **editable** | | `deliveryAddress` | **editable** | | `bankAccount` | **hidden** | **Example of Affirm configuration object with default visibility values** ```ts affirm: { data: preFilledData, visibility: { companyDetails: "hidden", personalDetails: "editable", billingAddress: "editable", deliveryAddress: "editable", bankAccount: "hidden" } }; ``` ## Capture the payment After the goods have been sent, you also need to capture the payment. All Affirm payments have to be captured within 28 days. Capturing the payment is what triggers the installment payment schedule for the shopper. If you do not capture the payment within 28 days, the authorization will expire. If for any reason you need to capture a lesser amount than what was authorised, you need to issue a [refund](/online-payments/refund) for the difference after the capture. For example, a customer purchases two items of USD 500 each, totaling USD 1,000, but only one is fulfilled. After capturing USD 1,000, you should issue a subsequent refund for the unfulfilled item of USD 500. ## Test and go live To receive your test credentials, contact Affirm. After reviewing your test transactions, Affirm will provide you with the credentials for processing live transactions. You can check the status of the test payments in your [test Customer Area](https://ca-test.adyen.com/) > **Transactions** > **Payments**. Before you can accept live Affirm payments, you need to [submit a request for Affirm](/payment-methods/add-payment-methods) in your [live Customer Area](https://ca-live.adyen.com/), and provide us with your Affirm live credentials.