---
title: Callback URL
slug: callback-url
docTags: 
createdAt: 2025-05-02T10:40:00.253Z
---

### Introduction

The application can call transaction functions using an optional parameter called `callbackUrl`. Once this parameter is set Pay3 payment modal will **redirect** the user to this URL with in couple of seconds after transaction is complete. Pay3 payment modal also added an additional parameter `data` as a query parameter so that your user can be shown the transaction result within this page.&#x20;

This works well with the `mode=redirect` or `mode=returnUrl` where Pay3 will not be able to send Javascript events to the starting page.&#x20;

**Example**

```javascript
const checkoutObj = {
  "requestId": requestId,
  "user": {
    "email": "user@email.address"
  },
  "payment": [
    {
      "amount": "20.25",
      "name": "brl_bz",
    }
  ],
  "mode": "redirect",
  "callbackUrl": "https://your-whitelisted-url.com/xyz"
};
pay3Pay.openCheckout(checkoutObj);
```

### Payment Results

Payment results are added to the `callbackUrl` using a parameter `data`. The value of the parameter is a base64 encoded, JSON string of the result.&#x20;

**Sample code to decode the data payload**

```javascript
// After completing transaction, Pay3 payment modal will redirect
// to callbackUrl - For example
// https://your-whitelisted-url.com/xyz?data=eyJkYXRhIjp7InN0YXR1cyI6IlNVQ0NFU1MiLCJtZXNzYWdlIjoiVHJhbnNhY3Rpb24gY29tcGxldGVkIHN1Y2Nlc3NmdWxseSIsIm9yZGVySWQiOiIwOWQ4Mzc1Zi04MDUxLTQyNTctYWI0NC1hNTY1OGIzNTBiZDMiLCJyZXF1ZXN0SWQiOjQ2ODg3NywicmVjZWlwdCI6InR4blJlY2VpcHQifX0= 

data='eyJkYXRhIjp7InN0YXR1cyI6IlNVQ0NFU1MiLCJtZXNzYWdlIjoiVHJhbnNhY3Rpb24gY29tcGxldGVkIHN1Y2Nlc3NmdWxseSIsIm9yZGVySWQiOiIwOWQ4Mzc1Zi04MDUxLTQyNTctYWI0NC1hNTY1OGIzNTBiZDMiLCJyZXF1ZXN0SWQiOjQ2ODg3NywicmVjZWlwdCI6InR4blJlY2VpcHQifX0=';
resultObj = JSON.parse(atob(data));

/*
{
    "data": {
        "status": "SUCCESS",
        "message": "Transaction completed successfully",
        "orderId": "09d8375f-8051-4257-ab44-a5658b350bd3",
        "requestId": 468877,
        "receipt": "txnReceipt"
    }
}
*/
```

**Payload**

1. `data` (Type Object): Following keys are present in this object&#x20;
   1. `status` (Type string): The status can have one of these values - SUCCESS or ERROR or INITIATED.
   2. `message` (Type string): User-friendly message returned after completion of the transaction.
   3. `orderId` (Type string): Pay3 Order ID. &#x20;
   4. `requestId` (Type string): Unique ID passed by Application

### Whitelisting of Callback URL

The domain of the callback URL needs to be whitelisted for the clientId. Please reach out to support if you see following error. The domain needs to be whitelisted. According to the above example `https://your-whitelisted-url.com` needs to be whitelisted.

::Image[]{src="https://api.archbee.com/api/optimize/9JcgbaqQe2mz216pCFoHU/TAFeEm-pVk18eerzEFtTV_screenshot-2024-06-26-at-40348-pm.png" size="50" width="458" height="336" position="center" caption="Domain not whitelisted error" alt="Image of domain not whitelisted error" showCaption="true"}

***

