Commit 788ef957 by yemin

no message

parent da3855fe
...@@ -11,6 +11,7 @@ import ( ...@@ -11,6 +11,7 @@ import (
"github.com/wechatpay-apiv3/wechatpay-go/core/downloader" "github.com/wechatpay-apiv3/wechatpay-go/core/downloader"
"github.com/wechatpay-apiv3/wechatpay-go/core/notify" "github.com/wechatpay-apiv3/wechatpay-go/core/notify"
"github.com/wechatpay-apiv3/wechatpay-go/core/option" "github.com/wechatpay-apiv3/wechatpay-go/core/option"
"github.com/wechatpay-apiv3/wechatpay-go/services/partnerpayments"
"github.com/wechatpay-apiv3/wechatpay-go/services/partnerpayments/jsapi" "github.com/wechatpay-apiv3/wechatpay-go/services/partnerpayments/jsapi"
"github.com/wechatpay-apiv3/wechatpay-go/services/payments" "github.com/wechatpay-apiv3/wechatpay-go/services/payments"
"github.com/wechatpay-apiv3/wechatpay-go/utils" "github.com/wechatpay-apiv3/wechatpay-go/utils"
...@@ -93,12 +94,8 @@ func (s *WechatPartnerPayClient) getWxPayClient() *core.Client { ...@@ -93,12 +94,8 @@ func (s *WechatPartnerPayClient) getWxPayClient() *core.Client {
return wc return wc
} }
const (
TransactionSuccess = "TRANSACTION.SUCCESS"
RefundSuccess = "REFUND.SUCCESS"
)
// AnalysisPayNotifyResult 解析支付通知结果 // AnalysisPayNotifyResult 解析支付通知结果
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_5_5.shtml
func (s *WechatPartnerPayClient) AnalysisPayNotifyResult(request *http.Request) (*notify.Request, *payments.Transaction, error) { func (s *WechatPartnerPayClient) AnalysisPayNotifyResult(request *http.Request) (*notify.Request, *payments.Transaction, error) {
certVisitor := downloader.MgrInstance().GetCertificateVisitor(*s.MchId) certVisitor := downloader.MgrInstance().GetCertificateVisitor(*s.MchId)
handler, e := notify.NewRSANotifyHandler(*s.ApiKey, verifiers.NewSHA256WithRSAVerifier(certVisitor)) handler, e := notify.NewRSANotifyHandler(*s.ApiKey, verifiers.NewSHA256WithRSAVerifier(certVisitor))
...@@ -113,7 +110,21 @@ func (s *WechatPartnerPayClient) AnalysisPayNotifyResult(request *http.Request) ...@@ -113,7 +110,21 @@ func (s *WechatPartnerPayClient) AnalysisPayNotifyResult(request *http.Request)
return notifyReq, content, nil return notifyReq, content, nil
} }
const defaultExpireTime int64 = 30 // QueryOrderByOutTradeNo 商户订单号查询订单
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_5_2.shtml
func (s *WechatPartnerPayClient) QueryOrderByOutTradeNo(payCode string) (*partnerpayments.Transaction, error) {
wxClient := s.getWxPayClient()
svc := jsapi.JsapiApiService{Client: wxClient}
resp, _, err := svc.QueryOrderByOutTradeNo(context.Background(),
jsapi.QueryOrderByOutTradeNoRequest{
OutTradeNo: &payCode,
SpMchid: s.SpMchId,
SubMchid: s.MchId})
if err != nil {
return nil, err
}
return resp, nil
}
func getTimeExpire(expireTime *int64) time.Time { func getTimeExpire(expireTime *int64) time.Time {
if expireTime == nil || *expireTime == 0 { if expireTime == nil || *expireTime == 0 {
......
package partnerpay
const (
TransactionSuccess = "TRANSACTION.SUCCESS"
RefundSuccess = "REFUND.SUCCESS"
)
const defaultExpireTime int64 = 30
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment