发起退款的接口 response 结构体声明错误
u0x01 opened this issue · 1 comments
根据文档 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_9.shtml
此处结构体文件
目前的接口如果用户使用了优惠会导致解析报错:
http request error:json: cannot unmarshal array into Go struct field RefundPromotionDetail.promotion_detail.goods_detail of type struct { MerchantGoodsID string "json:\"merchant_goods_id\""; WechatPayGoodsID string "json:\"wechatpay_goods_id\""; GoodsName string "json:\"goods_name\""; UnitPrice int "json:\"unit_price\""; RefundAmount int "json:\"refund_amount\""; RefundQuantity int "json:\"refund_quantity\"" }
以下 JSON 是服务器返回的 JSON 样例:
{ "amount": { "currency": "CNY", "discount_refund": 700, "from": [], "payer_refund": 14200, "payer_total": 14200, "refund": 14900, "refund_fee": 80, "settlement_refund": 14900, "settlement_total": 14900, "total": 14900 }, "channel": "ORIGINAL", "create_time": "2022-12-08T14:08:15+08:00", "funds_account": "AVAILABLE", "out_refund_no": "ORDERNO123456", "out_trade_no": "ORDERNO123456", "promotion_detail": [ { "amount": 600, "goods_detail": [], "promotion_id": "39542421", "refund_amount": 600, "scope": "GLOBAL", "type": "COUPON" }, { "amount": 100, "goods_detail": [], "promotion_id": "3958275", "refund_amount": 100, "scope": "GLOBAL", "type": "COUPON" } ], "refund_id": "50302", "status": "SUCCESS", "success_time": "2022-12-08T14:08:24+08:00", "transaction_id": "420000159", "user_received_account": "xx银行借记卡1234" }
请更新至v2.0.38
type GoodsDetail struct {
MerchantGoodsID string json:"merchant_goods_id"
WechatPayGoodsID string json:"wechatpay_goods_id"
GoodsName string json:"goods_name"
UnitPrice int json:"unit_price"
RefundAmount int json:"refund_amount"
RefundQuantity int json:"refund_quantity"
}
type RefundPromotionDetail struct {
PromotionID string json:"promotion_id"
Scope string json:"scope"
Type string json:"type"
Amount int json:"amount"
RefundAmount int json:"refund_amount"
GoodsDetail []*GoodsDetail json:"goods_detail"
}