If you want to make recurring payment for your user, you can use Subscription API. For example of usage, check Postman Collection
Per current implementation, recurring payment is only supported by Xendit gateway. Here are the recurring payment features:
- Supported payment method: Credit Card, Bank Transfer VA, OVO
- User can make n times recurring payment. If you specify
0
fortotal_recurrence
, it creates unlimited number of recurring payment. - User can
Create
,Pause
,Resume
andStop
subscription. - User can choose its payment method through Xendit Invoice every time they want to pay invoice. If credit card is used once, the next payment will be done automatically by charging the credit card.
Notes:
-
If user specify
card_token
in subscription create request, the card will directly be charged. You can leave it blank in order to use other payment method. -
If user doesnt pay the latest invoice, the next invoice will still be sent to the user on the next period. If you want to automatically stop the subscription when the invoice is not paid, please change this following line in subscription.go to
MissedPaymentAction: MissedPaymentActionStop,
This default value will be configured through configuration file later.
- You can use any integer as
schedule.interval
. day
,month
andyear
are the valid values forschedule.interval_unit
- If
charge_immediately
istrue
,schedule.start_at
will be ignored and automatically set to now. - If
charge_immediately
isfalse
,schedule.start_at
must not be empty.
POST /payment/subscriptions
{
"name": "Imre Subscription",
"description": "Mantul",
"amount": 10000,
"user_id": "imre@gmail.com",
"currency": "IDR",
"total_recurrence": 2,
"card_token": "",
"charge_immediately": true,
"schedule": {
"interval": 1,
"interval_unit": "day",
"start_at": "2020-06-10T00:00:00.000Z"
}
}
If you are using xendit and charge the user immediately, last_created_invoice
will not be empty. Use this to redirect
your user to payment page.
{
"id": 8,
"number": "9b9f1999-b2c8-4eb3-8188-23a115237a4c",
// redacted ....
// .....
"charge_immediately": true,
"last_created_invoice": "https://invoice-staging.xendit.co/web/invoices/5edc5b024eb7c20fe6c8ae91",
"status": "ACTIVE",
"recurrence_progress": 0
}