Paychant webhooks allow you to get automatic updates anytime the status on your widget instance changes.
The webhook will be called when the transaction reaches the processing status and also when it is complete. Once configured, your URL will receive notifications for the PROCESSING, COMPLETE, and FAILED statuses.
Once Webhook as been created, you can monitor all past and present event details in the logs.
Receiving Event
To start receiving event, you need to create unauthenticated POST route on your application.
constcrypto=require('crypto');constsecret=process.env.SECRET_KEY; // Your paychant webhook secret// Using Expressrouter.post("/webhook/url",function(req, res) {res.sendStatus(200); // Return status code 200 quickly// Validate event consthmac=crypto.createHmac('sha512', secret);consthash=hmac.update(JSON.stringify(req.body)).digest('hex');constheaderSig=req.headers['paychant-signature'];if (hash === headerSig) {var event =req.body;// Do someting with the event }});
<?php// Only a post method and headers that contain paychant-signature will be allowedif ((strtoupper($_SERVER['REQUEST_METHOD'])!='POST' ) ||!array_key_exists('paychant-signature', $_SERVER) ) {exit();}// Retrieve the request's body$input =@file_get_contents("php://input");// SET the SECRET KEYdefine('PAYCHANT_WEBHOOK_SECRET_KEY','SECRET_KEY');// Validate eventif($_SERVER['HTTP_PAYCHANT_SIGNATURE'] !==hash_hmac('sha512', $input, PAYCHANT_WEBHOOK_SECRET_KEY)){exit();}// Return status code 200 quicklyhttp_response_code(200);// Do someting with the event$event =json_decode($input);exit();?>php
For webhook notification event delivery to be satisfied, your endpoint must return a HTTP status code of 2xx to Paychant. All response codes outside this range, including 3xx codes, indicate to Paychant that you did not receive the event, and thus continue to send the notification event every 30 minutes for 24 hours. After 24 hours Paychant marks the event as failed and stops trying to send it to your endpoint.
Below is the list of the events when we send the webhook:
Buy (OnRamp)
Event Code
Description
CREATED
When the transaction is created.
AWAITING_PAYMENT
When the transaction state is expecting the user to make a payment.
PAYMENT_CONFIRMED
When we have received the fiat payment from the user.
PAYMENT_COMPLETED
When we have received the fiat payment and the crypto is successfully sent to the user.
PAYMENT_INSUFFICIENT
When we received the fiat payment but the amount of fiat sent by the user is not sufficient.
PAYMENT_TIMEOUT
When the user failed to make the fiat payment within the given timeframe.
PAYMENT_FAILED
There are a couple of things that can make a transaction fail, it can either be, a canceled transaction by the user, payment not made within the given timeframe, or a network connection problem.
Sell (OffRamp)
Event Code
Description
CREATED
When the transaction is created.
AWAITING_PAYMENT
When a wallet address is generated for the user to send the crypto payment.
PAYMENT_CONFIRMED
When the crypto payment is received & the fiat transfer is initiated via our fiat vendor.
PAYMENT_COMPLETED
When the fiat transfer is successfully delivered to the user's bank account or mobile wallet by our fiat vendor.
PAYMENT_INSUFFICIENT
When we received the crypto payment but the amount of crypto sent by the user is not sufficient.
PAYMENT_TIMEOUT
When the user failed to make the crypto payment within the given timeframe.
PAYMENT_FAILED
There are a couple of things that can make a transaction fail, it can either be, a canceled transaction by the user, payment not made within the given timeframe, or a network connection problem.