qq

package
v1.5.41 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// 支付类型
	TradeType_MicroPay = "MICROPAY" // 提交付款码支付
	TradeType_JsApi    = "JSAPI"    // 公众号支付
	TradeType_Native   = "NATIVE"   // 原生扫码支付
	TradeType_App      = "APP"      // APP支付
	TradeType_Mini     = "MINIAPP"  // QQ小程序支付

	// 签名方式
	SignType_MD5         = "MD5"
	SignType_HMAC_SHA256 = "HMAC-SHA256"
)

Variables

This section is empty.

Functions

func ParseNotifyToBodyMap added in v1.5.9

func ParseNotifyToBodyMap(req *http.Request) (bm gopay.BodyMap, err error)

ParseNotifyToBodyMap 解析QQ支付异步通知的结果到BodyMap

req:*http.Request
返回参数bm:Notify请求的参数
返回参数err:错误信息

func VerifySign

func VerifySign(apiKey, signType string, bean interface{}) (ok bool, err error)

VerifySign QQ同步返回参数验签或异步通知参数验签

ApiKey:API秘钥值
signType:签名类型(调用API方法时填写的类型)
bean:微信同步返回的结构体 qqRsp 或 异步通知解析的结构体 notifyReq
返回参数ok:是否验签通过
返回参数err:其他错误信息,不要根据 error 是否为空来判断验签正确与否,需再单独判断返回的 ok

Types

type Client

type Client struct {
	MchId       string
	ApiKey      string
	IsProd      bool
	DebugSwitch gopay.DebugSwitch
	// contains filtered or unexported fields
}

func NewClient

func NewClient(mchId, apiKey string) (client *Client)

初始化QQ客户端(正式环境)

mchId:商户ID
ApiKey:API秘钥值

func (*Client) AccRoll

func (q *Client) AccRoll(bm gopay.BodyMap) (qqRsp string, err error)

资金账单

文档地址:https://qpay.qq.com/buss/wiki/38/3089

func (*Client) AddCertFileContent added in v1.5.28

func (q *Client) AddCertFileContent(certFileContent, keyFileContent, pkcs12FileContent []byte) (err error)

添加QQ证书内容

certFileContent:apiclient_cert.pem 内容
keyFileContent:apiclient_key.pem 内容
pkcs12FileContent:apiclient_cert.p12 内容
返回err

func (*Client) AddCertFilePath

func (q *Client) AddCertFilePath(certFilePath, keyFilePath, pkcs12FilePath interface{}) (err error)

添加QQ证书 Path 路径

certFilePath:apiclient_cert.pem 路径
keyFilePath:apiclient_key.pem 路径
pkcs12FilePath:apiclient_cert.p12 路径
返回err

func (*Client) CloseOrder

func (q *Client) CloseOrder(bm gopay.BodyMap) (qqRsp *CloseOrderResponse, err error)

关闭订单

文档地址:https://qpay.qq.com/buss/wiki/38/1206

func (*Client) DownloadRedListFile added in v1.5.19

func (q *Client) DownloadRedListFile(bm gopay.BodyMap) (qqRsp string, err error)

DownloadRedListFile 对账单下载

注意:data类型为int类型,例如:date=20200909,2020年9月9日
文档:https://qpay.qq.com/buss/wiki/221/1224

func (*Client) MicroPay

func (q *Client) MicroPay(bm gopay.BodyMap) (qqRsp *MicroPayResponse, err error)

提交付款码支付

文档地址:https://qpay.qq.com/buss/wiki/1/1122

func (*Client) OrderQuery

func (q *Client) OrderQuery(bm gopay.BodyMap) (qqRsp *OrderQueryResponse, err error)

订单查询

文档地址:https://qpay.qq.com/buss/wiki/38/1205

func (*Client) PostQQAPISelf added in v1.5.15

func (q *Client) PostQQAPISelf(bm gopay.BodyMap, url string, tlsConfig *tls.Config) (bs []byte, err error)

