pay

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Ignores = []string{"sign", "key", "xmlString", "xmlDoc", "couponList"}

Functions

func Sign added in v0.5.0

func Sign(params interface{}, st SignType, sk string, ignoreParams ...string) string

func SignEnt added in v0.5.0

func SignEnt(actName, mchBillNo, mchId, nonceStr, reOpenid, wxAppId, signKey string, totalAmount uint64, st SignType) string

Types

type BaseWxPayRequest

type BaseWxPayRequest struct {
	XMLName xml.Name `xml:"xml" json:"-"`

	// 公众号或者小程序appId
	AppId string `json:"appid" xml:"appid"`
	// 商户号.
	MchId string `json:"mch_id" xml:"mch_id"`
	// 服务商模式下的子商户公众账号ID.
	SubAppId string `json:"sub_app_id,omitempty" xml:"sub_app_id,omitempty"`
	// 服务商模式下的子商户号.
	SubMchId string `json:"sub_mch_id,omitempty" xml:"sub_mch_id,omitempty"`
	// 随机字符串.不长于32位。推荐随机数生成算法
	NonceStr string `json:"nonce_str" xml:"nonce_str"`
	// 签名.
	Sign string `json:"sign,omitempty" xml:"sign,omitempty"`
	// 签名类型.
	SignType SignType `json:"sign_type" xml:"sign_type,omitempty"`
	// 企业微信签名
	WorkWxSign string `json:"work_wx_sign,omitempty" xml:"work_wx_sign,omitempty"`
}

基础请求对象

func (*BaseWxPayRequest) CheckAndSign added in v0.5.0

func (r *BaseWxPayRequest) CheckAndSign(c *WxPayConfig)

func (*BaseWxPayRequest) GetSignType added in v0.5.0

func (r *BaseWxPayRequest) GetSignType() SignType

func (*BaseWxPayRequest) IgnoredParamsForSign added in v0.5.0

func (r *BaseWxPayRequest) IgnoredParamsForSign() []string

func (*BaseWxPayRequest) IsIgnoreAppId added in v0.5.0

func (r *BaseWxPayRequest) IsIgnoreAppId() bool

func (*BaseWxPayRequest) IsIgnoreSubAppId added in v0.5.0

func (r *BaseWxPayRequest) IsIgnoreSubAppId() bool

func (*BaseWxPayRequest) IsIgnoreSubMchId added in v0.5.0

func (r *BaseWxPayRequest) IsIgnoreSubMchId() bool

func (*BaseWxPayRequest) NeedNonceStr added in v0.5.0

func (r *BaseWxPayRequest) NeedNonceStr() bool

type BaseWxPayResult

type BaseWxPayResult struct {
	XMLName xml.Name `xml:"xml" json:"-"`

	common.Err
	ResultCode string `json:"result_code" xml:"result_code"`
	RetMsg     string `json:"retmsg" xml:"retmsg"`

	ReturnCode string `json:"return_code" xml:"return_code"`
	ReturnMsg  string `json:"return_msg" xml:"return_msg"`

	ErrCode    string `json:"err_code" xml:"err_code"`
	ErrCodeDes string `json:"err_code_des" xml:"err_code_des"`

	AppId    string `json:"appid" xml:"appid"`
	MchId    string `json:"mch_id" xml:"mch_id"`
	SubAppId string `json:"sub_app_id" xml:"sub_app_id"`
	SubMchId string `json:"sub_mch_id" xml:"sub_mch_id"`
	// 以时间戳为随机字符串,可以不设置.
	NonceStr string `json:"nonce_str" xml:"nonce_str"`
	Sign     string `json:"sign" xml:"sign"`

	Content []byte `xml:",innerxml"`
}

基础响应对象

func (*BaseWxPayResult) CheckResult added in v0.5.0

func (r *BaseWxPayResult) CheckResult(service WxPayService, signType SignType, checkSuccess bool) error

func (*BaseWxPayResult) Compose added in v0.5.0

func (r *BaseWxPayResult) Compose()

func (*BaseWxPayResult) Error added in v0.5.0

func (r *BaseWxPayResult) Error() string

type EntPayBankQueryRequest added in v0.5.0

type EntPayBankQueryRequest struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	EntPayQueryRequest

	PartnerTradeNo string `json:"partner_trade_no" xml:"partner_trade_no"`
}

type EntPayBankQueryResult added in v0.5.0

type EntPayBankQueryResult struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayResult

	PartnerTradeNo string `json:"partner_trade_no" xml:"partner_trade_no"`
	PaymentNo      string `json:"payment_no" xml:"payment_no"`
	BankNoMd5      string `json:"bank_no_md_5" xml:"bank_no_md_5"`
	TrueNameMd5    string `json:"true_name_md_5" xml:"true_name_md_5"`
	Amount         uint64 `json:"amount" xml:"amount"`
	Status         string `json:"status" xml:"status"`
	CmmsAmount     uint64 `json:"cmms_amount" xml:"cmms_amount"`
	CreateTime     string `json:"create_time" xml:"create_time"`
	PaySuccessTime string `json:"pay_success_time" xml:"pay_success_time"`
	FailReason     string `json:"fail_reason" xml:"fail_reason"`
}

type EntPayBankRequest added in v0.5.0

type EntPayBankRequest struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayRequest

	PartnerTradeNo string `json:"partner_trade_no" xml:"partner_trade_no"`
	EncBankNo      string `json:"enc_bank_no" xml:"enc_bank_no"`
	EncTrueName    string `json:"enc_true_name" xml:"enc_true_name"`
	BankCode       string `json:"bank_code" xml:"bank_code"`
	Amount         uint64 `json:"amount" xml:"amount"`
	Description    string `json:"description" xml:"description"`
}

type EntPayBankResult added in v0.5.0

type EntPayBankResult struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayResult

	Amount         uint64 `json:"amount" xml:"amount"`
	PartnerTradeNo string `json:"partner_trade_no" xml:"partner_trade_no"`
	PaymentNo      string `json:"payment_no" xml:"payment_no"`
	CmmsAmount     uint64 `json:"cmms_amount" xml:"cmms_amount"`
}

type EntPayQueryRequest added in v0.5.0

type EntPayQueryRequest struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayRequest

	PartnerTradeNo string `json:"partner_trade_no" xml:"partner_trade_no"`
}

func (EntPayQueryRequest) IsIgnoreAppId added in v0.5.0

func (r EntPayQueryRequest) IsIgnoreAppId() bool

type EntPayQueryResult added in v0.5.0

