pay

package
v0.0.0-...-082c262 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Trade_state_success    = "SUCCESS"
	Trade_state_refund     = "REFUND"
	Trade_state_noypay     = "NOTPAY"
	Trade_state_closed     = "CLOSED"
	Trade_state_revoked    = "REVOKED"
	Trade_state_userpaying = "USERPAYING"
	Trade_state_payerror   = "PAYERROR"
)

Variables

View Source
var WithdrawalGateway_bank = "https://api.mch.weixin.qq.com/mmpaysptrans/pay_bank"
View Source
var WithdrawalGateway_wxbalance = "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers"

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	AppId     string `json:"appid"`
	MchId     string `json:"partnerid"`
	Timestamp string `json:"timestamp"`
	NonceStr  string `json:"noncestr"`
	PrePayID  string `json:"prepayid"`
	Package   string `json:"package"`
	PaySign   string `json:"sign"`
}

AppConfig 是传出用于 app sdk 用的参数

type Config

type Config struct {
	Timestamp string `json:"timestamp"`
	NonceStr  string `json:"nonceStr"`
	PrePayID  string `json:"prePayId"`
	SignType  string `json:"signType"`
	Package   string `json:"package"`
	PaySign   string `json:"paySign"`
}

Config 是传出用于 js sdk 用的参数

type H5Config

type H5Config struct {
	AppId     string `json:"appid"`
	MchId     string `json:"partnerid"`
	Timestamp string `json:"timestamp"`
	NonceStr  string `json:"noncestr"`
	PrePayID  string `json:"prepayid"`
	Package   string `json:"package"`
	PaySign   string `json:"sign"`
	Mweb_url  string `json:"mweb_url"` // h5 pay
}

H5Config 是传出用于 h5 sdk 用的参数

type NotifyResp

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

NotifyResp 消息通知返回

type NotifyResult

type NotifyResult struct {
	ReturnCode *string `xml:"return_code"`
	ReturnMsg  *string `xml:"return_msg"`

	AppID              *string `xml:"appid" json:"appid"`
	MchID              *string `xml:"mch_id"`
	DeviceInfo         *string `xml:"device_info"`
	NonceStr           *string `xml:"nonce_str"`
	Sign               *string `xml:"sign"`
	SignType           *string `xml:"sign_type"`
	ResultCode         *string `xml:"result_code"`
	ErrCode            *string `xml:"err_code"`
	ErrCodeDes         *string `xml:"err_code_des"`
	OpenID             *string `xml:"openid"`
	IsSubscribe        *string `xml:"is_subscribe"`
	TradeType          *string `xml:"trade_type"`
	BankType           *string `xml:"bank_type"`
	TotalFee           *int    `xml:"total_fee"`
	SettlementTotalFee *int    `xml:"settlement_total_fee"`
	FeeType            *string `xml:"fee_type"`
	CashFee            *string `xml:"cash_fee"`
	CashFeeType        *string `xml:"cash_fee_type"`
	CouponFee          *int    `xml:"coupon_fee"`
	CouponCount        *int    `xml:"coupon_count"`

	// coupon_type_$n 这里只声明 3 个,如果有更多的可以自己组合
	CouponType0 *string `xml:"coupon_type_0"`
	CouponType1 *string `xml:"coupon_type_1"`
	CouponType2 *string `xml:"coupon_type_2"`
	CouponID0   *string `xml:"coupon_id_0"`
	CouponID1   *string `xml:"coupon_id_1"`
	CouponID2   *string `xml:"coupon_id_2"`
	CouponFeed0 *string `xml:"coupon_fee_0"`
	CouponFeed1 *string `xml:"coupon_fee_1"`
	CouponFeed2 *string `xml:"coupon_fee_2"`

	TransactionID *string `xml:"transaction_id"`
	OutTradeNo    *string `xml:"out_trade_no"`
	Attach        *string `xml:"attach"`
	TimeEnd       *string `xml:"time_end"`
}

NotifyResult 下单回调

type Params

type Params struct {
	TotalFee   string
	CreateIP   string
	Body       string
	OutTradeNo string
	OpenID     string
	TradeType  string
	SignType   string
	Detail     string
	Attach     string
	GoodsTag   string
	NotifyURL  string
}