向QQ发送Post请求,对于本库未提供的QQ API,可自行实现,通过此方法发送请求

bm:请求参数的BodyMap
url:完整url地址,例如:https://qpay.qq.com/cgi-bin/pay/qpay_unified_order.cgi
tlsConfig:tls配置,如无需证书请求,传nil

func (*Client) QueryRedInfo added in v1.5.19

func (q *Client) QueryRedInfo(bm gopay.BodyMap) (qqRsp *QueryRedInfoResponse, err error)

QueryRedInfo 查询红包详情

文档:https://qpay.qq.com/buss/wiki/221/2174

func (*Client) Refund

func (q *Client) Refund(bm gopay.BodyMap, certFilePath, keyFilePath, pkcs12FilePath interface{}) (qqRsp *RefundResponse, err error)

申请退款

注意:如已使用client.AddCertFilePath()添加过证书,参数certFilePath、keyFilePath、pkcs12FilePath全传空字符串 nil,否则,3证书Path均不可空
文档地址:https://qpay.qq.com/buss/wiki/38/1207

func (*Client) RefundQuery

func (q *Client) RefundQuery(bm gopay.BodyMap) (qqRsp *RefundQueryResponse, err error)

退款查询

文档地址:https://qpay.qq.com/buss/wiki/38/1208

func (*Client) Reverse

func (q *Client) Reverse(bm gopay.BodyMap) (qqRsp *ReverseResponse, err error)

撤销订单

文档地址:https://qpay.qq.com/buss/wiki/1/1125

func (*Client) SendCashRed added in v1.5.19

func (q *Client) SendCashRed(bm gopay.BodyMap, certFilePath, keyFilePath, pkcs12FilePath interface{}) (qqRsp *SendCashRedResponse, err error)

SendCashRed 创建现金红包

// 注意:如已使用client.AddCertFilePath()添加过证书,参数certFilePath、keyFilePath、pkcs12FilePath全传 nil,否则,3证书Path均不可空
文档:https://qpay.qq.com/buss/wiki/221/1220

func (*Client) StatementDown

func (q *Client) StatementDown(bm gopay.BodyMap) (qqRsp string, err error)

交易账单

文档地址:https://qpay.qq.com/buss/wiki/38/1209

func (*Client) UnifiedOrder

func (q *Client) UnifiedOrder(bm gopay.BodyMap) (qqRsp *UnifiedOrderResponse, err error)

统一下单

文档地址:https://qpay.qq.com/buss/wiki/38/1203

type CloseOrderResponse

type CloseOrderResponse struct {
	ReturnCode string `xml:"return_code,omitempty" json:"return_code,omitempty"`
	ReturnMsg  string `xml:"return_msg,omitempty" json:"return_msg,omitempty"`
	RetCode    string `xml:"retcode,omitempty" json:"retcode,omitempty"`
	RetMsg     string `xml:"retmsg,omitempty" json:"retmsg,omitempty"`
	Appid      string `xml:"appid,omitempty" json:"appid,omitempty"`
	MchId      string `xml:"mch_id,omitempty" json:"mch_id,omitempty"`
	Sign       string `xml:"sign,omitempty" json:"sign,omitempty"`
	ResultCode string `xml:"result_code,omitempty" json:"result_code,omitempty"`
	ErrCode    string `xml:"err_code,omitempty" json:"err_code,omitempty"`
	ErrCodeDes string `xml:"err_code_des,omitempty" json:"err_code_des,omitempty"`
	NonceStr   string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"`
}

type Detail added in v1.5.19

type Detail struct {
	Uin []string `xml:"uin,omitempty" json:"uin,omitempty"`
}

type MicroPayResponse

