A subscription comprises three parts:
product nameprice
id field referring to SKU is an optional field, 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.| Interval |
|---|
day |
week |
month |
year |
Update Subscription API with Plan ID to update individual subscriptions.{
"plan_id": "xpay_plan_6f51cae83bbb45bd8588fe0c95e4c2b6"
}
If plan_id is added, it will update the latest billing cycle, products, and payment from the plan ID and override any such value being added in the payload.
<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 level but at the plan level. If different plans are offered to different 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 |
For every recurring payment, XPay will create an invoice.
paid but the third one 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 and collect_advance: false to be set. XPay will create a subscription and start collecting recurring payments as per the schedule.