curl --request POST \
--url https://api.xpaycheckout.com/setup-method/s2s/create \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"currency": "USD",
"billingDetails": {
"name": "John Doe",
"email": "john.doe@example.com",
"contactNumber": "+919123456789",
"customerAddress": {
"addressLine1": "123 Main St",
"addressLine2": "Apt 1",
"city": "New York",
"state": "NY",
"country": "US",
"postalCode": "2424"
}
},
"callbackUrl": "https://example.com/callback",
"cardDetails": {
"cardNumber": "4000002500000003",
"expiryMonth": 1,
"expiryYear": 28,
"cvv": "123",
"cardHolderName": "John Doe",
"country": "US",
"postalCode": "2424"
},
"customerId": "cus_Tfd3Jq1tZxPjYVhRQW2r3",
"customerReferenceId": "eTfd3Jq1tZxPjYVhRQW2r3",
"storeFrontId": "sf_sK8d3Jq1tZxPjYVhRQW2rf",
"phoneNumberRequired": false,
"amount": 100,
"receiptId": "order123",
"metadata": {
"orderId": "12345",
"customerNote": "Setup for recurring payments"
}
}
'import requests
url = "https://api.xpaycheckout.com/setup-method/s2s/create"
payload = {
"currency": "USD",
"billingDetails": {
"name": "John Doe",
"email": "john.doe@example.com",
"contactNumber": "+919123456789",
"customerAddress": {
"addressLine1": "123 Main St",
"addressLine2": "Apt 1",
"city": "New York",
"state": "NY",
"country": "US",
"postalCode": "2424"
}
},
"callbackUrl": "https://example.com/callback",
"cardDetails": {
"cardNumber": "4000002500000003",
"expiryMonth": 1,
"expiryYear": 28,
"cvv": "123",
"cardHolderName": "John Doe",
"country": "US",
"postalCode": "2424"
},
"customerId": "cus_Tfd3Jq1tZxPjYVhRQW2r3",
"customerReferenceId": "eTfd3Jq1tZxPjYVhRQW2r3",
"storeFrontId": "sf_sK8d3Jq1tZxPjYVhRQW2rf",
"phoneNumberRequired": False,
"amount": 100,
"receiptId": "order123",
"metadata": {
"orderId": "12345",
"customerNote": "Setup for recurring payments"
}
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
currency: 'USD',
billingDetails: {
name: 'John Doe',
email: 'john.doe@example.com',
contactNumber: '+919123456789',
customerAddress: {
addressLine1: '123 Main St',
addressLine2: 'Apt 1',
city: 'New York',
state: 'NY',
country: 'US',
postalCode: '2424'
}
},
callbackUrl: 'https://example.com/callback',
cardDetails: {
cardNumber: '4000002500000003',
expiryMonth: 1,
expiryYear: 28,
cvv: '123',
cardHolderName: 'John Doe',
country: 'US',
postalCode: '2424'
},
customerId: 'cus_Tfd3Jq1tZxPjYVhRQW2r3',
customerReferenceId: 'eTfd3Jq1tZxPjYVhRQW2r3',
storeFrontId: 'sf_sK8d3Jq1tZxPjYVhRQW2rf',
phoneNumberRequired: false,
amount: 100,
receiptId: 'order123',
metadata: {orderId: '12345', customerNote: 'Setup for recurring payments'}
})
};
fetch('https://api.xpaycheckout.com/setup-method/s2s/create', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.xpaycheckout.com/setup-method/s2s/create",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'currency' => 'USD',
'billingDetails' => [
'name' => 'John Doe',
'email' => 'john.doe@example.com',
'contactNumber' => '+919123456789',
'customerAddress' => [
'addressLine1' => '123 Main St',
'addressLine2' => 'Apt 1',
'city' => 'New York',
'state' => 'NY',
'country' => 'US',
'postalCode' => '2424'
]
],
'callbackUrl' => 'https://example.com/callback',
'cardDetails' => [
'cardNumber' => '4000002500000003',
'expiryMonth' => 1,
'expiryYear' => 28,
'cvv' => '123',
'cardHolderName' => 'John Doe',
'country' => 'US',
'postalCode' => '2424'
],
'customerId' => 'cus_Tfd3Jq1tZxPjYVhRQW2r3',
'customerReferenceId' => 'eTfd3Jq1tZxPjYVhRQW2r3',
'storeFrontId' => 'sf_sK8d3Jq1tZxPjYVhRQW2rf',
'phoneNumberRequired' => false,
'amount' => 100,
'receiptId' => 'order123',
'metadata' => [
'orderId' => '12345',
'customerNote' => 'Setup for recurring payments'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.xpaycheckout.com/setup-method/s2s/create"
payload := strings.NewReader("{\n \"currency\": \"USD\",\n \"billingDetails\": {\n \"name\": \"John Doe\",\n \"email\": \"john.doe@example.com\",\n \"contactNumber\": \"+919123456789\",\n \"customerAddress\": {\n \"addressLine1\": \"123 Main St\",\n \"addressLine2\": \"Apt 1\",\n \"city\": \"New York\",\n \"state\": \"NY\",\n \"country\": \"US\",\n \"postalCode\": \"2424\"\n }\n },\n \"callbackUrl\": \"https://example.com/callback\",\n \"cardDetails\": {\n \"cardNumber\": \"4000002500000003\",\n \"expiryMonth\": 1,\n \"expiryYear\": 28,\n \"cvv\": \"123\",\n \"cardHolderName\": \"John Doe\",\n \"country\": \"US\",\n \"postalCode\": \"2424\"\n },\n \"customerId\": \"cus_Tfd3Jq1tZxPjYVhRQW2r3\",\n \"customerReferenceId\": \"eTfd3Jq1tZxPjYVhRQW2r3\",\n \"storeFrontId\": \"sf_sK8d3Jq1tZxPjYVhRQW2rf\",\n \"phoneNumberRequired\": false,\n \"amount\": 100,\n \"receiptId\": \"order123\",\n \"metadata\": {\n \"orderId\": \"12345\",\n \"customerNote\": \"Setup for recurring payments\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.xpaycheckout.com/setup-method/s2s/create")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"currency\": \"USD\",\n \"billingDetails\": {\n \"name\": \"John Doe\",\n \"email\": \"john.doe@example.com\",\n \"contactNumber\": \"+919123456789\",\n \"customerAddress\": {\n \"addressLine1\": \"123 Main St\",\n \"addressLine2\": \"Apt 1\",\n \"city\": \"New York\",\n \"state\": \"NY\",\n \"country\": \"US\",\n \"postalCode\": \"2424\"\n }\n },\n \"callbackUrl\": \"https://example.com/callback\",\n \"cardDetails\": {\n \"cardNumber\": \"4000002500000003\",\n \"expiryMonth\": 1,\n \"expiryYear\": 28,\n \"cvv\": \"123\",\n \"cardHolderName\": \"John Doe\",\n \"country\": \"US\",\n \"postalCode\": \"2424\"\n },\n \"customerId\": \"cus_Tfd3Jq1tZxPjYVhRQW2r3\",\n \"customerReferenceId\": \"eTfd3Jq1tZxPjYVhRQW2r3\",\n \"storeFrontId\": \"sf_sK8d3Jq1tZxPjYVhRQW2rf\",\n \"phoneNumberRequired\": false,\n \"amount\": 100,\n \"receiptId\": \"order123\",\n \"metadata\": {\n \"orderId\": \"12345\",\n \"customerNote\": \"Setup for recurring payments\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xpaycheckout.com/setup-method/s2s/create")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"currency\": \"USD\",\n \"billingDetails\": {\n \"name\": \"John Doe\",\n \"email\": \"john.doe@example.com\",\n \"contactNumber\": \"+919123456789\",\n \"customerAddress\": {\n \"addressLine1\": \"123 Main St\",\n \"addressLine2\": \"Apt 1\",\n \"city\": \"New York\",\n \"state\": \"NY\",\n \"country\": \"US\",\n \"postalCode\": \"2424\"\n }\n },\n \"callbackUrl\": \"https://example.com/callback\",\n \"cardDetails\": {\n \"cardNumber\": \"4000002500000003\",\n \"expiryMonth\": 1,\n \"expiryYear\": 28,\n \"cvv\": \"123\",\n \"cardHolderName\": \"John Doe\",\n \"country\": \"US\",\n \"postalCode\": \"2424\"\n },\n \"customerId\": \"cus_Tfd3Jq1tZxPjYVhRQW2r3\",\n \"customerReferenceId\": \"eTfd3Jq1tZxPjYVhRQW2r3\",\n \"storeFrontId\": \"sf_sK8d3Jq1tZxPjYVhRQW2rf\",\n \"phoneNumberRequired\": false,\n \"amount\": 100,\n \"receiptId\": \"order123\",\n \"metadata\": {\n \"orderId\": \"12345\",\n \"customerNote\": \"Setup for recurring payments\"\n }\n}"
response = http.request(request)
puts response.read_body{
"setupMethodId": "sm_sK8d3Jq1tZxPjYVhRQW2rf",
"fwdUrl": "https://pay.xpaycheckout.com/setup-method?id=sm_sK8d3Jq1tZxPjYVhRQW2rf&secret=4b5PyxKSOuunnnFruohoiF"
}{
"errorCode": "bad_request",
"errorDescription": "Failed to read request"
}Create S2S Setup Method
Create a new setup method for storing payment methods server to server
curl --request POST \
--url https://api.xpaycheckout.com/setup-method/s2s/create \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"currency": "USD",
"billingDetails": {
"name": "John Doe",
"email": "john.doe@example.com",
"contactNumber": "+919123456789",
"customerAddress": {
"addressLine1": "123 Main St",
"addressLine2": "Apt 1",
"city": "New York",
"state": "NY",
"country": "US",
"postalCode": "2424"
}
},
"callbackUrl": "https://example.com/callback",
"cardDetails": {
"cardNumber": "4000002500000003",
"expiryMonth": 1,
"expiryYear": 28,
"cvv": "123",
"cardHolderName": "John Doe",
"country": "US",
"postalCode": "2424"
},
"customerId": "cus_Tfd3Jq1tZxPjYVhRQW2r3",
"customerReferenceId": "eTfd3Jq1tZxPjYVhRQW2r3",
"storeFrontId": "sf_sK8d3Jq1tZxPjYVhRQW2rf",
"phoneNumberRequired": false,
"amount": 100,
"receiptId": "order123",
"metadata": {
"orderId": "12345",
"customerNote": "Setup for recurring payments"
}
}
'import requests
url = "https://api.xpaycheckout.com/setup-method/s2s/create"
payload = {
"currency": "USD",
"billingDetails": {
"name": "John Doe",
"email": "john.doe@example.com",
"contactNumber": "+919123456789",
"customerAddress": {
"addressLine1": "123 Main St",
"addressLine2": "Apt 1",
"city": "New York",
"state": "NY",
"country": "US",
"postalCode": "2424"
}
},
"callbackUrl": "https://example.com/callback",
"cardDetails": {
"cardNumber": "4000002500000003",
"expiryMonth": 1,
"expiryYear": 28,
"cvv": "123",
"cardHolderName": "John Doe",
"country": "US",
"postalCode": "2424"
},
"customerId": "cus_Tfd3Jq1tZxPjYVhRQW2r3",
"customerReferenceId": "eTfd3Jq1tZxPjYVhRQW2r3",
"storeFrontId": "sf_sK8d3Jq1tZxPjYVhRQW2rf",
"phoneNumberRequired": False,
"amount": 100,
"receiptId": "order123",
"metadata": {
"orderId": "12345",
"customerNote": "Setup for recurring payments"
}
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
currency: 'USD',
billingDetails: {
name: 'John Doe',
email: 'john.doe@example.com',
contactNumber: '+919123456789',
customerAddress: {
addressLine1: '123 Main St',
addressLine2: 'Apt 1',
city: 'New York',
state: 'NY',
country: 'US',
postalCode: '2424'
}
},
callbackUrl: 'https://example.com/callback',
cardDetails: {
cardNumber: '4000002500000003',
expiryMonth: 1,
expiryYear: 28,
cvv: '123',
cardHolderName: 'John Doe',
country: 'US',
postalCode: '2424'
},
customerId: 'cus_Tfd3Jq1tZxPjYVhRQW2r3',
customerReferenceId: 'eTfd3Jq1tZxPjYVhRQW2r3',
storeFrontId: 'sf_sK8d3Jq1tZxPjYVhRQW2rf',
phoneNumberRequired: false,
amount: 100,
receiptId: 'order123',
metadata: {orderId: '12345', customerNote: 'Setup for recurring payments'}
})
};
fetch('https://api.xpaycheckout.com/setup-method/s2s/create', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.xpaycheckout.com/setup-method/s2s/create",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'currency' => 'USD',
'billingDetails' => [
'name' => 'John Doe',
'email' => 'john.doe@example.com',
'contactNumber' => '+919123456789',
'customerAddress' => [
'addressLine1' => '123 Main St',
'addressLine2' => 'Apt 1',
'city' => 'New York',
'state' => 'NY',
'country' => 'US',
'postalCode' => '2424'
]
],
'callbackUrl' => 'https://example.com/callback',
'cardDetails' => [
'cardNumber' => '4000002500000003',
'expiryMonth' => 1,
'expiryYear' => 28,
'cvv' => '123',
'cardHolderName' => 'John Doe',
'country' => 'US',
'postalCode' => '2424'
],
'customerId' => 'cus_Tfd3Jq1tZxPjYVhRQW2r3',
'customerReferenceId' => 'eTfd3Jq1tZxPjYVhRQW2r3',
'storeFrontId' => 'sf_sK8d3Jq1tZxPjYVhRQW2rf',
'phoneNumberRequired' => false,
'amount' => 100,
'receiptId' => 'order123',
'metadata' => [
'orderId' => '12345',
'customerNote' => 'Setup for recurring payments'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.xpaycheckout.com/setup-method/s2s/create"
payload := strings.NewReader("{\n \"currency\": \"USD\",\n \"billingDetails\": {\n \"name\": \"John Doe\",\n \"email\": \"john.doe@example.com\",\n \"contactNumber\": \"+919123456789\",\n \"customerAddress\": {\n \"addressLine1\": \"123 Main St\",\n \"addressLine2\": \"Apt 1\",\n \"city\": \"New York\",\n \"state\": \"NY\",\n \"country\": \"US\",\n \"postalCode\": \"2424\"\n }\n },\n \"callbackUrl\": \"https://example.com/callback\",\n \"cardDetails\": {\n \"cardNumber\": \"4000002500000003\",\n \"expiryMonth\": 1,\n \"expiryYear\": 28,\n \"cvv\": \"123\",\n \"cardHolderName\": \"John Doe\",\n \"country\": \"US\",\n \"postalCode\": \"2424\"\n },\n \"customerId\": \"cus_Tfd3Jq1tZxPjYVhRQW2r3\",\n \"customerReferenceId\": \"eTfd3Jq1tZxPjYVhRQW2r3\",\n \"storeFrontId\": \"sf_sK8d3Jq1tZxPjYVhRQW2rf\",\n \"phoneNumberRequired\": false,\n \"amount\": 100,\n \"receiptId\": \"order123\",\n \"metadata\": {\n \"orderId\": \"12345\",\n \"customerNote\": \"Setup for recurring payments\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.xpaycheckout.com/setup-method/s2s/create")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"currency\": \"USD\",\n \"billingDetails\": {\n \"name\": \"John Doe\",\n \"email\": \"john.doe@example.com\",\n \"contactNumber\": \"+919123456789\",\n \"customerAddress\": {\n \"addressLine1\": \"123 Main St\",\n \"addressLine2\": \"Apt 1\",\n \"city\": \"New York\",\n \"state\": \"NY\",\n \"country\": \"US\",\n \"postalCode\": \"2424\"\n }\n },\n \"callbackUrl\": \"https://example.com/callback\",\n \"cardDetails\": {\n \"cardNumber\": \"4000002500000003\",\n \"expiryMonth\": 1,\n \"expiryYear\": 28,\n \"cvv\": \"123\",\n \"cardHolderName\": \"John Doe\",\n \"country\": \"US\",\n \"postalCode\": \"2424\"\n },\n \"customerId\": \"cus_Tfd3Jq1tZxPjYVhRQW2r3\",\n \"customerReferenceId\": \"eTfd3Jq1tZxPjYVhRQW2r3\",\n \"storeFrontId\": \"sf_sK8d3Jq1tZxPjYVhRQW2rf\",\n \"phoneNumberRequired\": false,\n \"amount\": 100,\n \"receiptId\": \"order123\",\n \"metadata\": {\n \"orderId\": \"12345\",\n \"customerNote\": \"Setup for recurring payments\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xpaycheckout.com/setup-method/s2s/create")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"currency\": \"USD\",\n \"billingDetails\": {\n \"name\": \"John Doe\",\n \"email\": \"john.doe@example.com\",\n \"contactNumber\": \"+919123456789\",\n \"customerAddress\": {\n \"addressLine1\": \"123 Main St\",\n \"addressLine2\": \"Apt 1\",\n \"city\": \"New York\",\n \"state\": \"NY\",\n \"country\": \"US\",\n \"postalCode\": \"2424\"\n }\n },\n \"callbackUrl\": \"https://example.com/callback\",\n \"cardDetails\": {\n \"cardNumber\": \"4000002500000003\",\n \"expiryMonth\": 1,\n \"expiryYear\": 28,\n \"cvv\": \"123\",\n \"cardHolderName\": \"John Doe\",\n \"country\": \"US\",\n \"postalCode\": \"2424\"\n },\n \"customerId\": \"cus_Tfd3Jq1tZxPjYVhRQW2r3\",\n \"customerReferenceId\": \"eTfd3Jq1tZxPjYVhRQW2r3\",\n \"storeFrontId\": \"sf_sK8d3Jq1tZxPjYVhRQW2rf\",\n \"phoneNumberRequired\": false,\n \"amount\": 100,\n \"receiptId\": \"order123\",\n \"metadata\": {\n \"orderId\": \"12345\",\n \"customerNote\": \"Setup for recurring payments\"\n }\n}"
response = http.request(request)
puts response.read_body{
"setupMethodId": "sm_sK8d3Jq1tZxPjYVhRQW2rf",
"fwdUrl": "https://pay.xpaycheckout.com/setup-method?id=sm_sK8d3Jq1tZxPjYVhRQW2rf&secret=4b5PyxKSOuunnnFruohoiF"
}{
"errorCode": "bad_request",
"errorDescription": "Failed to read request"
}- Use this endpoint when you already gathered card details and consent within your PCI DSS compliant environment
- You must obtain explicit approval from hello@xpaycheckout.com before using this API
Authorizations
Basic authentication header of the form Basic <encoded-value>, where <encoded-value> is the base64-encoded string username:password.
Headers
A unique key for making the request idempotent. Must match pattern: ^[a-zA-Z0-9\-_:\.]+$. See Idempotent Requests for more details.
255^[a-zA-Z0-9\-_:\.]+$Body
Create S2S Setup Method
Three letter abbreviation of the currency. Refer supported currencies
"USD"
Billing details for the customer.
Show child attributes
Show child attributes
The URL we will callback to once the setup is complete
"https://example.com/callback"
Payment card information collected by you
Show child attributes
Show child attributes
The unique identifier for the customer, generated via the create-customer API.
⚠️ Please note: Provide either customerReferenceId or this field, not both, as they are mutually exclusive.
"cus_Tfd3Jq1tZxPjYVhRQW2r3"
Your unique identifier for the customer.
⚠️ Please note: Provide either customerId or this field, not both, as they are mutually exclusive.
"eTfd3Jq1tZxPjYVhRQW2r3"
The unique identifier for your storefront
"sf_sK8d3Jq1tZxPjYVhRQW2rf"
Flag to indicate whether phone number is required from the customer during checkout. By default, this is false.
false
The amount to charge immediately while setting up the payment method token. The amount in lowest count unit e.g.: For USD 1, amount is 100 representing 100 cents. Should be greater than 0.
100
Your identifier of the order. This will be persisted in the intent created while setting up the payment method token.
"order123"
A collection of key-value pairs that can be attached to an object for storing additional structured information.
Constraints:
- Maximum of 50 key-value pairs allowed.
- Each key must be no longer than 40 characters.
- Each value must be a string and cannot exceed 500 characters.
Show child attributes
Show child attributes
{
"orderId": "12345",
"customerNote": "Setup for recurring payments"
}
Response
Setup Method created successfully
Was this page helpful?