type EntPayQueryResult struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayResult

	PartnerTradeNo string `json:"partner_trade_no" xml:"partner_trade_no"`
	DetailId       string `json:"detail_id" xml:"detail_id"`
	Status         string `json:"status" xml:"status"`
	Reason         string `json:"reason" xml:"reason"`
	Openid         string `json:"openid" xml:"openid"`
	TransferName   string `json:"transfer_name" xml:"transfer_name"`
	PaymentAmount  uint64 `json:"payment_amount" xml:"payment_amount"`
	TransferTime   string `json:"transfer_time" xml:"transfer_time"`
	PaymentTime    string `json:"payment_time" xml:"payment_time"`
	Desc           string `json:"desc" xml:"desc"`
}

type EntPayRedPackQueryRequest added in v0.5.0

type EntPayRedPackQueryRequest struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayRequest

	MchBillNo string `json:"mch_billno" xml:"mch_billno"`
}

type EntPayRedPackQueryResult added in v0.5.0

type EntPayRedPackQueryResult struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayResult

	MchBillNo           string `json:"mch_billno" xml:"mch_billno"`
	DetailId            string `json:"detail_id" xml:"detail_id"`
	Status              string `json:"status" xml:"status"`
	TotalAmount         uint64 `json:"total_amount" xml:"total_amount"`
	Reason              string `json:"reason" xml:"reason"`
	SendTime            string `json:"send_time" xml:"send_time"`
	RefundTime          string `json:"refund_time" xml:"refund_time"`
	RefundAmount        uint64 `json:"refund_amount" xml:"refund_amount"`
	Wishing             string `json:"wishing" xml:"wishing"`
	Remark              string `json:"remark" xml:"remark"`
	ActName             string `json:"act_name" xml:"act_name"`
	Openid              string `json:"openid" xml:"openid"`
	Amount              uint64 `json:"amount" xml:"amount"`
	RcvTime             uint64 `json:"rcv_time" xml:"rcv_time"`
	SenderName          uint64 `json:"sender_name" xml:"sender_name"`
	SenderHeaderMediaId uint64 `json:"sender_header_media_id" xml:"sender_header_media_id"`
}

type EntPayRedPackRequest added in v0.5.0

type EntPayRedPackRequest struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayRequest

	MchBillNo           string `json:"mch_billno" xml:"mch_billno"`
	WxAppId             string `json:"wx_appid" xml:"wx_appid"`
	SenderName          string `json:"sender_name" xml:"sender_name"`
	AgentId             string `json:"agentid" xml:"agentid"`
	SenderHeaderMediaId string `json:"sender_header_media_id" xml:"sender_header_media_id"`
	ReOpenid            string `json:"re_openid" xml:"re_openid"`
	TotalAmount         uint64 `json:"total_amount" xml:"total_amount"`
	Wishing             string `json:"wishing" xml:"wishing"`
	ActName             string `json:"act_name" xml:"act_name"`
	Remark              string `json:"remark" xml:"remark"`
	SceneId             string `json:"scene_id" xml:"scene_id"`
}

func (EntPayRedPackRequest) IsIgnoreAppId added in v0.5.0

func (r EntPayRedPackRequest) IsIgnoreAppId() bool

func (EntPayRedPackRequest) IsIgnoreSubAppId added in v0.5.0

func (r EntPayRedPackRequest) IsIgnoreSubAppId() bool

func (EntPayRedPackRequest) IsIgnoreSubMchId added in v0.5.0

func (r EntPayRedPackRequest) IsIgnoreSubMchId() bool

func (EntPayRedPackRequest) IsWxWorkSign added in v0.5.0

func (r EntPayRedPackRequest) IsWxWorkSign() bool

type EntPayRedPackResult added in v0.5.0

type EntPayRedPackResult struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayResult

	MchBillNo           string `json:"mch_billno" xml:"mch_billno"`
	MchId               string `json:"mch_id" xml:"mch_id"`
	WxAppId             string `json:"wx_appid" xml:"wx_appid"`
	ReOpenid            string `json:"re_openid" xml:"re_openid"`
	TotalAmount         uint64 `json:"total_amount" xml:"total_amount"`
	SendListId          string `json:"sendListid" xml:"sendListid"`
	SenderName          string `json:"sender_name" xml:"sender_name"`
	SenderHeaderMediaId string `json:"sender_header_media_id" xml:"sender_header_media_id"`
}

type GetPublicKeyResult added in v0.5.0

type GetPublicKeyResult struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayResult

	PubKey string `json:"pub_key" xml:"pub_key"`
}

type ReqInfo added in v0.5.0

type ReqInfo struct {
	TransactionId       string `json:"transaction_id" xml:"transaction_id"`
	OutTradeNo          string `json:"out_trade_no" xml:"out_trade_no"`
	RefundId            string `json:"refund_id" xml:"refund_id"`
	OutRefundNo         string `json:"out_refund_no" xml:"out_refund_no"`
	TotalFee            uint64 `json:"total_fee" xml:"total_fee"`
	SettlementTotalFee  uint64 `json:"settlement_total_fee" xml:"settlement_total_fee"`
	RefundFee           uint64 `json:"refund_fee" xml:"refund_fee"`
	SettlementRefundFee uint64 `json:"settlement_refund_fee" xml:"settlement_refund_fee"`
	RefundStatus        string `json:"refund_status" xml:"refund_status"`
	SuccessTime         string `json:"success_time" xml:"success_time"`
	RefundRecvAccout    string `json:"refund_recv_accout" xml:"refund_recv_accout"`
	RefundAccount       string `json:"refund_account" xml:"refund_account"`
	RefundRequestSource string `json:"refund_request_source" xml:"refund_request_source"`
}

type SignType

type SignType string
const (
	HmacSha256 SignType = "HMAC-SHA256"
	MD5        SignType = "MD5"
)

type TradeType

type TradeType string
const (
	JSAPI  TradeType = "JSAPI"
	NATIVE TradeType = "NATIVE"
	APP    TradeType = "APP"
	H5     TradeType = "MWEB"
	MICRO  TradeType = "MICROPAY"
)

type WxEntPayRequest added in v0.5.0

type WxEntPayRequest struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayRequest

	AppId          string `json:"mch_appid" xml:"mch_appid"`
	MchId          string `json:"mchid" xml:"mchid"`
	DeviceInfo     string `json:"device_info" xml:"device_info"`
	PartnerTradeNo string `json:"partner_trade_no" xml:"partner_trade_no"`
	Openid         string `json:"openid" xml:"openid"`
	CheckName      string `json:"check_name" xml:"check_name"`
	ReUserName     string `json:"re_user_name" xml:"re_user_name"`
	Amount         uint64 `json:"amount" xml:"amount"`
	Description    string `json:"description" xml:"description"`
	SpbillCreateIp string `json:"spbill_create_ip" xml:"spbill_create_ip"`
}

