Business flow diagram
用户意图
│
├─ 下单支付("帮我付款")──→ createOrder → 支付订单卡片
│ │
│ 用户点击"确认支付"
│ ↓
│ 调用 wx.requestPayment
│ ↓
│ 支付成功/失败
│
├─ 查询订单("查一下订单")──→ queryOrder → 订单状态卡片
│
├─ 关闭订单("取消这个订单")─→ closeOrder → 订单状态卡片(已关闭)
│
├─ 申请退款("我要退款")───→ refundOrder → 退款结果卡片
│
├─ 查询退款("退款进度")───→ queryRefund → 退款状态卡片
│
├─ 商家转账("转账给我")───→ transferMoney → 转账结果卡片
│
└─ 查询转账("转账到了吗")──→ queryTransfer → 转账状态卡片
createOrder must be called before payment—only after obtaining payment parameters can WeChat Pay be invoked. refundOrder must be called after the order is paid successfully—unpaid orders cannot be refunded. closeOrder applies only to unpaid orders—paid orders cannot be closed and must go through the refund process.
Atomic API dependencies
| API | Purpose | Component | Precondition |
|---|---|---|---|
| createOrder | Create a payment order and invoke payment | payment-card | User explicitly expresses payment intent |
| queryOrder | Query order status | order-status-card | outTradeNo already exists |
| closeOrder | Close an unpaid order | order-status-card | Order status is NOTPAY |
| refundOrder | Apply for refund | refund-card | Order status is SUCCESS |
| queryRefund | Query refund progress | refund-card | outRefundNo already exists |
| transferMoney | Initiate merchant transfer | transfer-card | User confirms transfer |
| queryTransfer | Query transfer status | transfer-card | outBillNo already exists |
Business constraints (cross-API iron rules)
1. Output format
- For all APIs that return successfully (isError=false) and are bound to a component,a card must be displayed, and it is forbidden to list the detailed data in the card as plain text.
- The Agent may append a brief guiding sentence when replying, butit is forbidden to expand order numbers, amounts, statuses, etc. in the form of a markdown list。
2. Execution order
refundOrdermust be called afterqueryOrderconfirms the order is in SUCCESS status.closeOrdermust be called afterqueryOrderconfirms the order is in NOTPAY status.- Concurrent calls to the payment API are forbidden; the next payment must be initiated only after the previous one has ended.
3. Data source
outTradeNomust come from the original value ofcreateOrderreturned byoutTradeNo, and fabrication is forbidden.outRefundNomust come from the original value ofrefundOrderreturned byoutRefundNo, and fabrication is forbidden.outBillNomust come from the original value oftransferMoneyreturned byoutBillNo, and fabrication is forbidden.
4. Amount handling
- All amounts are in units offen(e.g., 1 yuan = 100 fen).
- It is forbidden to use an amount passed in from the frontend to place an order directly; in production, it should be queried from the backend.
- The refund amount cannot exceed the total order amount.
5. Security constraints
- The backend calls through
wx.cloud.callHTTPFunction, and the platform automatically authenticates. payer.openidis automatically obtained by the backend from thex-wx-openidheader, and the frontend does not need to pass it.- It is forbidden to hardcode any key or certificate information in the frontend.
User intent routing
Direct intent (triggers this SKILL)
- "Help me pay"
- "I want to pay"
- "Pay the bill"
- "Check the order status"
- "This order hasn't been paid yet, right"
- "Cancel the order"
- "Close this order"
- "I want a refund"
- "Apply for return and refund"
- "Where did the refund go"
- "Transfer to me"
- "Send a red packet"
Intent routing rules
- User says "payment/pay/checkout" →
createOrder - User asks "order status/check order" →
queryOrder - User says "cancel/close order" →
closeOrder(first check the order to confirm NOTPAY) - User says "refund/return money" →
refundOrder(first check the order to confirm SUCCESS) - User asks "refund progress/has it arrived" →
queryRefund - User says "transfer/send money" →
transferMoney - User asks "transfer status" →
queryTransfer - User expression is ambiguous → ask a clarifying question first, guessing is prohibited