> ## 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

> Understand HaiPay MIT (Merchant Initiated Transaction) mode, including flowchart, collection API, query and refund endpoints.

<Warning>
  **Before reading this API documentation, be sure to review the [API Description Guide](/docs/en/guide/api_description_guide)**
</Warning>

<Tip>
  Use [Payment Link](/docs/en/V20260628/api/version2/payment-link) or [Front-End Component](/docs/en/V20260628/api/version2/frontend-payment-element) to quickly integrate MIT payment.
</Tip>

## MIT Mode Overview

**MIT (Merchant Initiated Transaction)**
After a user completes a one-time payment authorization, the merchant can initiate charges without the user being present.
This mode is widely used for **subscription billing, installment payments, membership renewals, and deferred charges**.

### Basic Flow

1. **User Authorization**
   * The user enters payment information during the first transaction and completes the required authentication.
   * The merchant stores the user's payment credentials (`tokenID`) for subsequent charge requests.

2. **Merchant Initiates Charge**
   * The merchant directly initiates a charge request using the stored credentials based on the agreed schedule or conditions.
   * Since the transaction is an **off-session** scenario (the user does not participate), the system processes it based on user authorization and compliance requirements.

3. **Authentication Requirements**
   * In most cases, the transaction completes directly.
   * If the issuing bank or risk control system requires re-verification, the transaction may enter a pending state that requires the user to provide additional verification.

### Key Features

* **Better UX**: Users do not need to manually enter payment information each time.
* **Compliant & Secure**: Meets international payment regulations and Strong Customer Authentication (SCA) requirements.
* **Wide Application**: Suitable for subscription billing, auto-renewal, installment deductions, and deferred settlement.

## MIT Flowchart

```mermaid theme={null}
flowchart TD
    A[User: places order on merchant platform] --> B{Transaction type check}
    N[Payment callback]
    O[Merchant: deliver service/goods]
    P[Merchant: notify user of Payment Failed]

    subgraph S2 [Scenario 2: subsequent transaction]
        direction TB
        I[Subsequent] --> J[Merchant: sends transaction<br>request with token to Haipay]
        J --> K{HaiPay: Verify token}
        K -->|Valid| L[HaiPay: Execute auto-charge]
        L --> N
        K -->|Invalid/Failed| M[Payment Failed]
        M --> P
    end

    subgraph S1 [Scenario 1: first transaction]
        direction TB
        C[First transaction] --> D[HaiPay: provide Payment URL]
        D --> E[User: confirm payment]
        E --> F[Payment Success]
        F --> G[HaiPay: Generate secure token<br>(bind user & merchant)]
        G --> N
        N --> O
    end

    B --> C
    B --> I
```

## Transaction Limits

| Transaction Type | Limit (USD) |
| :--------------- | ----------- |
| Collection       | 0.99-1000   |

## MIT Payment API

### Collection Apply

**Description:**

* Create a MIT mode collection order

**URL:**

USD: `/usd/mit/apply`
Description: Use the appId corresponding to USD. After successful payment, the user's USD balance increases.

**Parameters:**