提现请求对象

func (WxEntPayRequest) IgnoredParamsForSign added in v0.5.0

func (r WxEntPayRequest) IgnoredParamsForSign() []string

type WxEntPayResult added in v0.5.0

type WxEntPayResult struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayResult

	MchId          string `json:"mchid" xml:"mchid"`
	AppId          string `json:"mch_appid" xml:"mch_appid"`
	DeviceInfo     string `json:"device_info" xml:"device_info"`
	PartnerTradeNo string `json:"partner_trade_no" xml:"partner_trade_no"`
	PaymentNo      string `json:"payment_no" xml:"payment_no"`
	PaymentTime    string `json:"payment_time" xml:"payment_time"`
}

提现响应对象

type WxEntPayService

type WxEntPayService interface {
	/* 企业付款API.
	   企业付款业务是基于微信支付商户平台的资金管理能力,为了协助商户方便地实现企业向个人付款,针对部分有开发能力的商户,提供通过API完成企业付款的功能。
	   比如目前的保险行业向客户退保、给付、理赔。
	   企业付款将使用商户的可用余额,需确保可用余额充足。查看可用余额、充值、提现请登录商户平台“资金管理”https://pay.weixin.qq.com/进行操作。
	   注意:与商户微信支付收款资金并非同一账户,需要单独充值。
	   文档详见: https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_2 */
	EntPay(*WxEntPayRequest) (*WxEntPayResult, error)
	/* 查询企业付款API.
	   用于商户的企业付款操作进行结果查询,返回付款操作详细结果。
	   文档详见:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_3 */
	QueryEntPayBy(partnerTradeNo string) (*EntPayQueryResult, error)
	/* 查询企业付款API.
	   用于商户的企业付款操作进行结果查询,返回付款操作详细结果。
	   文档详见:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_3 */
	QueryEntPay(request *EntPayQueryRequest) (*EntPayQueryResult, error)
	/* 获取RSA加密公钥API.
	   RSA算法使用说明(非对称加密算法,算法采用RSA/ECB/OAEPPadding模式)
	   1、 调用获取RSA公钥API获取RSA公钥,落地成本地文件,假设为public.pem
	   2、 确定public.pem文件的存放路径,同时修改代码中文件的输入路径,加载RSA公钥
	   3、 用标准的RSA加密库对敏感信息进行加密,选择RSA_PKCS1_OAEP_PADDING填充模式
	   (eg:Java的填充方式要选 " RSA/ECB/OAEPWITHSHA-1ANDMGF1PADDING")
	   4、 得到进行rsa加密并转base64之后的密文
	   5、 将密文传给微信侧相应字段,如付款接口(enc_bank_no/enc_true_name)

	   接口默认输出PKCS#1格式的公钥,商户需根据自己开发的语言选择公钥格式
	   文档详见:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=24_7&index=4 */
	GetPublicKey() (string, error)
	/* 企业付款到银行卡.
	   用于企业向微信用户银行卡付款
	   目前支持接口API的方式向指定微信用户的银行卡付款。
	   文档详见:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=24_2 */
	PayBank(request *EntPayBankRequest) (*EntPayBankResult, error)
	/* 企业付款到银行卡查询.
	   用于对商户企业付款到银行卡操作进行结果查询,返回付款操作详细结果。
	   文档详见:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=24_3 */
	QueryPayBankBy(partnerTradeNo string) (*EntPayBankQueryResult, error)
	/* 企业付款到银行卡查询.
	   用于对商户企业付款到银行卡操作进行结果查询,返回付款操作详细结果。
	   文档详见:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=24_3 */
	QueryPayBank(request *EntPayBankQueryRequest) (*EntPayBankQueryResult, error)
	/* 企业发送微信红包给个人用户
	   文档地址:https://work.weixin.qq.com/api/doc
	*/
	SendEnterpriseRedPack(request *EntPayRedPackRequest) (*EntPayRedPackResult, error)
	/* 企业发送微信红包查询
	   文档地址:https://work.weixin.qq.com/api/doc */
	QueryEnterpriseRedPack(request *EntPayRedPackQueryRequest) (*EntPayRedPackQueryResult, error)
}

type WxEntPayServiceImpl

type WxEntPayServiceImpl struct {
	// contains filtered or unexported fields
}

func (*WxEntPayServiceImpl) EntPay

func (w *WxEntPayServiceImpl) EntPay(request *WxEntPayRequest) (*WxEntPayResult, error)

func (*WxEntPayServiceImpl) GetPublicKey added in v0.5.0

func (w *WxEntPayServiceImpl) GetPublicKey() (string, error)

func (*WxEntPayServiceImpl) PayBank added in v0.5.0

func (*WxEntPayServiceImpl) QueryEntPay added in v0.5.0

func (w *WxEntPayServiceImpl) QueryEntPay(request *EntPayQueryRequest) (*EntPayQueryResult, error)

func (*WxEntPayServiceImpl) QueryEntPayBy added in v0.5.0

func (w *WxEntPayServiceImpl) QueryEntPayBy(partnerTradeNo string) (*EntPayQueryResult, error)

func (*WxEntPayServiceImpl) QueryEnterpriseRedPack added in v0.5.0

func (w *WxEntPayServiceImpl) QueryEnterpriseRedPack(request *EntPayRedPackQueryRequest) (*EntPayRedPackQueryResult, error)

func (*WxEntPayServiceImpl) QueryPayBank added in v0.5.0

func (*WxEntPayServiceImpl) QueryPayBankBy added in v0.5.0

func (w *WxEntPayServiceImpl) QueryPayBankBy(partnerTradeNo string) (*EntPayBankQueryResult, error)

func (*WxEntPayServiceImpl) SendEnterpriseRedPack added in v0.5.0

func (w *WxEntPayServiceImpl) SendEnterpriseRedPack(request *EntPayRedPackRequest) (*EntPayRedPackResult, error)

type WxPayConfig