Params was NEEDED when request unifiedorder 传入的参数,用于生成 prepay_id 的必需参数

type Pay

type Pay struct {
	*context.Context
}

Pay struct extends context

func NewPay

func NewPay(ctx *context.Context) *Pay

NewPay return an instance of Pay package

func (*Pay) BridgeAppConfig

func (pcf *Pay) BridgeAppConfig(p *Params) (cfg AppConfig, err error)

BridgeAppConfig get app sdk config

func (*Pay) BridgeConfig

func (pcf *Pay) BridgeConfig(p *Params) (cfg Config, err error)

BridgeConfig get js bridge config

func (*Pay) BridgeH5Config

func (pcf *Pay) BridgeH5Config(p *Params) (cfg H5Config, err error)

BridgeAppConfig get app sdk config

func (*Pay) PrePayID

func (pcf *Pay) PrePayID(p *Params) (prePayID string, err error)

PrePayID will request wechat merchant api and request for a pre payment order id

func (*Pay) PrePayOrder

func (pcf *Pay) PrePayOrder(p *Params) (payOrder PreOrder, err error)

PrePayOrder return data for invoke wechat payment

func (*Pay) Queryorder

func (pcf *Pay) Queryorder(p *QueryOrderRequest) (rsp QueryOrderResponse, err error)

func (*Pay) Refund

func (pcf *Pay) Refund(p *RefundParams) (rsp RefundResponse, err error)

Refund 退款申请

func (*Pay) VerifySign

func (pcf *Pay) VerifySign(notifyRes NotifyResult) bool

VerifySign 验签

func (*Pay) WithDrawal_bank

func (pcf *Pay) WithDrawal_bank(req *WithdrawalRequest_bank) (rsp *WithdrawalResponse_bank, err error)

func (*Pay) Withdrawal_wxbalance

func (pcf *Pay) Withdrawal_wxbalance(req *WithdrawalRequest_wxbalance) (rsp *WithdrawalResponse_wxbalance, err error)

type PreOrder

type PreOrder struct {
	ReturnCode string `xml:"return_code"`
	ReturnMsg  string `xml:"return_msg"`
	AppID      string `xml:"appid,omitempty"`
	MchID      string `xml:"mch_id,omitempty"`
	NonceStr   string `xml:"nonce_str,omitempty"`
	Sign       string `xml:"sign,omitempty"`
	ResultCode string `xml:"result_code,omitempty"`
	TradeType  string `xml:"trade_type,omitempty"`
	PrePayID   string `xml:"prepay_id,omitempty"`
	CodeURL    string `xml:"code_url,omitempty"`
	ErrCode    string `xml:"err_code,omitempty"`
	ErrCodeDes string `xml:"err_code_des,omitempty"`

	Mweb_url string `xml:"mweb_url,omitempty"` // h5 pay
}

PreOrder 是 unifie order 接口的返回

type QueryOrderRequest

type QueryOrderRequest struct {
	Appid         string `xml:"appid,omitempty" json:"appid,omitempty"`                   //   必传
	MchId         string `xml:"mch_id,omitempty" json:"mch_id,omitempty"`                 //   必传
	TransactionId string `xml:"transaction_id,omitempty" json:"transaction_id,omitempty"` // 二选一
	OutTradeNo    string `xml:"out_trade_no,omitempty" json:"out_trade_no,omitempty"`     // 二选一
	NonceStr      string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"`           //   必传
	Sign          string `xml:"sign,omitempty" json:"sign,omitempty"`                     //   必传
	SignType      string `xml:"sign_type,omitempty"`                                      // 非必传
}

请求参数

type QueryOrderResponse

