curl https://checkout-test.adyen.com/v68/payments \
-H "x-API-key: YOUR_X-API-KEY" \
-H "content-type: application/json" \
-d '{
"merchantAccount":"YOUR_MERCHANT_ACCOUNT",
"countryCode":"US",
"amount":{
"currency":"USD",
"value":1000
},
"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.com/checkout?shopperOrder=12xy..",
"lineItems":[
{
"quantity":"1",
"amountExcludingTax":"331",
"description":"Shoes",
"id":"Item #1",
"taxAmount":"69",
"productUrl":"https://your-company.com/item1/",
"imageUrl":"https://your-company.com/item1.jpg"
},
{
"quantity":"2",
"amountExcludingTax":"248",
"description":"Socks",
"id":"Item #2",
"taxAmount":"52",
"productUrl":"https://your-company.com/item2/",
"imageUrl":"https://your-company.com/item2.jpg"
}
]
}'
# Set your X-API-KEY with the API key from the Customer Area.
adyen = Adyen::Client.new
adyen.env = :test
adyen.api_key = "YOUR_X-API-KEY"
response = adyen.checkout.payments({
:merchantAccount => "YOUR_MERCHANT_ACCOUNT",
:returnUrl => "https://your-company.com/checkout?shopperOrder=12xy..",
:countryCode => "US",
:amount => {
:currency => "USD",
:value => 1000
},
: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 => {
:street => "Brannan St.",
:houseNumberOrName => "274",
:city => "San Francisco",
:postalCode => "94107",
:stateOrProvince: "CA",
:country => "US"
},
:deliveryAddress => {
:street => "Brannan St.",
:houseNumberOrName => "274",
:city => "San Francisco",
:postalCode => "94107",
:stateOrProvince: "CA",
:country => "US"
},
:lineItems => [
{
:quantity => "1",
:amountExcludingTax => "331",
:description => "Shoes",
:id => "Item #1",
:taxAmount => "69",
:productUrl => "https://your-company.com/item1/",
:imageUrl => "https://your-company.com/item1.jpg"
},
{
:quantity => "2",
:amountExcludingTax => "248",
:description => "Socks",
:id => "Item #2",
:taxAmount => "52",
:productUrl => "https://your-company.com/item2/",
:imageUrl => "https://your-company.com/item2.jpg"
}
]
})
Client client = new Client("YOUR_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(1000L);
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.com/checkout?shopperOrder=12xy..");
List<LineItem> lineItems = new ArrayList<>();
lineItems.add(
new LineItem()
.quantity(1L)
.amountExcludingTax(331L)
.description("Shoes")
.id("Item #1")
.taxAmount(69L)
.productUrl("https://your-company.com/item1/")
.imageUrl("https://your-company.com/item1.jpg")
);
lineItems.add(
new LineItem()
.quantity(2L)
.amountExcludingTax(248L)
.description("Socks")
.id("Item #2")
.taxAmount(52L)
.productUrl("https://your-company.com/item2/")
.imageUrl("https://your-company.com/item2.jpg")
);
paymentsRequest.setLineItems(lineItems);
PaymentsResponse paymentsResponse = checkout.payments(paymentsRequest);
// Set your X-API-KEY with the API key from the Customer Area.
$client = new \Adyen\Client();
$client->setXApiKey("YOUR_X-API-KEY");
$service = new \Adyen\Service\Checkout($client);
$params = [
"merchantAccount" => "YOUR_MERCHANT_ACCOUNT",
"countryCode" => "US",
"amount" => [
"currency" => "USD",
"value" => 1000
],
"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.com/checkout?shopperOrder=12xy..",
"lineItems" => [
[
"quantity" => "1",
"amountExcludingTax" => "331",
"description" => "Shoes",
"id" => "Item #1",
"taxAmount" => "69",
"productUrl" => "https://your-company.com/item1/",
"imageUrl" => "https://your-company.com/item1.jpg"
],
[
"quantity" => "2",
"amountExcludingTax" => "248",
"description" => "Socks",
"id" => "Item #2",
"taxAmount" => "52",
"productUrl" => "https://your-company.com/item2/",
"imageUrl" => "https://your-company.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']
}
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Set your X-API-KEY with the API key from the Customer Area.
adyen = Adyen.Adyen()
adyen.client.xapikey = "YOUR_X-API-KEY"
result = adyen.checkout.payments({
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
"countryCode": "US",
"amount": {
"currency": "USD",
"value": 1000
},
"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.com/checkout?shopperOrder=12xy..",
"lineItems": [
{
"quantity": "1",
"amountExcludingTax": "331",
"description": "Shoes",
"id": "Item #1",
"taxAmount": "69",
"productUrl": "https://your-company.com/item1/",
"imageUrl": "https://your-company.com/item1.jpg"
},
{
"quantity": "2",
"amountExcludingTax": "248",
"description": "Socks",
"id": "Item #2",
"taxAmount": "52",
"productUrl": "https://your-company.com/item2/",
"imageUrl": "https://your-company.com/item2.jpg"
}
]
})
var paymentsRequest = new Adyen.Model.Checkout.PaymentRequest
{
MerchantAccount = "YOUR_MERCHANT_ACCOUNT",
CountryCode = "US",
Amount = new Adyen.Model.Checkout.Amount("USD", 1000),
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.com/checkout?shopperOrder=12xy..",
LineItems = new List<LineItem>
{
new LineItem(amountExcludingTax: 248, quantity: 2, id: "Item #1", taxAmount: 69, description: "Shoes", productUrl: "https://your-company.com/item1/", imageUrl: "https://your-company.com/item1.jpg"),
new LineItem(amountExcludingTax: 248, quantity: 2, id: "Item #2", taxAmount: 52, description: "Socks", productUrl: "https://your-company.com/item2/", imageUrl: "https://your-company.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"
}
};
// Set your X-API-KEY with the API key from the Customer Area.
const {Client, Config, CheckoutAPI} = require('@adyen/api-library');
const config = new Config();
// Set your X-API-KEY with the API key from the Customer Area.
config.apiKey = '[API_KEY]';
config.merchantAccount = '[MERCHANT_ACCOUNT]';
const client = new Client({ config });
client.setEnvironment("TEST");
const checkout = new CheckoutAPI(client);
checkout.payments({
merchantAccount: "YOUR_MERCHANT_ACCOUNT",
countryCode:"US",
amount: {
currency: "USD",
value: "1000"
},
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: {
street: "Brannan St.",
houseNumberOrName: "274",
city: "San Francisco",
postalCode: "94107",
stateOrProvince: "CA",
country: "US"
},
deliveryAddress: {
street: "Brannan St.",
houseNumberOrName: "274",
city: "San Francisco",
postalCode: "94107",
stateOrProvince: "CA",
country: "US"
},
returnUrl: "https://your-company.com/checkout?shopperOrder=12xy..",
lineItems: [
{
quantity: "1",
amountExcludingTax: "331",
taxPercentage: "2100",
description: "Shoes",
id: "Item 1",
taxAmount: "69",
productUrl: "https://your-company.com/item1/",
imageUrl: "https://your-company.com/item1.jpg"
},
{
quantity: "2",
amountExcludingTax: "248",
taxPercentage: "2100",
description: "Socks",
id: "Item 2",
taxAmount: "52",
productUrl: "https://your-company.com/item2/",
imageUrl: "https://your-company.com/item2.jpg"
}
]
}).then(res => res);