Commit da3855fe by yemin

no message

parent 6536c4f9
...@@ -7,11 +7,16 @@ import ( ...@@ -7,11 +7,16 @@ import (
"errors" "errors"
"fmt" "fmt"
"github.com/wechatpay-apiv3/wechatpay-go/core" "github.com/wechatpay-apiv3/wechatpay-go/core"
"github.com/wechatpay-apiv3/wechatpay-go/core/auth/verifiers"
"github.com/wechatpay-apiv3/wechatpay-go/core/downloader"
"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/jsapi" "github.com/wechatpay-apiv3/wechatpay-go/services/partnerpayments/jsapi"
"github.com/wechatpay-apiv3/wechatpay-go/services/payments"
"github.com/wechatpay-apiv3/wechatpay-go/utils" "github.com/wechatpay-apiv3/wechatpay-go/utils"
"log" "log"
"math/big" "math/big"
"net/http"
"strings" "strings"
"time" "time"
) )
...@@ -88,6 +93,26 @@ func (s *WechatPartnerPayClient) getWxPayClient() *core.Client { ...@@ -88,6 +93,26 @@ func (s *WechatPartnerPayClient) getWxPayClient() *core.Client {
return wc return wc
} }
const (
TransactionSuccess = "TRANSACTION.SUCCESS"
RefundSuccess = "REFUND.SUCCESS"
)
// AnalysisPayNotifyResult 解析支付通知结果
func (s *WechatPartnerPayClient) AnalysisPayNotifyResult(request *http.Request) (*notify.Request, *payments.Transaction, error) {
certVisitor := downloader.MgrInstance().GetCertificateVisitor(*s.MchId)
handler, e := notify.NewRSANotifyHandler(*s.ApiKey, verifiers.NewSHA256WithRSAVerifier(certVisitor))
if e != nil {
return nil, nil, e
}
content := new(payments.Transaction)
notifyReq, err := handler.ParseNotifyRequest(context.Background(), request, content)
if err != nil {
return nil, nil, errors.New(getErrMessage(err.Error()))
}
return notifyReq, content, nil
}
const defaultExpireTime int64 = 30 const defaultExpireTime int64 = 30
func getTimeExpire(expireTime *int64) time.Time { func getTimeExpire(expireTime *int64) time.Time {
......
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