---
title: Pay3 Webhooks
slug: crypto/pay3-webhooks
docTags: 
createdAt: 2023-11-24T05:06:16.486Z
---

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&#x20;**&#x6F;n receiving the data. The server side will retry sending the data 10 times.

```curl
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

```javascript
{
 
  "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

1. `data` : Following keys are present in this object.
   1. `orderId`: It provides a unique identification of the order which is managed by Pay3.
   2. `orderStatus`: It indicates the various status in which an order can be. Details about different kind of statuses can be find below [Order Status](docId\:zrZwEJX2fU4croVOWvGWN).&#x20;
   3. `paymentStatus`: It indicates the payment status of the order. Details about different kind of payment statuses can be find below [Payment Status](docId\:zrZwEJX2fU4croVOWvGWN).&#x20;
   4. `walletAddress` : It shows the wallet address assigned to the order.
2. `error` (Type Object, Optional): Following keys will be present if there is an error. Please refer to [SDK Errors](docId:94KYVQwbRSg1DFMLjddbS) for reference
   1. &#x20;`code` (Type number): Error code.
   2. `message` (Type string):  Error message.&#x20;
3. `requestId` : Request Id that was passed by App while initialising the modal.
4. `type` : Type of the event.&#x20;
   1\. For all Order status / Payment Status changes, the type will be **pay3-sdk-transaction-status**.&#x20;

Refer [Pay3 Order Status](docId\:zrZwEJX2fU4croVOWvGWN) 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 :&#x20;

```javascript
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.

***

