> For the complete documentation index, see [llms.txt](https://aliniex.gitbook.io/alix-pay/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://aliniex.gitbook.io/alix-pay/api-reference/alixpay-remittance-api/create-the-cash-out-order.md).

# Create the cash-out order

<mark style="color:green;">`POST`</mark> `/api/v2/orders/create-cashout`

Allows your customer to create an order with the corresponding fiat amount

{% hint style="success" %}
**Supported fiat currencies.**

* VND  :flag\_vn:
  {% endhint %}

{% hint style="danger" %}
**Alix Pay required the parameter from partner's integration**

<mark style="color:red;">userEmail</mark>&#x20;
{% endhint %}

### **Headers**

| Name         | Value                                                                                    |    |               |
| ------------ | ---------------------------------------------------------------------------------------- | -- | ------------- |
| Content-Type | `application/json`                                                                       |    |               |
| lang         | <p>The default will en if this param has been empty. </p><p>Supported languages:<code>en | cn | vi</code></p> |

### **Request Body**

**Vietnam** :flag\_vn:

* VietQR

<details>

<summary>Example of request data payload</summary>

```
{
  "externalOrderId": "f1a2acc8-c865-44fe-8e6d-d0857ada4d37",
  "partnerCode": "kaiAlinex",
  "webhookSecretKey": "81663eae----83636b86b",
  "cryptoCurrency": "USDT",
  "userEmail": "dummy@abc.com"
  "fiatAmount": 10000,
  "fiatCurrency": "VND",
  "extendInfo": {
    "transferContent": "transfer",
    "recipientName": "NGUYEN VAN A",
    "recipientNumber": "888812345678",
    "recipientBankCode": "TECHCOMBANK",
    "recipientType": ""
  },
  "signature": "I7XDfTngWIraq----J6lN/Aw==",
}
```

</details>

<table><thead><tr><th width="192">Name</th><th width="85.4140625">Type</th><th width="89.52734375">Condition</th><th>Description</th></tr></thead><tbody><tr><td>partnerCode</td><td>string</td><td>required</td><td>Code of of the partner</td></tr><tr><td><mark style="color:red;">userEmail</mark></td><td><mark style="color:red;">string</mark></td><td><mark style="color:red;">required</mark></td><td><mark style="color:red;">The email address from the end-user of your application</mark></td></tr><tr><td>cryptoCurrency</td><td>string</td><td>required</td><td>cryptocurrency that you wants to sell. for example: <code>USDT</code> </td></tr><tr><td><mark style="color:red;"><strong>fiatCurrency</strong></mark> </td><td><mark style="color:red;"><strong>string</strong></mark></td><td><mark style="color:red;"><strong>optional</strong></mark></td><td><p><mark style="color:red;"><strong>Supported fiat currencies:</strong></mark></p><ul><li><mark style="color:red;"><strong>VND</strong></mark></li></ul></td></tr><tr><td></td><td></td><td></td><td></td></tr><tr><td>fiatAmount</td><td>number</td><td>required</td><td><p>The amount of fiat (VND) the user wants to sell. <br><mark style="color:red;">The minimum value should be:</mark></p><ul><li><mark style="color:red;">VND 10000 (Sandbox: 50000)</mark></li></ul></td></tr><tr><td>webhookSecretKey</td><td>string</td><td>required</td><td>It is secret key created by partner dashboard</td></tr><tr><td>signature</td><td>string</td><td>required</td><td><ul><li>The signature created with  SHA256 by using RSA created private key of partner</li><li>The <strong>public key</strong> that has been provided to you during onboarding.</li><li>The data shall be signed according to the structure: <strong><code>partnerCode|externalOrderId|currency|</code>fiatAmount<code>|bankCode|bankAccountNumber|content|</code></strong><mark style="color:red;"><strong><code>userEmail</code></strong></mark><strong><code>|secretKey</code></strong></li></ul></td></tr><tr><td>externalOrderId</td><td>string</td><td>required</td><td>This <strong>unique id</strong> for order created and managed in partner side. It will keep the update for transaction status after created it</td></tr><tr><td>extendInfo</td><td>Object</td><td>Optional</td><td><p></p><pre><code>  {
    "transferContent": "transfer",
    "recipientName": "NGUYEN VAN A",
    "recipientNumber": "888812345678",
    "recipientBankCode": "TECHCOMBANK",
    "recipientType": ""
  }
</code></pre></td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "externalOrderId": "string",
  "type": "string",
  "fiatAmount": 0,
  "paidAmount": 0,
  "tokenTransfer": {
    "currency": "string",
    "network": "string",
    "price": 0,
    "amount": 0,
    "walletAddress": "string",
    "txHash": "string"
  },
  "bankTransfer": {
    "bankAccountName": "string",
    "bankAccountNumber": "string",
    "bankName": "string",
    "contentPayment": "string",
    "totalPayment": 0,
    "qrUrl": "string"
  },
  "fees": {
    "systemFee": 0,
    "processingFee": 0
  },
  "status": "string", // AWAITING_PAYMENT | PAYMENT_COMPLETED | PROCESSING_TOKEN_TRANSFER | SUCCESS | ERROR 
  "description": "string",
  "createdAt": "string",
  "expiresAt": "string",
  "signature": "string"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Signature**&#x20;

* Partner will digitally sign the transmitted data using **`SHA256`** with RSA algorithm
* The **private key** that has been of yours
* Data shall be signed according to the structure **externalOrderId`|type|fiatAmount|status|secretKey`**
  {% endhint %}

### How to create and verify the signature  <a href="#how-to-do-signature-creation-verification" id="how-to-do-signature-creation-verification"></a>

#### 1. Creation

```typescript
import * as crypto from 'crypto';

function create(data: string, privateKey: string): string 
{
  const signer = crypto.createSign('RSA-SHA256');
  signer.update(data);
  signer.end();

  return signer.sign(privateKey, 'base64');
}
```

#### 2. Verification

```typescript

function verify (data: string, signature: string, pubKey: string): boolean
{
        const verify = createVerify('RSA-SHA256');
        verify.update(data);
        verify.end();
        return verify.verify(pubKey, signature, 'base64');
}
```

**Transaction status**

| Status name                 | Description                                                                                                                                  |
| --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| AWAITING\_PAYMENT           | <p>The order created successfully. It is waiting </p><p><mark style="color:red;">(please wait IPN or manual check with operation)</mark></p> |
| PAYMENT\_COMPLETED          | When payment has transferred from AliX Pay to your customer bank account                                                                     |
| PROCESSING\_TOKEN\_TRANSFER | When the token has deducted from your account wallet on AliX Pay                                                                             |
| SUCCESS                     | When an transaction has completed                                                                                                            |
| FAIL                        | When an transaction has failed with any reasons                                                                                              |
| ERROR                       | When an transaction has failed with any reasons                                                                                              |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://aliniex.gitbook.io/alix-pay/api-reference/alixpay-remittance-api/create-the-cash-out-order.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
