代码拉取完成,页面将自动刷新
/*
* @Author: i@douxuefeng.cn
* @Date: 2022-05-14 17:02:20
* @LastEditTime: 2022-06-01 10:53:19
* @LastEditors: i@douxuefeng.cn
* @Description:
* @FilePath: \go-utils\wechat\pay\app.go
*/
package pay
import (
"github.com/wechatpay-apiv3/wechatpay-go/core"
"github.com/wechatpay-apiv3/wechatpay-go/services/payments"
pay_app "github.com/wechatpay-apiv3/wechatpay-go/services/payments/app"
)
type app struct {
*PayConfig
}
func NewApp(cfg *PayConfig) *app {
return &app{cfg}
}
func (p *app) PrepayOrder(prepay OrderRequest) (*pay_app.PrepayResponse, *core.APIResult, error) {
client, ctx, err := GetClient(p.PayConfig)
if err != nil {
return nil, nil, err
}
svc := pay_app.AppApiService{Client: client}
resp, result, err := svc.Prepay(ctx, pay_app.PrepayRequest{
Appid: core.String(p.AppAppid),
Mchid: core.String(p.MchId),
Description: core.String(prepay.Description),
OutTradeNo: core.String(prepay.OutTradeNo),
Attach: core.String(prepay.Attach),
NotifyUrl: core.String(p.Notify),
Amount: &pay_app.Amount{
Total: core.Int64(int64(prepay.Amount) * 100),
},
SceneInfo: &pay_app.SceneInfo{
PayerClientIp: core.String(prepay.ClientIp),
},
})
return resp, result, err
}
func (p *app) QueryOrderByTransactionId(transactionId string) (*payments.Transaction, *core.APIResult, error) {
client, ctx, err := GetClient(p.PayConfig)
if err != nil {
return nil, nil, err
}
svc := pay_app.AppApiService{Client: client}
return svc.QueryOrderById(ctx, pay_app.QueryOrderByIdRequest{
Mchid: core.String(p.MchId),
TransactionId: core.String(transactionId),
})
}
func (p *app) QueryOrderByOutTradeNo(outNo string) (*payments.Transaction, *core.APIResult, error) {
client, ctx, err := GetClient(p.PayConfig)
if err != nil {
return nil, nil, err
}
svc := pay_app.AppApiService{Client: client}
return svc.QueryOrderByOutTradeNo(ctx, pay_app.QueryOrderByOutTradeNoRequest{
Mchid: core.String(p.MchId),
OutTradeNo: core.String(outNo),
})
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。