curl --request POST \
--url https://api.xpaycheckout.com/payments/s2s/charge-raw-card \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 2000,
"currency": "USD",
"cardDetails": {
"cardNumber": "4000002500000003",
"expiryMonth": 1,
"expiryYear": 28,
"cvv": "123",
"cardHolderName": "John Doe",
"country": "US",
"postalCode": "2424"
},
"callbackUrl": "https://example.com/callback",
"receiptId": "order123",
"metadata": {
"orderId": "12345",
"customerNote": "Deliver after 5 PM"
},
"customerId": "cus_Tfd3Jq1tZxPjYVhRQW2r3",
"customerReferenceId": "eTfd3Jq1tZxPjYVhRQW2r3"
}
'import requests
url = "https://api.xpaycheckout.com/payments/s2s/charge-raw-card"
payload = {
"amount": 2000,
"currency": "USD",
"cardDetails": {
"cardNumber": "4000002500000003",
"expiryMonth": 1,
"expiryYear": 28,
"cvv": "123",
"cardHolderName": "John Doe",
"country": "US",
"postalCode": "2424"
},
"callbackUrl": "https://example.com/callback",
"receiptId": "order123",
"metadata": {
"orderId": "12345",
"customerNote": "Deliver after 5 PM"
},
"customerId": "cus_Tfd3Jq1tZxPjYVhRQW2r3",
"customerReferenceId": "eTfd3Jq1tZxPjYVhRQW2r3"
}
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: 2000,
currency: 'USD',
cardDetails: {
cardNumber: '4000002500000003',
expiryMonth: 1,
expiryYear: 28,
cvv: '123',
cardHolderName: 'John Doe',
country: 'US',
postalCode: '2424'
},
callbackUrl: 'https://example.com/callback',
receiptId: 'order123',
metadata: {orderId: '12345', customerNote: 'Deliver after 5 PM'},
customerId: 'cus_Tfd3Jq1tZxPjYVhRQW2r3',
customerReferenceId: 'eTfd3Jq1tZxPjYVhRQW2r3'
})
};
fetch('https://api.xpaycheckout.com/payments/s2s/charge-raw-card', 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/s2s/charge-raw-card",
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' => 2000,
'currency' => 'USD',
'cardDetails' => [
'cardNumber' => '4000002500000003',
'expiryMonth' => 1,
'expiryYear' => 28,
'cvv' => '123',
'cardHolderName' => 'John Doe',
'country' => 'US',
'postalCode' => '2424'
],
'callbackUrl' => 'https://example.com/callback',
'receiptId' => 'order123',
'metadata' => [
'orderId' => '12345',
'customerNote' => 'Deliver after 5 PM'
],
'customerId' => 'cus_Tfd3Jq1tZxPjYVhRQW2r3',
'customerReferenceId' => 'eTfd3Jq1tZxPjYVhRQW2r3'
]),
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/s2s/charge-raw-card"
payload := strings.NewReader("{\n \"amount\": 2000,\n \"currency\": \"USD\",\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 \"callbackUrl\": \"https://example.com/callback\",\n \"receiptId\": \"order123\",\n \"metadata\": {\n \"orderId\": \"12345\",\n \"customerNote\": \"Deliver after 5 PM\"\n },\n \"customerId\": \"cus_Tfd3Jq1tZxPjYVhRQW2r3\",\n \"customerReferenceId\": \"eTfd3Jq1tZxPjYVhRQW2r3\"\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/s2s/charge-raw-card")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 2000,\n \"currency\": \"USD\",\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 \"callbackUrl\": \"https://example.com/callback\",\n \"receiptId\": \"order123\",\n \"metadata\": {\n \"orderId\": \"12345\",\n \"customerNote\": \"Deliver after 5 PM\"\n },\n \"customerId\": \"cus_Tfd3Jq1tZxPjYVhRQW2r3\",\n \"customerReferenceId\": \"eTfd3Jq1tZxPjYVhRQW2r3\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xpaycheckout.com/payments/s2s/charge-raw-card")
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\": 2000,\n \"currency\": \"USD\",\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 \"callbackUrl\": \"https://example.com/callback\",\n \"receiptId\": \"order123\",\n \"metadata\": {\n \"orderId\": \"12345\",\n \"customerNote\": \"Deliver after 5 PM\"\n },\n \"customerId\": \"cus_Tfd3Jq1tZxPjYVhRQW2r3\",\n \"customerReferenceId\": \"eTfd3Jq1tZxPjYVhRQW2r3\"\n}"
response = http.request(request)
puts response.read_body{
"nextActionRedirectionURL": "https://pay.xpaycheckout.com/?id=in_gKAqC775RFeXjkGM&secret=7Cduomd3LDV6zimJC7vXwh",
"intentId": "in_gKAqB3B2aVbFEtbI"
}{
"errorCode": "bad_request",
"errorDescription": "Failed to read request"
}Charge Raw Card
curl --request POST \
--url https://api.xpaycheckout.com/payments/s2s/charge-raw-card \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 2000,
"currency": "USD",
"cardDetails": {
"cardNumber": "4000002500000003",
"expiryMonth": 1,
"expiryYear": 28,
"cvv": "123",
"cardHolderName": "John Doe",
"country": "US",
"postalCode": "2424"
},
"callbackUrl": "https://example.com/callback",
"receiptId": "order123",
"metadata": {
"orderId": "12345",
"customerNote": "Deliver after 5 PM"
},
"customerId": "cus_Tfd3Jq1tZxPjYVhRQW2r3",
"customerReferenceId": "eTfd3Jq1tZxPjYVhRQW2r3"
}
'import requests
url = "https://api.xpaycheckout.com/payments/s2s/charge-raw-card"
payload = {
"amount": 2000,
"currency": "USD",
"cardDetails": {
"cardNumber": "4000002500000003",
"expiryMonth": 1,
"expiryYear": 28,
"cvv": "123",
"cardHolderName": "John Doe",
"country": "US",
"postalCode": "2424"
},
"callbackUrl": "https://example.com/callback",
"receiptId": "order123",
"metadata": {
"orderId": "12345",
"customerNote": "Deliver after 5 PM"
},
"customerId": "cus_Tfd3Jq1tZxPjYVhRQW2r3",
"customerReferenceId": "eTfd3Jq1tZxPjYVhRQW2r3"
}
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: 2000,
currency: 'USD',
cardDetails: {
cardNumber: '4000002500000003',
expiryMonth: 1,
expiryYear: 28,
cvv: '123',
cardHolderName: 'John Doe',
country: 'US',
postalCode: '2424'
},
callbackUrl: 'https://example.com/callback',
receiptId: 'order123',
metadata: {orderId: '12345', customerNote: 'Deliver after 5 PM'},
customerId: 'cus_Tfd3Jq1tZxPjYVhRQW2r3',
customerReferenceId: 'eTfd3Jq1tZxPjYVhRQW2r3'
})
};
fetch('https://api.xpaycheckout.com/payments/s2s/charge-raw-card', 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/s2s/charge-raw-card",
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' => 2000,
'currency' => 'USD',
'cardDetails' => [
'cardNumber' => '4000002500000003',
'expiryMonth' => 1,
'expiryYear' => 28,
'cvv' => '123',
'cardHolderName' => 'John Doe',
'country' => 'US',
'postalCode' => '2424'
],
'callbackUrl' => 'https://example.com/callback',
'receiptId' => 'order123',
'metadata' => [
'orderId' => '12345',
'customerNote' => 'Deliver after 5 PM'
],
'customerId' => 'cus_Tfd3Jq1tZxPjYVhRQW2r3',
'customerReferenceId' => 'eTfd3Jq1tZxPjYVhRQW2r3'
]),
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/s2s/charge-raw-card"
payload := strings.NewReader("{\n \"amount\": 2000,\n \"currency\": \"USD\",\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 \"callbackUrl\": \"https://example.com/callback\",\n \"receiptId\": \"order123\",\n \"metadata\": {\n \"orderId\": \"12345\",\n \"customerNote\": \"Deliver after 5 PM\"\n },\n \"customerId\": \"cus_Tfd3Jq1tZxPjYVhRQW2r3\",\n \"customerReferenceId\": \"eTfd3Jq1tZxPjYVhRQW2r3\"\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/s2s/charge-raw-card")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 2000,\n \"currency\": \"USD\",\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 \"callbackUrl\": \"https://example.com/callback\",\n \"receiptId\": \"order123\",\n \"metadata\": {\n \"orderId\": \"12345\",\n \"customerNote\": \"Deliver after 5 PM\"\n },\n \"customerId\": \"cus_Tfd3Jq1tZxPjYVhRQW2r3\",\n \"customerReferenceId\": \"eTfd3Jq1tZxPjYVhRQW2r3\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xpaycheckout.com/payments/s2s/charge-raw-card")
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\": 2000,\n \"currency\": \"USD\",\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 \"callbackUrl\": \"https://example.com/callback\",\n \"receiptId\": \"order123\",\n \"metadata\": {\n \"orderId\": \"12345\",\n \"customerNote\": \"Deliver after 5 PM\"\n },\n \"customerId\": \"cus_Tfd3Jq1tZxPjYVhRQW2r3\",\n \"customerReferenceId\": \"eTfd3Jq1tZxPjYVhRQW2r3\"\n}"
response = http.request(request)
puts response.read_body{
"nextActionRedirectionURL": "https://pay.xpaycheckout.com/?id=in_gKAqC775RFeXjkGM&secret=7Cduomd3LDV6zimJC7vXwh",
"intentId": "in_gKAqB3B2aVbFEtbI"
}{
"errorCode": "bad_request",
"errorDescription": "Failed to read request"
}nextActionRedirectURL, where the customer can complete the payment with a single click.- 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
The amount in lowest count unit. e.g.: For USD 1, amount is 100 representing 100 cents (The minimum amount should be greater than 1 USD)
2000
Three letter abbreviation of the currency. Refer supported currencies
"USD"
Payment card information collected by you
Show child attributes
Show child attributes
URL that the customer will be redirected to once the payment is processed in case 3ds authentication is required.
"https://example.com/callback"
Your identifier for the order
"order123"
A collection of key-value pairs that can be attached to an object for storing additional structured information. This is useful for capturing custom data or context-specific attributes.
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": "Deliver after 5 PM"
}
The unique identifier for the customer, generated via the create-customer API. This can be used to associate the payment with a specific customer in your system.
"cus_Tfd3Jq1tZxPjYVhRQW2r3"
Your unique identifier for the customer. This can be used to associate the payment with a specific customer in your system.
"eTfd3Jq1tZxPjYVhRQW2r3"
Details of the customer. Required if customerId is not provided.
Show child attributes
Show child attributes
Response
Charge raw card response
Identifier of the payment intent created for this charge.
"in_gKAqR0DjLeOihdTE"
URL to redirect your customer to xpay's secure link to complete any pending 3DS or next action steps. Present only when additional authentication is required.
"https://pay.xpaycheckout.com/?id=67f53a6e2097773e4f0112c8"
Machine readable failure reason when status is FAILED. See all possible values here.
"insufficient_funds"
Was this page helpful?