type MicroPayResponse struct {
	ReturnCode     string `xml:"return_code,omitempty" json:"return_code,omitempty"`
	ReturnMsg      string `xml:"return_msg,omitempty" json:"return_msg,omitempty"`
	RetCode        string `xml:"retcode,omitempty" json:"retcode,omitempty"`
	RetMsg         string `xml:"retmsg,omitempty" json:"retmsg,omitempty"`
	Appid          string `xml:"appid,omitempty" json:"appid,omitempty"`
	MchId          string `xml:"mch_id,omitempty" json:"mch_id,omitempty"`
	Sign           string `xml:"sign,omitempty" json:"sign,omitempty"`
	ResultCode     string `xml:"result_code,omitempty" json:"result_code,omitempty"`
	ErrCode        string `xml:"err_code,omitempty" json:"err_code,omitempty"`
	ErrCodeDes     string `xml:"err_code_des,omitempty" json:"err_code_des,omitempty"`
	NonceStr       string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"`
	DeviceInfo     string `xml:"device_info,omitempty" json:"device_info,omitempty"`
	TradeType      string `xml:"trade_type,omitempty" json:"trade_type,omitempty"`
	TradeState     string `xml:"trade_state,omitempty" json:"trade_state,omitempty"`
	BankType       string `xml:"bank_type,omitempty" json:"bank_type,omitempty"`
	FeeType        string `xml:"fee_type,omitempty" json:"fee_type,omitempty"`
	TotalFee       string `xml:"total_fee,omitempty" json:"total_fee,omitempty"`
	CashFee        string `xml:"cash_fee,omitempty" json:"cash_fee,omitempty"`
	CouponFee      string `xml:"coupon_fee,omitempty" json:"coupon_fee,omitempty"`
	CouponFee0     string `xml:"coupon_fee_0,omitempty" json:"coupon_fee_0,omitempty"`
	CouponFee1     string `xml:"coupon_fee_1,omitempty" json:"coupon_fee_1,omitempty"`
	TransactionId  string `xml:"transaction_id,omitempty" json:"transaction_id,omitempty"`
	OutTradeNo     string `xml:"out_trade_no,omitempty" json:"out_trade_no,omitempty"`
	Attach         string `xml:"attach,omitempty" json:"attach,omitempty"`
	TimeEnd        string `xml:"time_end,omitempty" json:"time_end,omitempty"`
	TradeStateDesc string `xml:"trade_state_desc,omitempty" json:"trade_state_desc,omitempty"`
	Openid         string `xml:"openid,omitempty" json:"openid,omitempty"`
}

type NotifyRequest

type NotifyRequest struct {
	Appid         string `xml:"appid,omitempty" json:"appid,omitempty"`
	MchId         string `xml:"mch_id,omitempty" json:"mch_id,omitempty"`
	NonceStr      string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"`
	Sign          string `xml:"sign,omitempty" json:"sign,omitempty"`
	DeviceInfo    string `xml:"device_info,omitempty" json:"device_info,omitempty"`
	TradeType     string `xml:"trade_type,omitempty" json:"trade_type,omitempty"`
	TradeState    string `xml:"trade_state,omitempty" json:"trade_state,omitempty"`
	BankType      string `xml:"bank_type,omitempty" json:"bank_type,omitempty"`
	FeeType       string `xml:"fee_type,omitempty" json:"fee_type,omitempty"`
	TotalFee      string `xml:"total_fee,omitempty" json:"total_fee,omitempty"`
	CashFee       string `xml:"cash_fee,omitempty" json:"cash_fee,omitempty"`
	CouponFee     string `xml:"coupon_fee,omitempty" json:"coupon_fee,omitempty"`
	TransactionId string `xml:"transaction_id,omitempty" json:"transaction_id,omitempty"`
	OutTradeNo    string `xml:"out_trade_no,omitempty" json:"out_trade_no,omitempty"`
	Attach        string `xml:"attach,omitempty" json:"attach,omitempty"`
	TimeEnd       string `xml:"time_end,omitempty" json:"time_end,omitempty"`
	Openid        string `xml:"openid,omitempty" json:"openid,omitempty"`
}

func ParseNotify added in v1.5.9

func ParseNotify(req *http.Request) (notifyReq *NotifyRequest, err error)

Deprecated 推荐使用 ParseNotifyToBodyMap

