From 3e4a1ded725f36b63f8dd1352ca16f00d2a08e2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Wed, 7 Sep 2022 17:40:44 +0800 Subject: [PATCH] - update profitsharing --- const.go | 2 +- pay.partner.transactions.jsapi.notify.gin.go | 1 + profitsharing.receivers.notify.gin.go | 56 ++++++++++++++++++++ refund.domestic.refunds.notify.gin.go | 1 + 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 profitsharing.receivers.notify.gin.go diff --git a/const.go b/const.go index 629cc70..5d21a25 100644 --- a/const.go +++ b/const.go @@ -14,7 +14,7 @@ const ( // SDK 相关信息 const ( - Version = "1.0.16" // SDK 版本 + Version = "1.0.17" // SDK 版本 UserAgentFormat = "WechatPay-Go/%s (%s) GO/%s" // UserAgent中的信息 ) diff --git a/pay.partner.transactions.jsapi.notify.gin.go b/pay.partner.transactions.jsapi.notify.gin.go index 840d35f..4a68fff 100644 --- a/pay.partner.transactions.jsapi.notify.gin.go +++ b/pay.partner.transactions.jsapi.notify.gin.go @@ -39,6 +39,7 @@ func (c *Client) PayPartnerTransactionsJsapiNotifyGin(ctx context.Context, ginCt return validateJson, response, gcm, err } +// PayPartnerTransactionsJsapiNotifyGinResponse JSAPI下单 - 回调通知 - 解密后数据 type PayPartnerTransactionsJsapiNotifyGinResponse struct { SpAppid string `json:"sp_appid"` // 服务商应用ID SpMchid string `json:"sp_mchid"` // 服务商户号 diff --git a/profitsharing.receivers.notify.gin.go b/profitsharing.receivers.notify.gin.go new file mode 100644 index 0000000..7033916 --- /dev/null +++ b/profitsharing.receivers.notify.gin.go @@ -0,0 +1,56 @@ +package wechatpayopen + +import ( + "context" + "encoding/json" + "github.com/gin-gonic/gin" +) + +// ProfitSharingReceiversNotifyGinRequest 分账动账通知API - 回调通知 - 请求参数 +type ProfitSharingReceiversNotifyGinRequest struct { + Id string `form:"id" json:"status" xml:"id" uri:"id" binding:"required"` // 通知ID + CreateTime string `form:"create_time" json:"create_time" xml:"create_time" uri:"create_time" binding:"required"` // 通知创建时间 + EventType string `form:"event_type" json:"event_type" xml:"event_type" uri:"event_type" binding:"required"` // 通知类型 + Summary string `form:"summary" json:"summary" xml:"summary" uri:"summary" binding:"required"` // 通知简要说明 + ResourceType string `form:"resource_type" json:"resource_type" xml:"resource_type" uri:"resource_type" binding:"required"` // 通知数据类型 + Resource struct { + Algorithm string `form:"algorithm" json:"algorithm" xml:"algorithm" uri:"algorithm" binding:"required"` // 加密算法类型 + Ciphertext string `form:"ciphertext" json:"ciphertext" xml:"ciphertext" uri:"ciphertext" binding:"required"` // 数据密文 + AssociatedData string `form:"associated_data" json:"associated_data" xml:"associated_data" uri:"associated_data" binding:"omitempty"` // 附加数据 + OriginalType string `form:"original_type" json:"original_type" xml:"original_type" uri:"original_type" binding:"required"` // 原始类型 + Nonce string `form:"nonce" json:"nonce" xml:"nonce" uri:"nonce" binding:"required"` // 随机串 + } `form:"resource" json:"resource" xml:"resource" uri:"resource" binding:"required"` // 通知数据 +} + +// ProfitSharingReceiversNotifyGin 分账动账通知API - 回调通知 +// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_5.shtml +func (c *Client) ProfitSharingReceiversNotifyGin(ctx context.Context, ginCtx *gin.Context) (validateJson ProfitSharingReceiversNotifyGinRequest, response ProfitSharingReceiversNotifyGinResponse, gcm []byte, err error) { + + // 解析 + err = ginCtx.ShouldBind(&validateJson) + + gcm, err = c.decryptGCM(c.GetApiV3(), validateJson.Resource.Nonce, validateJson.Resource.Ciphertext, validateJson.Resource.AssociatedData) + if err != nil { + return validateJson, response, gcm, err + } + + err = json.Unmarshal(gcm, &response) + + return validateJson, response, gcm, err +} + +// ProfitSharingReceiversNotifyGinResponse 分账动账通知API - 回调通知 - 解密后数据 +type ProfitSharingReceiversNotifyGinResponse struct { + SpMchid string `json:"sp_mchid"` // 服务商商户号 + SubMchid string `json:"sub_mchid"` // 子商户号 + TransactionId string `json:"transaction_id"` // 微信订单号 + OrderId string `json:"order_id"` // 微信分账/回退单号 + OutOrderNo string `json:"out_order_no"` // 商户分账/回退单号 + Receiver struct { + Type string `json:"type"` // 分账接收方类型 + Account string `json:"account"` // 分账接收方账号 + Amount int `json:"amount"` // 分账动账金额 + Description string `json:"description"` // 分账/回退描述 + } `json:"receiver"` // 分账接收方列表 + SuccessTime string `json:"success_time"` // 成功时间 +} diff --git a/refund.domestic.refunds.notify.gin.go b/refund.domestic.refunds.notify.gin.go index ea2766e..2513872 100644 --- a/refund.domestic.refunds.notify.gin.go +++ b/refund.domestic.refunds.notify.gin.go @@ -39,6 +39,7 @@ func (c *Client) RefundDomesticRefundsNoNotifyGin(ctx context.Context, ginCtx *g return validateJson, response, gcm, err } +// RefundDomesticRefundsNoNotifyGinResponse 申请退款API - 回调通知 - 解密后数据 type RefundDomesticRefundsNoNotifyGinResponse struct { SpMchid string `json:"sp_mchid"` // 服务商户号 SubMchid string `json:"sub_mchid"` // 子商户号