mwechat

package
v0.0.37 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2022 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckSign

func CheckSign(appSecret string, paramsMap gin.H) bool

CheckSign 检查签名

func GetSign

func GetSign(appSecret string, paramsMap gin.H) string

GetSign 获取签名

func PayV1GetPrepay

func PayV1GetPrepay(appID, mchID, mchKey, payBody, outTradeNo, clientIP, cbURL, tradeType, openID string, totalFee int64) (gin.H, error)

PayV1GetPrepay 获取预支付信息

func PayV3CheckSign

func PayV3CheckSign(header map[string][]string, body []byte, cerStr string) error

PayV3CheckSign v3签名验证

func PayV3Decrype

func PayV3Decrype(key string, cipherStr, nonce, associatedData string) (string, error)

PayV3Decrype 解密

func PayV3GetHeaderByKey

func PayV3GetHeaderByKey(header map[string][]string, key string) (string, error)

PayV3GetHeaderByKey 获取头

func PayV3GetPrepay

func PayV3GetPrepay(keySerial string, key *rsa.PrivateKey, appID, mchID, openID, payBody, outTradeNo, cbURL string, totalFee int64, expireAt time.Time) (gin.H, string, error)

PayV3GetPrepay 获取预支付信息

func PayV3Sign

func PayV3Sign(mchid, keySerial string, key *rsa.PrivateKey, req *gorequest.SuperAgent) (*gorequest.SuperAgent, error)

PayV3Sign v3签名

func PayV3SignPrepayid

func PayV3SignPrepayid(key *rsa.PrivateKey, appID, prepayid string) (gin.H, error)

PayV3SignPrepayid 签名prepayid

func PayV3SignStr

func PayV3SignStr(key *rsa.PrivateKey, cols []string) (string, error)

PayV3SignStr 获取签名结果

func RsaSign

func RsaSign(signContent string, privateKey *rsa.PrivateKey, hash crypto.Hash) (string, error)

RsaSign 签名

func SQLRedisGetWxToken

func SQLRedisGetWxToken(c context.Context, tx mdb.ExecuteAble, redisClient *redis.Client, appID string,
	funcSQLGetToken func(context.Context, mdb.ExecuteAble, string) (string, string, int64, error),
	funcSQLSetToken func(context.Context, mdb.ExecuteAble, string, string, string, int64) error,
) (string, error)

SQLRedisGetWxToken 获取小程序token

func SQLRedisRestWxToken

func SQLRedisRestWxToken(c context.Context, tx mdb.ExecuteAble, redisClient *redis.Client, appID string,
	funcSQLResetToken func(context.Context, mdb.ExecuteAble, string) error,
)

SQLRedisRestWxToken 重置小程序token

func XMLWalk

func XMLWalk(bs []byte) (gin.H, error)

XMLWalk 遍历xml

Types

type StRefundRespXML

type StRefundRespXML struct {
	XMLName           xml.Name `xml:"xml"`
	Text              string   `xml:",chardata"`
	ReturnCode        string   `xml:"return_code"`
	ReturnMsg         string   `xml:"return_msg"`
	Appid             string   `xml:"appid"`
	MchID             string   `xml:"mch_id"`
	NonceStr          string   `xml:"nonce_str"`
	Sign              string   `xml:"sign"`
	ResultCode        string   `xml:"result_code"`
	TransactionID     string   `xml:"transaction_id"`
	OutTradeNo        string   `xml:"out_trade_no"`
	OutRefundNo       string   `xml:"out_refund_no"`
	RefundID          string   `xml:"refund_id"`
	RefundChannel     string   `xml:"refund_channel"`
	RefundFee         int64    `xml:"refund_fee"`
	CouponRefundFee   int64    `xml:"coupon_refund_fee"`
	TotalFee          int64    `xml:"total_fee"`
	CashFee           int64    `xml:"cash_fee"`
	CouponRefundCount int64    `xml:"coupon_refund_count"`
	CashRefundFee     int64    `xml:"cash_refund_fee"`
}

StRefundRespXML 回复内容

func PayV1Refund

func PayV1Refund(cer tls.Certificate, appID, mchID, mchKey, transactionID, outRefundNo, cbURL string, totalFee, refundFee int64) (*StRefundRespXML, error)

PayV1Refund 申请退款

type StWeChatCbBody

