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

This API creates a payin order to enable users to make checkout transactions. It accepts amount and currency details. On creating an order a dynamic `token` is returned from this api which is required to be passed to Pay3 Android SDK

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

:::ApiMethodV2
```json
{
  "name": "Create Checkout Order",
  "method": "POST",
  "url": "https://your-hostname.pay3.app/v1/client/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/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  \"currencyId\":\"currency-id\",\n  \"fiatAmount\":\"input-amount\",\n  \"clientId\":\"your-client-id\",\n  \"paymentMethodId\":\"your-paymentMethod-id\",\n  \"email:\"user-email\", \n}'",
        "customLabel": ""
      }
    ],
    "selectedLanguageId": "nyfSHp7J-NrsuqTH3FW7t"
  },
  "results": {
    "languages": [
      {
        "id": "VQyRchSR38UbBEhATUpjh",
        "language": "200",
        "customLabel": "",
        "code": "{\n    \"requestId\": \"9824649238\",\n    \"token\": \"a35dc551-9fb4-491c-9f9b-44d9c2ef4b32\",\n    \"status\": \"CREATED\",\n    \"offerInfoData\": {\n        \"userAddress\": \"user@email.com\",\n        \"clientId\": \"your-client-id\",\n        \"selectedPaymentMethod\": \"your-paymentMethodId\",\n        \"totalFiatAmount\": \"1.00\",\n        \"expiryTs\": \"2025-04-21T16:12:09.287975+00:00\",\n        \"currencyId\": \"your-currency-id\",\n        \"type\": \"BUY\"\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": "currencyId",
        "kind": "required",
        "type": "string",
        "description": "This will be provided by Pay3 during onboarding",
        "": "This will be provided by Pay3 during onboarding"
      },
      {
        "name": "fiatAmount",
        "kind": "required",
        "type": "string",
        "description": "Amount user have to Pay in string format. Maximum two decimal places are allowed",
        "": "Amount user have to Pay in string format. Maximum two decimal places are allowed"
      },
      {
        "name": "paymentMethodId",
        "kind": "required",
        "type": "string",
        "description": "Unique string identifier. This will be provided by Pay3 during onboarding ",
        "": "Unique string identifier. This will be provided by Pay3 during onboarding "
      },
      {
        "name": "email",
        "kind": "required",
        "type": "string",
        "description": "User email to identify the user, which will be available in reporting dashboard",
        "": "required"
      },
      {
        "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. It is required to be globally unique example UUID.",
        "": "Identifier that is created by client application's backend. This will be passed in relevant events and webhooks from Pay3 to Application. It is required to be globally unique example UUID."
      },
      {
        "name": "clientId",
        "kind": "required",
        "type": "string",
        "description": "Client id. Application's identifier",
        "children": []
      },
      {
        "name": "userId",
        "kind": "optional",
        "type": "string",
        "description": "It is a type of UUID. It will used as unique identifier of the user. If this is not passed, email will be used as a unique identifier of the user within Pay3.",
        "": "It is a type of UUID. It will used as unique identifier of the user. If this is not passed, email will be used as a unique identifier of the user within Pay3."
      },
      {
        "name": "userMessage",
        "kind": "optional",
        "type": "string",
        "description": "Short meaningful name of the asset user is about to purchase. ",
        "": "Short meaningful name of the asset user is about to purchase. "
      },
      {
        "name": "firstName",
        "kind": "optional",
        "type": "string",
        "description": "First name of the user with maximum length of 50 characters.",
        "": "First name of the user with maximum length of 50 characters."
      },
      {
        "name": "lastName",
        "kind": "optional",
        "type": "string",
        "description": "Last name of the user with maximum length of 50 characters.",
        "": "Last name of the user with maximum length of 50 characters."
      },
      {
        "name": "phoneNumber",
        "kind": "optional",
        "type": "string",
        "description": "This is the phone number of the user in E.164 format [+][country code][number including area code] which can have a maximum of fifteen digits.",
        "": "This is the phone number of the user in E.164 format [+][country code][number including area code] which can have a maximum of fifteen digits."
      },
      {
        "name": "mode",
        "kind": "optional",
        "type": "string",
        "description": "returnUrl - In this mode, the API returns a Pay3 payment URL that can be embedded directly into the client’s application. This is useful when the client wants to open the Pay3 URL inside a WKWebView (iOS), WebView (Android/React Native), or an <iframe> in a web app.\n\nreturnAppUrl - In this mode, the api will return supported Android / iOS application url. This requires valid targetApp parameter in the body.",
        "": "returnUrl - In this mode, the API returns a Pay3 payment URL that can be embedded directly into the client’s application. This is useful when the client wants to open the Pay3 URL inside a WKWebView (iOS), WebView (Android/React Native), or an <iframe> in a web app.\n\nreturnAppUrl - In this mode, the api will return supported Android / iOS application url. This requires valid targetApp parameter in the body."
      },
      {
        "name": "targetApp",
        "kind": "optional",
        "type": "string",
        "description": "This is required when the user chooses a perticular iOS/Android application to complete the payment.",
        "": "This is required when the user chooses a perticular iOS/Android application to complete the payment."
      },
      {
        "name": "deviceContext",
        "kind": "optional",
        "type": "object",
        "description": "Information about the mobile environment",
        "": "Information about the mobile environment",
        "children": [
          {
            "name": "deviceOS",
            "kind": "optional",
            "type": "string",
            "description": "ANDROID or IOS"
          }
        ],
        "schema": [
          {
            "name": "deviceOS",
            "kind": "optional",
            "type": "string",
            "description": "ANDROID or IOS"
          }
        ]
      },
      {
        "name": "pixKey",
        "kind": "optional",
        "type": "string",
        "description": "This is the unique identifier for a user in the PIX system, provided by the user. It can be an email address, phone number, CPF, or a random key.",
        "": "This is the unique identifier for a user in the PIX system, provided by the user. It can be an email address, phone number, CPF, or a random key."
      },
      {
        "name": "intlBankAccount",
        "kind": "optional",
        "type": "string",
        "description": "This is the International Bank Account Number (IBAN) entered by the user. It follows the standard IBAN format, which includes the country code, check digits, and the bank account number.",
        "": "This is the International Bank Account Number (IBAN) entered by the user. It follows the standard IBAN format, which includes the country code, check digits, and the bank account number."
      },
      {
        "name": "bankAccount",
        "kind": "optional",
        "type": "string",
        "description": "This is the bank account number entered by the user. It is specific to the user's bank and is used to identify the user's account within the financial institution.",
        "": "This is the bank account number entered by the user. It is specific to the user's bank and is used to identify the user's account within the financial institution."
      },
      {
        "name": "docType",
        "kind": "optional",
        "type": "string",
        "description": "This specifies the type of document, which for instance for Brazil is CPF (Cadastro de Pessoas Físicas). CPF is the Brazilian individual taxpayer registry identification.",
        "": "This specifies the type of document, which for instance for Brazil is CPF (Cadastro de Pessoas Físicas). CPF is the Brazilian individual taxpayer registry identification."
      },
      {
        "name": "docId",
        "kind": "optional",
        "type": "string",
        "description": "This is the Documentation ID, entered by the user. It corresponds to the specific identifier for the type of document (e.g., CPF number) provided.",
        "": "This is the Documentation ID, entered by the user. It corresponds to the specific identifier for the type of document (e.g., CPF number) provided."
      },
      {
        "name": "callbackUrl",
        "kind": "optional",
        "type": "string",
        "description": "Application can provide a url in this parameter. After completion of the transaction, user will be redirected to this url. An additional parameter data query parameter will be added to the url. ",
        "": "Application can provide a url in this parameter. After completion of the transaction, user will be redirected to this url. An additional parameter data query parameter will be added to the url. "
      }
    ],
    "formDataParameters": []
  },
  "currentNewParameter": {
    "label": "Body Parameter",
    "value": "bodyDataParameters"
  },
  "hasTryItOut": false
}
```
:::

##

## Signature Generation

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

:::CodeblockTabs
```kotlin
import javax.crypto.Mac
import javax.crypto.spec.SecretKeySpec


class Signature {

fun getPay3Signature(secretKey: String, requestId: String, fiatAmount: String, currencyId: String): String {
        return try {
            val stringToSign = "currencyId=$currencyId&fiatAmount=$fiatAmount&requestId=$requestId"

            val mac = Mac.getInstance("HmacSHA256")
            val secretKeySpec = SecretKeySpec(secretKey.toByteArray(), "HmacSHA256")
            mac.init(secretKeySpec)

            val hash = mac.doFinal(stringToSign.toByteArray(Charsets.UTF_8))
            Base64.getEncoder().encodeToString(hash)
        } catch (e: Exception) {
            throw RuntimeException("Error generating signature", e)
        }
    }
}
```

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

// Required Parameters
const secretKey="Api-Secret-Provided-By-Pay3";
const fiatAmount =  "0.02";
const requestId = "Order-Id-Generated-By-Application";
const clientId = "your-client-id";
const accessToken = "dynamic-access-token";

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

###

