wx_pay

package
v0.0.0-...-bd81c7d Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//WX_APP_ID            = "wxb7107d9243749e29" //小程序id
	//WX_MCH_ID            = "1543115441"
	//WX_APP_KEY           = "bt7U56KBDNgXzaVLAOpTJE2eOziTrz2T"
	WX_TRANSFERS_URL     = "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers"
	WX_TRANSFERSinfo_URL = "https://api.mch.weixin.qq.com/mmpaymkttransfers/gettransferinfo"
	WX_UNIFIED_ORDER     = "https://api.mch.weixin.qq.com/pay/unifiedorder"
	WX_REFUND_URL        = "https://api.mch.weixin.qq.com/secapi/pay/refund"
	WX_NotifyURL         = "https://api.yjlsj.cn/v1/wx/pay_callback"
)

地址的定义

Variables

This section is empty.

Functions

func DoWXRefund

func DoWXRefund(transactionID, outRefundNo string, totalFee, refundFee int, refundDesc string) error

申请退款

func GetTransferInfo

func GetTransferInfo(tradeNO string)

获取企业微信支付订单状态

Types

type Client

type Client struct {
	AppId  string
	MchId  string
	ApiKey string
	WXKey  []byte
	WXCert []byte
	// contains filtered or unexported fields
}

API客户端

var WXPayClient *Client // InitWXPayClient(WX_APP_ID, WX_MCH_ID, WX_APP_KEY)

func InitWXPayClient

func InitWXPayClient(appId, mchId, apiKey, wxKey, wxCert string) *Client

实例化API客户端

func (*Client) CheckSign

func (c *Client) CheckSign(params WXPayParams) bool

验证签名

func (*Client) Encode

func (c *Client) Encode(params WXPayParams) io.Reader

XML编码

func (*Client) SetTimeout

func (c *Client) SetTimeout(d time.Duration)

设置请求超时时间

func (*Client) Sign

func (c *Client) Sign(params WXPayParams) string

生成签名

func (*Client) WithCert

func (c *Client) WithCert(certFile, keyFile string) error

附着商户证书

func (*Client) WithCertBytes

func (c *Client) WithCertBytes(cert, key []byte) error

type GetTransferInfoRsp

type GetTransferInfoRsp struct {
	XMLName        xml.Name `xml:"xml"`
	ReturnCode     string   `xml:"return_code"`
	ReturnMsg      string   `xml:"return_msg"`
	ResultCode     string   `xml:"result_code"`
	MchID          string   `xml:"mch_id"`
	AppID          string   `xml:"appid"`
	DetailID       string   `xml:"detail_id"`
	PartnerTradeNo string   `xml:"partner_trade_no"`
	Status         string   `xml:"status"`
	PaymentAmount  string   `xml:"payment_amount"`
	Openid         string   `xml:"openid"`
	TransferTime   string   `xml:"transfer_time"`
	TransferName   string   `xml:"transfer_name"`
	Desc           string   `xml:"desc"`
	Reason         string   `xml:"reason"`
}

type WXPayParams

type WXPayParams map[string]string

func DecodeWXPayParamsFromXML

func DecodeWXPayParamsFromXML(r io.Reader) WXPayParams

XML解码

func PlaceAnWXPayOrder

func PlaceAnWXPayOrder(orderNo, orderBody string, totalFee int, clientIP, notifyURL, openID string) (*WXPayParams, error)

用户下单

func (WXPayParams) GetInt64

func (p WXPayParams) GetInt64(k string) int64

func (WXPayParams) GetString

func (p WXPayParams) GetString(k string) string

func (WXPayParams) SetInt64

func (p WXPayParams) SetInt64(k string, i int64)

func (WXPayParams) SetString

func (p WXPayParams) SetString(k, s string)

type WeiXinTransferPayRsp

type WeiXinTransferPayRsp struct {
	XMLName        xml.Name `xml:"xml"`
	ReturnCode     string   `xml:"return_code"`
	ReturnMsg      string   `xml:"return_msg"`
	ResultCode     string   `xml:"result_code"`
	MchAppid       string   `xml:"mch_appid"`
	Mchid          string   `xml:"mchid"`
	NonceStr       string   `xml:"nonce_str"`
	PartnerTradeNo string   `xml:"partner_trade_no"`
	PaymentNo      string   `xml:"payment_no"`
	PaymentTime    string   `xml:"payment_time"`
	ErrCode        string   `xml:"err_code"`
	ErrCodeDes     string   `xml:"err_code_des"`
}

func WXTransfer

func WXTransfer(amount int, openid, tradeNo, desc, createIP string) (rsp WeiXinTransferPayRsp, err error)

微信企业支付

Jump to

Keyboard shortcuts

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