> For the complete documentation index, see [llms.txt](https://dcgate.gitbook.io/oxipay/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dcgate.gitbook.io/oxipay/api-endpoints/generate-payment-token.md).

# Generate Payment Token

#### Generate Payment Token

**Endpoint:** `POST /api/payment`

**Description:** The `Generate Payment Token` API is used to create a unique token for initiating a cryptocurrency payment. This token is required to redirect the user to the payment page and complete the transaction.

**Request URL:**

```
https://pay.oxichange.com/api/payment
```

**Method:** `POST`

**Query Parameters:**

| Parameter     | Type   | Required | Description                                           |
| ------------- | ------ | -------- | ----------------------------------------------------- |
| `merchant_id` | string | Yes      | The unique identifier of the merchant.                |
| `amount`      | number | Yes      | The amount to be paid in the selected cryptocurrency. |
| currency      | string | No       | The currency type (USD or EUR). Default is USD.       |

**Example Request:**

```
POST https://pay.oxichange.com/api/payment?merchant_id=M102F1159BDC770520718A376E686F1&amount=65
```

**Successful Response:**

```
{
  "data": {
    "status": "1",
    "message": "Token generated successfully.",
    "result": {
      "transaction_id": "PYD1740514010",
      "token": "532448e702cdd6e52bcd3dd6871e542674bc8a61c7678b1a5b6f453aee53520",
      "base_url": "https://pay.oxichange.com/invoice",
      "payment_link": "https://pay.oxichange.com/invoice?token=532448e702cdd6e52bcd3dd6871e542674bc8a61c7678b1a5b6f453aee53520"
    }
  }
}
```

#### Error Codes

| Status Code | Message                         | Description                               |
| ----------- | ------------------------------- | ----------------------------------------- |
| `1`         | Success                         | Token generated successfully.             |
| `-1`        | Invalid Merchant ID.            | The provided `merchant_id` is not valid.  |
| `-2`        | Website status is not approved. | The merchant's website is not approved.   |
| `-3`        | Invalid currency type.          | The provided currency must be USD or EUR. |
