Pay3 Webhooks
As an order progresses through it's lifecycle, Pay3 shares webhook events with the App's backend about the status of order and other relevant details. This page explains different status and the information related to the webhook. This page also explains how a App can consume the events towards the end of this page.
API Signature
The application needs to share an API endpoint to which Pay3 service will be sending a webhook as a POST request with a payload which contains webhook data. Below is an example curl of how Pay3 service will be calling the provided webhook endpoint with the data. The API needs to respond back with http status code 200 on receiving the data. The server side will retry sending the data 10 times.
curl --location 'https://your-host-webhookserver.com/sample-webhook-path' \
--header 'Content-Type: application/json' -X POST \
--data '{
"payload": "eyJhbGciOiJIUzM4NCJ9.eyJvcmRlclR5cGUiOiJGSUFUIiwib3JkZXJJZCI6IjdhZWQwNjRiLWNiMmQtNDJmOC05NTYwLTc3NDEzZGNjNWZjNCIsIm9yZGVyU3RhdHVzIjoiQ09NUExFVEVEIiwib2ZmZXJJZCI6IjMzMGNkNGJiLTE4YTUtNGVkZC1hMWY0LWNkMzczMzU2ZGEwOCJ9.DmIg6ontoWke1hEGVV62gDDNKlT9L3fcRQRWemnLqjf565pH28L3_Nr7_b1C2KTp"
}'Sample Payload
Below is an example payload which is received in the webhook events provided by Pay3
{
"requestId": "ed821e55-7084-467c-9e3f-4279e4d39c97"
"data": {
"orderType": "CHECKOUT",
"orderId": "9c4dd5b3-64de-4d94-b696-3e92cd6b12ba",
"orderStatus": "COMPLETED"
"walletAddress": "0x..."
},
"type": "pay3-sdk-transaction-status"
}Payload Schema
- data : Following keys are present in this object.
- orderType: Indicates the type of order for which the event is sent for. If the given order contains a crypto transaction as well as fiat transaction, two events of different order types will be sent for the same orderId.
- CHECKOUT - Payment done by user using Fiat currency
- PAYOUT - Withdraw Fiat request done by user
- CRYPTO - Payment done by user using Crypto currency
- orderId: It provides a unique identification of the order which is managed by Pay3.
- orderStatus: It indicates the various status in which an order can be. Details about different kind of statuses can be find below (Order Status).
- paymentStatus: It indicates the payment status of the order. Details about different kind of payment statuses can be find below (Payment Status)
- walletAddress: It shows the wallet address assigned to the order.
- error (Type Object, Optional): Following keys will be present if there is an error. Please refer to SDK Errors for reference
- code (Type number): Error code.
- message (Type string): Error message.
- requestId : Request Id that was passed by App while initialising the modal.
- type : Type of the event. 1. For all Order status / Payment Status changes, the type will be pay3-sdk-transaction-status.
Refer Status Reference for all order and payment status details.
Usage of Webhooks functionality
The payload of webhooks is in the form of Json Web Tokens (JWT). These tokens can be decoded using a secret to retrieve the status for a given order. This secret will be shared by Pay3 team.
Sample code to decode data :
const jwt = require('jsonwebtoken');
let inputData = 'eyJhbGciOiJIUzM4NCJ9.eyJvcmRlclR5cGUiOiJGSUFUIiwib3JkZXJJZCI6IjdhZWQwNjRiLWNiMmQtNDJmOC05NTYwLTc3NDEzZGNjNWZjNCIsIm9yZGVyU3RhdHVzIjoiQ09NUExFVEVEIiwib2ZmZXJJZCI6IjMzMGNkNGJiLTE4YTUtNGVkZC1hMWY0LWNkMzczMzU2ZGEwOCJ9.DmIg6ontoWke1hEGVV62gDDNKlT9L3fcRQRWemnLqjf565pH28L3_Nr7_b1C2KTp';
let secret = 'YOUR_CLIENT_SECRET';
let decodedData = jwt.verify(data, secret);
Some of our downstream partners don't provide with all the statuses , in those cases some events might be skipped. But COMPLETED / FAILED will always be the terminal events.