About Callback
Callback or Webhook in Xendit works to let your application or website know when events happen.
In Xendit, callback works when a payment has been processed successfully by Xendit, or refunded or failed, so your system can act accordingly based on the payment status.
Callback Set Up Criteria
In order to handle a callback or webhook, you only need to build a small web application that can accept the HTTP requests. If you already have a web application set up, handling a Webhook is usually as easy as adding a new URL to your application.
To be able to set up webhook/callback url in Xendit, your business application/website needs to fulfill several criteria listed below:
- A LIVE (Public) Website URL;
- Have HTTPS;
- No localhost (localhost://invoice-paid);
- No Port (invoice.com:4444/paid.);
- No IP in callback URL (1.1.1.1);
- Able to send back a response with the status after it has been received;
- Able to specify the callback endpoint for the product.
Callback Set Up Guide
Below are few simple steps to set up callback in Xendit:
via Dashboard
- Sign in or sign up to your Xendit Account
- Make sure you are on the right environment ("Live Mode" or "Test") on the toggle on the top right corner
- Put the toggle in "Live Mode" if you wish to generate API for Live / Production Mode where you will integrate to transact with real money;
- Put the toggle in "Test Mode" if you wish to generate API for Test / Sandbox Mode where you will integrate just to do transaction testing with fictional money;
- Once logged in to your Xendit Dashboard, choose 'Settings'
- Click 'Callback' section on Settings Page
- Enable auto-retry for failed callback.
- This should be done to have a better experience in handling your callback
- This should be done to have a better experience in handling your callback
- Obtain your callback verification token.
- Click View "Callback Verification Token";
- Enter your password;
- Keep that token inside your server side.
- This token will be used to verify message authenticity later on.
- Set up your callback URL.
- Choose which product (payment method) that you want to set the callback URL for;
- Fill up your URL handling for the callback under the Callback URL section according to the product (payment method) you are going to use in Xendit.
- In order for you to setup a callback, you must have a callback URL to listen to callback;
- In this context, we will use Invoice as a journey example for your callback;
- In this example, we are using
https://hendry-sukses.com/webhook.php
as an example for your reference.
- Click save and test.
- You might be seeing
NO_RESPONSE
, but do not worry.- This is normal and expected, because you might not yet set the listener for the callback URL set, we’ll cover that later.
- This is normal and expected, because you might not yet set the listener for the callback URL set, we’ll cover that later.
- You might be seeing
via API
Follow the tutorial on this link:
https://developers.xendit.co/api-reference/#set-callback-urls
- The endpoint that will be used is as follows:
POST https://api.xendit.co/callback_urls/:type
- Make sure that you have inputted the correct API Key on the right place;
- Input TEST Secret API Key to change callback URL on TEST Mode;
- Input LIVE Secret API Key to change callback URL on LIVE Mode;
- Input one of the callback type on the ":type" endpoint path parameters that is listed below;
- Money-in
invoice
: Notification when Invoice has been paid or expired;payment_method_v2
: Notification when payment method V2 is expiring and/or has activated or expired;payment_method
: Notification when payment method is expiring and/or has expired;- Payment Method is a mandatory step to abstract Debit Card / Bank Account for Direct Debit transactions;
direct_debit
: Notification for any Direct Debit successful payment event;ewallet
: New eWallet type to receive charge and other eWallet events across eWallets channels from /ewallets/charges API;fva_status
: Notification when Virtual Account in Indonesia has been created or updated successfully;fva_paid
: Notification when Virtual Account in Indonesia has been paid successfully;ro_fpc_paid
: Notification when Retail Outlet payment code (Alfamart/Indomaret) in Indonesia has been paid successfully;regional_ro_paid
: Notification when Over-the-Counter payment code (7 Eleven, Cebuana, ECPay) in Philippines has been paid successfully.
-
Money-Out
batch_disbursement
: Notification when Batch Disbursement on Indonesian accounts have been executed successfully by Xendit.disbursement
: Notification when disbursement on Indonesian account has been executed successfully, either withCOMPLETED
orFAILED
status;ph_disbursement
: Notification when disbursement on the Philippines account has been executed successfully, either withCOMPLETED
orFAILED
status;
- Money-in
- Input the desired callback URL for your sub account on the request body under parameter "url";
- Click "Send";
- If the callback URL is successfully updated, parameter status on API response will return “SUCCESSFUL”.
For more reference about Callback or Webhook, you can refer to your knowledge documentation below: