---
title: Create Crypto Refund with UI
slug: crypto/create-crypto-refund-with-ui
docTags: 
createdAt: 2025-05-02T10:40:00.252Z
---

This API creates a crypto refund order to enable merchants to refund a successfully processed crypto  transaction. It accepts amount, orderId and the other order details.  &#x20;

This API requires access token that can be generated using [Access Token](docId\:lq-v6fF_2i-h1O3XD5KKA) API.

:::ApiMethodV2
```json
{
  "name": "Create Refund ",
  "method": "POST",
  "url": "https://your-hostname.pay3.app/v1/client/crypto-refund/create-order",
  "description": "Create an order with refund details from your application's backend",
  "tab": "examples",
  "examples": {
    "languages": [
      {
        "id": "eXhyHL9RWXfgU_lG6oq1Q",
        "language": "curl",
        "code": "curl --location 'https://api.pprod.pay3.app/v1/client/crypto-refund/create-order' \\\n--header 'signature: {{signature}}' \\\n--header 'Access-token: {{access-token}}' \\\n--header 'Content-Type: application/json' \\\n--data '{\n    \"clientId\":\"\",\n    \"requestId\":\"\",\n    \"orderId\":\"\",\n    \"amount\": \"1.0\",\n    \"currency\": \"usdc_sepolia\",\n    \"mode\":\"returnUrl\",\n    \"sponsorFee\":false\n}'",
        "customLabel": ""
      }
    ],
    "selectedLanguageId": "eXhyHL9RWXfgU_lG6oq1Q"
  },
  "results": {
    "languages": [
      {
        "id": "VQyRchSR38UbBEhATUpjh",
        "language": "200",
        "code": "{\n    \"token\": \"d0614ad6-91a5-4bf4-8e87-f4907b5b8fce\",\n    \"requestId\": \"4a7ee93e-7eb7-4e80-9cc7-4faf804bc183\",\n    \"url\": \"https://pay3-sample-payment-Url\"\n}",
        "customLabel": ""
      }
    ],
    "selectedLanguageId": "VQyRchSR38UbBEhATUpjh"
  },
  "request": {
    "pathParameters": [],
    "queryParameters": [],
    "headerParameters": [
      {
        "name": "signature",
        "kind": "required",
        "type": "string",
        "description": "Signature generated with sha256 followed by base64 encoding. Check below section for more details",
        "children": []
      },
      {
        "name": "access-token",
        "kind": "required",
        "type": "string",
        "description": "Access token received from Access token API. You can reuse the access token across multiple API calls till it is expired",
        "children": []
      }
    ],
    "bodyDataParameters": [
      {
        "name": "orderId",
        "kind": "required",
        "type": "string",
        "description": "The orderId of the parent order, this can be found in the dashboard or from Order details API.",
        "": "The orderId of the parent order, this can be found in the dashboard or from Order details API."
      },
      {
        "name": "requestId",
        "kind": "required",
        "type": "string",
        "description": "Identifier that is created by client application's backend. This will be passed in relevant events and webhooks from Pay3 to Application",
        "": "requestId"
      },
      {
        "name": "clientId",
        "kind": "required",
        "type": "string",
        "description": "Client id. Application's identifier",
        "children": []
      },
      {
        "name": "mode",
        "kind": "required",
        "type": "string",
        "description": "Set the mode to returnUrl, the API response includes an additional field url, which provides a direct  page link for processing crypto refunds. This provides an option to enter the wallet address in UI.\n\n\"returnUrl\" is only supported mode.",
        "": "Set the mode to returnUrl, the API response includes an additional field url, which provides a direct  page link for processing crypto refunds. This provides an option to enter the wallet address in UI.\n\n\"returnUrl\" is only supported mode."
      },
      {
        "name": "amount",
        "kind": "optional",
        "type": "string",
        "description": "Amount in crypto user can be refunded in string format. This amount should be less than or equal to the parent order amount. This parameter is required when \"fiatAmount\" is not passed. Maximum two decimal places are allowed.",
        "": "Amount in crypto user can be refunded in string format. This amount should be less than or equal to the parent order amount. This parameter is required when \"fiatAmount\" is not passed. Maximum two decimal places are allowed."
      },
      {
        "name": "currency",
        "kind": "optional",
        "type": "string",
        "description": "The currency is Pay3's unique string ID denoting the token that needs to be purchased. This param is required along \"with \"amount\" param when \"fiatAmount\" is not passed. \n\nIt has to be same type that of the parent order for which refund is being created.\n\nExample value are btc_bitcoin, usdt_polygon, usdc_etehreum , usdt_tron , uni_eth. ",
        "": "The currency is Pay3's unique string ID denoting the token that needs to be purchased. This param is required along \"with \"amount\" param when \"fiatAmount\" is not passed. \n\nIt has to be same type that of the parent order for which refund is being created.\n\nExample value are btc_bitcoin, usdt_polygon, usdc_etehreum , usdt_tron , uni_eth. "
      },
      {
        "name": "fiatAmount",
        "kind": "optional",
        "type": "string",
        "description": "Amount in Fiat say USD (eg: 10.50). This parameter is required when \"amount\" is not passed. This amount should be less than or equal to the parent order amount.\nExample values for ten dollar fifty cents is 10.50",
        "": "Amount in Fiat say USD (eg: 10.50). This parameter is required when \"amount\" is not passed. This amount should be less than or equal to the parent order amount.\nExample values for ten dollar fifty cents is 10.50"
      },
      {
        "name": "fiatCurrency",
        "kind": "optional",
        "type": "string",
        "description": "Fiat currency code is Pay3's unique string ID denoting the fiat currency. This parameter is required along with fiatAmount when \"amount\" param is not passed. Pay3 uses current exchange rate to translate fiatAmount to amount.\nSupported fiat currencies are usd_usa, gbp_gb , aed_ae and eur_eu.",
        "": "Fiat currency code is Pay3's unique string ID denoting the fiat currency. This parameter is required along with fiatAmount when \"amount\" param is not passed. Pay3 uses current exchange rate to translate fiatAmount to amount.\nSupported fiat currencies are usd_usa, gbp_gb , aed_ae and eur_eu."
      },
      {
        "name": "sponsorFee",
        "kind": "optional",
        "type": "string",
        "description": "When sponsorFee is set to false(default), the amount is sent to the destination address (user's address) after deducting the gas fees.\n\nWhen sponsorFee is set to true, the complete amount is sent to the destination address.\n",
        "": "When sponsorFee is set to false(default), the amount is sent to the destination address (user's address) after deducting the gas fees.\n\nWhen sponsorFee is set to true, the complete amount is sent to the destination address.\n"
      },
      {
        "name": "userId",
        "kind": "optional",
        "type": "string",
        "description": "Pass any string for the user (uniqueId) to identify and map the orders against the user. This can be same value which you are using in your application to uniquely identify the users.",
        "": "Pass any string for the user (uniqueId) to identify and map the orders against the user. This can be same value which you are using in your application to uniquely identify the users."
      },
      {
        "name": "Parameter name",
        "kind": "optional",
        "type": "string",
        "description": "",
        "children": []
      }
    ],
    "formDataParameters": []
  },
  "currentNewParameter": {
    "label": "Body Parameter",
    "value": "bodyDataParameters"
  },
  "hasTryItOut": false,
  "autoGeneratedAnchorSlug": "create-refund",
  "legacyHash": "s1MVV-x5s_t_WktqzDlSQ"
}
```
:::

