> 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/jian-ti-zhong-wen/testing.md).

# 集成测试

Staging（测试）环境支持**魔法测试金额**，无需真实资金即可验证完整的集成流程 — 创建支付、状态轮询和回调处理。

> 魔法金额**仅在 staging 环境生效**。在生产环境中会被视为普通金额并路由到真实支付通道。

## 魔法金额

触发规则为金额**整数部分的最后两位数字**：

| 整数部分结尾 | 结果                       |
| ------ | ------------------------ |
| `11`   | 交易在约 5–10 秒后变为 `SUCCESS` |
| `22`   | 交易在约 5–10 秒后变为 `FAILED`  |
| 其他     | 路由到真实支付通道                |

示例：`111.00` 或 `511.00` → SUCCESS；`122.00` 或 `522.00` → FAILED。

小数部分不参与判断 — `100.11` **不是**魔法金额（整数部分为 `100`），而 `511.50` **是**（整数部分为 `511`）。

魔法金额适用于**所有支付方式**（DuitNow、TNG、FPX），并且**同时支持充值和提现**。选择哪种支付方式不影响结果，只有金额决定结果。

## 流程说明

1. 使用魔法金额创建支付（或提现），流程与生产环境完全一致。
2. 充值：支付页面会显示一个占位测试二维码（不可支付 — 不会产生真实扣款）。
3. 约 5–10 秒后，交易状态变为 `SUCCESS` 或 `FAILED`。
4. 您的 `callback_url` 会收到**真实的回调** — 报文结构、签名方案、重试机制均与生产环境相同。请按照[回调通知](/jian-ti-zhong-wen/webhooks.md)文档验证签名。
5. Staging 环境中的余额、手续费和交易记录会与真实交易完全一样地更新。

## 测试提现

提现需要可用余额。请先用魔法**充值**（例如 `111.00`）为 staging 余额充值，然后使用魔法金额创建提现：

* 结尾 `11` → 提现确认（`SUCCESS` 回调）。
* 结尾 `22` → 提现失败（`FAILED` 回调），冻结金额退回可用余额。

魔法提现可使用[银行代码](/jian-ti-zhong-wen/bank-codes.md)中的任意有效银行代码。

## 注意事项

* 魔法金额仍需在币种的正常最小/最大限额范围内。
* 测试交易的手续费为**零** — 魔法金额交易在回调和报表中的手续费字段均为 `0`。
* 魔法金额的优先级高于 `preferred_gateway`：魔法金额始终由测试通道处理，无论请求中指定了哪个首选通道。
* 如需查看真实支付页面体验（真实二维码、银行跳转），请在 staging 使用非魔法金额 — 但请注意 staging 上的真实通道可能拒绝交易；魔法金额是官方支持的端到端状态流测试方式。
* 在 staging 环境中，请避免将结尾为 `11` 或 `22` 的金额用于您*不希望*被自动完成的交易。


---

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.jgopay.com/jian-ti-zhong-wen/testing.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
