Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wechat-client-sdk
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
go
wechat-client-sdk
Commits
788ef957
Commit
788ef957
authored
Oct 27, 2022
by
yemin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
da3855fe
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
6 deletions
+24
-6
Client.go
partnerpay/Client.go
+17
-6
consts.go
partnerpay/consts.go
+7
-0
No files found.
partnerpay/Client.go
View file @
788ef957
...
@@ -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
{
...
...
partnerpay/consts.go
0 → 100644
View file @
788ef957
package
partnerpay
const
(
TransactionSuccess
=
"TRANSACTION.SUCCESS"
RefundSuccess
=
"REFUND.SUCCESS"
)
const
defaultExpireTime
int64
=
30
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment