---
title: Create Crypto Checkout Order (cloned)
slug: fiat-docs/create-crypto-checkout-order-cloned
docTags: 
createdAt: 2024-02-15T08:33:09.287Z
---

This API creates a payin order where user can deposit digital assets to wallet address provided by the application. It accepts `address`, `currency` and `amount`. On creating an order a dynamic `token` is returned from this api which is required to be passed [openCryptoCheckout()](docId:5YeEhTUtJ0mhyfY85CrKd)

This api requires access token that can be generated using [Access Token](docId\:GI_JR7M__MODsX5DXyFrw) API.

:::ApiMethodV2
```json
{
  "name": "Create Crypto Order",
  "method": "POST",
  "url": "https://your-hostname.pay3.app/v1/client/crypto-checkout/create-order",
  "description": "Create an order with payin details from application's backend",
  "tab": "examples",
  "examples": {
    "languages": [
      {
        "id": "nyfSHp7J-NrsuqTH3FW7t",
        "language": "curl",
        "code": "curl --location 'https://your-hostname.pay3.app/v1/client/crypto-checkout/create-order' \\\n--header 'signature': \"generated-signature\"\\\n--header 'access-token' : \"dynamic-access-token\" \\\n--header 'Accept: application/json' \\\n--header 'Content-Type: application/json' \\\n--data '{\n  \"requestId\":\"input-request-id\",\n  \"address\":\"input-destination-address\",\n  \"currency\":\"currency-id\",\n  \"amount\":\"input-amount-in-eth-or-btc\",\n  \"clientId\":\"your-client-id\"\n}'",
        "customLabel": ""
      }
    ],
    "selectedLanguageId": "nyfSHp7J-NrsuqTH3FW7t"
  },
  "results": {
    "languages": [
      {
        "id": "VQyRchSR38UbBEhATUpjh",
        "language": "200",
        "customLabel": "",
        "code": "{\n    \"token\": \"generated-token-id\",\n    \"requestId\": \"input-request-id\",\n    \"requestInfoData\": {\n        \"amount\": \"crypto-amount-in-eth\",\n        \"address\": \"input-destination-address\",\n        \"clientId\": \"your-client-id\",\n        \"signature\": \"generated-signature\",\n        \"currency\": \"currency-id\",\n        \"type\": \"CRYPTO-CHECKOUT\"\n    }\n}"
      },
      {
        "id": "tIvoQbUSKGnrqallvNDVQ",
        "language": "401",
        "customLabel": "",
        "code": "{\n    error: {\n      code: '7001',\n      message: 'Order already exists for given requestId'\n    }\n}"
      }
    ],
    "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": "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",
        "children": []
      },
      {
        "name": "address",
        "kind": "required",
        "type": "string",
        "description": "The address is the destination wallet address where the purchased currency will be deposited during the purchase.",
        "children": []
      },
      {
        "name": "currency",
        "kind": "required",
        "type": "string",
        "description": "The currency is Pay3's unique string ID denoting the token that needs to be purchased. Example value are btc_bitcoin, usdt_polygon, uni_eth. "
      },
      {
        "name": "amount",
        "kind": "optional",
        "type": "string",
        "description": "The amount in ethereum / btc user needs to pay.  The API expects either this parameter or fiatAmount & fiatCurrency parameter.",
        "children": []
      },
      {
        "name": "clientId",
        "kind": "required",
        "type": "string",
        "description": "Client id. Application's identifier",
        "children": []
      },
      {
        "name": "fiatAmount",
        "kind": "optional",
        "type": "string",
        "description": "Amount in Fiat say USD (eg: 10.50). This parameter is required when amount is not passed. Example values for ten dollar fifty cents is 10.50.",
        "children": []
      },
      {
        "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 is not passed. Pay3 uses current exchange rate to translate fiatAmount to amount.\nSupported fiat currencies are usd_usa, gbp_gb and eur_eu.",
        "children": []
      },
      {
        "name": "mode",
        "kind": "optional",
        "type": "string",
        "description": "When the mode is set to returnUrl, the API response includes an additional field url, which provides a direct checkout page link for accepting crypto payments. The supported values for mode are returnUrl and default.\n",
        "": "When the mode is set to returnUrl, the API response includes an additional field url, which provides a direct checkout page link for accepting crypto payments. The supported values for mode are returnUrl and default.\n"
      }
    ],
    "formDataParameters": []
  },
  "currentNewParameter": {
    "label": "Body Parameter",
    "value": "bodyDataParameters"
  }
}
```
:::

##

## 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 address = "destination-wallet-address";
const currency = "currency-id";
const amount =  "0.02";
const requestId = "Order-Id-Generated-By-Application";

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

```

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

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

// Required Parameters
const secretKey="Api-Secret-Provided-By-Pay3";
const address = "destination-wallet-address";
const currency = "currency-id";
const fiatAmount =  "10.50"; // $10.50
const fiatCurrency =  "usd_usa"; // Example for USD
const requestId = "Order-Id-Generated-By-Application";

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

```

