# 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/global/payment-gateway/transaction-management/ipn.md). The token can be used for the next payment.

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

## Next payment

1. Authentication&#x20;

Reference to [Platform Authentication](/docs/global/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&#x20;
* 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/global/payment-gateway/transaction-management/ipn.md).


---

# Agent Instructions: 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://docs.neox.vn/docs/global/payment-gateway/integrations/direct-api/tokenization.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.