type NotifyResponse

type NotifyResponse struct {
	ReturnCode string `xml:"return_code"`
	ReturnMsg  string `xml:"return_msg"`
}

func (*NotifyResponse) ToXmlString

func (w *NotifyResponse) ToXmlString() (xmlStr string)

ToXmlString 返回数据给QQ

type OrderQueryResponse

type OrderQueryResponse struct {
	ReturnCode     string `xml:"return_code,omitempty" json:"return_code,omitempty"`
	ReturnMsg      string `xml:"return_msg,omitempty" json:"return_msg,omitempty"`
	RetCode        string `xml:"retcode,omitempty" json:"retcode,omitempty"`
	RetMsg         string `xml:"retmsg,omitempty" json:"retmsg,omitempty"`
	Appid          string `xml:"appid,omitempty" json:"appid,omitempty"`
	MchId          string `xml:"mch_id,omitempty" json:"mch_id,omitempty"`
	Sign           string `xml:"sign,omitempty" json:"sign,omitempty"`
	ResultCode     string `xml:"result_code,omitempty" json:"result_code,omitempty"`
	ErrCode        string `xml:"err_code,omitempty" json:"err_code,omitempty"`
	ErrCodeDes     string `xml:"err_code_des,omitempty" json:"err_code_des,omitempty"`
	NonceStr       string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"`
	DeviceInfo     string `xml:"device_info,omitempty" json:"device_info,omitempty"`
	TradeType      string `xml:"trade_type,omitempty" json:"trade_type,omitempty"`
	TradeState     string `xml:"trade_state,omitempty" json:"trade_state,omitempty"`
	BankType       string `xml:"bank_type,omitempty" json:"bank_type,omitempty"`
	FeeType        string `xml:"fee_type,omitempty" json:"fee_type,omitempty"`
	TotalFee       string `xml:"total_fee,omitempty" json:"total_fee,omitempty"`
	CashFee        string `xml:"cash_fee,omitempty" json:"cash_fee,omitempty"`
	CouponFee      string `xml:"coupon_fee,omitempty" json:"coupon_fee,omitempty"`
	TransactionId  string `xml:"transaction_id,omitempty" json:"transaction_id,omitempty"`
	OutTradeNo     string `xml:"out_trade_no,omitempty" json:"out_trade_no,omitempty"`
	Attach         string `xml:"attach,omitempty" json:"attach,omitempty"`
	TimeEnd        string `xml:"time_end,omitempty" json:"time_end,omitempty"`
	TradeStateDesc string `xml:"trade_state_desc,omitempty" json:"trade_state_desc,omitempty"`
	Openid         string `xml:"openid,omitempty" json:"openid,omitempty"`
}

type QueryRedInfoResponse added in v1.5.19

type QueryRedInfoResponse struct {
	Result      string  `xml:"result,omitempty" json:"result,omitempty"`
	ResInfo     string  `xml:"res_info,omitempty" json:"res_info,omitempty"`
	Listid      string  `xml:"listid,omitempty" json:"listid,omitempty"`
	State       string  `xml:"state,omitempty" json:"state,omitempty"`
	TotalNum    string  `xml:"total_num,omitempty" json:"total_num,omitempty"`
	RecvNum     string  `xml:"recv_num,omitempty" json:"recv_num,omitempty"`
	TotalAmount string  `xml:"total_amount,omitempty" json:"total_amount,omitempty"`
	RecvAmount  string  `xml:"recv_amount,omitempty" json:"recv_amount,omitempty"`
	RecvDetails *Detail `xml:"recv_details,omitempty" json:"recv_details,omitempty"`
}

type RefundQueryResponse