type WxPayConfig struct {
	PayBaseUrl string `json:"pay_base_url"` // 微信支付接口请求地址域名部分.

	AppId     string    `json:"app_id"`      // 公众号/小程序 appid
	MchId     string    `json:"mch_id"`      // 微信支付商户号.
	MchKey    string    `json:"mch_key"`     // 微信支付商户密钥.
	NotifyUrl string    `json:"notify_url"`  // 微信支付异步回掉地址,通知url必须为直接可访问的url,不能携带参数.
	KeyPath   string    `json:"key_path"`    // apiclient_cert.p12文件的绝对路径,或者如果放在项目中,请以classpath:开头指定.
	SubAppId  string    `json:"sub_app_id"`  // 服务商模式下的子商户公众账号ID,普通模式请不要配置,请在配置文件中将对应项删除.
	SubMchId  string    `json:"sub_mch_id"`  // 服务商模式下的子商户号,普通模式请不要配置,最好是请在配置文件中将对应项删除.
	TradeType TradeType `json:"trade_type"`  // 交易类型.
	SignType  SignType  `json:"sign_type"`   // 签名方式.
	EntPayKey string    `json:"ent_pay_key"` // 企业支付密钥.

	PrivateKeyPath  string `json:"private_key_path"`  // apiv3 商户apiclient_key.pem
	PrivateCertPath string `json:"private_cert_path"` // apiv3 商户apiclient_cert.pem

	ApiV3Key           string `json:"api_v_3_key"`           // apiV3 秘钥值.
	CertSerialNo       string `json:"cert_serial_no"`        // apiV3 证书序列号值
	ServiceId          string `json:"service_id"`            // 微信支付分serviceId
	PayScoreNotifyUrl  string `json:"pay_score_notify_url"`  // 微信支付分回调地址
	PrivateKey         string `json:"private_key"`           // 私钥信息
	CertAutoUpdateTime int    `json:"cert_auto_update_time"` // 证书自动更新时间差(分钟),默认一分钟

	HttpConnectionTimeout int `json:"http_connection_timeout"` // http请求连接超时时间 5000
	HttpTimeout           int `json:"http_timeout"`            // http请求数据读取等待时间 10000

	UseSandboxEnv     bool   `json:"use_sandbox_env"`
	IfSaveApiData     bool   `json:"if_save_api_data"`
	HttpProxyHost     string `json:"http_proxy_host"`
	HttpProxyPort     string `json:"http_proxy_port"`
	HttpProxyUsername string `json:"http_proxy_username"`
	HttpProxyPassword string `json:"http_proxy_password"`
}

func NewWxPayV2Config added in v0.6.1

func NewWxPayV2Config(appId, mchId, mchKey, notifyUrl, keyPath string) *WxPayConfig

func (*WxPayConfig) GetPayBaseUrl

func (c *WxPayConfig) GetPayBaseUrl() string

type WxPayDefaultRequest added in v0.5.0

type WxPayDefaultRequest struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayRequest
}

默认参数,与基础参数一致

func (*WxPayDefaultRequest) IsIgnoreAppId added in v0.5.0

func (r *WxPayDefaultRequest) IsIgnoreAppId() bool

type WxPayOrderCloseRequest

type WxPayOrderCloseRequest struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayRequest

	// 订单支付编号
	OutTradeNo string `json:"out_trade_no" xml:"out_trade_no"`
}

订单关闭请求对象

type WxPayOrderCloseResult

type WxPayOrderCloseResult struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayResult

	// 业务结果描述
	ResultMsg string `json:"result_msg" xml:"result_msg"`
}

订单关闭响应对象

type WxPayOrderCoupon added in v0.5.0

type WxPayOrderCoupon struct {
	CouponType string `json:"coupon_type" xml:"coupon_type"`
	CouponId   string `json:"coupon_id" xml:"coupon_id"`
	CouponFee  uint64 `json:"coupon_fee" xml:"coupon_fee"`
}

type WxPayOrderNotifyResult added in v0.5.0

type WxPayOrderNotifyResult struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayResult

	PromotionDetail    string   `json:"promotion_detail" xml:"promotion_detail"`
	DeviceInfo         string   `json:"device_info" xml:"device_info"`
	Openid             string   `json:"openid" xml:"openid"`
	IsSubscribe        string   `json:"is_subscribe" xml:"is_subscribe"`
	SubOpenid          string   `json:"sub_openid" xml:"sub_openid"`
	SubIsSubscribe     string   `json:"sub_is_subscribe" xml:"sub_is_subscribe"`
	TradeType          string   `json:"trade_type" xml:"trade_type"`
	BankType           string   `json:"bank_type" xml:"bank_type"`
	TotalFee           string   `json:"total_fee" xml:"total_fee"`
	SettlementTotalFee string   `json:"settlement_total_fee" xml:"settlement_total_fee"`
	FeeType            string   `json:"fee_type" xml:"fee_type"`
	CashFee            string   `json:"cash_fee" xml:"cash_fee"`
	CashFeeType        string   `json:"cash_fee_type" xml:"cash_fee_type"`
	CouponFee          string   `json:"coupon_fee" xml:"coupon_fee"`
	CouponCount        uint64   `json:"coupon_count" xml:"coupon_count"`
	TransactionId      string   `json:"transaction_id" xml:"transaction_id"`
	OutTradeNo         string   `json:"out_trade_no" xml:"out_trade_no"`
	Attach             string   `json:"attach" xml:"attach"`
	TimeEnd            string   `json:"time_end" xml:"time_end"`
	Version            string   `json:"version" xml:"version"`
	RateValue          string   `json:"rate_value" xml:"rate_value"`
	SignType           SignType `json:"sign_type" xml:"sign_type"`

	Coupons []*WxPayOrderCoupon `json:"coupons" xml:"-"`
}

func (WxPayOrderNotifyResult) CheckResult added in v0.5.0

func (r WxPayOrderNotifyResult) CheckResult(service WxPayService, signType SignType, checkSuccess bool) error

func (*WxPayOrderNotifyResult) Compose added in v0.5.0

func (r *WxPayOrderNotifyResult) Compose()

type WxPayOrderQueryRequest

type WxPayOrderQueryRequest struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayRequest

	Version       string `json:"version" xml:"version"`
	TransactionId string `json:"transaction_id" xml:"transaction_id"`
	OutTradeNo    string `json:"out_trade_no" xml:"out_trade_no"`
}

订单查询请求对象

type WxPayOrderQueryResult

