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

# 取消支付

> 在 Payment Intent 到达终态前取消该支付，适用于卡支付和钱包支付。

只有在订单尚未到达终态时，你才能取消一个 Payment Intent。
一旦 Payment Intent 被取消，订单即关闭，客户将无法再完成该笔支付。

<h2 id="cancellation-service-information">取消服务说明</h2>

| 项目        | 详情                                                                                                                                                                                                                       |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **取消条件**  | 对于**卡支付**，仅当 Payment Intent 尚未到达终态时可取消。<br />对于**钱包支付**，当 Payment Intent 处于非终态时支持取消；对当天状态为 **SUCCEEDED** 的 PI 也可能支持取消（视渠道支持情况而定）。<br />完整 PI 状态列表请参考 [PaymentIntent 状态参考](/zh/global-acquiring/v1.6/guide/core-concepts) |
| **可取消金额** | 仅支持按全额取消。                                                                                                                                                                                                                |

<h2 id="how-to-cancel-a-payment">如何取消一笔支付</h2>

<h3 id="cancel-payment-via-api">通过 API 取消</h3>

下例展示调用 [Cancel a PaymentIntent](/zh/global-acquiring/v1.6/api-reference/cancel-payment-intent) endpoint 的请求和响应。

<h4 id="sample-request">示例请求</h4>

```shell theme={null}
curl --location 'https://api-sandbox.uqpaytech.com/api/v2/payment_intents/PI1961262700944166912/cancel' \
--header 'x-on-behalf-of;' \
--header 'x-idempotency-key: f20232c9-82b7-4ce5-a351-6718fc61a3d5' \
--header 'x-client-id: xcH5neaVpPAuN4yLfgCjGh' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-auth-token: Bearer your_bearer_token' \
--data '{
"cancellation_reason": "requested_by_customer"
}'
```

<h4 id="sample-response">示例响应</h4>

```json theme={null}
{
  "amount": "0.01",
  "available_payment_method_types": null,
  "cancel_time": "",
  "cancellation_reason": "requested_by_customer",
  "captured_amount": "0.01",
  "client_secret": "eyJhb****XTg",
  "complete_time": "",
  "create_time": "2025-08-29T11:00:41+08:00",
  "currency": "SGD",
  "description": "wechat pay test",
  "intent_status": "REQUIRES_CUSTOMER_ACTION",
  "latest_payment_attempt": {
    "amount": "0.01",
    "attempt_id": "PA1961262701099356160",
    "attempt_status": "AUTHENTICATION_REDIRECTED",
    "captured_amount": "0.01",
    "complete_time": "",
    "create_time": "2025-08-29T11:00:41+08:00",
    "currency": "SGD",
    "failure_code": "",
    "refunded_amount": "0",
    "update_time": "2025-08-29T11:00:41+08:00"
  },
  "merchant_order_id": "04007403-a2f6-4531-97df-cdc8102f6713",
  "metadata": {
    "request_id": "b4fc2aea-5300-4ab8-bf48-4c0aa16cb5b7"
  },
  "next_action": {
    "display_qr_code": {
      "expires_at": "2025-08-29T11:30:41.061+08:00",
      "qr_code": "weixin://wxpay/bizpayurl?pr=1gEb7g3z1",
      "qr_code_url": "https://sg-acquiring-bucket-sandbox.s3.ap-southeast-1.amazonaws.com/payment/20250829/qrcode_PA1961262701099356160?X-Amz-Algorithm=AWS4-HMAC-SHA256\u0026X-Amz-Credential=ASIAY******f987429"
    }
  },
  "payment_intent_id": "PI1961262700944166912",
  "return_url": "https://paymentresultpage.com",
  "update_time": "2025-08-29T11:01:32+08:00"
}
```

你可以通过监听 `acquiring.cancel.succeeded` webhook，或主动调用 [**Retrieve a payment intent**](/zh/global-acquiring/v1.6/api-reference/retrieve-payment-intent) API 查询 Payment Intent 状态，来判断取消是否已成功处理。

<h3 id="cancel-payment-via-dashboard">通过控制台取消</h3>

在控制台中，点击订单旁的操作按钮，选择 **Cancel**
