cURL
curl --request POST \
--url https://api.xpaycheckout.com/setup-method/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",
"paymentMethods": [
"CARD",
"GOOGLE_PAY",
"APPLE_PAY"
],
"customerId": "cus_Tfd3Jq1tZxPjYVhRQW2r3",
"storeFrontId": "sf_sK8d3Jq1tZxPjYVhRQW2rf",
"metadata": {
"orderId": "12345",
"customerNote": "Setup for recurring payments"
},
"phoneNumberRequired": false
}
'import requests
url = "https://api.xpaycheckout.com/setup-method/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",
"paymentMethods": ["CARD", "GOOGLE_PAY", "APPLE_PAY"],
"customerId": "cus_Tfd3Jq1tZxPjYVhRQW2r3",
"storeFrontId": "sf_sK8d3Jq1tZxPjYVhRQW2rf",
"metadata": {
"orderId": "12345",
"customerNote": "Setup for recurring payments"
},
"phoneNumberRequired": False
}
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',
paymentMethods: ['CARD', 'GOOGLE_PAY', 'APPLE_PAY'],
customerId: 'cus_Tfd3Jq1tZxPjYVhRQW2r3',
storeFrontId: 'sf_sK8d3Jq1tZxPjYVhRQW2rf',
metadata: {orderId: '12345', customerNote: 'Setup for recurring payments'},
phoneNumberRequired: false
})
};
fetch('https://api.xpaycheckout.com/setup-method/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/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',
'paymentMethods' => [
'CARD',
'GOOGLE_PAY',
'APPLE_PAY'
],
'customerId' => 'cus_Tfd3Jq1tZxPjYVhRQW2r3',
'storeFrontId' => 'sf_sK8d3Jq1tZxPjYVhRQW2rf',
'metadata' => [
'orderId' => '12345',
'customerNote' => 'Setup for recurring payments'
],
'phoneNumberRequired' => false
]),
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/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 \"paymentMethods\": [\n \"CARD\",\n \"GOOGLE_PAY\",\n \"APPLE_PAY\"\n ],\n \"customerId\": \"cus_Tfd3Jq1tZxPjYVhRQW2r3\",\n \"storeFrontId\": \"sf_sK8d3Jq1tZxPjYVhRQW2rf\",\n \"metadata\": {\n \"orderId\": \"12345\",\n \"customerNote\": \"Setup for recurring payments\"\n },\n \"phoneNumberRequired\": false\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/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 \"paymentMethods\": [\n \"CARD\",\n \"GOOGLE_PAY\",\n \"APPLE_PAY\"\n ],\n \"customerId\": \"cus_Tfd3Jq1tZxPjYVhRQW2r3\",\n \"storeFrontId\": \"sf_sK8d3Jq1tZxPjYVhRQW2rf\",\n \"metadata\": {\n \"orderId\": \"12345\",\n \"customerNote\": \"Setup for recurring payments\"\n },\n \"phoneNumberRequired\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xpaycheckout.com/setup-method/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 \"paymentMethods\": [\n \"CARD\",\n \"GOOGLE_PAY\",\n \"APPLE_PAY\"\n ],\n \"customerId\": \"cus_Tfd3Jq1tZxPjYVhRQW2r3\",\n \"storeFrontId\": \"sf_sK8d3Jq1tZxPjYVhRQW2rf\",\n \"metadata\": {\n \"orderId\": \"12345\",\n \"customerNote\": \"Setup for recurring payments\"\n },\n \"phoneNumberRequired\": false\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"
}Setup Method
Create Setup Method
Create a new setup method for storing payment methods
POST
/
setup-method
/
create
cURL
curl --request POST \
--url https://api.xpaycheckout.com/setup-method/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",
"paymentMethods": [
"CARD",
"GOOGLE_PAY",
"APPLE_PAY"
],
"customerId": "cus_Tfd3Jq1tZxPjYVhRQW2r3",
"storeFrontId": "sf_sK8d3Jq1tZxPjYVhRQW2rf",
"metadata": {
"orderId": "12345",
"customerNote": "Setup for recurring payments"
},
"phoneNumberRequired": false
}
'import requests
url = "https://api.xpaycheckout.com/setup-method/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",
"paymentMethods": ["CARD", "GOOGLE_PAY", "APPLE_PAY"],
"customerId": "cus_Tfd3Jq1tZxPjYVhRQW2r3",
"storeFrontId": "sf_sK8d3Jq1tZxPjYVhRQW2rf",
"metadata": {
"orderId": "12345",
"customerNote": "Setup for recurring payments"
},
"phoneNumberRequired": False
}
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',
paymentMethods: ['CARD', 'GOOGLE_PAY', 'APPLE_PAY'],
customerId: 'cus_Tfd3Jq1tZxPjYVhRQW2r3',
storeFrontId: 'sf_sK8d3Jq1tZxPjYVhRQW2rf',
metadata: {orderId: '12345', customerNote: 'Setup for recurring payments'},
phoneNumberRequired: false
})
};
fetch('https://api.xpaycheckout.com/setup-method/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/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',
'paymentMethods' => [
'CARD',
'GOOGLE_PAY',
'APPLE_PAY'
],
'customerId' => 'cus_Tfd3Jq1tZxPjYVhRQW2r3',
'storeFrontId' => 'sf_sK8d3Jq1tZxPjYVhRQW2rf',
'metadata' => [
'orderId' => '12345',
'customerNote' => 'Setup for recurring payments'
],
'phoneNumberRequired' => false
]),
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/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 \"paymentMethods\": [\n \"CARD\",\n \"GOOGLE_PAY\",\n \"APPLE_PAY\"\n ],\n \"customerId\": \"cus_Tfd3Jq1tZxPjYVhRQW2r3\",\n \"storeFrontId\": \"sf_sK8d3Jq1tZxPjYVhRQW2rf\",\n \"metadata\": {\n \"orderId\": \"12345\",\n \"customerNote\": \"Setup for recurring payments\"\n },\n \"phoneNumberRequired\": false\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/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 \"paymentMethods\": [\n \"CARD\",\n \"GOOGLE_PAY\",\n \"APPLE_PAY\"\n ],\n \"customerId\": \"cus_Tfd3Jq1tZxPjYVhRQW2r3\",\n \"storeFrontId\": \"sf_sK8d3Jq1tZxPjYVhRQW2rf\",\n \"metadata\": {\n \"orderId\": \"12345\",\n \"customerNote\": \"Setup for recurring payments\"\n },\n \"phoneNumberRequired\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xpaycheckout.com/setup-method/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 \"paymentMethods\": [\n \"CARD\",\n \"GOOGLE_PAY\",\n \"APPLE_PAY\"\n ],\n \"customerId\": \"cus_Tfd3Jq1tZxPjYVhRQW2r3\",\n \"storeFrontId\": \"sf_sK8d3Jq1tZxPjYVhRQW2rf\",\n \"metadata\": {\n \"orderId\": \"12345\",\n \"customerNote\": \"Setup for recurring payments\"\n },\n \"phoneNumberRequired\": false\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"
}This feature is disabled by default. To turn it on for your account, please contact your account manager or hello@xpaycheckout.com.
Authorizations
Headers
A unique key for making the request idempotent. Must match pattern: ^[a-zA-Z0-9\-_:\.]+$. See Idempotent Requests for more details.
Maximum string length:
255Pattern:
^[a-zA-Z0-9\-_:\.]+$Body
application/json
Create Setup Method
Three letter abbreviation of the currency. Refer supported currencies
Example:
"USD"
List of payment methods to be enabled for setup. supported payment methods
š” If a selected payment method is unavailable, the system will automatically fallback to card payments to ensure a smooth checkout experience.
Example:
["CARD", "GOOGLE_PAY", "APPLE_PAY"]
The unique identifier for the customer, generated via the create-customer API.
Example:
"cus_Tfd3Jq1tZxPjYVhRQW2r3"
Response
Setup Method created successfully
Was this page helpful?