type WxPayOrderQueryResult struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayResult

	PromotionDetail    string `json:"promotion_detail" xml:"promotion_detail"`
	DeviceInfo         string `json:"device_info" xml:"device_info"`
	Openid             string `json:"openid" xml:"openid"`
	IsSubscribe        string `json:"is_subscribe" xml:"is_subscribe"`
	SubOpenid          string `json:"sub_openid" xml:"sub_openid"`
	IsSubscribeSub     string `json:"is_subscribe_sub" xml:"is_subscribe_sub"`
	TradeType          string `json:"trade_type" xml:"trade_type"`
	TradeState         string `json:"trade_state" xml:"trade_state"`
	BankType           string `json:"bank_type" xml:"bank_type"`
	Detail             string `json:"detail" xml:"detail"`
	TotalFee           uint64 `json:"total_fee" xml:"total_fee"`
	FeeType            string `json:"fee_type" xml:"fee_type"`
	SettlementTotalFee uint64 `json:"settlement_total_fee" xml:"settlement_total_fee"`
	CashFee            uint64 `json:"cash_fee" xml:"cash_fee"`
	CashFeeType        string `json:"cash_fee_type" xml:"cash_fee_type"`
	CouponFee          uint64 `json:"coupon_fee" xml:"coupon_fee"`
	CouponCount        uint64 `json:"coupon_count" xml:"coupon_count"`
	TransactionId      string `json:"transaction_id" xml:"transaction_id"`
	OutTradeNo         string `json:"out_trade_no" xml:"out_trade_no"`
	Attach             string `json:"attach" xml:"attach"`
	TimeEnd            string `json:"time_end" xml:"time_end"`
	TradeStateDesc     string `json:"trade_state_desc" xml:"trade_state_desc"`

	Coupons []*WxPayOrderCoupon `json:"coupons" xml:"-"`
}

订单查询响应对象

func (WxPayOrderQueryResult) Compose added in v0.5.0

func (r WxPayOrderQueryResult) Compose()

type WxPayRefundCoupon added in v0.5.0

type WxPayRefundCoupon struct {
	CouponRefundId  string `json:"coupon_refund_id" xml:"coupon_refund_id"`
	CouponType      string `json:"coupon_type" xml:"coupon_type"`
	CouponRefundFee uint64 `json:"coupon_refund_fee" xml:"coupon_refund_fee"`
}

type WxPayRefundNotifyResult added in v0.5.0

type WxPayRefundNotifyResult struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayResult

	ReqInfoString    string  `json:"-" xml:"req_info"`
	ReqInfo          ReqInfo `json:"req_info" xml:"-"`
	DecryptedReqInfo string  `json:"-" xml:"-"`

	MchKey string `json:"-" xml:"-"`
}

func (*WxPayRefundNotifyResult) Compose added in v0.5.0

func (r *WxPayRefundNotifyResult) Compose()

type WxPayRefundPromotionDetail added in v0.5.0

type WxPayRefundPromotionDetail struct {
	PromotionId  string `json:"promotion_id"`
	Scope        string `json:"scope"`
	TypeStr      string `json:"type_str"`
	RefundAmount string `json:"refund_amount"`
	GoodsDetails struct {
		GoodsId        string `json:"goods_id"`
		RefundAmount   uint64 `json:"refund_amount"`
		RefundQuantity uint64 `json:"refund_quantity"`
		Price          uint64 `json:"price"`
	} `json:"goods_details"`
}

type WxPayRefundQueryRequest added in v0.5.0

type WxPayRefundQueryRequest struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayRequest

	// 必填 ...
	// 以下四选一
	// 微信订单号
	TransactionId string `json:"transaction_id" xml:"transaction_id"`
	// 微信订单号
	OutTradeNo string `json:"out_trade_no" xml:"out_trade_no"`
	// 商户退款单号
	OutRefundNo string `json:"out_refund_no" xml:"out_refund_no"`
	// 商户退款单号
	RefundId string `json:"refund_id" xml:"refund_id"`
	// 订单总金额,单位为分,只能为整数
	TotalFee uint64 `json:"total_fee" xml:"total_fee"`

	// 选填 ...
	// 设备号
	DeviceInfo string `json:"device_info" xml:"device_info"`
}

type WxPayRefundQueryResult added in v0.5.0

type WxPayRefundQueryResult struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayResult

	// 微信订单号
	TransactionId string `json:"transaction_id" xml:"transaction_id"`
	// 微信订单号
	OutTradeNo string `json:"out_trade_no" xml:"out_trade_no"`
	// 订单总金额,单位为分,只能为整数
	TotalFee uint64 `json:"total_fee" xml:"total_fee"`

	// 设备号
	DeviceInfo            string `json:"device_info" xml:"device_info"`
	SettlementTotalFee    uint64 `json:"settlement_total_fee" xml:"settlement_total_fee"`
	FeeType               string `json:"fee_type" xml:"fee_type"`
	CashFee               uint64 `json:"cash_fee" xml:"cash_fee"`
	RefundCount           uint64 `json:"refund_count" xml:"refund_count"`
	PromotionDetailString string `json:"promotion_detail_string" xml:"promotion_detail_string"`

	RefundRecords    []*WxPayRefundRecord          `json:"refund_records" xml:"-"`
	PromotionDetails []*WxPayRefundPromotionDetail `json:"promotion_details" xml:"-"`
}

func (*WxPayRefundQueryResult) Compose added in v0.5.0

func (r *WxPayRefundQueryResult) Compose()

type WxPayRefundRecord added in v0.5.0

type WxPayRefundRecord struct {
	OutRefundNo         string               `json:"out_refund_no"`
	RefundId            string               `json:"refund_id"`
	RefundChannel       string               `json:"refund_channel"`
	RefundFee           uint64               `json:"refund_fee"`
	SettlementRefundFee uint64               `json:"settlement_refund_fee"`
	RefundAccount       string               `json:"refund_account"`
	CouponRefundFee     uint64               `json:"coupon_refund_fee"`
	CouponRefundCount   uint64               `json:"coupon_refund_count"`
	RefundCoupons       []*WxPayRefundCoupon `json:"refund_coupons"`
	RefundStatus        string               `json:"refund_status"`
	RefundRecvAccount   string               `json:"refund_recv_account"`
	RefundSuccessTime   string               `json:"refund_success_time"`
}

type WxPayRefundRequest added in v0.5.0

type WxPayRefundRequest struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayRequest

	// 必填 ...
	// transaction_id 和 out_trade_no 二选一
	TransactionId string `json:"transaction_id,omitempty" xml:"transaction_id,omitempty"`
	// transaction_id 和 out_trade_no 二选一
	OutTradeNo string `json:"out_trade_no,omitempty" xml:"out_trade_no,omitempty"`
	// 商户系统内部的退款单号,商户系统内部唯一,只能是数字、大小写字母_-|*@ ,同一退款单号多次请求只退一笔。
	OutRefundNo string `json:"out_refund_no" xml:"out_refund_no"`
	// 订单总金额,单位为分,只能为整数
	TotalFee uint64 `json:"total_fee" xml:"total_fee"`
	// 退款金额,最大订单总金额,单位为分,只能为整数
	RefundFee uint64 `json:"refund_fee" xml:"refund_fee"`

	// 选填 ...
	DeviceInfo    string `json:"device_info,omitempty" xml:"device_info,omitempty"`
	RefundFeeType string `json:"refund_fee_type,omitempty" xml:"refund_fee_type,omitempty"`
	// 操作员帐号, 默认为商户号
	OpUserId      string `json:"op_user_id,omitempty" xml:"op_user_id,omitempty"`
	RefundAccount string `json:"refund_account,omitempty" xml:"refund_account,omitempty"`
	RefundDesc    string `json:"refund_desc,omitempty" xml:"refund_desc,omitempty"`
	NotifyUrl     string `json:"notify_url,omitempty" xml:"notify_url,omitempty"`
	Detail        string `json:"detail,omitempty" xml:"detail,omitempty"`
}