type StWeChatCbBody struct {
	XMLName       xml.Name `xml:"xml"`
	Text          string   `xml:",chardata"`
	Appid         string   `xml:"appid"`
	Attach        string   `xml:"attach"`
	BankType      string   `xml:"bank_type"`
	FeeType       string   `xml:"fee_type"`
	IsSubscribe   string   `xml:"is_subscribe"`
	MchID         string   `xml:"mch_id"`
	NonceStr      string   `xml:"nonce_str"`
	Openid        string   `xml:"openid"`
	OutTradeNo    string   `xml:"out_trade_no"`
	ResultCode    string   `xml:"result_code"`
	ReturnCode    string   `xml:"return_code"`
	Sign          string   `xml:"sign"`
	TimeEnd       string   `xml:"time_end"`
	TotalFee      string   `xml:"total_fee"`
	CouponFee     string   `xml:"coupon_fee"`
	CouponCount   string   `xml:"coupon_count"`
	CouponType    string   `xml:"coupon_type"`
	CouponID      string   `xml:"coupon_id"`
	TradeType     string   `xml:"trade_type"`
	TransactionID string   `xml:"transaction_id"`
}

StWeChatCbBody 回调信息

func PayV1CheckCb

func PayV1CheckCb(mchKey string, body []byte) (*StWeChatCbBody, error)

PayV1CheckCb 验证回调

type StWxPayRawResp

type StWxPayRawResp struct {
	ID           string    `json:"id"`
	CreateTime   time.Time `json:"create_time"`
	ResourceType string    `json:"resource_type"`
	EventType    string    `json:"event_type"`
	Summary      string    `json:"summary"`
	Resource     struct {
		OriginalType   string `json:"original_type"`
		Algorithm      string `json:"algorithm"`
		Ciphertext     string `json:"ciphertext"`
		AssociatedData string `json:"associated_data"`
		Nonce          string `json:"nonce"`
	} `json:"resource"`
}

StWxPayRawResp 回复

type StWxPayResp

type StWxPayResp struct {
	Mchid          string    `json:"mchid"`
	Appid          string    `json:"appid"`
	OutTradeNo     string    `json:"out_trade_no"`
	TransactionID  string    `json:"transaction_id"`
	TradeType      string    `json:"trade_type"`
	TradeState     string    `json:"trade_state"`
	TradeStateDesc string    `json:"trade_state_desc"`
	BankType       string    `json:"bank_type"`
	Attach         string    `json:"attach"`
	SuccessTime    time.Time `json:"success_time"`
	Payer          struct {
		Openid string `json:"openid"`
	} `json:"payer"`
	Amount struct {
		Total         int    `json:"total"`
		PayerTotal    int    `json:"payer_total"`
		Currency      string `json:"currency"`
		PayerCurrency string `json:"payer_currency"`
	} `json:"amount"`
}

StWxPayResp 回复

func PayV3DecodePayResp

func PayV3DecodePayResp(v3Key string, body []byte, mchid, appid string) (*StWxPayResp, error)

PayV3DecodePayResp 解析支付回调

type StWxRefundCb

type StWxRefundCb struct {
	XMLName             xml.Name `xml:"root"`
	Text                string   `xml:",chardata"`
	OutRefundNo         string   `xml:"out_refund_no"`
	OutTradeNo          string   `xml:"out_trade_no"`
	RefundAccount       string   `xml:"refund_account"`
	RefundFee           string   `xml:"refund_fee"`
	RefundID            string   `xml:"refund_id"`
	RefundRecvAccout    string   `xml:"refund_recv_accout"`
	RefundRequestSource string   `xml:"refund_request_source"`
	RefundStatus        string   `xml:"refund_status"`
	SettlementRefundFee string   `xml:"settlement_refund_fee"`
	SettlementTotalFee  string   `xml:"settlement_total_fee"`
	SuccessTime         string   `xml:"success_time"`
	TotalFee            string   `xml:"total_fee"`
	TransactionID       string   `xml:"transaction_id"`
}

StWxRefundCb 回调

func PayCheckRefundCb

func PayCheckRefundCb(mchKey string, body []byte) (*StWxRefundCb, error)

PayCheckRefundCb 验证回调

type StWxV3RefundCb added in v0.0.11

type StWxV3RefundCb struct {
	ID           string    `json:"id"`
	CreateTime   time.Time `json:"create_time"`
	ResourceType string    `json:"resource_type"`
	EventType    string    `json:"event_type"`
	Summary      string    `json:"summary"`
	Resource     struct {
		OriginalType   string `json:"original_type"`
		Algorithm      string `json:"algorithm"`
		Ciphertext     string `json:"ciphertext"`
		AssociatedData string `json:"associated_data"`
		Nonce          string `json:"nonce"`
	} `json:"resource"`
}

