ArtisanCloud / PowerWeChat

PowerWechat是一款基于WeChat SDK for Golang,支持小程序、微信支付、企业微信、公众号等全微信生态
https://powerwechat.artisan-cloud.com
MIT License
1.21k stars 149 forks source link

发起退款的接口 response 结构体声明错误 #217

Closed u0x01 closed 1 year ago

u0x01 commented 1 year ago

根据文档 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_9.shtml 此处结构体文件 https://github.com/ArtisanCloud/PowerWeChat/blob/cd3343f4a2393e26e945ae33963cef76fb0ee356/src/payment/refund/response/responseRefund.go#L40 应为数组类型。

image

目前的接口如果用户使用了优惠会导致解析报错: 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" }

Matrix-X commented 1 year ago

请更新至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" }