curl --request POST \
--url https://api.xpaycheckout.com/link/merchant/generate-link \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 100,
"currency": "USD",
"customerDetails": {
"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"
}
},
"expiryDate": 32526868154000,
"receiptId": "order123",
"description": "Order for 2 items",
"callbackUrl": "https://example.com/callback",
"cancelUrl": "https://example.com/cancel",
"paymentMethods": [
"CARD",
"GOOGLE_PAY",
"APPLE_PAY"
],
"storeFrontId": "sf_sK8d3Jq1tZxPjYVhRQW2rf",
"multiUseLimit": 5,
"phoneNumberRequired": false,
"allowedCardInstallmentTenures": [
"three",
"six"
]
}
'import requests
url = "https://api.xpaycheckout.com/link/merchant/generate-link"
payload = {
"amount": 100,
"currency": "USD",
"customerDetails": {
"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"
}
},
"expiryDate": 32526868154000,
"receiptId": "order123",
"description": "Order for 2 items",
"callbackUrl": "https://example.com/callback",
"cancelUrl": "https://example.com/cancel",
"paymentMethods": ["CARD", "GOOGLE_PAY", "APPLE_PAY"],
"storeFrontId": "sf_sK8d3Jq1tZxPjYVhRQW2rf",
"multiUseLimit": 5,
"phoneNumberRequired": False,
"allowedCardInstallmentTenures": ["three", "six"]
}
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({
amount: 100,
currency: 'USD',
customerDetails: {
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'
}
},
expiryDate: 32526868154000,
receiptId: 'order123',
description: 'Order for 2 items',
callbackUrl: 'https://example.com/callback',
cancelUrl: 'https://example.com/cancel',
paymentMethods: ['CARD', 'GOOGLE_PAY', 'APPLE_PAY'],
storeFrontId: 'sf_sK8d3Jq1tZxPjYVhRQW2rf',
multiUseLimit: 5,
phoneNumberRequired: false,
allowedCardInstallmentTenures: ['three', 'six']
})
};
fetch('https://api.xpaycheckout.com/link/merchant/generate-link', 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/link/merchant/generate-link",
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([
'amount' => 100,
'currency' => 'USD',
'customerDetails' => [
'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'
]
],
'expiryDate' => 32526868154000,
'receiptId' => 'order123',
'description' => 'Order for 2 items',
'callbackUrl' => 'https://example.com/callback',
'cancelUrl' => 'https://example.com/cancel',
'paymentMethods' => [
'CARD',
'GOOGLE_PAY',
'APPLE_PAY'
],
'storeFrontId' => 'sf_sK8d3Jq1tZxPjYVhRQW2rf',
'multiUseLimit' => 5,
'phoneNumberRequired' => false,
'allowedCardInstallmentTenures' => [
'three',
'six'
]
]),
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/link/merchant/generate-link"
payload := strings.NewReader("{\n \"amount\": 100,\n \"currency\": \"USD\",\n \"customerDetails\": {\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 \"expiryDate\": 32526868154000,\n \"receiptId\": \"order123\",\n \"description\": \"Order for 2 items\",\n \"callbackUrl\": \"https://example.com/callback\",\n \"cancelUrl\": \"https://example.com/cancel\",\n \"paymentMethods\": [\n \"CARD\",\n \"GOOGLE_PAY\",\n \"APPLE_PAY\"\n ],\n \"storeFrontId\": \"sf_sK8d3Jq1tZxPjYVhRQW2rf\",\n \"multiUseLimit\": 5,\n \"phoneNumberRequired\": false,\n \"allowedCardInstallmentTenures\": [\n \"three\",\n \"six\"\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/link/merchant/generate-link")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 100,\n \"currency\": \"USD\",\n \"customerDetails\": {\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 \"expiryDate\": 32526868154000,\n \"receiptId\": \"order123\",\n \"description\": \"Order for 2 items\",\n \"callbackUrl\": \"https://example.com/callback\",\n \"cancelUrl\": \"https://example.com/cancel\",\n \"paymentMethods\": [\n \"CARD\",\n \"GOOGLE_PAY\",\n \"APPLE_PAY\"\n ],\n \"storeFrontId\": \"sf_sK8d3Jq1tZxPjYVhRQW2rf\",\n \"multiUseLimit\": 5,\n \"phoneNumberRequired\": false,\n \"allowedCardInstallmentTenures\": [\n \"three\",\n \"six\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xpaycheckout.com/link/merchant/generate-link")
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 \"amount\": 100,\n \"currency\": \"USD\",\n \"customerDetails\": {\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 \"expiryDate\": 32526868154000,\n \"receiptId\": \"order123\",\n \"description\": \"Order for 2 items\",\n \"callbackUrl\": \"https://example.com/callback\",\n \"cancelUrl\": \"https://example.com/cancel\",\n \"paymentMethods\": [\n \"CARD\",\n \"GOOGLE_PAY\",\n \"APPLE_PAY\"\n ],\n \"storeFrontId\": \"sf_sK8d3Jq1tZxPjYVhRQW2rf\",\n \"multiUseLimit\": 5,\n \"phoneNumberRequired\": false,\n \"allowedCardInstallmentTenures\": [\n \"three\",\n \"six\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"shortUrl": "https://api.xpaycheckout.com/link/pcTrro7D",
"disclaimer": "GBP is not supported on Klarna. The payment will default to USD."
}{
"errorCode": "bad_request",
"errorDescription": "Failed to read request"
}Payments Links
This API can be used to generate payment links programmatically. Payments links are basically standalone webpages where your customer can make a one time payment.
curl --request POST \
--url https://api.xpaycheckout.com/link/merchant/generate-link \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 100,
"currency": "USD",
"customerDetails": {
"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"
}
},
"expiryDate": 32526868154000,
"receiptId": "order123",
"description": "Order for 2 items",
"callbackUrl": "https://example.com/callback",
"cancelUrl": "https://example.com/cancel",
"paymentMethods": [
"CARD",
"GOOGLE_PAY",
"APPLE_PAY"
],
"storeFrontId": "sf_sK8d3Jq1tZxPjYVhRQW2rf",
"multiUseLimit": 5,
"phoneNumberRequired": false,
"allowedCardInstallmentTenures": [
"three",
"six"
]
}
'import requests
url = "https://api.xpaycheckout.com/link/merchant/generate-link"
payload = {
"amount": 100,
"currency": "USD",
"customerDetails": {
"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"
}
},
"expiryDate": 32526868154000,
"receiptId": "order123",
"description": "Order for 2 items",
"callbackUrl": "https://example.com/callback",
"cancelUrl": "https://example.com/cancel",
"paymentMethods": ["CARD", "GOOGLE_PAY", "APPLE_PAY"],
"storeFrontId": "sf_sK8d3Jq1tZxPjYVhRQW2rf",
"multiUseLimit": 5,
"phoneNumberRequired": False,
"allowedCardInstallmentTenures": ["three", "six"]
}
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({
amount: 100,
currency: 'USD',
customerDetails: {
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'
}
},
expiryDate: 32526868154000,
receiptId: 'order123',
description: 'Order for 2 items',
callbackUrl: 'https://example.com/callback',
cancelUrl: 'https://example.com/cancel',
paymentMethods: ['CARD', 'GOOGLE_PAY', 'APPLE_PAY'],
storeFrontId: 'sf_sK8d3Jq1tZxPjYVhRQW2rf',
multiUseLimit: 5,
phoneNumberRequired: false,
allowedCardInstallmentTenures: ['three', 'six']
})
};
fetch('https://api.xpaycheckout.com/link/merchant/generate-link', 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/link/merchant/generate-link",
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([
'amount' => 100,
'currency' => 'USD',
'customerDetails' => [
'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'
]
],
'expiryDate' => 32526868154000,
'receiptId' => 'order123',
'description' => 'Order for 2 items',
'callbackUrl' => 'https://example.com/callback',
'cancelUrl' => 'https://example.com/cancel',
'paymentMethods' => [
'CARD',
'GOOGLE_PAY',
'APPLE_PAY'
],
'storeFrontId' => 'sf_sK8d3Jq1tZxPjYVhRQW2rf',
'multiUseLimit' => 5,
'phoneNumberRequired' => false,
'allowedCardInstallmentTenures' => [
'three',
'six'
]
]),
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/link/merchant/generate-link"
payload := strings.NewReader("{\n \"amount\": 100,\n \"currency\": \"USD\",\n \"customerDetails\": {\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 \"expiryDate\": 32526868154000,\n \"receiptId\": \"order123\",\n \"description\": \"Order for 2 items\",\n \"callbackUrl\": \"https://example.com/callback\",\n \"cancelUrl\": \"https://example.com/cancel\",\n \"paymentMethods\": [\n \"CARD\",\n \"GOOGLE_PAY\",\n \"APPLE_PAY\"\n ],\n \"storeFrontId\": \"sf_sK8d3Jq1tZxPjYVhRQW2rf\",\n \"multiUseLimit\": 5,\n \"phoneNumberRequired\": false,\n \"allowedCardInstallmentTenures\": [\n \"three\",\n \"six\"\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/link/merchant/generate-link")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 100,\n \"currency\": \"USD\",\n \"customerDetails\": {\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 \"expiryDate\": 32526868154000,\n \"receiptId\": \"order123\",\n \"description\": \"Order for 2 items\",\n \"callbackUrl\": \"https://example.com/callback\",\n \"cancelUrl\": \"https://example.com/cancel\",\n \"paymentMethods\": [\n \"CARD\",\n \"GOOGLE_PAY\",\n \"APPLE_PAY\"\n ],\n \"storeFrontId\": \"sf_sK8d3Jq1tZxPjYVhRQW2rf\",\n \"multiUseLimit\": 5,\n \"phoneNumberRequired\": false,\n \"allowedCardInstallmentTenures\": [\n \"three\",\n \"six\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xpaycheckout.com/link/merchant/generate-link")
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 \"amount\": 100,\n \"currency\": \"USD\",\n \"customerDetails\": {\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 \"expiryDate\": 32526868154000,\n \"receiptId\": \"order123\",\n \"description\": \"Order for 2 items\",\n \"callbackUrl\": \"https://example.com/callback\",\n \"cancelUrl\": \"https://example.com/cancel\",\n \"paymentMethods\": [\n \"CARD\",\n \"GOOGLE_PAY\",\n \"APPLE_PAY\"\n ],\n \"storeFrontId\": \"sf_sK8d3Jq1tZxPjYVhRQW2rf\",\n \"multiUseLimit\": 5,\n \"phoneNumberRequired\": false,\n \"allowedCardInstallmentTenures\": [\n \"three\",\n \"six\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"shortUrl": "https://api.xpaycheckout.com/link/pcTrro7D",
"disclaimer": "GBP is not supported on Klarna. The payment will default to USD."
}{
"errorCode": "bad_request",
"errorDescription": "Failed to read request"
}Authorizations
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
Generate Payment Link
Three letter abbreviation of the currency. Refer supported currencies
"USD"
List of payment methods to be enabled for the link. supported payment methods
š” If a selected payment method is unavailable, the system will automatically fallback to card payments to ensure a smooth checkout experience.
["CARD", "GOOGLE_PAY", "APPLE_PAY"]
šµ Beta Feature - The unique identifier for your storefront. This ID is used to associate the payment link with a specific storefront in your account. When provided, it will replace the default DBA and logo with the corresponding storefront's branding. This feature is currently in beta testing and may be subject to changes.
To enable this feature, please contact hello@xpaycheckout.com
"sf_sK8d3Jq1tZxPjYVhRQW2rf"
Response
Generate Payment Link
Was this page helpful?