pay

package
v1.1.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VerifySign added in v1.1.0

func VerifySign(payKey string, notifyRes NotifyResult) bool

VerifySign 验签

Types

type Base added in v1.1.0

type Base struct {
	PayNotifyInfo PayType `xml:"-"` // 回调类型

	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"`
	ReqInfo  string `xml:"req_info"` // 退款加密数据
}

Base 公用参数

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 NotifyResp added in v1.1.0

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

NotifyResp 消息通知返回

type NotifyResult added in v1.1.0

type NotifyResult struct {
	Base
	OutTradeNo    string `xml:"out_trade_no"`   // 商户订单号
	TotalFee      int    `xml:"total_fee"`      // 订单金额
	TransactionId string `xml:"transaction_id"` // 微信订单号

	// 支付成功回调
	ResultCode  string `xml:"result_code"`
	OpenID      string `xml:"openid"`
	IsSubscribe string `xml:"is_subscribe"`
	TradeType   string `xml:"trade_type"`
	BankType    string `xml:"bank_type"`
	FeeType     string `xml:"fee_type"`
	CashFee     int    `xml:"cash_fee"`
	CashFeeType string `xml:"cash_fee_type"`
	Attach      string `xml:"attach"`
	TimeEnd     string `xml:"time_end"`

	// 退款相关
	RefundId            string `xml:"refund_id"`             // 微信退款单号
	OutRefundNo         string `xml:"out_refund_no"`         // 商户退款单号
	SettlementTotalFee  int    `xml:"settlement_total_fee"`  // 应结订单金额 当该订单有使用非充值券时,返回此字段。应结订单金额=订单金额-非充值代金券金额,应结订单金额<=订单金额。
	RefundFee           int    `xml:"refund_fee"`            // 申请退款金额
	SettlementRefundFee int    `xml:"settlement_refund_fee"` // 退款金额
	RefundStatus        string `xml:"refund_status"`         // 退款状态 SUCCESS-退款成功 CHANGE-退款异常 REFUNDCLOSE—退款关闭
	SuccessTime         string `xml:"success_time"`          // 退款成功时间
	RefundRecvAccout    string `xml:"refund_recv_accout"`    // 退款入账账户
	RefundAccount       string `xml:"refund_account"`        // 退款资金来源
	RefundRequestSource string `xml:"refund_request_source"` // 退款发起来源
}

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) BridgeConfig

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

BridgeConfig get js bridge 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) Refund

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

Refund 退款申请

type PayType added in v1.1.0

type PayType string
const (
	// PayTypePay 支付回调
	PayTypePay PayType = "pay"
	// PayTypeRefund 退款回调
	PayTypeRefund = "refund"
)

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"`
}

PreOrder 是 unifie order 接口的返回

type RefundParams

type RefundParams struct {
	TransactionID string
	OutRefundNo   string
	TotalFee      string
	RefundFee     string
	RefundDesc    string
	// RootCa        string //ca证书
	P12 []byte // 微信加密证书
}

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 接口返回

Jump to

Keyboard shortcuts

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