退款请求对象

func (*WxPayRefundRequest) CheckAndSign added in v0.5.0

func (r *WxPayRefundRequest) CheckAndSign(c *WxPayConfig)

type WxPayRefundResult added in v0.5.0

type WxPayRefundResult struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayResult

	// transaction_id 和 out_trade_no 二选一
	TransactionId string `json:"transaction_id,omitempty" xml:"transaction_id,omitempty"`
	// transaction_id 和 out_trade_no 二选一
	OutTradeNo string `json:"out_trade_no,omitempty" xml:"out_trade_no,omitempty"`
	// 商户系统内部的退款单号,商户系统内部唯一,只能是数字、大小写字母_-|*@ ,同一退款单号多次请求只退一笔。
	OutRefundNo string `json:"out_refund_no" xml:"out_refund_no"`
	// 微信退款单号.
	RefundId string `json:"refund_id" xml:"refund_id"`
	// 退款金额,最大订单总金额,单位为分,只能为整数
	RefundFee uint64 `json:"refund_fee" xml:"refund_fee"`
	// 订单总金额,单位为分,只能为整数
	TotalFee uint64 `json:"total_fee" xml:"total_fee"`

	SettlementRefundFee   uint64 `json:"settlement_refund_fee" xml:"settlement_refund_fee"`
	SettlementTotalFee    uint64 `json:"settlement_total_fee" xml:"settlement_total_fee"`
	FeeType               string `json:"fee_type" xml:"fee_type"`
	CashFee               uint64 `json:"cash_fee" xml:"cash_fee"`
	CashFeeType           string `json:"cash_fee_type" xml:"cash_fee_type"`
	CashRefundFee         uint64 `json:"cash_refund_fee" xml:"cash_refund_fee"`
	CouponRefundCount     uint64 `json:"coupon_refund_count" xml:"coupon_refund_count"`
	CouponRefundFee       uint64 `json:"coupon_refund_fee" xml:"coupon_refund_fee"`
	PromotionDetailString string `json:"promotion_detail_string" xml:"promotion_detail_string"`

	RefundCoupons    []*WxPayRefundCoupon          `json:"refund_coupons" xml:"-"`
	PromotionDetails []*WxPayRefundPromotionDetail `json:"promotion_details" xml:"-"`
}

退款响应对象

func (*WxPayRefundResult) Compose added in v0.5.0

func (r *WxPayRefundResult) Compose()

type WxPayRequest added in v0.5.0

type WxPayRequest interface {
	CheckAndSign(c *WxPayConfig)
	IsIgnoreAppId() bool
	IsIgnoreSubAppId() bool
	IsIgnoreSubMchId() bool
	NeedNonceStr() bool

	GetSignType() SignType
	IgnoredParamsForSign() []string
}

type WxPayResult added in v0.5.0

type WxPayResult interface {
	CheckResult(service WxPayService, signType SignType, checkSuccess bool) error
	Compose()
}

type WxPaySandboxSignKeyResult

type WxPaySandboxSignKeyResult struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayResult
	SandboxSignkey string `json:"sandbox_signkey" xml:"sandbox_signkey"`
}

沙河请求签名结果

type WxPayService

