curl --request POST \
--url https://api.xpaycheckout.com/subscription/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,
"interval": "MONTH",
"intervalCount": 2,
"cycleCount": 2,
"receiptId": "order123",
"description": "Order for 2 items",
"callbackUrl": "https://example.com/callback",
"cancelUrl": "https://example.com/cancel",
"upfrontAmount": 200,
"trialPeriodCount": 7,
"trialPeriodInterval": "DAY",
"multiUseLimit": 5,
"phoneNumberRequired": false
}
'import requests
url = "https://api.xpaycheckout.com/subscription/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,
"interval": "MONTH",
"intervalCount": 2,
"cycleCount": 2,
"receiptId": "order123",
"description": "Order for 2 items",
"callbackUrl": "https://example.com/callback",
"cancelUrl": "https://example.com/cancel",
"upfrontAmount": 200,
"trialPeriodCount": 7,
"trialPeriodInterval": "DAY",
"multiUseLimit": 5,
"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({
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,
interval: 'MONTH',
intervalCount: 2,
cycleCount: 2,
receiptId: 'order123',
description: 'Order for 2 items',
callbackUrl: 'https://example.com/callback',
cancelUrl: 'https://example.com/cancel',
upfrontAmount: 200,
trialPeriodCount: 7,
trialPeriodInterval: 'DAY',
multiUseLimit: 5,
phoneNumberRequired: false
})
};
fetch('https://api.xpaycheckout.com/subscription/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/subscription/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,
'interval' => 'MONTH',
'intervalCount' => 2,
'cycleCount' => 2,
'receiptId' => 'order123',
'description' => 'Order for 2 items',
'callbackUrl' => 'https://example.com/callback',
'cancelUrl' => 'https://example.com/cancel',
'upfrontAmount' => 200,
'trialPeriodCount' => 7,
'trialPeriodInterval' => 'DAY',
'multiUseLimit' => 5,
'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/subscription/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 \"interval\": \"MONTH\",\n \"intervalCount\": 2,\n \"cycleCount\": 2,\n \"receiptId\": \"order123\",\n \"description\": \"Order for 2 items\",\n \"callbackUrl\": \"https://example.com/callback\",\n \"cancelUrl\": \"https://example.com/cancel\",\n \"upfrontAmount\": 200,\n \"trialPeriodCount\": 7,\n \"trialPeriodInterval\": \"DAY\",\n \"multiUseLimit\": 5,\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/subscription/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 \"interval\": \"MONTH\",\n \"intervalCount\": 2,\n \"cycleCount\": 2,\n \"receiptId\": \"order123\",\n \"description\": \"Order for 2 items\",\n \"callbackUrl\": \"https://example.com/callback\",\n \"cancelUrl\": \"https://example.com/cancel\",\n \"upfrontAmount\": 200,\n \"trialPeriodCount\": 7,\n \"trialPeriodInterval\": \"DAY\",\n \"multiUseLimit\": 5,\n \"phoneNumberRequired\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xpaycheckout.com/subscription/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 \"interval\": \"MONTH\",\n \"intervalCount\": 2,\n \"cycleCount\": 2,\n \"receiptId\": \"order123\",\n \"description\": \"Order for 2 items\",\n \"callbackUrl\": \"https://example.com/callback\",\n \"cancelUrl\": \"https://example.com/cancel\",\n \"upfrontAmount\": 200,\n \"trialPeriodCount\": 7,\n \"trialPeriodInterval\": \"DAY\",\n \"multiUseLimit\": 5,\n \"phoneNumberRequired\": false\n}"
response = http.request(request)
puts response.read_body{
"shortUrl": "https://api.xpaycheckout.com/subscription/link/pcTrro7D",
"disclaimer": "GBP is not supported on Klarna. The payment will default to USD."
}{
"errorCode": "bad_request",
"errorDescription": "Failed to read request"
}Subscription Link
This API can be used to generate subscription links programmatically. Subscription links are basically standalone webpages where your customer can make a subscription payment.
curl --request POST \
--url https://api.xpaycheckout.com/subscription/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,
"interval": "MONTH",
"intervalCount": 2,
"cycleCount": 2,
"receiptId": "order123",
"description": "Order for 2 items",
"callbackUrl": "https://example.com/callback",
"cancelUrl": "https://example.com/cancel",
"upfrontAmount": 200,
"trialPeriodCount": 7,
"trialPeriodInterval": "DAY",
"multiUseLimit": 5,
"phoneNumberRequired": false
}
'import requests
url = "https://api.xpaycheckout.com/subscription/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,
"interval": "MONTH",
"intervalCount": 2,
"cycleCount": 2,
"receiptId": "order123",
"description": "Order for 2 items",
"callbackUrl": "https://example.com/callback",
"cancelUrl": "https://example.com/cancel",
"upfrontAmount": 200,
"trialPeriodCount": 7,
"trialPeriodInterval": "DAY",
"multiUseLimit": 5,
"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({
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,
interval: 'MONTH',
intervalCount: 2,
cycleCount: 2,
receiptId: 'order123',
description: 'Order for 2 items',
callbackUrl: 'https://example.com/callback',
cancelUrl: 'https://example.com/cancel',
upfrontAmount: 200,
trialPeriodCount: 7,
trialPeriodInterval: 'DAY',
multiUseLimit: 5,
phoneNumberRequired: false
})
};
fetch('https://api.xpaycheckout.com/subscription/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/subscription/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,
'interval' => 'MONTH',
'intervalCount' => 2,
'cycleCount' => 2,
'receiptId' => 'order123',
'description' => 'Order for 2 items',
'callbackUrl' => 'https://example.com/callback',
'cancelUrl' => 'https://example.com/cancel',
'upfrontAmount' => 200,
'trialPeriodCount' => 7,
'trialPeriodInterval' => 'DAY',
'multiUseLimit' => 5,
'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/subscription/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 \"interval\": \"MONTH\",\n \"intervalCount\": 2,\n \"cycleCount\": 2,\n \"receiptId\": \"order123\",\n \"description\": \"Order for 2 items\",\n \"callbackUrl\": \"https://example.com/callback\",\n \"cancelUrl\": \"https://example.com/cancel\",\n \"upfrontAmount\": 200,\n \"trialPeriodCount\": 7,\n \"trialPeriodInterval\": \"DAY\",\n \"multiUseLimit\": 5,\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/subscription/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 \"interval\": \"MONTH\",\n \"intervalCount\": 2,\n \"cycleCount\": 2,\n \"receiptId\": \"order123\",\n \"description\": \"Order for 2 items\",\n \"callbackUrl\": \"https://example.com/callback\",\n \"cancelUrl\": \"https://example.com/cancel\",\n \"upfrontAmount\": 200,\n \"trialPeriodCount\": 7,\n \"trialPeriodInterval\": \"DAY\",\n \"multiUseLimit\": 5,\n \"phoneNumberRequired\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xpaycheckout.com/subscription/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 \"interval\": \"MONTH\",\n \"intervalCount\": 2,\n \"cycleCount\": 2,\n \"receiptId\": \"order123\",\n \"description\": \"Order for 2 items\",\n \"callbackUrl\": \"https://example.com/callback\",\n \"cancelUrl\": \"https://example.com/cancel\",\n \"upfrontAmount\": 200,\n \"trialPeriodCount\": 7,\n \"trialPeriodInterval\": \"DAY\",\n \"multiUseLimit\": 5,\n \"phoneNumberRequired\": false\n}"
response = http.request(request)
puts response.read_body{
"shortUrl": "https://api.xpaycheckout.com/subscription/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 Subscription Link
Three letter abbreviation of the currency. Refer supported currencies
"USD"
An optional amount that merchants can set to be charged to the customer at the time the subscription is activated. This amount replaces the first billing cycle charge — the regular subscription amount is not added on top of it. Regular billing resumes from the next cycle.
The amount is in the lowest count unit. e.g.: For USD 1, amount is 100 representing 100 cents (minimum amount should be greater than 1 USD).
Validation Rules:
- Not compatible with
trialPeriodCountandtrialPeriodInterval— cannot be provided simultaneously
x >= 1200
The number of trial periods before the first billing cycle. Must be greater than or equal to 0 if provided.
Validation Rules:
- If
trialPeriodCountis provided,trialPeriodIntervalmust also be provided trialPeriodCountis not compatible withupfrontAmount- both cannot be provided simultaneously
x >= 07
Response
Generate Subscription Link
Was this page helpful?