POST
/
subscription
/
create
curl --request POST \
  --url https://api.xpaycheckout.com/subscription/create \
  --header 'Authorization: Basic <encoded-value>' \
  --header 'Content-Type: application/json' \
  --data '{
  "amount": 100,
  "currency": "USD",
  "receiptId": "order123",
  "customerDetails": {
    "name": "John Doe",
    "email": "john.doe@example.com",
    "contactNumber": "9123456789",
    "customerAddress": {
      "addressLine1": "123 Main St",
      "addressLine2": "Apt 101",
      "city": "Los Angeles",
      "state": "California",
      "country": "United States",
      "postalCode": "123456"
    }
  },
  "description": "Order for 2 items",
  "callbackUrl": "https://example.com/callback",
  "interval": "MONTH",
  "intervalCount": 2,
  "cycleCount": 2,
  "upfrontAmount": 200
}'
{
  "subscriptionId": "66f53a6e2097773e4f0112c8",
  "createdAt": "2024-09-26T10:41:50.472+00:00",
  "fwdUrl": "https://pay.xpaycheckout.com/?subscription_id=67f53a6e2097773e4f0112c8"
}

Authorizations

Authorization
string
header
required

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

Body

application/json
Create Subscription
amount
integer
required

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)

currency
string
required

Three letter abbreviation of the currency. Refer supported currencies

customerDetails
object
required

Details about the customer

callbackUrl
string
required

The URL we will callback to with the order status once it finishes.

interval
enum<string>
required

The interval group between subscriptions.

Available options:
DAY,
WEEK,
MONTH,
YEAR
intervalCount
integer
required

The number of intervals between subscription billings. For example, interval = MONTH and intervalCount = 3 bills every 3 months.

cycleCount
integer
required

The number of billing cycles for which the subscription will renew before ending. The first cycle is included in this count.

receiptId
string

Your identifier of the order

description
string

Description of the order, if any

upfrontAmount
integer

The amount to be charged at the start of the subscription. The upfront amount replaces the first subscription cycle amount. Regular amount apply from the next cycle.

Response

200
application/json
Create Subscription response
subscriptionId
string

Unique identifier of the subscription

createdAt
string

Timestamp of when the subscription was created

fwdUrl
string

The URL to redirect the customer to the xPay payment gateway for payment.