type WxPayService interface {
	// 执行操作
	Do(url string, request WxPayRequest, res WxPayResult, useKey bool) error
	// 执行Post请求
	Post(url, contentType string, data interface{}, args ...interface{}) ([]byte, error)
	// Post 执行Post请求并将结果转成对象
	PostFor(v interface{}, url, contentType string, data interface{}, args ...interface{}) error
	// Post 携带证书执行Post请求
	PostKey(url string, contentType string, data interface{}, args ...interface{}) ([]byte, error)
	// Post 携带证书执行Post请求并将结果转成对象
	PostKeyFor(v interface{}, url, contentType string, data interface{}, args ...interface{}) error

	// 获取微信支付请求url前缀,沙箱环境可能不一样.
	GetPayBaseUr() string

	// 统一支付
	// 调用统一下单接口,并组装生成支付所需参数对象.
	UnifyPay(*WxPayUnifiedOrderRequest) ([]byte, error)
	/** 统一下单
	  (详见https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_1)
	  在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"
	  接口地址:https://api.mch.weixin.qq.com/pay/unifiedorder */
	UnifyOrder(*WxPayUnifiedOrderRequest) (*WxPayUnifiedOrderResult, error)

	/* 关闭订单.
	   应用场景
	   以下情况需要调用关单接口:
	   1. 商户订单支付失败需要生成新单号重新发起支付,要对原订单号调用关单,避免重复支付;
	   2. 系统下单后,用户支付超时,系统退出不再受理,避免用户继续,请调用关单接口。
	   注意:订单生成后不能马上调用关单接口,最短调用时间间隔为5分钟。
	   接口地址:https://api.mch.weixin.qq.com/pay/closeorder
	   是否需要证书:   不需要。 */
	CloseOrderBy(string) (*WxPayOrderCloseResult, error)
	/* 关闭订单.
	   应用场景
	   以下情况需要调用关单接口:
	   1. 商户订单支付失败需要生成新单号重新发起支付,要对原订单号调用关单,避免重复支付;
	   2. 系统下单后,用户支付超时,系统退出不再受理,避免用户继续,请调用关单接口。
	   注意:订单生成后不能马上调用关单接口,最短调用时间间隔为5分钟。
	   接口地址:https://api.mch.weixin.qq.com/pay/closeorder
	   是否需要证书:   不需要。 */
	CloseOrder(*WxPayOrderCloseRequest) (*WxPayOrderCloseResult, error)
	/* 查询订单(适合于需要自定义子商户号和子商户appid的情形).
	   详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2
	   该接口提供所有微信支付订单的查询,商户可以通过查询订单接口主动查询订单状态,完成下一步的业务逻辑。
	   需要调用查询接口的情况:
	   ◆ 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知;
	   ◆ 调用支付接口后,返回系统错误或未知交易状态情况;
	   ◆ 调用被扫支付API,返回USERPAYING的状态;
	   ◆ 调用关单或撤销接口API之前,需确认支付状态; */
	QueryOrderBy(outTradeNo, transactionId string) (*WxPayOrderQueryResult, error)
	/* 查询订单(适合于需要自定义子商户号和子商户appid的情形).
	   详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2
	   该接口提供所有微信支付订单的查询,商户可以通过查询订单接口主动查询订单状态,完成下一步的业务逻辑。
	   需要调用查询接口的情况:
	   ◆ 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知;
	   ◆ 调用支付接口后,返回系统错误或未知交易状态情况;
	   ◆ 调用被扫支付API,返回USERPAYING的状态;
	   ◆ 调用关单或撤销接口API之前,需确认支付状态; */
	QueryOrder(*WxPayOrderQueryRequest) (*WxPayOrderQueryResult, error)

	/* 微信支付-申请退款.
	   详见 https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_4
	   1、交易时间超过一年的订单无法提交退款
	   2、微信支付退款支持单笔交易分多次退款,多次退款需要提交原支付订单的商户订单号和设置不同的退款单号。申请退款总金额不能超过订单金额。 一笔退款失败后重新提交,请不要更换退款单号,请使用原商户退款单号
	   3、请求频率限制:150qps,即每秒钟正常的申请退款请求次数不超过150次
	       错误或无效请求频率限制:6qps,即每秒钟异常或错误的退款申请请求不超过6次
	   4、每个支付订单的部分退款次数不能超过50次
	   5、如果同一个用户有多笔退款,建议分不同批次进行退款,避免并发退款导致退款失败 */
	Refund(*WxPayRefundRequest) (*WxPayRefundResult, error)
	RefundV2(*WxPayRefundRequest) (*WxPayRefundResult, error)
	/* 微信支付-查询退款(适合于需要自定义子商户号和子商户appid的情形).
	   应用场景:
	     提交退款申请后,通过调用该接口查询退款状态。退款有一定延时,用零钱支付的退款20分钟内到账,
	     银行卡支付的退款3个工作日后重新查询退款状态。
	   详见 https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_5 */
	RefundQuery(*WxPayRefundQueryRequest) (*WxPayRefundQueryResult, error)
	/* 微信支付-查询退款API(支持单品).
	   应用场景:提交退款申请后,通过调用该接口查询退款状态。退款有一定延时,用零钱支付的退款20分钟内到账,银行卡支付的退款3个工作日后重新查询退款状态。
	   注意:
	   1、本接口支持查询单品优惠相关退款信息,且仅支持按微信退款单号或商户退款单号查询,若继续调用老查询退款接口,
	      请见https://pay.weixin.qq.com/wiki/doc/api/jsapi_sl.php?chapter=9_5
	   2、请求频率限制:300qps,即每秒钟正常的退款查询请求次数不超过300次
	   3、错误或无效请求频率限制:6qps,即每秒钟异常或错误的退款查询请求不超过6次 */
	RefundQueryV2(*WxPayRefundQueryRequest) (*WxPayRefundQueryResult, error)
	/* 解析支付结果通知.
	   详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7 */
	ParseOrderNotifyResult(xmlData string, signType SignType) (*WxPayOrderNotifyResult, error)
	/* 解析退款结果通知
	   详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_16&index=9 */
	ParseRefundNotifyResult(xmlData string) (*WxPayRefundNotifyResult, error)
	/* 解析扫码支付回调通知
	   详见https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4 */
	ParseScanPayNotifyResult(xmlData string) (*WxScanPayNotifyResult, error)

	// 获取配置
	GetWxPayConfig() *WxPayConfig
	// 设置配置
	SetWxPayConfig(*WxPayConfig)

	// 获取提现接口
	GetEntPayService() WxEntPayService

	// 获取沙河环境
	GetSandboxSignKey(*WxPayDefaultRequest) (*WxPaySandboxSignKeyResult, error)

	// 签名
	Sign(params interface{}, st SignType, ignoreParams ...string) string
}

func NewWxPayService

func NewWxPayService(config *WxPayConfig) WxPayService

func NewWxPayServiceBy added in v0.6.0

func NewWxPayServiceBy(appId, mchId, mchKey, notifyUrl, keyPath string) WxPayService

type WxPayUnifiedOrderRequest

type WxPayUnifiedOrderRequest struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayRequest

	/* 总金额.
	   订单总金额,单位为分,详见支付金额 */
	TotalFee uint64 `json:"total_fee" xml:"total_fee"`
	/* 通知地址.
	   接收微信支付异步通知回调地址,通知url必须为直接可访问的url,不能携带参数。 */
	NotifyUrl string `json:"notify_url" xml:"notify_url"`
	/* 用户标识.
	   trade_type=JSAPI,此参数必传,用户在商户appid下的唯一标识。
	   openid如何获取,可参考【获取openid】。
	   企业号请使用【企业号OAuth2.0接口】获取企业号内成员userid,再调用【企业号userid转openid接口】进行转换 */
	Openid string `json:"openid" xml:"openid"`
	// 商品描述.
	Body string `json:"body" xml:"body"`
	/* 商户订单号.
	   商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号 */
	OutTradeNo string `json:"out_trade_no" xml:"out_trade_no"`

	/* 附加数据.
	   附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据 */
	Attach string `json:"attach,omitempty" xml:"attach,omitempty"`
	/* 终端IP.
	   APP和网页支付提交用户端ip,Native支付填调用微信支付API的机器IP。 */
	SpbillCreateIp string `json:"spbill_create_ip,omitempty" xml:"spbill_create_ip,omitempty"`
	/* 接口版本号.
	   是否必填:单品优惠必填
	   类型:String(32) 示例值:1.0
	   描述:单品优惠新增字段,接口版本号,区分原接口,默认填写1.0。
	   入参新增version后,则支付通知接口也将返回单品优惠信息字段promotion_detail,请确保支付通知的签名验证能通过。
	   更多信息,详见文档:https://pay.weixin.qq.com/wiki/doc/api/danpin.php?chapter=9_102&index=2 */
	Version string `json:"version,omitempty" xml:"version,omitempty"`
	/* 设备号.
	   类型:String(32)
	   终端设备号(门店号或收银设备Id),注意:PC网页或公众号内支付请传"WEB" */
	DeviceInfo string `json:"device_info,omitempty" xml:"device_info,omitempty"`
	// 商品详情.
	Detail string `json:"detail,omitempty" xml:"detail,omitempty"`
	/* 货币类型.
	   符合ISO 4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型 */
	FeeType string `json:"fee_type,omitempty" xml:"fee_type,omitempty"`
	/* 交易起始时间.
	   订单生成时间,格式为yyyyMMddHHmmss,如2009年12月25日9点10分10秒表示为20091225091010。其他详见时间规则 */
	TimeStart string `json:"time_start,omitempty" xml:"time_start,omitempty"`
	/* 交易结束时间.
	   订单失效时间,格式为yyyyMMddHHmmss,如2009年12月27日9点10分10秒表示为20091227091010。其他详见时间规则
	   注意:最短失效时间间隔必须大于5分钟 */
	TimeExpire string `json:"time_expire,omitempty" xml:"time_expire,omitempty"`
	GoodsTag   string `json:"goods_tag,omitempty" xml:"goods_tag,omitempty"`
	/* 交易类型.
	   取值如下:
	   JSAPI--公众号支付、
	   NATIVE --原生扫码支付、
	   APP--app支付,统一下单接口trade_type的传参可参考这里 */
	TradeType     TradeType `json:"trade_type" xml:"trade_type"`
	ProductId     string    `json:"product_id,omitempty" xml:"product_id,omitempty"`
	LimitPay      string    `json:"limit_pay,omitempty" xml:"limit_pay,omitempty"`
	SubOpenid     string    `json:"sub_openid,omitempty" xml:"sub_openid,omitempty"`
	Receipt       string    `json:"receipt,omitempty" xml:"receipt,omitempty"`
	SceneInfo     string    `json:"scene_info,omitempty" xml:"scene_info,omitempty"`
	Fingerprint   string    `json:"fingerprint,omitempty" xml:"fingerprint,omitempty"`
	ProfitSharing string    `json:"profit_sharing,omitempty" xml:"profit_sharing,omitempty"`
}

