> ## Documentation Index
> Fetch the complete documentation index at: https://doc.haipay.net/llms.txt
> Use this file to discover all available pages before exploring further.

# MIT Payment Integration Guide

> Learn how to integrate HaiPay MIT (Merchant-Initiated Transaction) payments via /usd/mit/apply, including initial on-session card authorization (tokenID) and subsequent off-session charges.

> [!WARNING]
>
> Before integrating, please review the [**API Description and Common Rules**](https://doc.haipay.net/en/guide/api-conventions.md) and [**CIT vs. MIT Transaction Modes**](https://doc.haipay.net/en/payments/cit-mit.md).

**MIT (Merchant-Initiated Transaction)** allows your server to initiate subsequent off-session charges using a stored payment credential (`tokenID`) after the cardholder completes an initial on-session (CIT) payment and authorization. It is ideal for **usage-based billing, auto top-ups, installments, and merchant-scheduled recurring billing**.

> [!TIP]
>
> * **If you offer fixed-amount, fixed-cycle plans with a defined term**, we recommend using HaiPay's managed [**Subscription Payment (`/subscription/apply`)**](https://doc.haipay.net/en/payments/subscription), where HaiPay schedules recurring charges automatically.
> * **When using Component Mode for MIT, always set `mode: 'payment'`** (MIT is categorized as standard collection on HaiPay; `'subscription'` is only for fixed-term subscriptions).

## Two-Phase Integration Flow

**1. Phase 1: Initial Transaction (On-Session Authorization & First Charge to Obtain tokenID)**

1. Your backend calls [MIT Collection Apply `POST /usd/mit/apply`](https://doc.haipay.net/en/api-reference/card/mit-apply) **without passing `tokenID`**.
2. Use the returned `payUrl` ([Checkout Mode](https://doc.haipay.net/en/payments/payment-link.md)) or `clientToken` ([Component Mode with `mode: 'payment'`](https://doc.haipay.net/en/payments/frontend-payment-element)) so the shopper completes the first payment and authentication on-session.
3. Upon payment success, HaiPay sends an asynchronous webhook to `notifyUrl` containing the **`tokenID`** bound to the user and card. Securely store the mapping between `tokenID` and `partnerUserId`.

**2. Phase 2: Subsequent Transactions (Off-Session Merchant-Initiated Charges)**

1. Whenever a charge condition is met, your backend calls `POST /usd/mit/apply` again, **passing the stored `tokenID`** (along with the same `partnerUserId`).
2. HaiPay validates the `tokenID`, executes the off-session charge directly, and notifies your `notifyUrl` asynchronously (you can also query status via `/usd/collect/query`).

## MIT-Specific Parameters

In addition to standard collection parameters, `/usd/mit/apply` includes the following fields:

| Parameter | Required | Type | Description |
| :- | :- | :- | :- |
| `tokenID` | No | String | **Stored credential token**: • **Initial transaction (Phase 1)**: Omit this field; obtain `tokenID` from the payment webhook after success. • **Subsequent charge (Phase 2)**: **Required** to charge the previously authorized card or wallet. |
| `loadingType` | No | Integer | Result page display control: • `0` (default): Display the standard payment result view. • `1`: Display a loading spinner only without order details. |
| `inBankCode` / `paymentMethods` | Mutually Exclusive | String | When `inBankCode` is omitted, `paymentMethods` is required, and vice versa. Pass `paymentMethods` (e.g., `"GOOGLE_PAY,CREDIT_CARD"`) to dynamically control displayed payment methods and their top-to-bottom order. |

## Request Examples (`POST /usd/mit/apply`)

> [tab] Phase 1: Initial Card-Saving Charge (omit tokenID)
>
> ```json theme={null}
> {
>   "appId": 1054,
>   "orderId": "MIT_INIT_20261110001",
>   "amount": "19.99",
>   "phone": "+12025551234",
>   "email": "robert.taylor@gmail.com",
>   "name": "Robert Taylor",
>   "payType": "BANK_TRANSFER",
>   "inBankCode": "CREDIT_CARD",
>   "callBackUrl": "https://merchant.com/payment/success",
>   "callBackFailUrl": "https://merchant.com/payment/fail",
>   "cancelUrl": "https://merchant.com/payment/cancel",
>   "notifyUrl": "https://merchant.com/api/notify",
>   "subject": "Initial card authorization & payment",
>   "partnerUserId": "149597870",
>   "sign": "af0gAHkUOyYHu9owQp8NJ4mPEeUW4vuJcjdxqLIzrVw8AvpLSjD1DXupReSG..."
> }
> ```

> [tab] Phase 2: Subsequent Off-Session Charge (pass tokenID)
>
> ```json theme={null}
> {
>   "appId": 1054,
>   "orderId": "MIT_SUBSEQ_20261210001",
>   "amount": "29.99",
>   "phone": "+12025551234",
>   "email": "robert.taylor@gmail.com",
>   "name": "Robert Taylor",
>   "payType": "BANK_TRANSFER",
>   "inBankCode": "CREDIT_CARD",
>   "tokenID": "tok_abc123def456",
>   "loadingType": 0,
>   "callBackUrl": "https://merchant.com/payment/success",
>   "callBackFailUrl": "https://merchant.com/payment/fail",
>   "notifyUrl": "https://merchant.com/api/notify",
>   "subject": "Auto top-up / renewal charge",
>   "partnerUserId": "149597870",
>   "sign": "af0gAHkUOyYHu9owQp8NJ4mPEeUW4vuJcjdxqLIzrVw8AvpLSjD1DXupReSG..."
> }
> ```

## Payment Types, Codes & Limits

Single-transaction limits for MIT are **0.99 – 1000 USD**:

| Currency | Payment Type (`payType`) | Payment Code (`inBankCode`) | Single Limit (USD) | Status | Card Network / Wallet |
| :- | :- | :- | :- | :- | :- |
| USD | `BANK_TRANSFER` | `CREDIT_CARD` | 0.99 - 1000 | Available | VISA |
| USD | `BANK_TRANSFER` | `CREDIT_CARD` | 0.99 - 1000 | Available | MasterCard |
| USD | `BANK_TRANSFER` | `CREDIT_CARD` | 0.99 - 1000 | Available | JCB |
| USD | `BANK_TRANSFER` | `CREDIT_CARD` | 0.99 - 1000 | Available | American Express (AMEX) |
| USD | `BANK_TRANSFER` | `CREDIT_CARD` | 0.99 - 1000 | Available | Diners Club (DINERS) |
| USD | `BANK_TRANSFER` | `CREDIT_CARD` | 0.99 - 1000 | Available | Discover (DISCOVER) |
| USD | `EWALLET` | `GOOGLE_PAY` | 0.99 - 1000 | Available | Google Pay |
| USD | `EWALLET` | `APPLE_PAY` | 0.99 - 1000 | Available | Apple Pay |

> [!NOTE]
>
> **Mutual Exclusivity between `inBankCode` and `paymentMethods`**:
>
> * Pass `inBankCode` when specifying a single payment method (leave `paymentMethods` empty).
> * Pass `paymentMethods` (comma-separated, e.g., `"GOOGLE_PAY,CREDIT_CARD"`) to dynamically control which payment methods are displayed and their **top-to-bottom display order** (leave `inBankCode` empty). For example, passing `"GOOGLE_PAY,CREDIT_CARD"` displays only Google Pay followed by Credit Card from top to bottom.
> * This dynamic display and ordering capability also maps to the [Global Cashier](https://doc.haipay.net/en/payments/global-cashier.md).

## Core API Reference

For full field specifications, response schemas, and live debugging, visit the API Reference:

> [card] [MIT Collection Apply](https://doc.haipay.net/en/api-reference/card/mit-apply.md)
>
> `POST /usd/mit/apply` — Initiate initial authorization or subsequent off-session charges.

> [card] [Collection Order Query](https://doc.haipay.net/en/api-reference/card/collect-query.md)
>
> `POST /usd/collect/query` — Query the final status of an MIT order.

> [card] [Refund Apply & Query](https://doc.haipay.net/en/api-reference/card/refund-apply.md)
>
> `POST /usd/refund/apply` — Issue full or partial refunds for completed MIT charges.

## Related Topics

* [CIT vs. MIT Transaction Modes](https://doc.haipay.net/en/payments/cit-mit.md)
* [Component Mode](https://doc.haipay.net/en/payments/frontend-payment-element.md)
* [Checkout Mode](https://doc.haipay.net/en/payments/payment-link.md)
* [Subscription Payment Guide](https://doc.haipay.net/en/payments/subscription.md)
* [Test Card Numbers](https://doc.haipay.net/en/payments/test-cards.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.