## Signature Generation

The request for creating payout order requires a header `signature`. This can be generated using following javascript code snippet.&#x20;

### Case 1: With fiatAmount & fiatCurrency parameter&#x20;

```javascript
const crypto = require('crypto');

// Required Parameters
const secretKey="Api-Secret-Provided-By-Pay3";
const fiatAmount =  "0.02";
const fiatCurrency = "aed_ae";
const orderId = "Order_ID_Of_the_Pay-in_Order";
const requestId = "Order-Id-Generated-By-Application";

const getSignature = (secretKey, fiatAmount, fiatCurrency , orderId ,requestId) => {
    // Prepare the string to sign in same format. 
   
    const stringToSign = 'fiatAmount=' + fiatAmount + '&fiatCurrency=' + fiatCurrency + '&orderId=' + orderId + '&requestId=' + requestId;
    
    // Generating signature using SHA256 and provided secret and
    // base64 encode the result
    const mac = crypto.createHmac('sha256', secretKey);
    return mac.update(stringToSign).digest('base64');
}

// Generate Signature
const signature = getSignature(secretKey, fiatAmount, fiatCurrency , orderId ,requestId);

```

***

### Case 2: With amount parameter&#x20;

```javascript
const crypto = require('crypto');

// Required Parameters
const secretKey="Api-Secret-Provided-By-Pay3";
const amount =  "0.02";
const currency = "usdc_ethereum";
const orderId = "Order_ID_Of_the_Pay-in_Order";
const requestId = "Order-Id-Generated-By-Application";

const getSignature = (secretKey, amount, currency , orderId ,requestId) => {
    // Prepare the string to sign in same format. 
   
    const stringToSign = 'amount=' + amount + '&currency=' + currency + '&orderId=' + orderId + '&requestId=' + requestId;
    
    // Generating signature using SHA256 and provided secret and
    // base64 encode the result
    const mac = crypto.createHmac('sha256', secretKey);
    return mac.update(stringToSign).digest('base64');
}

// Generate Signature
const signature = getSignature(secretKey, amount, currency , orderId ,requestId);

```