StWxV3RefundCb 退款回调

type StWxV3RefundCbContent added in v0.0.11

type StWxV3RefundCbContent struct {
	Mchid         string    `json:"mchid"`
	OutTradeNo    string    `json:"out_trade_no"`
	TransactionID string    `json:"transaction_id"`
	OutRefundNo   string    `json:"out_refund_no"`
	RefundID      string    `json:"refund_id"`
	RefundStatus  string    `json:"refund_status"`
	SuccessTime   time.Time `json:"success_time"`
	Amount        struct {
		Total       int `json:"total"`
		Refund      int `json:"refund"`
		PayerTotal  int `json:"payer_total"`
		PayerRefund int `json:"payer_refund"`
	} `json:"amount"`
	UserReceivedAccount string `json:"user_received_account"`
}

StWxV3RefundCbContent 退款回调解密内容

func PayV3DecodeRefundsCb added in v0.0.11

func PayV3DecodeRefundsCb(v3Key string, body []byte) (*StWxV3RefundCbContent, error)

PayV3DecodeRefundsCb 解析退款回调

type StWxV3RefundResp added in v0.0.11

type StWxV3RefundResp struct {
	Amount struct {
		Currency         string `json:"currency"`
		DiscountRefund   int    `json:"discount_refund"`
		PayerRefund      int    `json:"payer_refund"`
		PayerTotal       int    `json:"payer_total"`
		Refund           int    `json:"refund"`
		SettlementRefund int    `json:"settlement_refund"`
		SettlementTotal  int    `json:"settlement_total"`
		Total            int    `json:"total"`
	} `json:"amount"`
	Channel             string        `json:"channel"`
	CreateTime          time.Time     `json:"create_time"`
	FundsAccount        string        `json:"funds_account"`
	OutRefundNo         string        `json:"out_refund_no"`
	OutTradeNo          string        `json:"out_trade_no"`
	PromotionDetail     []interface{} `json:"promotion_detail"`
	RefundID            string        `json:"refund_id"`
	Status              string        `json:"status"`
	TransactionID       string        `json:"transaction_id"`
	UserReceivedAccount string        `json:"user_received_account"`
	Code                string        `json:"code"`
	Message             string        `json:"message"`
}

StWxV3RefundResp 退款调用回复

func PayV3Refunds added in v0.0.11

func PayV3Refunds(keySerial string, key *rsa.PrivateKey, mchID, transactionID, outRefundNo, cbURL string, totalFee, refundFee int64) (*StWxV3RefundResp, error)

PayV3Refunds 退款

type WxAppCodeResp

type WxAppCodeResp struct {
	AccessToken  string `json:"access_token"`
	ExpiresIn    int64  `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	Openid       string `json:"openid"`
	Scope        string `json:"scope"`
	ErrCode      int64  `json:"errcode"`
}

WxAppCodeResp jscode回复

func WxAppCode

func WxAppCode(appID, appSecret, code string) (*WxAppCodeResp, error)

WxAppCode app登录

type WxAppUserInfoResp

type WxAppUserInfoResp struct {
	Openid     string `json:"openid"`
	Nickname   string `json:"nickname"`
	Sex        int64  `json:"sex"`
	Province   string `json:"province"`
	City       string `json:"city"`
	Country    string `json:"country"`
	Headimgurl string `json:"headimgurl"`
	Unionid    string `json:"unionid"`
	ErrCode    int64  `json:"errcode"`
}

WxAppUserInfoResp userinfo回复

func WxAppUserInfo

func WxAppUserInfo(accessToken, openID string) (*WxAppUserInfoResp, error)

WxAppUserInfo 用户信息

type WxJsCodeResp

type WxJsCodeResp struct {
	OpenID     string `json:"openid"`
	SessionKey string `json:"session_key"`
	Unionid    string `json:"unionid"`
	Errcode    int64  `json:"errcode"`
	Errmsg     string `json:"errmsg"`
}

WxJsCodeResp jscode回复

func WxJsCode

func WxJsCode(appID, appSecret, code string) (*WxJsCodeResp, error)

WxJsCode js登录

type XMLNode

type XMLNode struct {
	XMLName xml.Name
	Content string    `xml:",chardata"`
	Nodes   []XMLNode `xml:",any"`
}

XMLNode xml结构

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL