> For the complete documentation index, see [llms.txt](https://docs.jgopay.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.jgopay.com/english/create-payment.md). Agents can also search and read this documentation through its [MCP server](https://docs.jgopay.com/~gitbook/mcp).

# Create Payment

## Integration modes

| Mode                            | Request                                       | Customer flow                                                                                                                                        |
| ------------------------------- | --------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Mode 1 — Direct integration** | Supply `payment_method`                       | Your integration chooses the method and handles the returned QR page or gateway redirect. For online banking, supply `metadata.provider_channel_id`. |
| **Mode 2 — Hosted checkout**    | Omit `payment_method` and `preferred_gateway` | Open `payment_url`. The customer selects TNG, DuitNow QR, or online banking, then selects their bank when needed.                                    |

These modes use the same endpoint; do not send a `mode` field. Mode 2 starts as `PENDING` and has no `gateway` data until the customer selects a method. The checkout shows our payment ID and amount, without the merchant name or merchant reference.

### Opening MYR checkout

Open checkout as a full page in the current tab, or use a customer-clicked link to open a new tab. Do not rely on FPX/TNG authorization working inside an iframe. A new window is optional; a full-page redirect in the same tab also works. Browser popup and iframe restrictions can prevent automatic navigation.

If Mode 2 is embedded, customers see **Open payment page**, which opens the same session in a new tab before method selection. A copy-link fallback is provided. If a Mode 1 payment (`payment_method` set) with an FPX or TNG redirect is embedded, the page does not navigate the iframe (banks and e-wallets refuse to load inside a frame); customers see **Open Payment Page**, which opens the gateway in a new tab. A merchant sandbox must permit new tabs (`allow-popups allow-popups-to-escape-sandbox`) or the merchant should provide a link outside the iframe. Do not create another payment for this handoff. Continue to use server callbacks to confirm payment status.

### Online banking availability

The master can set a per-merchant **Minimum amount to show online banking (MYR)**. RM0 adds no restriction. With RM100 configured, payments below RM100 do not show online banking; at RM100 and above it is eligible, subject to gateway availability and limits. This covers the FPX bank group, while TNG and DuitNow QR remain subject to their existing availability rules.

This setting applies only to Mode 2, including server-side selection validation. Existing direct integrations are unchanged. Pending sessions use the latest setting; payments already processing continue normally.

## Endpoint

```http
POST /payment/request
Authorization: Bearer <access_token>
Content-Type: application/json
```

## Request Body

| Field            | Type   | Required    | Description                                                                                                                                                                                                                                                                    |
| ---------------- | ------ | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `amount`         | number | Yes         | Payment amount (see [Amount Rules](#amount-rules))                                                                                                                                                                                                                             |
| `currency`       | string | No          | ISO 4217 currency code (`MYR`). Defaults to your configured currency                                                                                                                                                                                                           |
| `reference_id`   | string | Yes         | Your unique order/invoice ID (max 100 chars, **alphanumeric only**)                                                                                                                                                                                                            |
| `customer_name`  | string | Yes         | Customer's name                                                                                                                                                                                                                                                                |
| `customer_phone` | string | Yes         | Customer's phone number (include country code, no `+`)                                                                                                                                                                                                                         |
| `callback_url`   | string | No          | Callback URL for payment notifications. Falls back to merchant default                                                                                                                                                                                                         |
| `redirect_url`   | string | No          | URL to redirect customer after payment                                                                                                                                                                                                                                         |
| `payment_method` | string | Mode 1 only | Payment method code (`QR_PAYMENT`, `BANK_TRANSFER`, `MOBILE_WALLET`)                                                                                                                                                                                                           |
| `metadata`       | object | No          | Custom key-value data stored with the transaction. **Not** returned in callbacks — use `reference_id` to correlate. **Required for `BANK_TRANSFER`:** include `provider_channel_id` (see [Payment Methods](https://docs.jgopay.com/english/payment-methods.md#fpx-bank-codes)) |

> **Security:** `callback_url` and `redirect_url` must use HTTPS (`https://`) in production. HTTP URLs are rejected with HTTP 422. This prevents interception of callback payloads containing payment status and signatures.

> **Warning:** `redirect_url` is not validated against a pre-registered domain. If your API key is compromised, an attacker could create payments that redirect your customers to phishing sites after payment. To mitigate this:
>
> * Restrict API key access to backend servers only — never expose in client-side code
> * Monitor payment creation logs for unexpected `redirect_url` values
> * Rotate your API key immediately if compromise is suspected (see [Authentication](https://docs.jgopay.com/english/authentication.md#emergency-revocation))

## Field Validation

| Field            | Rule                                  | Notes                                                                                |
| ---------------- | ------------------------------------- | ------------------------------------------------------------------------------------ |
| `reference_id`   | **Alphanumeric only** (a-z, A-Z, 0-9) | No spaces, hyphens, or special characters. Will return `VALIDATION_ERROR` if invalid |
| `customer_phone` | String, 1-50 characters               | Include country code without `+` (e.g., `60123456789`)                               |
| `amount`         | Positive number                       | Up to 2 decimal places                                                               |

> **`BANK_TRANSFER` (FPX):** When using `payment_method: "BANK_TRANSFER"`, you must include `metadata.provider_channel_id` with the customer's bank code. See [Payment Methods](https://docs.jgopay.com/english/payment-methods.md#fpx-bank-codes) for the full list.

## Amount Rules

| Currency | Format           | Min Amount | Max Amount |
| -------- | ---------------- | ---------- | ---------- |
| **MYR**  | Up to 2 decimals | 5 MYR      | 50,000 MYR |

## Mode 1 response

You receive gateway-specific data:

```json
{
  "status": "success",
  "data": {
    "payment_id": "PAY_MYR12346",
    "payment_url": "https://payment.yourbrand.com/p/MYR12346",
    "status": "PROCESSING",
    "amount": 100.00,
    "currency": "MYR",
    "reference_id": "ORDER20260325002",
    "expires_in": 1800,
    "expires_at": "2026-03-25T12:30:00Z",
    "gateway": {
      "behavior": "REDIRECT_EXTERNAL",
      "redirect_url": "https://gateway.example.com/pay/xyz789",
      "qr_data_string": null
    }
  }
}
```

### Response Fields

| Field                  | Type   | Description                                                                   |
| ---------------------- | ------ | ----------------------------------------------------------------------------- |
| `payment_id`           | string | Unique payment identifier                                                     |
| `payment_url`          | string | Hosted checkout URL — use for all Mode 2 requests and Mode 1 `QR_PAYMENT`     |
| `status`               | string | Initial status: `PROCESSING` for Mode 1, `PENDING` for Mode 2                 |
| `amount`               | number | Confirmed payment amount                                                      |
| `currency`             | string | Currency code                                                                 |
| `reference_id`         | string | Your reference ID                                                             |
| `expires_in`           | number | Seconds until expiry                                                          |
| `expires_at`           | string | Expiry timestamp (ISO 8601)                                                   |
| `gateway.behavior`     | string | How to handle the response                                                    |
| `gateway.redirect_url` | string | Redirect URL — send the customer here for `BANK_TRANSFER` and `MOBILE_WALLET` |

### Mode 1: Which URL to Send the Customer To

| `payment_method` | Send the customer to                                     |
| ---------------- | -------------------------------------------------------- |
| `QR_PAYMENT`     | `payment_url` — the payment page displays the DuitNow QR |
| `BANK_TRANSFER`  | `gateway.redirect_url` — the bank authorization page     |
| `MOBILE_WALLET`  | `gateway.redirect_url` — the TNG authorization page      |

## Mode 2 example

Omit the method and gateway preference. No bank metadata is needed; checkout collects the bank selection.

```json
{
  "amount": 100.0,
  "currency": "MYR",
  "reference_id": "ORDER20260910001",
  "customer_name": "Ahmad bin Ali",
  "customer_phone": "60123456789"
}
```

Response (illustrative IDs and expiry):

```json
{
  "status": "success",
  "data": {
    "payment_id": "PAY_MYR12346",
    "payment_url": "https://payment.yourbrand.com/p/MYR12346",
    "status": "PENDING",
    "amount": 100.0,
    "currency": "MYR",
    "reference_id": "ORDER20260910001",
    "expires_in": 1800,
    "expires_at": "2026-09-10T12:30:00Z"
  }
}
```

Always send the Mode 2 customer to `payment_url`.

## Check Payment Status

Query the current status of a payment.

```http
GET /payment/status/:identifier
Authorization: Bearer <access_token>
```

`:identifier` accepts either the JGoPay `payment_id` (`PAY_xxx`) or your own `reference_id` — so you can check status without storing our ID. Reference IDs are alphanumeric, so no URL encoding is needed. If a `payment_id` match is found it wins; otherwise the value is looked up as a `reference_id` within your account.

### Response

```json
{
  "status": "success",
  "data": {
    "payment_id": "PAY_MYR12345",
    "reference_id": "ORDER20260325001",
    "amount": 100.00,
    "currency": "MYR",
    "status": "SUCCESS",
    "gateway_reference": "TXN_20260325_ABC123",
    "created_at": "2026-03-25T12:00:00Z",
    "completed_at": "2026-03-25T12:15:30Z",
    "expires_at": "2026-03-25T12:30:00Z"
  }
}
```

| Field               | Type   | Description                                                                                       |
| ------------------- | ------ | ------------------------------------------------------------------------------------------------- |
| `payment_id`        | string | JGoPay payment identifier                                                                         |
| `reference_id`      | string | Your original reference ID                                                                        |
| `amount`            | number | Payment amount                                                                                    |
| `currency`          | string | Currency code                                                                                     |
| `status`            | string | Current status (`PENDING`, `PROCESSING`, `SUCCESS`, `FAILED`, `EXPIRED`, `CANCELLED`, `REFUNDED`) |
| `gateway_reference` | string | Gateway's transaction reference (`null` until processed)                                          |
| `created_at`        | string | Creation timestamp (ISO 8601)                                                                     |
| `completed_at`      | string | Completion timestamp (`null` if not completed)                                                    |
| `expires_at`        | string | Expiry timestamp (`null` if not set)                                                              |

> Use this endpoint as a fallback to verify payment status if you don't receive a callback. Do not use it as the primary status mechanism — rely on [callbacks](https://docs.jgopay.com/english/webhooks.md) instead.

## Gateway Behaviors

| Behavior            | Action                               | Methods    |
| ------------------- | ------------------------------------ | ---------- |
| `REDIRECT_EXTERNAL` | Redirect to authorization page       | FPX, TNG   |
| `QR_DISPLAY_POLL`   | Open `payment_url` to display the QR | DuitNow QR |

FPX and TNG use external authorization redirects. For DuitNow QR, use `payment_url` to display the QR; gateway behavior may vary by route. For Mode 2, always open `payment_url` and let checkout handle the selected method.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.jgopay.com/english/create-payment.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
