---
title: Create Crypto Refund (Server Side)
slug: crypto/create-crypto-refund-server-side
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 address , 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-execute",
  "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-execute' \\\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_ethereum\",\n    \"address\": \"0x..\",\n    \"sponsorFee\":false\n}'",
        "customLabel": ""
      }
    ],
    "selectedLanguageId": "eXhyHL9RWXfgU_lG6oq1Q"
  },
  "results": {
    "languages": [
      {
        "id": "VQyRchSR38UbBEhATUpjh",
        "language": "200",
        "code": "{\n    \"orderId\": \"a059335a-d766-4074-92fe-5685e7d693e5\",\n    \"orderType\": \"CryptoRefund\",\n    \"status\": \"ORDER_PAYMENT_PROCESSING\",\n    \"requestId\": \"8f7a28fe-8c86-4d83-b9ed-39acd8101f95\"\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",
        "": "required"
      },
      {
        "name": "clientId",
        "kind": "required",
        "type": "string",
        "description": "Client id. Application's identifier",
        "children": []
      },
      {
        "name": "address",
        "kind": "required",
        "type": "string",
        "description": "The address is the destination wallet address where the crypto token currency will be deposited after the refund is processed. (User's wallet address should be passed in this)",
        "": "The address is the destination wallet address where the crypto token currency will be deposited after the refund is processed. (User's wallet address should be passed in this)"
      },
      {
        "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.\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.\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."
      }
    ],
    "formDataParameters": []
  },
  "currentNewParameter": {
    "label": "Body Parameter",
    "value": "bodyDataParameters"
  },
  "hasTryItOut": false,
  "autoGeneratedAnchorSlug": "create-refund",
  "legacyHash": "XHRgW0CUDlxruiYbWkETl"
}
```
:::

## 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 amount parameter&#x20;

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

// Required Parameters
const secretKey="Api-Secret-Provided-By-Pay3";
const amount =  "1.00";
const currency = "usdc_ethereum";
const address = "0x....hiudfh":
const orderId = "Order_ID_Of_the_Pay-in_Order";
const requestId = "Order-Id-Generated-By-Application";

const getSignature = (secretKey, amount , currency , address , orderId , requestId) => {
    // Prepare the string to sign in same format. 
    let stringToSign;
    stringToSign = 'address=' + address
            + '&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 , address ,orderId ,requestId);

```

***

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

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

// Required Parameters
const secretKey="Api-Secret-Provided-By-Pay3";
const fiatAmount =  "1.00";
const fiatCurrency = "aed_ae";
const address = "0x....hiudfh":
const orderId = "Order_ID_Of_the_Pay-in_Order";
const requestId = "Order-Id-Generated-By-Application";

const getSignature = (secretKey, fiatAmount , fiatCurrency , address , orderId , requestId) => {
    // Prepare the string to sign in same format. 
    let stringToSign;
    stringToSign = 'address=' + address
            + '&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 , address ,orderId ,requestId);

```

