Skip to main content
POST
/
subscription
/
merchant
/
one-time-charge
cURL
curl --request POST \
  --url https://api.xpaycheckout.com/subscription/merchant/one-time-charge \
  --header 'Authorization: Basic <encoded-value>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "subscriptionId": "sub_fooBOwYsaK50AEfK",
  "amount": 500,
  "currency": "USD",
  "comments": "One-time setup fee for premium add-on"
}
'
import requests

url = "https://api.xpaycheckout.com/subscription/merchant/one-time-charge"

payload = {
    "subscriptionId": "sub_fooBOwYsaK50AEfK",
    "amount": 500,
    "currency": "USD",
    "comments": "One-time setup fee for premium add-on"
}
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({
    subscriptionId: 'sub_fooBOwYsaK50AEfK',
    amount: 500,
    currency: 'USD',
    comments: 'One-time setup fee for premium add-on'
  })
};

fetch('https://api.xpaycheckout.com/subscription/merchant/one-time-charge', 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/merchant/one-time-charge",
  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([
    'subscriptionId' => 'sub_fooBOwYsaK50AEfK',
    'amount' => 500,
    'currency' => 'USD',
    'comments' => 'One-time setup fee for premium add-on'
  ]),
  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/merchant/one-time-charge"

	payload := strings.NewReader("{\n  \"subscriptionId\": \"sub_fooBOwYsaK50AEfK\",\n  \"amount\": 500,\n  \"currency\": \"USD\",\n  \"comments\": \"One-time setup fee for premium add-on\"\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/merchant/one-time-charge")
  .header("Authorization", "Basic <encoded-value>")
  .header("Content-Type", "application/json")
  .body("{\n  \"subscriptionId\": \"sub_fooBOwYsaK50AEfK\",\n  \"amount\": 500,\n  \"currency\": \"USD\",\n  \"comments\": \"One-time setup fee for premium add-on\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.xpaycheckout.com/subscription/merchant/one-time-charge")

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  \"subscriptionId\": \"sub_fooBOwYsaK50AEfK\",\n  \"amount\": 500,\n  \"currency\": \"USD\",\n  \"comments\": \"One-time setup fee for premium add-on\"\n}"

response = http.request(request)
puts response.read_body
{ "intentId": "in_gKAqR0DjLeOihdTE", "status": "SUCCESS", "errorCode": null, "errorMessage": null }

Authorizations

Authorization
string
header
required

Basic authentication header of the form Basic <encoded-value>, where <encoded-value> is the base64-encoded string username:password.

Headers

Idempotency-Key
string

A unique key for making the request idempotent. Must match pattern: ^[a-zA-Z0-9\-_:\.]+$. See Idempotent Requests for more details.

Maximum string length: 255
Pattern: ^[a-zA-Z0-9\-_:\.]+$

Body

application/json

Subscription One Time Charge

subscriptionId
string
required

Unique identifier of the subscription to charge against. The subscription's saved payment method will be used for this charge.

Example:

"sub_fooBOwYsaK50AEfK"

amount
integer<int64>
required

The amount in lowest count unit. e.g.: For USD 1, amount is 100 representing 100 cents. Must be within the currency's supported minimum and maximum bounds.

Example:

500

currency
string
required

Three letter abbreviation of the currency. Refer supported currencies

Example:

"USD"

comments
string

Optional free-form note describing the reason for this one-time charge.

Example:

"One-time setup fee for premium add-on"

Response

Subscription One Time Charge response

intentId
string

Unique identifier of the payment intent created for this one-time charge.

Example:

"in_gKAqR0DjLeOihdTE"

status
string

The status of the payment intent. Refer payment intent status

Example:

"SUCCESS"

errorCode
string | null

Machine readable failure reason when status is FAILED. null on a successful charge. See all possible values here.

Example:

"card_declined"

errorMessage
string | null

Human readable description of the failure reason when the charge was not successful. null on a successful charge.

Example:

"The payment has been declined by the customer's bank."