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

# WhatsApp 支付更新 Webhook 示例

> 处理 WhatsApp 支付状态更新。

<Note>如需查看完整的 Schema 衍生目录，请参阅[所有示例](/zh/api-reference/guides/examples/webhook-examples/webhook-payload-examples)。</Note>

## 概述

处理 WhatsApp 支付状态更新。

## 准备工作

* 在您的应用程序中创建一个公开的 HTTPS 端点。
* 为您所需的事件类型配置 YCloud Webhook 端点。
* 安全存储端点签名密钥。
* 确保事件处理具有幂等性。

## 工作原理

事件发生时，YCloud 会发送 HTTP `POST` 请求。验证签名，持久化记录事件，返回 `2xx` 响应，并异步处理耗时任务。

## 请求

以下场景展示了发送到您的 Webhook URL 的请求。将事件 `id` 视为传递标识符，并使用 `type` 路由有效负载。

## 响应

接收事件后返回 `2xx` 状态。

```http theme={"theme":{"light":"github-light","dark":"github-dark"}}
HTTP/1.1 200 OK
```

<Note>有关端点设置、签名验证和重试机制的更多信息，请参阅[配置 Webhook](/zh/api-reference/guides/api-fundamentals/configure-webhooks)。</Note>

## 支付交易已更新

当用户发起的交易状态发生变更时，您将通过 Webhook 收到更新。这会在支付状态更改为 `captured`（支付成功完成）或 `pending`（用户已尝试但尚未收到交易成功信号）时发生。

### 请求

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "evt_eEkn26qar3nOB8md",
  "type": "whatsapp.payment.updated",
  "apiVersion": "v2",
  "createTime": "2024-10-10T07:08:00.000Z",
  "whatsappPayment": {
    "wabaId": "WABA-ID",
    "referenceId": "<reference-id>",
    "status": "captured | pending",
    "transactions": [
      {
        "id": "<transaction-id>",
        "type": "billdesk | payu | razorpay | zaakpay",
        "status": "pending | success | failed",
        "createdTimestamp": 1728544066000,
        "updatedTimestamp": 1728544066000,
        "amount": {
          "value": 21000,
          "offset": 100
        },
        "currency": "INR",
        "methodType": "upi | card | wallet | netbanking",
        "error": {
          "code": "error-code",
          "reason": "error-reason"
        }
      }
    ]
  }
}
```

### 响应

在持久化接收事件后确认投递。

```http theme={"theme":{"light":"github-light","dark":"github-dark"}}
HTTP/1.1 200 OK
```

### 说明

* 要发送订单详情消息以接收付款，请参阅[订单详情消息模板](/zh/api-reference/guides/examples/api-examples/whatsapp-messaging-examples#order-details-template-message)和[交互式订单详情消息](/zh/api-reference/guides/examples/api-examples/whatsapp-messaging-examples#interactive-order-details-message)。
* 客户尝试付款后，您将收到付款更新。要向客户通知订单状态，请参阅[订单状态消息模板](/zh/api-reference/guides/examples/api-examples/whatsapp-messaging-examples#order-status-template-message)和[交互式订单状态消息](/zh/api-reference/guides/examples/api-examples/whatsapp-messaging-examples#interactive-order-status-message)。


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