type RefundQueryResponse struct {
	ReturnCode        string `xml:"return_code,omitempty" json:"return_code,omitempty"`
	ReturnMsg         string `xml:"return_msg,omitempty" json:"return_msg,omitempty"`
	RetCode           string `xml:"retcode,omitempty" json:"retcode,omitempty"`
	RetMsg            string `xml:"retmsg,omitempty" json:"retmsg,omitempty"`
	Appid             string `xml:"appid,omitempty" json:"appid,omitempty"`
	MchId             string `xml:"mch_id,omitempty" json:"mch_id,omitempty"`
	Sign              string `xml:"sign,omitempty" json:"sign,omitempty"`
	ResultCode        string `xml:"result_code,omitempty" json:"result_code,omitempty"`
	ErrCode           string `xml:"err_code,omitempty" json:"err_code,omitempty"`
	ErrCodeDes        string `xml:"err_code_des,omitempty" json:"err_code_des,omitempty"`
	NonceStr          string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"`
	TransactionId     string `xml:"transaction_id,omitempty" json:"transaction_id,omitempty"`
	OutTradeNo        string `xml:"out_trade_no,omitempty" json:"out_trade_no,omitempty"`
	TotalFee          string `xml:"total_fee,omitempty" json:"total_fee,omitempty"`
	CashFee           string `xml:"cash_fee,omitempty" json:"cash_fee,omitempty"`
	FeeType           string `xml:"fee_type,omitempty" json:"fee_type,omitempty"`
	OutRefundNo0      string `xml:"out_refund_no_0,omitempty" json:"out_refund_no_0,omitempty"`
	OutRefundNo1      string `xml:"out_refund_no_1,omitempty" json:"out_refund_no_1,omitempty"`
	RefundId0         string `xml:"refund_id_0,omitempty" json:"refund_id_0,omitempty"`
	RefundId1         string `xml:"refund_id_1,omitempty" json:"refund_id_1,omitempty"`
	RefundChannel0    string `xml:"refund_channel_0,omitempty" json:"refund_channel_0,omitempty"`
	RefundChannel1    string `xml:"refund_channel_1,omitempty" json:"refund_channel_1,omitempty"`
	RefundFee0        string `xml:"refund_fee_0,omitempty" json:"refund_fee_0,omitempty"`
	RefundFee1        string `xml:"refund_fee_1,omitempty" json:"refund_fee_1,omitempty"`
	CouponRefundFee0  string `xml:"coupon_refund_fee_0,omitempty" json:"coupon_refund_fee_0,omitempty"`
	CouponRefundFee1  string `xml:"coupon_refund_fee_1,omitempty" json:"coupon_refund_fee_1,omitempty"`
	CashRefundFee0    string `xml:"cash_refund_fee_0,omitempty" json:"cash_refund_fee_0,omitempty"`
	CashRefundFee1    string `xml:"cash_refund_fee_1,omitempty" json:"cash_refund_fee_1,omitempty"`
	RefundStatus0     string `xml:"refund_status_0,omitempty" json:"refund_status_0,omitempty"`
	RefundStatus1     string `xml:"refund_status_1,omitempty" json:"refund_status_1,omitempty"`
	RefundRecvAccout0 string `xml:"refund_recv_accout_0,omitempty" json:"refund_recv_accout_0,omitempty"`
	RefundRecvAccout1 string `xml:"refund_recv_accout_1,omitempty" json:"refund_recv_accout_1,omitempty"`
}

type RefundResponse

type RefundResponse struct {
	ReturnCode    string `xml:"return_code,omitempty" json:"return_code,omitempty"`
	ReturnMsg     string `xml:"return_msg,omitempty" json:"return_msg,omitempty"`
	RetCode       string `xml:"retcode,omitempty" json:"retcode,omitempty"`
	RetMsg        string `xml:"retmsg,omitempty" json:"retmsg,omitempty"`
	Appid         string `xml:"appid,omitempty" json:"appid,omitempty"`
	MchId         string `xml:"mch_id,omitempty" json:"mch_id,omitempty"`
	Sign          string `xml:"sign,omitempty" json:"sign,omitempty"`
	ResultCode    string `xml:"result_code,omitempty" json:"result_code,omitempty"`
	ErrCode       string `xml:"err_code,omitempty" json:"err_code,omitempty"`
	ErrCodeDes    string `xml:"err_code_des,omitempty" json:"err_code_des,omitempty"`
	NonceStr      string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"`
	TransactionId string `xml:"transaction_id,omitempty" json:"transaction_id,omitempty"`
	OutTradeNo    string `xml:"out_trade_no,omitempty" json:"out_trade_no,omitempty"`
	TotalFee      string `xml:"total_fee,omitempty" json:"total_fee,omitempty"`
	OutRefundNo   string `xml:"out_refund_no,omitempty" json:"out_refund_no,omitempty"`
	RefundId      string `xml:"refund_id,omitempty" json:"refund_id,omitempty"`
	RefundChannel string `xml:"refund_channel,omitempty" json:"refund_channel,omitempty"`
	RefundFee     string `xml:"refund_fee,omitempty" json:"refund_fee,omitempty"`
}