| Parameter       | Required | Type    | Description                                                                                                                                 |
| :-------------- | :------- | :------ | :------------------------------------------------------------------------------------------------------------------------------------------ |
| appId           | Yes      | Long    | Business ID (obtained from the dashboard; use the one corresponding to the currency in the URL)                                             |
| orderId         | Yes      | String  | Merchant order number (must be unique, max 48 characters)                                                                                   |
| name            | No       | String  | User name; real name recommended. Format: firstName and lastName separated by space. Example: John Doe                                      |
| phone           | No       | String  | Real phone number (format reference: [phone format](/docs/en/guide/frequently_asked_question#phone_format))                                 |
| email           | No       | String  | Real email address                                                                                                                          |
| amount          | Yes      | String  | Transaction amount (2 decimal places; no punctuation such as ",")                                                                           |
| payType         | Yes      | String  | [Payment type](#Payment-methods)                                                                                                            |
| inBankCode      | Yes      | String  | [Payment code](#Payment-methods)                                                                                                            |
| clientIp        | No       | String  | Client IP address                                                                                                                           |
| callBackUrl     | Yes      | String  | Redirect URL after successful payment                                                                                                       |
| callBackFailUrl | Yes      | String  | Redirect URL after failed payment                                                                                                           |
| notifyUrl       | No       | String  | Callback URL                                                                                                                                |
| subject         | Yes      | String  | Payment remark                                                                                                                              |
| body            | No       | String  | Remark details                                                                                                                              |
| partnerUserId   | Yes      | String  | Unique user identifier (e.g. userId) for risk control. Must be real and valid. Format: digits, letters, or common symbols -\~!@#\$%&\*()\_. |
| tokenID         | No       | String  | Payment token. Not required for the first transaction; required for subsequent charges. Obtained via callback.                              |
| loadingType     | No       | Integer | 0 (default) – Show normal payment result page; 1 – Show loading animation, hide order info.                                                 |
| cancelUrl       | No       | String  | Cancel URL; if provided, user can click to return from payment page                                                                         |
| sign            | Yes      | String  | Signature                                                                                                                                   |

**Request Example**

```json theme={null}
{
  "appId": 1054,
  "orderId": "M233323000059",
  "amount": "300",
  "phone": "09230219312",
  "email": "23423@qq.com",
  "name": "test",
  "inBankCode": "USA",
  "payType": "BANK_TRANSFER",
  "partnerUserId": "149597870",
  "sign": "af0gAHkUOyYHu9owQp8NJ4mPEeUW4vuJcjdxqLIzrVw8AvpLSjD1DXupReSG/CyuSkFRyiIvCp5u703AuGGmfgD2gKDH3Ywau41bAbG2jnHJ8mtjiSJ5iWUzanyd4Kr7d1+rETbzUl7/BkW3t0X8UUFdqpxwG8DPUjAwUKfplWDHV7koG51Ozexd80DCsmW6eWdouAZ1uNXGLYmV3ftE3BmfNRtuv1C5bfTJWrTEIOxbF6g2uYOFZTlIgrQgd7/2PsAYwQQXNz8Q8CYl4OxqCv4pXJxaLWPbR5tqZu9og5kn32C9aHW/NlU1y39vzz+4ef81yPAqUV9oHlSMSPrMmw=="
}
```

**Response Example**

```json theme={null}
{
  "status": "1",
  "error": "00000000",
  "msg": "",
  "data": {
    "orderId": "M233323000059",
    "orderNo": "6023071013539074",
    "payUrl": "",
    "clientToken": "",
    "sign": "YEoA8Y2JzQFGVzwJSqmemm1Kfv/bfyIfCqv2dp7RNzT5B72AQvdD+nt2nR4sL1HWscvmNHyVt5ovAi7MMhy3ziih/sMph+wPx4YjH3W1h5DyBvSlWvaKfKrK5ViomZ0pPYWydwRHnnRnicxToHK9S6qtSy7Q73O0hdz4hJ9p41Th3ycBl2Q9SeqSZYSY1ohcPDhdyRf2y0prb8rHgpBKzxZ5BKX/1bsE9OmsSEHAEYT8OGgko6aNe8XPAhr4G48cpWTftvnGQuzh0O65nuZRI/PF+Axt2zJCVbFHDDSREI9NlAT82ebDqhlVdxQzKE67D1nxgjb3dPmDUYHOBpmwxQ=="
  }
}
```

Response data parameters

| Parameter   | Type   | Description                                                                                                                           |
| :---------- | :----- | :------------------------------------------------------------------------------------------------------------------------------------ |
| orderId     | String | Merchant order number (must be unique)                                                                                                |
| orderNo     | String | Platform order number                                                                                                                 |
| payUrl      | String | Payment URL                                                                                                                           |
| clientToken | String | Client token for use in the Front-End Component (see [Front-End Component](/docs/en/V20260628/api/version2/frontend-payment-element)) |
| sign        | String | Signature                                                                                                                             |

### Collection Query

**Description:**

* Query a collection order

**URL:**

USD: `/usd/collect/query`

**Parameters:**

| Parameter | Required | Type   | Description                                                                                     |
| :-------- | :------- | :----- | :---------------------------------------------------------------------------------------------- |
| appId     | Yes      | Long   | Business ID (obtained from the dashboard; use the one corresponding to the currency in the URL) |
| orderId   | Yes      | String | Merchant order number                                                                           |
| orderNo   | No       | String | Platform order number (faster response)                                                         |
| sign      | Yes      | String | Signature                                                                                       |

**Request Example**

```json theme={null}
{
  "appId": 1054,
  "orderId": "M22222000028",
  "sign": "EmyJGm3ELzG4FsOd0Krs9ncbSjo4oTGuXWML+7djYla3+VAwd9wS17z38p/7U2ZAjroO04XrE7YXcB1o76Dtyipj3h3bJzs7FYma1QNkMUdt9hh7m8U6hMsMQX7vIWHtXNwz4pbTSC75+kQWXaCew7KoE6LXECdJU8AISgNgeki2TK9R0pCfshr0Z2SZBPeuT6OvIH5LdmqgdZhuqnffGU2qnXk4KMkO848e6/WALLBR+LE1wyKHfPnYVcuKSMVYxkvKyyIL5JIPEgW0o5bh4RCbaUn3NZtyYwrU1uQ3ZDFRThm9j6XAQP+LBlmq3nOePqBtp/VDVarRaV+7FbQg3A=="
}
```

**Response Example**

```json theme={null}
{
  "status": "1",
  "error": "00000000",
  "msg": "",
  "data": {
    "orderId": "M22222000028",
    "orderNo": "6023042811314347",
    "amount": "50.00",
    "actualAmount": "0.00",
    "fee": "0.00",
    "status": 1,
    "sign": "fP433ygWVDLVGxYkVnIJj7riGq0U3vyVX+MbBAImxfGLZkZcEAHVEoVYuULZSmXAAXKRSyd67WlDNm+24pougM54ofAoH4HMtCL2tfCoBReFyz3z02AGKkrKE2xWhSpWoqfQoBvzwuN5iGMMu0s9Q1YvqiwJ8WDVIENnmiIyD8qDJN7caHTW2US14/faG+69AvnuIgJ/nu7/jogOlgEYdZdVYU7gcRDE+d47KjlFGswQkJ/h/uzV7cWtUqrtOO7ZnZ3/z33Xx8awokX36QoYcPSWAU0h+Ij9O9402HNhm1eTbYcLU0uI/z8xCAtyAI/tTyiFijpiNlxUKQj+zKsILw=="
  }
}
```

Response data parameters

| Parameter    | Type    | Description                                                                                                   |
| :----------- | :------ | :------------------------------------------------------------------------------------------------------------ |
| orderId      | String  | Merchant order number (must be unique)                                                                        |
| orderNo      | String  | Platform order number                                                                                         |
| amount       | String  | Transaction amount                                                                                            |
| actualAmount | String  | Actual amount received                                                                                        |
| fee          | String  | Fee                                                                                                           |
| status       | Integer | Status (0: not started, 1: paying, 2: success (final), 3: failed (final), -1: exception pending confirmation) |
| payTime      | String  | Payment success time (available when status=2), local time, format: yyyy-MM-dd HH:mm:ss                       |
| errorMsg     | String  | Payment failure reason (available when status=3)                                                              |
| sign         | String  | Signature                                                                                                     |

## Refund API

### Refund Apply

**Description:**

* Initiate a refund for the original credit card transaction. Note that the synchronously returned refund status should be confirmed via the query API.

**URL:**

USD: `/usd/refund/apply`

**Parameters:**

| Parameter    | Required | Type   | Description                                                                                                 |
| :----------- | :------- | :----- | :---------------------------------------------------------------------------------------------------------- |
| appId        | Yes      | Long   | Business ID (obtained from the dashboard; use the one corresponding to the currency in the URL)             |
| orderId      | Yes      | String | Merchant refund order number (new merchant order number; cannot reuse the original collection order number) |
| orderNo      | Yes      | String | Platform order number (from the original collection response)                                               |
| refundAmount | No       | String | Optional; if omitted, full refund is applied                                                                |
| sign         | Yes      | String | Signature                                                                                                   |

Response data parameters

| Parameter | Type   | Description                                                                                                                   |
| :-------- | :----- | :---------------------------------------------------------------------------------------------------------------------------- |
| appId     | String | Business ID                                                                                                                   |
| orderNo   | String | Platform order number (from the original collection response)                                                                 |
| orderId   | String | Merchant refund order number                                                                                                  |
| refundNo  | String | Platform refund number for this request                                                                                       |
| status    | String | Refund status: 1 = success, 0 = processing, 2 = failed. Normally returns processing initially; use query API to check status. |
| errorMsg  | String | Error message (may not always be present)                                                                                     |
| sign      | String | Signature                                                                                                                     |

### Refund Query

**Description:**

* Query the result of a refund request.

**URL:**

USD: `/usd/refund/refundQuery`

**Parameters:**

| Parameter | Required | Type   | Description                                                                                     |
| :-------- | :------- | :----- | :---------------------------------------------------------------------------------------------- |
| appId     | Yes      | Long   | Business ID (obtained from the dashboard; use the one corresponding to the currency in the URL) |
| orderId   | No       | String | Merchant refund order number                                                                    |
| refundNo  | No       | String | Platform refund number (returned from refund apply; prefer this field for queries if available) |
| sign      | Yes      | String | Signature                                                                                       |

Response data parameters

| Parameter    | Type   | Description                                                                                  |
| :----------- | :----- | :------------------------------------------------------------------------------------------- |
| appId        | String | Business ID                                                                                  |
| orderNo      | String | Platform order number (from the original collection response)                                |
| orderId      | String | Merchant order number                                                                        |
| refundNo     | String | Platform refund number                                                                       |
| status       | String | Refund status: 1 = success, 0 = processing, 2 = failed. Use this status as the final result. |
| errorMsg     | String | Error message (may not always be present)                                                    |
| refundAmount | String | Refund amount                                                                                |
| sign         | String | Signature                                                                                    |

## Payment Type and Payment Code<a id="inBankCode" />

| Currency | Payment Type (payType) | Payment Code (inBankCode) | Limit     | Status    | Description |
| :------- | :--------------------- | :------------------------ | :-------- | :-------- | :---------- |
| 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      | EWALLET                | GOOGLE\_PAY               | 0.99-1000 | Available | Google Pay  |
| USD      | EWALLET                | APPLE\_PAY                | 0.99-1000 | Available | Apple Pay   |

## Test Card Numbers

For test card numbers, see [Test Card Numbers](/docs/en/V20260628/api/version2/test-cards), covering successful payments, declines, and dispute scenarios.

## Related Topics

* [Front-End Component](/docs/en/V20260628/api/version2/frontend-payment-element)
* [Payment Link](/docs/en/V20260628/api/version2/payment-link)
* [VISA/MASTER Payment](/docs/en/V20260628/api/version2/creditcard)
