curl --request POST \
--url https://api.xpaycheckout.com/payments/charge-tokenised-pm \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"pmId": "pmt_ftoeKIYGC3f43frT",
"customerId": "cus_Tfd3Jq1tZxPjYVhRQW2r3",
"currency": "USD",
"amount": 1000,
"receiptId": "order123",
"storeFrontId": "sf_sadfsdfsdf213dsaf",
"metadata": {
"orderId": "12345",
"customerNote": "Charge for recurring payments"
}
}
'import requests
url = "https://api.xpaycheckout.com/payments/charge-tokenised-pm"
payload = {
"pmId": "pmt_ftoeKIYGC3f43frT",
"customerId": "cus_Tfd3Jq1tZxPjYVhRQW2r3",
"currency": "USD",
"amount": 1000,
"receiptId": "order123",
"storeFrontId": "sf_sadfsdfsdf213dsaf",
"metadata": {
"orderId": "12345",
"customerNote": "Charge 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({
pmId: 'pmt_ftoeKIYGC3f43frT',
customerId: 'cus_Tfd3Jq1tZxPjYVhRQW2r3',
currency: 'USD',
amount: 1000,
receiptId: 'order123',
storeFrontId: 'sf_sadfsdfsdf213dsaf',
metadata: {orderId: '12345', customerNote: 'Charge for recurring payments'}
})
};
fetch('https://api.xpaycheckout.com/payments/charge-tokenised-pm', 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/payments/charge-tokenised-pm",
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([
'pmId' => 'pmt_ftoeKIYGC3f43frT',
'customerId' => 'cus_Tfd3Jq1tZxPjYVhRQW2r3',
'currency' => 'USD',
'amount' => 1000,
'receiptId' => 'order123',
'storeFrontId' => 'sf_sadfsdfsdf213dsaf',
'metadata' => [
'orderId' => '12345',
'customerNote' => 'Charge 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/payments/charge-tokenised-pm"
payload := strings.NewReader("{\n \"pmId\": \"pmt_ftoeKIYGC3f43frT\",\n \"customerId\": \"cus_Tfd3Jq1tZxPjYVhRQW2r3\",\n \"currency\": \"USD\",\n \"amount\": 1000,\n \"receiptId\": \"order123\",\n \"storeFrontId\": \"sf_sadfsdfsdf213dsaf\",\n \"metadata\": {\n \"orderId\": \"12345\",\n \"customerNote\": \"Charge 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/payments/charge-tokenised-pm")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"pmId\": \"pmt_ftoeKIYGC3f43frT\",\n \"customerId\": \"cus_Tfd3Jq1tZxPjYVhRQW2r3\",\n \"currency\": \"USD\",\n \"amount\": 1000,\n \"receiptId\": \"order123\",\n \"storeFrontId\": \"sf_sadfsdfsdf213dsaf\",\n \"metadata\": {\n \"orderId\": \"12345\",\n \"customerNote\": \"Charge for recurring payments\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xpaycheckout.com/payments/charge-tokenised-pm")
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 \"pmId\": \"pmt_ftoeKIYGC3f43frT\",\n \"customerId\": \"cus_Tfd3Jq1tZxPjYVhRQW2r3\",\n \"currency\": \"USD\",\n \"amount\": 1000,\n \"receiptId\": \"order123\",\n \"storeFrontId\": \"sf_sadfsdfsdf213dsaf\",\n \"metadata\": {\n \"orderId\": \"12345\",\n \"customerNote\": \"Charge for recurring payments\"\n }\n}"
response = http.request(request)
puts response.read_body{
"intentId": "in_dHd3Jq1tZxPjYVhRQW2r3",
"status": "SUCCESS",
"errorCode": "card_declined"
}{
"errorCode": "bad_request",
"errorDescription": "Failed to read request"
}Charge Tokenised PM
Charge a payment using a tokenized payment method
curl --request POST \
--url https://api.xpaycheckout.com/payments/charge-tokenised-pm \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"pmId": "pmt_ftoeKIYGC3f43frT",
"customerId": "cus_Tfd3Jq1tZxPjYVhRQW2r3",
"currency": "USD",
"amount": 1000,
"receiptId": "order123",
"storeFrontId": "sf_sadfsdfsdf213dsaf",
"metadata": {
"orderId": "12345",
"customerNote": "Charge for recurring payments"
}
}
'import requests
url = "https://api.xpaycheckout.com/payments/charge-tokenised-pm"
payload = {
"pmId": "pmt_ftoeKIYGC3f43frT",
"customerId": "cus_Tfd3Jq1tZxPjYVhRQW2r3",
"currency": "USD",
"amount": 1000,
"receiptId": "order123",
"storeFrontId": "sf_sadfsdfsdf213dsaf",
"metadata": {
"orderId": "12345",
"customerNote": "Charge 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({
pmId: 'pmt_ftoeKIYGC3f43frT',
customerId: 'cus_Tfd3Jq1tZxPjYVhRQW2r3',
currency: 'USD',
amount: 1000,
receiptId: 'order123',
storeFrontId: 'sf_sadfsdfsdf213dsaf',
metadata: {orderId: '12345', customerNote: 'Charge for recurring payments'}
})
};
fetch('https://api.xpaycheckout.com/payments/charge-tokenised-pm', 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/payments/charge-tokenised-pm",
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([
'pmId' => 'pmt_ftoeKIYGC3f43frT',
'customerId' => 'cus_Tfd3Jq1tZxPjYVhRQW2r3',
'currency' => 'USD',
'amount' => 1000,
'receiptId' => 'order123',
'storeFrontId' => 'sf_sadfsdfsdf213dsaf',
'metadata' => [
'orderId' => '12345',
'customerNote' => 'Charge 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/payments/charge-tokenised-pm"
payload := strings.NewReader("{\n \"pmId\": \"pmt_ftoeKIYGC3f43frT\",\n \"customerId\": \"cus_Tfd3Jq1tZxPjYVhRQW2r3\",\n \"currency\": \"USD\",\n \"amount\": 1000,\n \"receiptId\": \"order123\",\n \"storeFrontId\": \"sf_sadfsdfsdf213dsaf\",\n \"metadata\": {\n \"orderId\": \"12345\",\n \"customerNote\": \"Charge 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/payments/charge-tokenised-pm")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"pmId\": \"pmt_ftoeKIYGC3f43frT\",\n \"customerId\": \"cus_Tfd3Jq1tZxPjYVhRQW2r3\",\n \"currency\": \"USD\",\n \"amount\": 1000,\n \"receiptId\": \"order123\",\n \"storeFrontId\": \"sf_sadfsdfsdf213dsaf\",\n \"metadata\": {\n \"orderId\": \"12345\",\n \"customerNote\": \"Charge for recurring payments\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xpaycheckout.com/payments/charge-tokenised-pm")
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 \"pmId\": \"pmt_ftoeKIYGC3f43frT\",\n \"customerId\": \"cus_Tfd3Jq1tZxPjYVhRQW2r3\",\n \"currency\": \"USD\",\n \"amount\": 1000,\n \"receiptId\": \"order123\",\n \"storeFrontId\": \"sf_sadfsdfsdf213dsaf\",\n \"metadata\": {\n \"orderId\": \"12345\",\n \"customerNote\": \"Charge for recurring payments\"\n }\n}"
response = http.request(request)
puts response.read_body{
"intentId": "in_dHd3Jq1tZxPjYVhRQW2r3",
"status": "SUCCESS",
"errorCode": "card_declined"
}{
"errorCode": "bad_request",
"errorDescription": "Failed to read request"
}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
Charge Tokenized Payment Method
Unique identifier of the payment method to charge
"pmt_ftoeKIYGC3f43frT"
The unique identifier for the customer, generated via the create-customer API
"cus_Tfd3Jq1tZxPjYVhRQW2r3"
Three letter abbreviation of the currency
"USD"
The amount in lowest count unit (e.g., cents for USD)
1000
Your identifier of the order
"order123"
Unique identifier of the storefront
"sf_sadfsdfsdf213dsaf"
A collection of key-value pairs that can be attached to an object for storing additional structured information
Show child attributes
Show child attributes
{
"orderId": "12345",
"customerNote": "Charge for recurring payments"
}
Response
Payment charged successfully
Unique identifier of the payment intent
"in_dHd3Jq1tZxPjYVhRQW2r3"
The status of the payment intent. Refer payment intent status
"SUCCESS"
Error code if the operation was not successful
"card_declined"
Was this page helpful?