Skip to content

Commit

Permalink
v1.5.104
Browse files Browse the repository at this point in the history
  • Loading branch information
iGoogle-ink committed Aug 15, 2024
1 parent 4c69964 commit 16f2f89
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 16 deletions.
8 changes: 5 additions & 3 deletions release_note.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
版本号:Release 1.5.104
修改记录:
(1) gopay:golang.org/x/crypto v0.24.0 版本升级到 v0.25.0。
(1) gopay:golang.org/x/crypto v0.24.0 版本升级到 v0.26.0。
(2) 支付宝:client.TradeOrderSettle(),response 完善字段。
(3) 微信V3:新增client.V3QQTransactionH5(), QQ小程序H5下单。
(4) 微信V3:新增client.V3CombineQQTransactionH5(), 合单QQ小程序下单-H5。
(3) 微信V3:新增 client.V3QQTransactionH5(),QQ小程序H5下单。
(4) 微信V3:新增 client.V3CombineQQTransactionH5(),合单QQ小程序下单-H5。
(5) 微信V3:新增 wechat.V3DecryptViolationNotifyCipherText(),解密 服务商子商户处置记录 回调中的加密信息。#412
(6) 微信V3:新增 V3NotifyReq method req.DecryptViolationCipherText(),解密 服务商子商户处置记录 回调中的加密信息。

版本号:Release 1.5.103
修改记录:
Expand Down
14 changes: 14 additions & 0 deletions wechat/v3/encrypt_decrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,17 @@ func V3DecryptInvoiceNotifyCipherText(ciphertext, nonce, additional, apiV3Key st
}
return result, nil
}

// 解密 服务商子商户处置记录 回调中的加密信息
func V3DecryptViolationNotifyCipherText(ciphertext, nonce, additional, apiV3Key string) (result *V3DecryptViolationResult, err error) {
cipherBytes, _ := base64.StdEncoding.DecodeString(ciphertext)
decrypt, err := aes.GCMDecrypt(cipherBytes, []byte(nonce), []byte(additional), []byte(apiV3Key))
if err != nil {
return nil, fmt.Errorf("aes.GCMDecrypt, err:%w", err)
}
result = &V3DecryptViolationResult{}
if err = json.Unmarshal(decrypt, result); err != nil {
return nil, fmt.Errorf("json.Unmarshal(%s), err:%w", string(decrypt), err)
}
return result, nil
}
28 changes: 15 additions & 13 deletions wechat/v3/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ type V3DecryptPartnerPayResult struct {
PromotionDetail []*PromotionDetail `json:"promotion_detail"`
}

// V3DecryptViolationNotificationResult 服务商子商户处置记录回调通知
type V3DecryptViolationNotificationResult struct {
// 服务商子商户处置记录回调通知
type V3DecryptViolationResult struct {
SubMchid string `json:"sub_mchid" dc:"子商户商户ID"`
CompanyName string `json:"company_name" dc:"子商户主体名称"`
RecordId string `json:"record_id" dc:"通知ID,可用于去重"`
Expand All @@ -69,17 +69,6 @@ type V3DecryptViolationNotificationResult struct {
RiskDescription string `json:"risk_description" dc:"风险描述"`
}

// V3DecryptViolationNotification 服务商子商户处置记录回调解密
func V3DecryptViolationNotification(req *http.Request, apiV3Key string) (res *V3DecryptViolationNotificationResult, err error) {
notifyResult, err := V3ParseNotify(req)
if err != nil {
return
}
var result *V3DecryptViolationNotificationResult
err = notifyResult.DecryptCipherTextToStruct(apiV3Key, &result)
return result, err
}

// 退款通知 解密结果
type V3DecryptRefundResult struct {
Mchid string `json:"mchid"`
Expand Down Expand Up @@ -548,6 +537,19 @@ func (v *V3NotifyReq) DecryptInvoiceCipherText(apiV3Key string) (result *V3Decry
return nil, errors.New("notify data Resource is nil")
}

// 解密 服务商子商户处置记录 回调中的加密信息
func (v *V3NotifyReq) DecryptViolationCipherText(apiV3Key string) (result *V3DecryptViolationResult, err error) {
if v.Resource != nil {
result, err = V3DecryptViolationNotifyCipherText(v.Resource.Ciphertext, v.Resource.Nonce, v.Resource.AssociatedData, apiV3Key)
if err != nil {
bytes, _ := json.Marshal(v)
return nil, fmt.Errorf("V3NotifyReq(%s) decrypt cipher text error(%w)", string(bytes), err)
}
return result, nil
}
return nil, errors.New("notify data Resource is nil")
}

// Deprecated
// 暂时不推荐此方法,请使用 wechat.V3ParseNotify()
// 解析微信回调请求的参数到 gopay.BodyMap
Expand Down

0 comments on commit 16f2f89

Please sign in to comment.