> For the complete documentation index, see [llms.txt](https://docs.neox.vn/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.neox.vn/docs/payment-gateway/integrations/direct-api/tokenization.md).

# Tokenization

## Generate token

1. Contact NeoX to register the service.

<figure><img src="/files/DS9k8iI0vFKrEspXUGG6" alt=""><figcaption><p>Check registration status at Account information page</p></figcaption></figure>

2. Create bill with enabled `neo_TokenCreate` field.

The bill created with field `neo_TokenCreate = true` will return the token (`neo_PayToken`) after payment success via [IPN](/docs/payment-gateway/transaction-management/ipn.md). The token can be used for the next payment.

[*How to create a bill?*](/docs/payment-gateway/integrations/hosted-checkout.md)

## Next payment

1. Authentication

Reference to [Platform Authentication](/docs/disbursement/integration/generate-token-api.md).

Using `scope = payment`

2. Pay by token API

* URL: <https://api.neopay.vn/oapi/v2/payment/payByToken>
* Method: POST
* Request: Content-Type: application/json

**Request Parameter**

<table><thead><tr><th width="176">Parameter</th><th width="118" align="center">Data type</th><th width="119" align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td>orderId</td><td align="center">String</td><td align="center">Y</td><td>Order ID</td></tr><tr><td>orderInfo</td><td align="center">String</td><td align="center">Y</td><td>Order description</td></tr><tr><td>merchantTxnId</td><td align="center">String</td><td align="center">Y</td><td>Merchant's transaction ID (unique)</td></tr><tr><td>currency</td><td align="center">String</td><td align="center">Y</td><td>Currency (default VND)</td></tr><tr><td>amount</td><td align="center">Number</td><td align="center">Y</td><td>Bill amount</td></tr><tr><td>payToken</td><td align="center">String</td><td align="center">Y</td><td><code>neo_PayToken</code> NeoX returned</td></tr></tbody></table>

Example:

```json
{
    "orderId": "DH123232234",
    "orderInfo": "Thanh toan DH123232234",
    "merchantTxnId": "323123221434",
    "currency": "VND",
    "amount": 100000,
    "payToken": "c9291339613c4e4a80818c87cbedb483"
}
```

**Response Data**

<table><thead><tr><th>Field name</th><th width="172.33333333333331" align="center">Data type</th><th>Description</th></tr></thead><tbody><tr><td>code</td><td align="center">Number</td><td><a href="/pages/kU24dUIxUPVgYJPLKotj">Error code</a></td></tr><tr><td>message</td><td align="center">String</td><td>Response message</td></tr><tr><td>data</td><td align="center">Object</td><td><ul><li>orderId: String</li><li>merchantTxnId: String</li></ul></td></tr></tbody></table>

Example:

```json
{
    "code": 99,
    "message": "Order is processing",
    "data": {
        "orderId": "DH12323234234",
        "merchantTxnId": "323123221434"
    }
}
```

#### Payment result

Last result of the request will be sent via [IPN](/docs/payment-gateway/transaction-management/ipn.md).