type ReverseResponse

type ReverseResponse struct {
	ReturnCode string `xml:"return_code,omitempty" json:"return_code,omitempty"`
	ReturnMsg  string `xml:"return_msg,omitempty" json:"return_msg,omitempty"`
	RetCode    string `xml:"retcode,omitempty" json:"retcode,omitempty"`
	RetMsg     string `xml:"retmsg,omitempty" json:"retmsg,omitempty"`
	Appid      string `xml:"appid,omitempty" json:"appid,omitempty"`
	SubAppid   string `xml:"sub_appid,omitempty" json:"sub_appid,omitempty"`
	MchId      string `xml:"mch_id,omitempty" json:"mch_id,omitempty"`
	SubMchId   string `xml:"sub_mch_id,omitempty" json:"sub_mch_id,omitempty"`
	Sign       string `xml:"sign,omitempty" json:"sign,omitempty"`
	ResultCode string `xml:"result_code,omitempty" json:"result_code,omitempty"`
	ErrCode    string `xml:"err_code,omitempty" json:"err_code,omitempty"`
	ErrCodeDes string `xml:"err_code_des,omitempty" json:"err_code_des,omitempty"`
	NonceStr   string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"`
	Recall     string `json:"recall,omitempty"`
}

type SendCashRedResponse added in v1.5.19

type SendCashRedResponse struct {
	ReturnCode string `xml:"return_code,omitempty" json:"return_code,omitempty"`
	ReturnMsg  string `xml:"return_msg,omitempty" json:"return_msg,omitempty"`
	RetCode    string `xml:"retcode,omitempty" json:"retcode,omitempty"`
	RetMsg     string `xml:"retmsg,omitempty" json:"retmsg,omitempty"`
	Listid     string `xml:"listid,omitempty" json:"listid,omitempty"`
}

type UnifiedOrderResponse

type UnifiedOrderResponse struct {
	ReturnCode string `xml:"return_code,omitempty" json:"return_code,omitempty"`
	ReturnMsg  string `xml:"return_msg,omitempty" json:"return_msg,omitempty"`
	RetCode    string `xml:"retcode,omitempty" json:"retcode,omitempty"`
	RetMsg     string `xml:"retmsg,omitempty" json:"retmsg,omitempty"`
	Appid      string `xml:"appid,omitempty" json:"appid,omitempty"`
	MchId      string `xml:"mch_id,omitempty" json:"mch_id,omitempty"`
	Sign       string `xml:"sign,omitempty" json:"sign,omitempty"`
	ResultCode string `xml:"result_code,omitempty" json:"result_code,omitempty"`
	ErrCode    string `xml:"err_code,omitempty" json:"err_code,omitempty"`
	ErrCodeDes string `xml:"err_code_des,omitempty" json:"err_code_des,omitempty"`
	NonceStr   string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"`
	TradeType  string `xml:"trade_type,omitempty" json:"trade_type,omitempty"`
	PrepayId   string `xml:"prepay_id,omitempty" json:"prepay_id,omitempty"`
	CodeUrl    string `xml:"code_url,omitempty" json:"code_url,omitempty"`
}

Jump to

Keyboard shortcuts

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