统一下单请求对象

func (*WxPayUnifiedOrderRequest) CheckAndSign added in v0.5.0

func (r *WxPayUnifiedOrderRequest) CheckAndSign(c *WxPayConfig)

type WxPayUnifiedOrderResult

type WxPayUnifiedOrderResult struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayResult

	// 微信生成的预支付回话标识,用于后续接口调用中使用,该值有效期为2小时
	PrepayId string `json:"prepay_id" xml:"prepay_id"`
	// 交易类型,取值为:JSAPI,NATIVE,APP等
	TradeType TradeType `json:"trade_type" xml:"trade_type"`
	// mweb_url 支付跳转链接
	MwebUrl string `json:"mweb_url" xml:"mweb_url"`
	// trade_type为NATIVE时有返回,用于生成二维码,展示给用户进行扫码支付
	CodeURL string `json:"code_url" xml:"code_url"`
}

统一下单响应对象

type WxPayV2ServiceImpl

type WxPayV2ServiceImpl struct {
	// contains filtered or unexported fields
}

func (*WxPayV2ServiceImpl) CloseOrder

func (*WxPayV2ServiceImpl) CloseOrderBy

func (p *WxPayV2ServiceImpl) CloseOrderBy(outTradeNo string) (*WxPayOrderCloseResult, error)

func (*WxPayV2ServiceImpl) Do added in v0.5.0

func (p *WxPayV2ServiceImpl) Do(url string, request WxPayRequest, res WxPayResult, useKey bool) error

操作

func (*WxPayV2ServiceImpl) GetEntPayService

func (p *WxPayV2ServiceImpl) GetEntPayService() WxEntPayService

func (*WxPayV2ServiceImpl) GetPayBaseUr

func (p *WxPayV2ServiceImpl) GetPayBaseUr() string

func (*WxPayV2ServiceImpl) GetSandboxSignKey

func (p *WxPayV2ServiceImpl) GetSandboxSignKey(request *WxPayDefaultRequest) (*WxPaySandboxSignKeyResult, error)

func (*WxPayV2ServiceImpl) GetWxPayConfig

func (p *WxPayV2ServiceImpl) GetWxPayConfig() *WxPayConfig

func (*WxPayV2ServiceImpl) ParseOrderNotifyResult added in v0.5.0

func (p *WxPayV2ServiceImpl) ParseOrderNotifyResult(xmlData string, signType SignType) (*WxPayOrderNotifyResult, error)

func (*WxPayV2ServiceImpl) ParseRefundNotifyResult added in v0.5.0

func (p *WxPayV2ServiceImpl) ParseRefundNotifyResult(xmlData string) (*WxPayRefundNotifyResult, error)

func (*WxPayV2ServiceImpl) ParseScanPayNotifyResult added in v0.5.0

func (p *WxPayV2ServiceImpl) ParseScanPayNotifyResult(xmlData string) (*WxScanPayNotifyResult, error)

func (*WxPayV2ServiceImpl) Post

func (p *WxPayV2ServiceImpl) Post(url string, contentType string, data interface{}, args ...interface{}) ([]byte, error)

func (*WxPayV2ServiceImpl) PostFor

func (p *WxPayV2ServiceImpl) PostFor(v interface{}, url string, contentType string, data interface{}, args ...interface{}) error

func (*WxPayV2ServiceImpl) PostKey

func (p *WxPayV2ServiceImpl) PostKey(url, contentType string, data interface{}, args ...interface{}) ([]byte, error)

func (*WxPayV2ServiceImpl) PostKeyFor

func (p *WxPayV2ServiceImpl) PostKeyFor(v interface{}, url, contentType string, data interface{}, args ...interface{}) error

func (*WxPayV2ServiceImpl) QueryOrder

func (*WxPayV2ServiceImpl) QueryOrderBy

func (p *WxPayV2ServiceImpl) QueryOrderBy(outTradeNo, transactionId string) (*WxPayOrderQueryResult, error)

func (*WxPayV2ServiceImpl) Refund added in v0.5.0

func (*WxPayV2ServiceImpl) RefundQuery added in v0.5.0

func (*WxPayV2ServiceImpl) RefundQueryV2 added in v0.5.0

func (*WxPayV2ServiceImpl) RefundV2 added in v0.5.0

func (*WxPayV2ServiceImpl) SetWxPayConfig

func (p *WxPayV2ServiceImpl) SetWxPayConfig(config *WxPayConfig)

func (*WxPayV2ServiceImpl) Sign added in v0.5.0

func (p *WxPayV2ServiceImpl) Sign(params interface{}, st SignType, ignoreParams ...string) string

微信支付签名算法(详见:https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=4_3).

func (*WxPayV2ServiceImpl) UnifyOrder

func (*WxPayV2ServiceImpl) UnifyPay

func (p *WxPayV2ServiceImpl) UnifyPay(request *WxPayUnifiedOrderRequest) ([]byte, error)

type WxScanPayNotifyResult added in v0.5.0

type WxScanPayNotifyResult struct {
	XMLName xml.Name `xml:"xml" json:"-"`
	BaseWxPayResult

	Openid      string `json:"openid" xml:"openid"`
	IsSubscribe string `json:"is_subscribe" xml:"is_subscribe"`
	ProductId   string `json:"product_id" xml:"product_id"`
}

Jump to

Keyboard shortcuts

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