Test Setup

Setting up

Testing and development with Xendit Subscriptions does not require an activated account. Once you register for a free Xendit account, you can begin testing via API immediately.

  1. To being testing Subscriptions with Xendit, first create a secret API key in test mode using Xendit dashboard. Make sure to assign permission for Money-In as WRITE
  2. Set up your preferrred Subscriptions callback URL in the Callbacks section of the Settings tab
  3. Follow and refer to our API Reference for details on request requirements

Simulating Statuses

In test mode, we recommend testing creation of Subscriptions plans using eWallets as the test scenarios are easily set up. The same result/ simulated flow should apply to all other payment methods. In test mode, Xendit uses magic numbers to help merchants complete their tests without complicated setups. Details on other payment methods are documented after the examples.

Success Plan Creation Simulation Example

POST https://api.xendit.co/recurring/plans 
{
  "reference_id": "test_reference_id",
  "customer_id": "cust-239c16f4-866d-43e8-9341-7badafbc019f",
  "recurring_action": "PAYMENT",
  "currency": "IDR",
  "amount": 13579,
  "schedule": {
    "reference_id": "test_reference_id",
    "interval": "MONTH",
    "interval_count": 1,
    "total_recurrence": 12,
    "anchor_date": "2022-02-15T16:23:52Z",
    "retry_interval": "DAY",
    "retry_interval_count": 3,
    "total_retry": 2,
    "failed_attempt_notifications": [2,4]
  },
  "immediate_action_type": "FULL_AMOUNT",
  "notification_config": {
    "recurring_created": ["WHATSAPP","EMAIL"],
    "recurring_succeeded": ["WHATSAPP","EMAIL"],
    "recurring_failed": ["WHATSAPP","EMAIL"],
    "locale": "en"},
  "failed_cycle_action": "STOP",
  "metadata": null,
  "description": "Video Game Subscription",
  "items": [
        {
            "type": "DIGITAL_PRODUCT",
            "name": "Cine Mraft",
            "net_unit_amount": 13579,
            "quantity": 1,
            "url": "https://www.xendit.co/",
            "category": "Gaming",
            "subcategory": "Open World"
        }
    ],
  "success_return_url": "https://www.xendit.co/successisthesumoffailures",
  "failure_return_url": "https://www.xendit.co/failureisthemotherofsuccess"
}
  • Perform account linking via eWallets on Xendit account linking page
  • Complete the flow until a success page is seen
  • Webhook notifications and end user notifications will be sent by Xendit

Failed Plan Creation Simulation Example

POST https://api.xendit.co/recurring/plans 
{
  "reference_id": "test_reference_id",
  "customer_id": "cust-239c16f4-866d-43e8-9341-7badafbc019f",
  "recurring_action": "PAYMENT",
  "currency": "IDR",
  "amount": 21110,
  "schedule": {
    "reference_id": "test_reference_id",
    "interval": "MONTH",
    "interval_count": 1,
    "total_recurrence": 12,
    "anchor_date": "2022-02-15T16:23:52Z",
    "retry_interval": "DAY",
    "retry_interval_count": 3,
    "total_retry": 2,
    "failed_attempt_notifications": [2,4]
  },
  "immediate_action_type": "FULL_AMOUNT",
  "notification_config": {
    "recurring_created": ["WHATSAPP","EMAIL"],
    "recurring_succeeded": ["WHATSAPP","EMAIL"],
    "recurring_failed": ["WHATSAPP","EMAIL"],
    "locale": "en"},
  "failed_cycle_action": "STOP",
  "metadata": null,
  "description": "Video Game Subscription",
  "items": [
        {
            "type": "DIGITAL_PRODUCT",
            "name": "Cine Mraft",
            "net_unit_amount": 21110,
            "quantity": 1,
            "url": "https://www.xendit.co/",
            "category": "Gaming",
            "subcategory": "Open World"
        }
    ],
  "success_return_url": "https://www.xendit.co/successisthesumoffailures",
  "failure_return_url": "https://www.xendit.co/failureisthemotherofsuccess"
}
  • Perform account linking via eWallets on Xendit account linking page
  • Complete the flow until a failed page is seen
  • Webhook notifications and end user notifications will be sent by Xendit

Success Cycle Simulation Example

  1. Simulate a Subscriptions Cycle with amount = 13579
POST https://api.xendit.co/recurring/plans/:plan_id/cycles/:id/simulate 
{
  "amount": 13579
}
  1. Webhook notifications and end user notifications will be sent by Xendit

Failed Cycle Simulation Example

  1. Simulate a Subscriptions Cycle with amount = 21110
POST https://api.xendit.co/recurring/plans/:plan_id/cycles/:id/simulate 
{ 
  "amount": 21110 
} 
  1. Webhook notifications and end user notifications will be sent by Xendit

List of Simulation Numbers

eWallets

Positive Scenario

ScenarioCriteriaExpected result
Successful paymentAmount = 135791. Linking process will be successful and related plan will become ACTIVE 2. Charge process on the scheduled date for the related cycle will be successful

Negative Scenario

ScenarioSimulation AmountExpected Result
Customer's account has been restricted by eWallet providerAmount = 21103ACCOUNT_ACCESS_BLOCKED failure code via callback
Customer's account detail is invalidAmount = 21106INVALID_ACCOUNT_DETAILS failure code via callback
Customer's account has reached maximum transaction limitAmount =21107MAXIMUM_LIMIT_REACHED failure code via callback
Insufficient balance on customer's walletAmount = 21110INSUFFICIENT_BALANCE failure code via callback

Cards

Cards - refer to (cards testing) for card numbers that work in test mode. Expiry dates and CVV can be random inputs.

Positive Scenario

ScenarioSimulation amountExpected result
Successful paymentAny number except magic numbers for the negative scenario1. Linking process will be successful and related plan will become ACTIVE 2. Charge process on the scheduled date for the related cycle will be successful

Negative Scenario

ScenarioSimulation AmountExpected Result
The card you are trying to capture has expiredAmount = 10051EXPIRED_CARD failure code via callback
The card you are trying to capture has been declined by the issuing bankAmount = 10052CARD_DECLINED failure code via callback
The card you are trying to capture does not have enough balance to complete the captureAmount = 10054INSUFFICIENT_BALANCE failure code via callback
The card you are trying to capture has been marked as stolenAmount = 10055STOLEN_CARD failure code via callback
The card you are trying to capture is inactiveAmount = 10056INACTIVE_CARD failure code via callback
The card you are trying to capture is declined due to cvn not matchedAmount = 10059INVALID_CVN failure code via callback

Direct Debit

Direct debit - refer to (direct debit testing) for account linking details in test mode.

Positive Scenario

ScenarioCriteriaExpected result
Sucessful paymentAny number except magic numbers for the negative scenario 1. Linking process will be successful and related plan will become ACTIVE 2. Charge process on the scheduled date for the related cycle will be successful

Negative Scenario

ScenarioSimulation AmountExpected Result
Transaction exceeds the channel’s allowed daily limitAmount = 11001MAX_AMOUNT_LIMIT_ERROR failure code via callback
End-customer’s balance is insufficient for the transactionAmount = 11002INSUFFICIENT_BALANCE failure code via callback
Channel has blocked access to the accountAmount = 11004ACCOUNT_ACCESS_BLOCKED failure code via callback

Last Updated on 2024-08-01