type QueryOrderResponse struct {
	ReturnCode         string `xml:"return_code,omitempty" json:"return_code,omitempty"`
	ReturnMsg          string `xml:"return_msg,omitempty" json:"return_msg,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"`
	NonceStr           string `xml:"nonce_str,omitempty" json:"nonce_str,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"`
	DeviceInfo         string `xml:"device_info,omitempty" json:"device_info,omitempty"`
	Openid             string `xml:"openid,omitempty" json:"openid,omitempty"`
	IsSubscribe        string `xml:"is_subscribe,omitempty" json:"is_subscribe,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"`
	TotalFee           string `xml:"total_fee,omitempty" json:"total_fee,omitempty"`
	SettlementTotalFee string `xml:"settlement_total_fee,omitempty" json:"settlement_total_fee,omitempty"`
	FeeType            string `xml:"fee_type,omitempty" json:"fee_type,omitempty"`
	CashFee            string `xml:"cash_fee,omitempty" json:"cash_fee,omitempty"`
	CashFeeType        string `xml:"cash_fee_type,omitempty" json:"cash_fee_type,omitempty"`
	CouponFee          string `xml:"coupon_fee,omitempty" json:"coupon_fee,omitempty"`
	CouponCount        string `xml:"coupon_count,omitempty" json:"coupon_count,omitempty"`
	CouponType0        string `xml:"coupon_type_0,omitempty" json:"coupon_type_0,omitempty"`
	CouponType1        string `xml:"coupon_type_1,omitempty" json:"coupon_type_1,omitempty"`
	CouponType2        string `xml:"coupon_type_2,omitempty" json:"coupon_type_2,omitempty"`
	CouponId0          string `xml:"coupon_id_0,omitempty" json:"coupon_id_0,omitempty"`
	CouponId1          string `xml:"coupon_id_1,omitempty" json:"coupon_id_1,omitempty"`
	CouponId2          string `xml:"coupon_id_2,omitempty" json:"coupon_id_2,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"`
	CouponFee2         string `xml:"coupon_fee_2,omitempty" json:"coupon_fee_2,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"`
}

接口返回

type RefundParams

type RefundParams struct {
	TransactionID string
	OutRefundNo   string
	TotalFee      int
	RefundFee     int
	RefundDesc    string
	RootCa        string //ca证书
}

RefundParams 调用参数

type RefundResponse

type RefundResponse struct {
	ReturnCode          string `xml:"return_code"`
	ReturnMsg           string `xml:"return_msg"`
	AppID               string `xml:"appid,omitempty"`
	MchID               string `xml:"mch_id,omitempty"`
	NonceStr            string `xml:"nonce_str,omitempty"`
	Sign                string `xml:"sign,omitempty"`
	ResultCode          string `xml:"result_code,omitempty"`
	ErrCode             string `xml:"err_code,omitempty"`
	ErrCodeDes          string `xml:"err_code_des,omitempty"`
	TransactionID       string `xml:"transaction_id,omitempty"`
	OutTradeNo          string `xml:"out_trade_no,omitempty"`
	OutRefundNo         string `xml:"out_refund_no,omitempty"`
	RefundID            string `xml:"refund_id,omitempty"`
	RefundFee           string `xml:"refund_fee,omitempty"`
	SettlementRefundFee string `xml:"settlement_refund_fee,omitempty"`
	TotalFee            string `xml:"total_fee,omitempty"`
	SettlementTotalFee  string `xml:"settlement_total_fee,omitempty"`
	FeeType             string `xml:"fee_type,omitempty"`
	CashFee             string `xml:"cash_fee,omitempty"`
	CashFeeType         string `xml:"cash_fee_type,omitempty"`
}

RefundResponse 接口返回

type WithdrawalRequest_bank

type WithdrawalRequest_bank struct {
	Mchid         string `json:"mchid" xml:"mchid"`                  //  必传       微信支付分配 的 商户号
	Nonce_str     string `json:"nonce_str" xml:"nonce_str"`          //  必传       随机字符串  不长于 32 位
	Enc_bank_no   string `json:"enc_bank_no" xml:"enc_bank_no"`      //  必传       收款方银行卡号 (采用标准RSA算法,公钥由微信侧提供 详见 https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=24_7
	Enc_true_name string `xml:"enc_true_name"  json:"enc_true_name"` //  必传       收款方用户名 (采用标准RSA算法,公钥由微信侧提供 详见 https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=24_7
	Bank_code     string `xml:"bank_code" json:"bank_code"`          //  必传       银行卡所在开户行编号 (银行卡所在开户行编号,详见https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=24_4
	Amount        int    `xml:"amount" json:"amount"`                //  必传       付款金额: RMB 分 (支付总额, 不含手续费) 注  大于 0  的整数
	Desc          string `xml:"desc" json:"desc"`                    //  可传       企业付款到银行卡付款说明,即订单备注(UTF8编码,允许100个字符以内)
	RootCa        string // ca 证书
}

