English
API ReferenceSign In

Testing

Last updated 03/18/2021

This section will explain how to simulate Virtual Account transactions from creating Virtual Accounts, making payments, and getting notifications / callbacks from successful transactions via the Virtual Account API. For a guide to simulating a Virtual Account with xenInvoice, please visit the following page.

Pra Testing

Make sure you have done the following steps before performing the simulation:

  1. Register Xendit account
  2. Make sure you have enabled the Virtual Account payment method in your settings. In the same section, you can also see the range of Virtual Account numbers provided for Fixed Virtual Accounts and Non-Fixed Virtual Accounts (Virtual Account xenInvoice).
  3. You are in test mode and get your secret API key which you can generate from your dashboard. Please take a note that you need write access to be able to create a Virtual Account.
  4. Download Postman and Xendit Collection. For further guidance about Postman, please visit the following article.
  5. Learn Virtual Account API by visiting our API Reference.
  6. Once you've completed the steps above, you're ready to start testing!

Test 1: Creating Fixed Virtual Account

Send POST request to https://api.xendit.co/callback_virtual_accounts using the secret API Key via Postman. See request parameters in Xendit API Reference.

Example Request

{
   "external_id": "VA_fixed-{{$timestamp}}",
   "bank_code": "MANDIRI",
   "name": "Ismail Rabbanii"
}

Example Response

{
    "is_closed": false,
    "status": "PENDING",
    "currency": "IDR",
    "owner_id": "5fd1c319b9986239d7ec5567",
    "external_id": "VA_fixed-1615935264",
    "bank_code": "MANDIRI",
    "merchant_code": "88608",
    "name": "Ismail Rabbanii",
    "account_number": "886089999497724",
    "is_single_use": false,
    "expiration_date": "2052-03-16T17:00:00.000Z",
    "id": "60513720d0435601d9d43e5e"
}

Test 2: Simulating Payment for Fixed Virtual Account

There are two options to simulate a payment on a Virtual Account:

Option 1: Send a POST request to https://api.xendit.co/callback_virtual_accounts/external_id={external_id}/simulate_payment for simulated payment using external_id . If you create multiple Virtual Accounts using the same external_id, then the payment simulation with external_id will be referred to the earliest virtual account that was created with that external_id.

Example Request

{
    "amount": 50000
}

Example Response

{
    "status": "COMPLETED",
    "message": "Payment for the Fixed VA with external id VA_fixed-1615935264 is currently being processed. Please ensure that you have set a callback URL for VA payments via Dashboard Settings and contact us if you do not receive a VA payment callback within the next 5 mins."
}

Option 2: Send a POST request to https://api.xendit.co/pool_virtual_accounts/simulate_payment for simulated payments using the Virtual Account number directly. You need to enter the request parameters as follows: bank_code, bank_account_number, and transfer_amount.

Example Request

{
    "transfer_amount": 10000,
    "bank_account_number":"886089999497724",
    "bank_code": "MANDIRI"
}

Example Response

{
    "status": "COMPLETED",
    "message": "Payment for the Pool VA is currently being processed. Please ensure that you have set a callback URL for Invoice payments via Dashboard Settings and contact us if you do not receive an Invoice payment callback within the next 5 mins."
}

Test 3: Updating Fixed Virtual Account

Send a PATCH request to https://api.xendit.co/callback_virtual_accounts/{fixed_virtual_account_id} using a secret API Key. Enter the parameters as listed in https://developers.xendit.co/api-reference/#update-virtual-account.

Example Request

{
   "expiration_date": "2022-03-16T17:00:00.000Z"
}

Example Response

{
    "is_closed": false,
    "status": "PENDING",
    "currency": "IDR",
    "owner_id": "5fd1c319b9986239d7ec5567",
    "external_id": "VA_fixed-1615935264",
    "bank_code": "MANDIRI",
    "merchant_code": "88608",
    "name": "Ismail Rabbanii",
    "account_number": "886089999497724",
    "is_single_use": false,
    "expiration_date": "2022-03-16T17:00:00.000Z",
    "id": "60513720d0435601d9d43e5e"
}

Test 4: Setting up Virtual Account Callback URL

Please set up your two notification / callback URLs for every Virtual Account created and paid for at https://dashboard.xendit.co/settings/developers#callbacks. Note: For further guidance regarding notifications / callbacks please visit https://developers.xendit.co/api-reference/#get-virtual-account-payment.

Example Callback Virtual Account: Created

{
    "is_closed": false,
    "status": "ACTIVE",
    "currency": "IDR",
    "owner_id": "5fd1c319b9986239d7ec5567",
    "external_id": "VA_fixed-1615935264",
    "bank_code": "MANDIRI",
    "merchant_code": "88608",
    "name": "Ismail Rabbanii",
    "account_number": "886089999497724",
    "is_single_use": false,
    "expiration_date": "2022-03-16T17:00:00.000Z",
    "id": "60513720d0435601d9d43e5e"
}

Example Callback Virtual Account: Paid

{
    "updated": "2017-02-15T11:01:52.896Z",
    "created": "2017-02-15T11:01:52.896Z",
    "payment_id": "1487156512722",
    "callback_virtual_account_id": "58a434ba39cc9e4a230d5a2b",
    "owner_id": "5824128aa6f9f9b648be9d76",
    "external_id": "fixed-va-1487156410",
    "account_number": "1001470126",
    "bank_code": "MANDIRI",
    "amount": 80000,
    "transaction_timestamp": "2017-02-15T11:01:52.722Z",
    "merchant_code": "88464",
    "id": "58a435201b6ce2a355f46070"
}

Example Callback Virtual Account: Expired

{
    "is_closed": false,
    "status": "INACTIVE",
    "currency": "IDR",
    "owner_id": "5fd1c319b9986239d7ec5567",
    "external_id": "VA_fixed-1615935264",
    "bank_code": "MANDIRI",
    "merchant_code": "88608",
    "name": "Ismail Rabbanii",
    "account_number": "886089999497724",
    "is_single_use": false,
    "expiration_date": "2021-03-16T17:00:00.000Z",
    "id": "60513720d0435601d9d43e5e"
}

Note: if you want to get a callback for the expiry VA, you can ask us to activate it for you through help@xendit.co.

Test 5: Verifying Virtual Account Callback

To verify whether the callback you receive is from Xendit, send a GET request to https://api.xendit.co/callback_virtual_account_payments/payment_id={payment_id} using the secret API Key.

Example Response

{
    "payment_id": "604f42fdf29b9863574cc671",
    "callback_virtual_account_id": "604f42714e7bca4030ceed7c",
    "external_id": "VA_fixed-1615935264",
    "account_number": "9999166585",
    "bank_code": "MANDIRI",
    "amount": 50000,
    "transaction_timestamp": "2021-03-15T11:20:29.000Z",
    "merchant_code": "88908",
    "currency": "IDR",
    "id": "604f42fdfcd42e2d1c7f210f"
}