mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-04 12:52:27 +08:00
[feature] Format the code and improve Mini Program authorization to o… (#473)
* [feature] Format the code and improve Mini Program authorization to obtain openid(miniprogram/auth/auth.go Code2Session) * [feature] CheckEncryptedData (https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/user-info/auth.checkEncryptedData.html) * upgrade json error * upgrade json error Co-authored-by: houseme <houseme@outlook.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package config
|
||||
|
||||
// Config config for pay
|
||||
// Config .config for pay
|
||||
type Config struct {
|
||||
AppID string `json:"app_id"`
|
||||
MchID string `json:"mch_id"`
|
||||
|
||||
@@ -4,12 +4,12 @@ import (
|
||||
"github.com/silenceper/wechat/v2/pay/config"
|
||||
)
|
||||
|
||||
//Notify 回调
|
||||
// Notify 回调
|
||||
type Notify struct {
|
||||
*config.Config
|
||||
}
|
||||
|
||||
//NewNotify new
|
||||
// NewNotify new
|
||||
func NewNotify(cfg *config.Config) *Notify {
|
||||
return &Notify{cfg}
|
||||
}
|
||||
|
||||
@@ -172,9 +172,9 @@ func (o *Order) BridgeConfig(p *Params) (cfg Config, err error) {
|
||||
// BridgeAppConfig get app bridge config
|
||||
func (o *Order) BridgeAppConfig(p *Params) (cfg ConfigForApp, err error) {
|
||||
var (
|
||||
timestamp string = strconv.FormatInt(time.Now().Unix(), 10)
|
||||
noncestr string = util.RandomStr(32)
|
||||
_package string = "Sign=WXPay"
|
||||
timestamp = strconv.FormatInt(time.Now().Unix(), 10)
|
||||
noncestr = util.RandomStr(32)
|
||||
_package = "Sign=WXPay"
|
||||
)
|
||||
order, err := o.PrePayOrder(p)
|
||||
if err != nil {
|
||||
|
||||
@@ -8,12 +8,12 @@ import (
|
||||
"github.com/silenceper/wechat/v2/pay/transfer"
|
||||
)
|
||||
|
||||
//Pay 微信支付相关API
|
||||
// Pay 微信支付相关API
|
||||
type Pay struct {
|
||||
cfg *config.Config
|
||||
}
|
||||
|
||||
//NewPay 实例化微信支付相关API
|
||||
// NewPay 实例化微信支付相关API
|
||||
func NewPay(cfg *config.Config) *Pay {
|
||||
return &Pay{cfg}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ func NewTransfer(cfg *config.Config) *Transfer {
|
||||
return &transfer
|
||||
}
|
||||
|
||||
//Params 调用参数
|
||||
// Params 调用参数
|
||||
type Params struct {
|
||||
DeviceInfo string
|
||||
PartnerTradeNo string
|
||||
@@ -34,10 +34,10 @@ type Params struct {
|
||||
Amount int
|
||||
Desc string
|
||||
SpbillCreateIP string
|
||||
RootCa string //ca证书
|
||||
RootCa string // ca证书
|
||||
}
|
||||
|
||||
//request 接口请求参数
|
||||
// request 接口请求参数
|
||||
type request struct {
|
||||
AppID string `xml:"mch_appid"`
|
||||
MchID string `xml:"mchid"`
|
||||
@@ -53,7 +53,7 @@ type request struct {
|
||||
SpbillCreateIP string `xml:"spbill_create_ip,omitempty"`
|
||||
}
|
||||
|
||||
//Response 接口返回
|
||||
// Response 接口返回
|
||||
type Response struct {
|
||||
ReturnCode string `xml:"return_code"`
|
||||
ReturnMsg string `xml:"return_msg"`
|
||||
@@ -69,7 +69,7 @@ type Response struct {
|
||||
PaymentTime string `xml:"payment_time"`
|
||||
}
|
||||
|
||||
//WalletTransfer 付款到零钱
|
||||
// WalletTransfer 付款到零钱
|
||||
func (transfer *Transfer) WalletTransfer(p *Params) (rsp Response, err error) {
|
||||
nonceStr := util.RandomStr(32)
|
||||
param := make(map[string]string)
|
||||
|
||||
Reference in New Issue
Block a user