# Webhooks

Charges take 3-10 minutes to settle once the customer makes the payment. Once a charge is complete, you might require your internal systems and databases to be updated. You may also wish to take appropriate actions such as dispatching the order and updating inventory.

Webhooks can be used to facilitate communication between your system and XanPay. They can notify your system with the relevant information. Our Notification format is documented here. Your endpoint would need to extract the relevant fields and execute the relevant business logic. Please note that notification formats and can vary depending on the version of your API Notifications.

Following are the steps to be followed to setup webhooks.

# Set up an endpoint

A webhook is an HTTP endpoint that receives notifications. Begin by setting up an HTTP endpoint on your server which will process notifications from XanPay. When the status of a charge changes, XanPay will send an HTTP POST request to your endpoint. Your endpoint must check authorization and process the details sent in the request body.

# Basic Authorization

The username and password should be used by your endpoint to authenticate incoming requests from XanPay. While calling a your webhook URL, we send the HTTP Basic Authorization (opens new window) header with username:password encoded in base64 to help secure the request. We expect that your API decodes this string and checks the username and password parameters to protect itself from unauthorized calls.

# Register webhook

Once you have created an endpoint with the appropriate authentication, you can register your webhook on the XanPay dashboard (opens new window).

To register a webhook, you are required to enter the endpoint's URL, a username and a password for Basic authorization and a checkbox for adding the webhook to the Sandbox environment. UI for adding webhook

Whenever the status of a charge changes, we notify all webhooks that you have registered for the appropriate environment, Production or Sandbox.

If you choose not to use webhooks, and would still like to check charge status, you can retrieve current information regarding the charge via the REST API.

# Test webhook

We recommend testing the webhooks you set up in the dashboard. Click Send webhooks button in the Webhooks (opens new window) section to check if your webhook is being called. It is also recommend that you use Sandbox mode to test your workflow as described here.