◆ 单商户日限额——单日10万元

◆ 单次限额——单次2万元

◆ 单商户给同一银行卡单日限额——单日2万元 企业付款到银行卡 请求参数

type WithdrawalRequest_wxbalance

type WithdrawalRequest_wxbalance struct {
	Mch_appid        string `json:"mch_appid"  xml:"mch_appid"`              //  必传       申请商户号的 app_id  或  商户号 绑定的 app_id
	Mchid            string `json:"mchid" xml:"mchid"`                       //  必传       微信支付分配 的 商户号
	Device_info      string `json:"device_info" xml:"device_info"`           //  可传       微信支付分配 的 终端设备号
	Nonce_str        string `json:"nonce_str" xml:"nonce_str"`               //  必传       随机字符串  不长于 32 位
	Sign             string `json:"sign" xml:"sign"`                         //  可传       签名  详见 签名算法  (https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=4_3
	Partner_trade_no string `json:"partner_trade_no" xml:"partner_trade_no"` //  必传       商户订单号 需保持 唯一性 (只能是 字母 或者 数字 , 不能 包含 其他 字符)
	Openid           string `xml:"openid" json:"openid"`                     //  必传       商户 app_id 下 ,某用户的 openid
	Check_name       string `xml:"check_name" json:"check_name"`             //  必传       NO_CHECK: 不校验真实性     FORCE_CHECK:强校验真实姓名
	Re_user_name     string `xml:"re_user_name" json:"re_user_name"`         //  可传       收款用户真实姓名
	Amount           int    `xml:"amount" json:"amount"`                     //  必传       企业付款金额 , 单位为 分
	Desc             string `xml:"desc" json:"desc"`                         //  必传              企业付款备注
	Spbill_create_ip string `xml:"spbill_create_ip" json:"spbill_create_ip"` //  可传    该ip同在商户平台设置的ip白名单中的IP没有关联,该ip 可传用户端或者 服务端的ip
	RootCa           string // ca证书
}

企业付款到零钱 请求参数

type WithdrawalResponse_bank

type WithdrawalResponse_bank struct {
	ReturnCode       string `xml:"return_code"`
	ReturnMsg        string `xml:"return_msg"` //  以上  默认返回
	ResultCode       string `xml:"result_code,omitempty"`
	ErrCode          string `xml:"err_code,omitempty"`
	ErrCodeDes       string `xml:"err_code_des,omitempty"` // 以上字段在return_code为SUCCESS的时候有返回
	Mch_id           string `xml:"mch_id,omitempty"`
	Partner_trade_no string `xml:"partner_trade_no,omitempty"`
	Amount           int    `xml:"amount,omitempty"`
	NonceStr         string `xml:"nonce_str,omitempty"`
	Sign             string `xml:"sign,omitempty"`
	Payment_no       string `xml:"payment_no,omitempty"`
	Cmms_amt         int    `xml:"cmms_amt,omitempty"`
}

企业付款到银行卡 接口返回

type WithdrawalResponse_wxbalance

type WithdrawalResponse_wxbalance struct {
	ReturnCode       string `xml:"return_code"`
	ReturnMsg        string `xml:"return_msg"` //  以上  默认返回
	Mch_appid        string `xml:"mch_appid,omitempty"`
	Mchid            string `xml:"mchid,omitempty"`
	Device_info      string `xml:"device_info,omitempty"`
	NonceStr         string `xml:"nonce_str,omitempty"`
	ResultCode       string `xml:"result_code,omitempty"`
	ErrCode          string `xml:"err_code,omitempty"`
	ErrCodeDes       string `xml:"err_code_des,omitempty"` // 以上字段在return_code为SUCCESS的时候有返回
	Partner_trade_no string `xml:"partner_trade_no,omitempty"`
	Payment_no       string `xml:"payment_no,omitempty"`
	Payment_time     string `xml:"payment_time,omitempty"`
}

企业付款到零钱 接口返回

Jump to

Keyboard shortcuts

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