Webhook in Xendit works to let your application or website know when events happen.
In Xendit, webhook 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.
Webhook URL Set Up Criteria
In order to handle a 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 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 webhook URL (22.214.171.124);
- Able to send back a response with the status after webhook has been received;
- Able to specify the webhook endpoint for the product.
Webhook Set Up Guide
Below are few simple steps to set up webhook URL in Xendit:
- 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 left 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 'Webhook' section on Settings Page
Enable auto-retry for failed webhook.
- This should be done to have a better experience in handling your webhook
Obtain your webhook verification token.
- Click View "Webhook 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 webhook URL.
- Choose which product (payment method) that you want to set the webhook URL for;
- Fill up your URL handling for the webhook under the webhook URL section according to the product (payment method) you are going to use in Xendit.
In order for you to setup a webhook, you must have a webhook URL to listen to webhook;
- In this context, we will use Invoice as a journey example for your webhook;
- In this example, we are using
https://hendry-sukses.com/webhook.phpas 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 webhook URL set, we’ll cover that later.
- You might be seeing
Follow the tutorial on this link:
The endpoint that will be used is as follows:
Make sure that you have inputted the correct API Key on the right place;
- Input TEST Secret API Key to change webhook URL on TEST Mode;
- Input LIVE Secret API Key to change webhook URL on LIVE Mode;
Input one of the webhook type on the ":type" endpoint path parameters that is listed below;
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.
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 with
ph_disbursement: Notification when disbursement on the Philippines account has been executed successfully, either with
- Input the desired webhook URL for your sub account on the request body under parameter "url";
- Click "Send";
If the webhook URL is successfully updated, parameter status on API response will return “SUCCESSFUL”.
For more reference about webhook, you can refer to your knowledge documentation below: