Subscription is a solution for managing recurring payments using Xendit's scheduler. It offers an easy and flexible integration, allowing you to configure and automate recurring payment cycles based on your setup. By using the Subscriptions product, you eliminate the need to build your own scheduling system, including handling failed payment recovery. Xendit optimizes the success rate of payments through features designed specifically for subscription management.
High level data objects
Data object name | Description | Created by |
---|---|---|
Plan | The primary data object for managing your subscription logic. It contains details such as the customer object, the amount to be deducted for each cycle, the schedule object, and the basic subscription plan configurations, including optional features. | You |
Schedule | Defines when subscription actions should occur. It includes merchant-defined timing details, such as intervals (e.g., daily, monthly, yearly) and retry logic. The schedule object can be created simultaneously with the subscription plan to enable plan customization for each customer. | You |
Cycle | Automatically generated based on the subscription plan object. Each subscription cycle represents an individual billing instance (e.g., a monthly plan for a year generates 12 cycles). Ad hoc changes can be made to specific cycles without affecting the base subscription plan. The subscription plan has a one-to-many relationship with its cycles. | Xendit |
Attempt | Represents each action taken to complete a subscription cycle (e.g., payments). Multiple attempts may occur within a single cycle depending on the retry configuration (e.g., a cycle with two retries can have up to three attempts). All attempts are stored within the corresponding cycle object. Each subscription cycle has a one-to-many relationship with its attempts. A single attempt can involve multiple | Xendit |
Integration flow
Example of integration flow if you are about to set up Subscriptions payment for your end user
Once the end user selects a subscription plan in your system, create the corresponding subscription plan in Xendit.
Use an existing
customer_id
if the customer is already registered in Xendit. Otherwise, create a new customer at this step.Create the subscription plan with the
customer_id
and agreed details (e.g., schedule, interval).If you already have your end user's linked payment method, provide the
payment_method_id
when creating the subscription. If you do not include it, Xendit will return aREQUIRES_ACTION
status and generate aaction
object to be executed. Thisaction.url
can be shared with your customer, allowing them to link their payment method on the Xendit-hosted page.Redirect the customer to the Xendit-hosted page using the
action.url
.The customer links their payment method on the Xendit-hosted page.
Once the payment method is linked, receive the
recurring.plan_activation
webhook, and the plan becomes active. See the Plan lifecycle below.Xendit processes subscription cycles based on the
anchor_date
andinterval
.For each cycle, receive webhooks indicating status updates:
recurring.cycle.created
: A new cycle is created.recurring.cycle.retrying
: A payment attempt failed, but a retry is scheduled onnext_retry_timestamp
.recurring.cycle.failed
: All retry attempts have failed.recurring.cycle.succeeded
: Payment for the cycle was successful.
Plan lifecycle
Status | Description | Webhook event |
---|---|---|
Requires Action | The subscription plan is in Redirect the end user to the | |
Pending | If | |
Active | The plan is |
|
Inactive | The plan becomes |
|
Cycle lifecycle
Status | Description | Webhook event |
---|---|---|
Created | The cycle has been created and is ready to execute based on the |
|
Retrying | If the first attempt fails and the plan has a retry configuration, you will receive the |
|
Succeeded | The cycle payment succeeded. You will receive the |
|
Failed | The cycle payment failed. You will receive the |
|