A subscription comprises three parts:
product name
price
id
key referring to SKU
is optional, but if provided, it will be considered unique for a merchant and can't be added to another product object.In the case of updating product prices, the plans and subscriptions associated with the products won't be updated automatically.
Update Subscription API
will need to be called to update the price of each product for a subscription.{
"payment": {
"latest_product_price": true
},
"product": [
{
"name": "Ali",
"product_id": "xpay_product_90e8c92b774641adad16325722fe8c20",
"quantity": 1
},
{
"name": " Raza",
"product_id": "xpay_product_e302a0a0ec984e18aadd09e296323c8c",
"quantity": 1
}
],
}
A plan is a schedule defining how merchants intend to collect recurring payments.
interval
, every
, etc.billing_cycle_anchor_config
, which lets you specify the exact point when the billing cycle should start.
interval
is month
, pass { day_of_month: <1–31> }
interval
is week
, pass { day_of_week: <0–6> }
(0 = Sunday, 6 = Saturday)interval
is year
, pass { month: <1–12>, day_of_month: <1–31> }
Interval |
---|
day |
week |
month |
year |
Update Subscription API
with Plan ID to update individual subscriptions.{
"plan_id": "xpay_plan_6f51cae83bbb45bd8588fe0c95e4c2b6"
}
<aside> ⚠️
<aside> 💡 To update a subscription's pricing, billing cycle, etc., kindly refer to Update a Subscription’s Schedule / Payment.
</aside>
By default, the price of each product will add up to the plan price. However, XPay supports manually adding amounts and currencies if pricing needs to be changed based on frequency, etc. In this case, the Create Plan API
expects the amount: number
, and currency: string
to be passed.
start_date
, plan_id
, timezone
, and payment_token
need to be mentioned.<aside> ⚠️ The subscription is not created at the customer but at the plan level. If different plans are offered to multiple customers, then merchants will save those plans in their system.
</aside>
Status | Reason |
---|---|
inactive |
Payment Failed |
paid |
Payment successful |
draft |
Created but no action performed |
XPay will create an invoice
for every recurring payment.
paid
but the third fails.start_date
and plan
provided.This is the use case where
The merchant can do this if the Payment Method token doesn’t exist.
confirmPayment()
SDK to authenticate, authorize, and collect payment method tokens.Create Subscription API
. XPay will create a subscription and start collecting recurring payments per the payload.Create Subscription API
.