核销订单

当店员确认可以使用后,再调用 redeem 进行正式核销。系统仍会再次检查商户权限及订单状态。

POST/api/integrations/merchant/bookings/redeem

为已验证商户核销指定订单。

Request 字段

字段
类型
必填
说明
bookingId
string
取得的凭证 Id。

Response 字段

字段
类型
说明
code
number
返回代码。
success
boolean
核销成功时会出现。
message
string
可读消息。
booking
object
核销完成后的订单摘要。
reason
string
code 4 时的受控错误原因。

返回代码

为了让商户文档及收银员界面更简单,Yuter 将此集成返回统一成四个顶层代码。

代码
含义
备注
1
成功
订单验证成功或已成功核销。
2
已核销
此订单在本次请求前已完成核销。
3
无效订单
booking id 无效,或找不到相关订单。
4
其他错误
认证失败、不可核销、商户无权限,或其他受控错误。

核销订单示例

核销订单 endpoint 的 request 与 response 示例。

cURL 示例

API_KEY='<raw merchant api key>'
BOOKING_ID='<booking id>'
TIMESTAMP=$(($(date +%s) * 1000))
NONCE=$(uuidgen)
BODY='{"bookingId":"'"$BOOKING_ID"'"}'
PATH='/api/integrations/merchant/bookings/redeem'
PAYLOAD="POST
$PATH
$TIMESTAMP
$NONCE
$BODY"
SIGNATURE=$(printf "%s" "$PAYLOAD" | openssl dgst -sha256 -hmac "$API_KEY" -hex | sed 's/^.* //')

curl -X POST "https://www.yuterwellness.com$PATH" \
  -H "Content-Type: application/json" \
  -H "x-api-key: $API_KEY" \
  -H "x-timestamp: $TIMESTAMP" \
  -H "x-nonce: $NONCE" \
  -H "x-signature: $SIGNATURE" \
  -d "$BODY"

响应示例

{
  "code": 1,
  "success": true,
  "message": "Booking redeemed successfully",
  "booking": {
    "_id": "69ce982e96a5b33a356abab0",
    "programTitle": "Private Merchant Test Event",
    "userName": "Test User",
    "userEmail": "test@example.com",
    "quantity": 1,
    "date": "2026-04-10",
    "status": "redeemed",
    "redeemedAt": "2026-04-10T10:22:16.120Z",
    "redeemedBy": "Merchant API: Merchant Test Key"
  }
}