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

# 更新订单状态

## 更新订单状态之前

在更新订单状态之前， **请确保订单已支付**。YCloud 将通过此 [Webhook](/zh/api-reference/webhooks/test-webhooks) 向您推送已支付状态。&#x20;

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

示例：

```
{
  "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"
        }
      }
    ]
  }
}
```

## 订单状态枚举值

| 值 | 描述 |
| - | - |
| `pending` | 用户尚未成功支付 |
| `processing` | 用户支付已授权，商家/合作伙伴正在履行订单、提供服务等。 |
| `partially-shipped` | 商家已发货订单中的部分商品 |
| `shipped` | 商家已发货订单中的所有商品 |
| `completed` | 订单已完成，用户或合作伙伴/商家无需采取进一步操作 |
| `canceled` | 合作伙伴/商家希望取消该订单/发票的 `order_details` 消息。如果该 `order_details` 消息已存在 `successful` 或 `pending` 支付，状态更新将失败 |

<img src="https://mintcdn.com/lchnan/WD-ixrYVrqB7b7aQ/product-assets/3be4b91634-image-596.webp?fit=max&auto=format&n=WD-ixrYVrqB7b7aQ&q=85&s=a91122cebfd41c2afbedd93da2cf01f3" alt="YCloud 产品截图" width="765" height="307" data-path="product-assets/3be4b91634-image-596.webp" />

## 如何向客户通知订单状态变更？

当订单确认或发货时，您可以通过发送订单状态更新模板来通知客户。

例如：当订单发货后，您可以向客户发送 **订单状态更新** 模板，通知他们最新的状态。

### 创建订单状态更新模板

<Info>
  前提条件是您已关联支付账户。
</Info>

1. 通过 API 创建

API 参考：[创建模板](/api-reference/whatsapp-templates/create-a-template)

创建示例：[创建模板](/api-reference/whatsapp-templates/create-a-template)

2. 在 YCloud 上创建

访问 [https://www.ycloud.com/console/#/app/dashboard/template](https://www.ycloud.com/console/#/app/dashboard/template)

<img src="https://mintcdn.com/lchnan/6CxA7mK2t7klNAOL/product-assets/9b7f2f2c98-image-597.webp?fit=max&auto=format&n=6CxA7mK2t7klNAOL&q=85&s=69883deedf4517a575e99109af6fa9d9" alt="YCloud 产品截图" width="1592" height="827" data-path="product-assets/9b7f2f2c98-image-597.webp" />

### 发送订单状态更新消息

API 参考：[直接发送消息](/api-reference/whatsapp-messages/send-a-message-directly)

示例：

```
curl 'https://api.ycloud.com/v2/whatsapp/messages/sendDirectly' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: {{YOUR-API-KEY}}' \
-d '{
  "from": "{{BUSINESS-PHONE-NUMBER}}",
  "to": "{{CUSTOMER-PHONE-NUMBER}}",
  "type": "template",
  "template": {
    "name": "order_status_template",
    "language": {
      "policy": "deterministic",
      "code": "en_US"
    },
    "components": [
      {
        "type": "order_status",
        "parameters": [
          {
            "type": "order_status",
            "order_status": {
              "reference_id": "<reference_id_value>",
              "order": {
                "status": "processing | partially_shipped | shipped | completed | canceled",
                "description": "<OPTIONAL_DESCRIPTION>"
              }
            }
          }
        ]
      }
    ]
  }
}'
```


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