wxpay

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: GPL-2.0 Imports: 21 Imported by: 0

README

微信支付集成文档

对微信支付的三方接口进行封装,方便使用

1. 如何安装

go get -u github.com/xintujing/gopkg/pay/wxpay
如果出现错误,先设置一下本地 Golang环境的GOPRIVATE:
    go env -w GOPRIVATE=github.com/xintujing

2. 如何使用

import "github.com/xintujing/gopkg/pay/wxpay"

func main() {
    // 初始化微信支付客户端
    client, err := wxpay.NewClient(&wxpay.PayConfig{
		AppID:       "你项目中的appid",
		MchID:       "你项目中的mchid",
		McsNum:      "你项目中的mcsnum",
		ApiV3Secret: "你项目中的apiv3secret",
		PemInfo: &wxpay.PemInfo{
			Path:    "你项目中的apiclient_key.pem的路径", // 可以和下面的Content二选一
			Content: []byte{"你项目中的apiclient_key.pem的路径"}, // 可以和上面的Path二选一
		},
	})
}
JsAPI 支付相关使用
// JsApi预支付
jsapiPrepayResp, err := client.JsApiPrepay(&wxpay.JsapiPrepayReq{...})

// JsApi调起支付
jsapiCallPayResp, err := client.JsApiCallPay(&wxpay.JsapiCallPayReq{...})

// JsApi根据微信支付订单号查询订单
jsapiQueryPayByTransactionIdResp, err := client.JsApiQueryPayByTransactionId(&wxpay.JsApiQueryPayByTransactionIdReq{...})

// JsApi根据商户订单号查询订单
jsapiQueryPayByOutTradeNoResp, err := client.JsApiQueryPayByOutTradeNo(&wxpay.JsApiQueryPayByOutTradeNoReq{...})

// JsApi关闭订单
err := client.JsApiClosePay(&wxpay.JsApiClosePayReq{...})

// JsApi申请退款
jsapiRefundResp, err := client.JsApiRefundPay(&wxpay.JsApiRefundReq{...})

// JsApi查询退款
jsapiQueryRefundResp, err := client.JsApiQueryRefund(&wxpay.JsApiQueryRefundReq{...})
App 支付相关使用
// App预支付
appPrepayResp, err := client.AppPrepay(&wxpay.AppPrepayReq{...})

// App调起支付
appCallPayResp, err := client.AppCallPay(&wxpay.AppCallPayReq{...})

Documentation

Index

Constants

View Source
const (
	TradeStateBySuccess = "SUCCESS"
	TradeStateByRefund  = "REFUND"
	TradeStateByNotPay  = "NOTPAY"
	TradeStateByClosed  = "CLOSED"
	TradeStateByRevoked = "REVOKED"
	TradeStateByPaying  = "USERPAYING"
	TradeStateByFail    = "PAYERROR"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AmountByPrepay

type AmountByPrepay struct {
	Total    int64  `json:"total,required"`     // 订单总金额,单位为分
	Currency string `json:"currency,omitempty"` // 货币类型,默认CNY:人民币,境内商户号仅支持人民币
}

AmountByPrepay 预支付金额信息

type AmountByQuery

type AmountByQuery struct {
	Total         int64  `json:"total,required"`           // 订单总金额,单位为分
	Currency      string `json:"currency,omitempty"`       // 货币类型,默认CNY:人民币,境内商户号仅支持人民币
	PayerTotal    int64  `json:"payer_total,omitempty"`    // 用户支付金额,单位为分
	PayerCurrency string `json:"payer_currency,omitempty"` // 用户支付币种
}

AmountByQuery 查询订单金额信息

type AmountByQueryRefund

type AmountByQueryRefund struct {
	Total            int64   // 订单总金额,单位为分
	Refund           int64   // 退款标价金额,单位为分,可以做部分退款
	PayerTotal       int64   // 现金支付金额,单位为分,只能为整数
	PayerRefund      int64   // 退款给用户的金额,不包含所有优惠券金额
	SettlementRefund int64   // 应结退款金额
	SettlementTotal  int64   // 应结订单金额
	DiscountRefund   int64   // 优惠退款金额
	Currency         string  // 退款币种
	From             []*From // 退款出资的账户类型及金额信息
}

AmountByQueryRefund 使用JsAPI查询退款时的金额信息

type AmountByRefundReq

type AmountByRefundReq struct {
	Refund   int64   `json:"refund,required"`   // 退款金额,单位为分,只能为整数,不能超过原订单支付金额
	Total    int64   `json:"total,required"`    // 原支付交易的订单总金额,单位为分
	Currency string  `json:"currency,required"` // 符合ISO 4217标准的三位字母代码,目前只支持人民币:CNY
	From     []*From `json:"from"`              // 退款出资账户及金额
}

AmountByRefundReq 退款金额信息请求参数

type AmountByRefundResp

type AmountByRefundResp struct {
	Total            int64   // 订单总金额,单位为分
	Refund           int64   // 退款标价金额,单位为分,可以做部分退款
	PayerTotal       int64   // 现金支付金额,单位为分,只能为整数
	PayerRefund      int64   // 退款给用户的金额,不包含所有优惠券金额
	SettlementRefund int64   // 应结退款金额
	SettlementTotal  int64   // 应结订单金额
	DiscountRefund   int64   // 优惠退款金额
	Currency         string  // 退款币种
	From             []*From // 退款出资的账户类型及金额信息
}

AmountByRefundResp 退款金额信息响应参数

type AppCallPayReq

type AppCallPayReq struct {
	PrepayID string `json:"prepay_id,required"` // 预支付交易会话标识。用于后续接口调用中使用,该值有效期为2小时
}

AppCallPayReq App调起支付请求参数

type AppCallPayResp

type AppCallPayResp struct {
	AppID     string // 商户申请的公众号对应的appid
	PartnerID string // 商户号
	PrepayID  string // 微信返回的支付交易会话ID
	TimeStamp string // 时间戳,标准北京时间,时区为东八区,自1970年1月1日 0点0分0秒以来的秒数
	NonceStr  string // 随机字符串,长度为32个字符以下。
	Package   string // JSAPI下单接口返回的prepay_id参数值,提交格式如:prepay_id=***
	Sign      string // 签名,签名,使用字段appId、timeStamp、nonceStr、prepayid
}

AppCallPayResp App调起支付返回参数

type AppClosePayReq added in v0.0.6

type AppClosePayReq struct {
	OutTradeNo string `json:"out_trade_no,required"` // 商户系统内部订单号
}

AppClosePayReq App关闭支付请求参数

type AppClosePayResp added in v0.0.6

type AppClosePayResp struct{}

type AppPrepayReq

type AppPrepayReq struct {
	Description   string          `json:"description,required"`     // 商品描述
	OutTradeNo    string          `json:"out_trade_no,required"`    // 商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯一
	NotifyURL     string          `json:"notify_url,required"`      // 支付结果通知的回调地址
	Amount        *AmountByPrepay `json:"amount,required"`          //【必传】 订单金额信息
	TimeExpire    string          `json:"time_expire,omitempty"`    // 订单失效时间,遵循rfc3339标准格式,示例值:2018-06-08T10:34:56+08:00
	Attach        string          `json:"attach,omitempty"`         // 附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用。
	GoodsTag      string          `json:"goods_tag,omitempty"`      // 订单优惠标记
	SupportFapiao bool            `json:"support_fapiao,omitempty"` // 电子发票入口开放标识,传入true时,支付成功消息和支付详情页将出现开票入口。需要在微信支付商户平台或微信公众平台开通电子发票功能,传此字段才可生效。
	Detail        *OrderDetail    `json:"detail,omitempty"`         // 商品详情
	SceneInfo     *SceneInfo      `json:"scene_info,omitempty"`     // 场景信息
	SettleInfo    *SettleInfo     `json:"settle_info,omitempty"`    // 结算信息
}

AppPrepayReq App预支付请求参数

type AppPrepayResp

type AppPrepayResp struct {
	PrepayID string // 预支付交易会话标识。用于后续接口调用中使用,该值有效期为2小时
}

AppPrepayResp App预支付返回参数

type AppQueryPayByOutTradeNoReq added in v0.0.6

type AppQueryPayByOutTradeNoReq struct {
	OutTradeNo string `json:"out_trade_no,required"` // 商户系统内部订单号
}

AppQueryPayByOutTradeNoReq App查询支付请求参数(通过商户订单号查询)

type AppQueryPayByTransactionIdReq added in v0.0.6

type AppQueryPayByTransactionIdReq struct {
	TransactionId string `json:"transaction_id,required"` // 微信支付订单号
}

AppQueryPayByTransactionIdReq App查询支付请求参数(通过微信支付订单号查询)

type AppQueryPayResp added in v0.0.6

type AppQueryPayResp struct {
	Appid           string                    // AppID
	Attach          string                    // 附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用。
	BankType        string                    // 付款银行
	Mchid           string                    // 商户号
	OutTradeNo      string                    // 商户系统内部订单号
	SuccessTime     string                    // 支付完成时间
	TradeState      string                    // SUCCESS—支付成功 REFUND—转入退款 NOTPAY—未支付 CLOSED—已关闭 REVOKED—已撤销(付款码支付)USERPAYING--用户支付中(付款码支付)PAYERROR--支付失败(其他原因,如银行返回失败)
	TradeStateDesc  string                    // 交易状态描述
	TradeType       string                    // 交易类型
	TransactionID   string                    // 微信支付订单号
	Payer           *Payer                    // 支付者信息
	Amount          *AmountByQuery            // 订单金额信息
	PromotionDetail []*PromotionDetailByQuery // 优惠功能
}

AppQueryPayResp App查询支付返回参数

type AppQueryRefundReq added in v0.0.6

type AppQueryRefundReq struct {
	OutRefundNo string `json:"out_refund_no,required"`
}

AppQueryRefundReq App查询退款请求参数

type AppQueryRefundResp added in v0.0.6

type AppQueryRefundResp struct {
	RefundID            string                     // 微信支付退款单号
	OutRefundNo         string                     // 商户系统内部的退款单号
	TransactionID       string                     // 微信支付交易订单号
	OutTradeNo          string                     // 原支付交易对应的商户订单号
	Channel             string                     // 退款渠道,ORIGINAL:原路退款,BALANCE:退回到余额,OTHER_BALANCE:原账户异常退到其他余额账户,OTHER_BANKCARD:原银行卡异常退到其他银行卡
	UserReceivedAccount string                     // 当前退款单的退款入账方
	SuccessTime         string                     // 退款成功时间,当退款状态为退款成功时有返回
	CreateTime          string                     // 退款受理时间
	Status              string                     // 退款状态,SUCCESS:退款成功,CLOSED:退款关闭,PROCESSING:退款处理中,ABNORMAL:退款异常
	FundsAccount        string                     // 退款所使用资金对应的资金账户类型,UNSETTLED : 未结算资金, AVAILABLE : 可用余额, UNAVAILABLE : 不可用余额, OPERATION : 运营户, BASIC : 基本账户(含可用余额和不可用余额)
	Amount              *AmountByQueryRefund       // 退款金额信息
	PromotionDetail     []*PromotionDetailByRefund // 优惠退款信息
}

AppQueryRefundResp App查询退款返回参数

type AppRefundPayReq added in v0.0.6

type AppRefundPayReq struct {
	TransactionID string                `json:"transaction_id"` // 原支付交易对应的微信订单号,与out_trade_no二选一
	OutTradeNo    string                `json:"out_trade_no"`   // 原支付交易对应的商户订单号,与transaction_id二选一
	OutRefundNo   string                `json:"out_refund_no"`  // 商户系统内部的退款单号
	Reason        string                `json:"reason"`         // 退款原因
	NotifyURL     string                `json:"notify_url"`     // 退款结果回调url
	FundsAccount  string                `json:"funds_account"`  // 退款资金来源
	Amount        *AmountByRefundReq    `json:"amount"`         // 订单金额信息
	GoodsDetail   []*GoodDetailByRefund `json:"goods_detail"`   // 指定商品退款需要传此参数,其他场景无需传递
}

AppRefundPayReq App退款请求参数

type AppRefundPayResp added in v0.0.6

type AppRefundPayResp struct {
	RefundID            string                     // 微信支付退款单号
	OutRefundNo         string                     // 商户系统内部的退款单号
	TransactionID       string                     // 微信支付交易订单号
	OutTradeNo          string                     // 原支付交易对应的商户订单号
	Channel             string                     // 退款渠道,ORIGINAL:原路退款,BALANCE:退回到余额,OTHER_BALANCE:原账户异常退到其他余额账户,OTHER_BANKCARD:原银行卡异常退到其他银行卡
	UserReceivedAccount string                     // 当前退款单的退款入账方
	SuccessTime         string                     // 退款成功时间,当退款状态为退款成功时有返回
	CreateTime          string                     // 退款受理时间
	Status              string                     // 退款状态,SUCCESS:退款成功,CLOSED:退款关闭,PROCESSING:退款处理中,ABNORMAL:退款异常
	FundsAccount        string                     // 退款所使用资金对应的资金账户类型,UNSETTLED : 未结算资金, AVAILABLE : 可用余额, UNAVAILABLE : 不可用余额, OPERATION : 运营户, BASIC : 基本账户(含可用余额和不可用余额)
	Amount              *AmountByRefundResp        // 金额详细信息
	PromotionDetail     []*PromotionDetailByRefund // 优惠退款信息
}

AppRefundPayResp App退款返回参数

type From

type From struct {
	Account string `json:"account,omitempty"` // 出资账户类型(AVAILABLE : 可用余额,UNAVAILABLE : 不可用余额)
	Amount  int64  `json:"amount,omitempty"`  // 对应账户出资金额
}

From 退款出资账户及金额

type GoodDetailByRefund

type GoodDetailByRefund struct {
	UnitPrice        int64  // 商品单价,单位
	RefundAmount     int64  // 商品退款金额,单位为分
	RefundQuantity   int64  // 单品的退款数量
	MerchantGoodsID  string // 商户侧商品编码,由半角的大小写字母、数字、中划线、下划线中的一种或几种组成
	WechatPayGoodsID string // 微信支付定义的统一商品编号(没有可不传)
	GoodsName        string // 商品的实际名称
}

GoodDetailByRefund 优惠商品发生退款时返回商品信息

type GoodsDetail

type GoodsDetail struct {
	MerchantGoodsID  string `json:"merchant_goods_id,omitempty"`  // 商户侧商品编码,由半角的大小写字母、数字、中划线、下划线中的一种或几种组成
	WechatPayGoodsID string `json:"wechatpay_goods_id,omitempty"` // 微信支付定义的统一商品编号(没有可不传)
	GoodsName        string `json:"goods_name,omitempty"`         // 商品的实际名称
	Quantity         int64  `json:"quantity,omitempty"`           // 用户购买的数量
	UnitPrice        int64  `json:"unit_price,omitempty"`         // 商品单价,单位为分
}

GoodsDetail 商品详情

type JsApiClosePayReq

type JsApiClosePayReq struct {
	OutTradeNo string `json:"out_trade_no,required"` // 商户系统内部订单号
}

JsApiClosePayReq JSAPI支付关闭订单请求参数

type JsApiClosePayResp

type JsApiClosePayResp struct{}

type JsApiQueryPayByOutTradeNoReq

type JsApiQueryPayByOutTradeNoReq struct {
	OutTradeNo string `json:"out_trade_no,required"` // 商户系统内部订单号
}

JsApiQueryPayByOutTradeNoReq JSAPI支付查询订单请求参数(通过商户订单号查询)

type JsApiQueryPayByTransactionIdReq

type JsApiQueryPayByTransactionIdReq struct {
	TransactionId string `json:"transaction_id,required"` // 微信支付订单号
}

JsApiQueryPayByTransactionIdReq JSAPI支付查询订单请求参数(通过微信支付订单号查询)

type JsApiQueryPayResp

type JsApiQueryPayResp struct {
	Appid           string                    // AppID
	Attach          string                    // 附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用。
	BankType        string                    // 付款银行
	Mchid           string                    // 商户号
	OutTradeNo      string                    // 商户系统内部订单号
	SuccessTime     string                    // 支付完成时间
	TradeState      string                    // SUCCESS—支付成功 REFUND—转入退款 NOTPAY—未支付 CLOSED—已关闭 REVOKED—已撤销(付款码支付)USERPAYING--用户支付中(付款码支付)PAYERROR--支付失败(其他原因,如银行返回失败)
	TradeStateDesc  string                    // 交易状态描述
	TradeType       string                    // 交易类型
	TransactionID   string                    // 微信支付订单号
	Payer           *Payer                    // 支付者信息
	Amount          *AmountByQuery            // 订单金额信息
	PromotionDetail []*PromotionDetailByQuery // 优惠功能
}

JsApiQueryPayResp JSAPI支付查询订单返回参数

type JsApiQueryRefundReq

type JsApiQueryRefundReq struct {
	OutRefundNo string `json:"out_refund_no,required"`
}

JsApiQueryRefundReq 查询退款参数

type JsApiQueryRefundResp

type JsApiQueryRefundResp struct {
	RefundID            string                     // 微信支付退款单号
	OutRefundNo         string                     // 商户系统内部的退款单号
	TransactionID       string                     // 微信支付交易订单号
	OutTradeNo          string                     // 原支付交易对应的商户订单号
	Channel             string                     // 退款渠道,ORIGINAL:原路退款,BALANCE:退回到余额,OTHER_BALANCE:原账户异常退到其他余额账户,OTHER_BANKCARD:原银行卡异常退到其他银行卡
	UserReceivedAccount string                     // 当前退款单的退款入账方
	SuccessTime         string                     // 退款成功时间,当退款状态为退款成功时有返回
	CreateTime          string                     // 退款受理时间
	Status              string                     // 退款状态,SUCCESS:退款成功,CLOSED:退款关闭,PROCESSING:退款处理中,ABNORMAL:退款异常
	FundsAccount        string                     // 退款所使用资金对应的资金账户类型,UNSETTLED : 未结算资金, AVAILABLE : 可用余额, UNAVAILABLE : 不可用余额, OPERATION : 运营户, BASIC : 基本账户(含可用余额和不可用余额)
	Amount              *AmountByQueryRefund       // 退款金额信息
	PromotionDetail     []*PromotionDetailByRefund // 优惠退款信息
}

JsApiQueryRefundResp 查询退款返回

type JsApiRefundPayReq

type JsApiRefundPayReq struct {
	TransactionID string                `json:"transaction_id"` // 原支付交易对应的微信订单号,与out_trade_no二选一
	OutTradeNo    string                `json:"out_trade_no"`   // 原支付交易对应的商户订单号,与transaction_id二选一
	OutRefundNo   string                `json:"out_refund_no"`  // 商户系统内部的退款单号
	Reason        string                `json:"reason"`         // 退款原因
	NotifyURL     string                `json:"notify_url"`     // 退款结果回调url
	FundsAccount  string                `json:"funds_account"`  // 退款资金来源
	Amount        *AmountByRefundReq    `json:"amount"`         // 订单金额信息
	GoodsDetail   []*GoodDetailByRefund `json:"goods_detail"`   // 指定商品退款需要传此参数,其他场景无需传递
}

JsApiRefundPayReq JSAPI支付申请退款请求参数

type JsApiRefundPayResp

type JsApiRefundPayResp struct {
	RefundID            string                     // 微信支付退款单号
	OutRefundNo         string                     // 商户系统内部的退款单号
	TransactionID       string                     // 微信支付交易订单号
	OutTradeNo          string                     // 原支付交易对应的商户订单号
	Channel             string                     // 退款渠道,ORIGINAL:原路退款,BALANCE:退回到余额,OTHER_BALANCE:原账户异常退到其他余额账户,OTHER_BANKCARD:原银行卡异常退到其他银行卡
	UserReceivedAccount string                     // 当前退款单的退款入账方
	SuccessTime         string                     // 退款成功时间,当退款状态为退款成功时有返回
	CreateTime          string                     // 退款受理时间
	Status              string                     // 退款状态,SUCCESS:退款成功,CLOSED:退款关闭,PROCESSING:退款处理中,ABNORMAL:退款异常
	FundsAccount        string                     // 退款所使用资金对应的资金账户类型,UNSETTLED : 未结算资金, AVAILABLE : 可用余额, UNAVAILABLE : 不可用余额, OPERATION : 运营户, BASIC : 基本账户(含可用余额和不可用余额)
	Amount              *AmountByRefundResp        // 金额详细信息
	PromotionDetail     []*PromotionDetailByRefund // 优惠退款信息
}

JsApiRefundPayResp JSAPI支付申请退款返回参数

type JsapiCallPayReq

type JsapiCallPayReq struct {
	PrepayID string `json:"prepay_id,required"` // 预支付交易会话标识。用于后续接口调用中使用,该值有效期为2小时
}

JsapiCallPayReq JSAPI支付调起支付请求参数

type JsapiCallPayResp

type JsapiCallPayResp struct {
	AppID     string // 商户申请的公众号对应的appid
	TimeStamp string // 时间戳,标准北京时间,时区为东八区,自1970年1月1日 0点0分0秒以来的秒数
	NonceStr  string // 随机字符串,长度为32个字符以下。
	Package   string // JSAPI下单接口返回的prepay_id参数值,提交格式如:prepay_id=***
	SignType  string // 签名算法,暂支持 RSA
	PaySign   string // 签名,使用字段appId、timeStamp、nonceStr、package计算
}

JsapiCallPayResp JSAPI支付调起支付返回参数

type JsapiPrepayReq

type JsapiPrepayReq struct {
	Description   string          `json:"description,required"`     // 商品描述
	OutTradeNo    string          `json:"out_trade_no,required"`    // 商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯一
	NotifyURL     string          `json:"notify_url,required"`      // 支付结果通知的回调地址
	Amount        *AmountByPrepay `json:"amount,required"`          // 订单金额信息
	Payer         *Payer          `json:"payer,required"`           // 支付者信息
	TimeExpire    string          `json:"time_expire,omitempty"`    // 订单失效时间,遵循rfc3339标准格式,示例值:2018-06-08T10:34:56+08:00
	Attach        string          `json:"attach,omitempty"`         // 附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用。
	GoodsTag      string          `json:"goods_tag,omitempty"`      // 订单优惠标记
	SupportFapiao bool            `json:"support_fapiao,omitempty"` // 电子发票入口开放标识,传入true时,支付成功消息和支付详情页将出现开票入口。需要在微信支付商户平台或微信公众平台开通电子发票功能,传此字段才可生效。
	Detail        *OrderDetail    `json:"detail,omitempty"`         // 商品详情
	SceneInfo     *SceneInfo      `json:"scene_info,omitempty"`     // 场景信息
	SettleInfo    *SettleInfo     `json:"settle_info,omitempty"`    // 结算信息
}

JsapiPrepayReq JSAPI支付预下单请求参数

type JsapiPrepayResp

type JsapiPrepayResp struct {
	PrepayID string // 预支付交易会话标识。用于后续接口调用中使用,该值有效期为2小时
}

JsapiPrepayResp JSAPI支付预下单返回参数

type OrderDetail

type OrderDetail struct {
	CostPrice   int64          `json:"cost_price,omitempty"`   // 订单原价
	InvoiceId   string         `json:"invoice_id,omitempty"`   // 小票ID
	GoodsDetail []*GoodsDetail `json:"goods_detail,omitempty"` // 商品详情
}

OrderDetail 订单详情

type PayConfig

type PayConfig struct {
	MchID       string   // 商户/服务商 商户号
	AppID       string   // 商户/服务商 AppId
	McsNum      string   // 商户证书序列号
	ApiV3Secret string   // API V3 密钥
	PemInfo     *PemInfo // Pem证书信息
}

type PayManager

type PayManager interface {
	// JsApiPrepay JsApi预支付
	JsApiPrepay(req *JsapiPrepayReq) (*JsapiPrepayResp, error)
	// JsApiCallPay JsApi调起支付
	JsApiCallPay(req *JsapiCallPayReq) (*JsapiCallPayResp, error)
	// JsApiQueryPayByTransactionId  JsApi根据微信支付号查询支付结果
	JsApiQueryPayByTransactionId(req *JsApiQueryPayByTransactionIdReq) (*JsApiQueryPayResp, error)
	// JsApiQueryPayByOutTradeNo JsApi根据商户订单号查询支付结果
	JsApiQueryPayByOutTradeNo(req *JsApiQueryPayByOutTradeNoReq) (*JsApiQueryPayResp, error)
	// JsApiClosePay JsApi关闭支付
	JsApiClosePay(req *JsApiClosePayReq) error
	// JsApiRefundPay JsApi退款
	JsApiRefundPay(req *JsApiRefundPayReq) (*JsApiRefundPayResp, error)
	// JsApiQueryRefund JsApi根据微信退款单号查询退款结果
	JsApiQueryRefund(req *JsApiQueryRefundReq) (*JsApiQueryRefundResp, error)
	// AppPrepay App预支付
	AppPrepay(req *AppPrepayReq) (*AppPrepayResp, error)
	// AppCallPay App调起支付
	AppCallPay(req *AppCallPayReq) (*AppCallPayResp, error)
	// AppQueryPayByTransactionId App根据微信支付号查询支付结果
	AppQueryPayByTransactionId(req *AppQueryPayByTransactionIdReq) (*AppQueryPayResp, error)
	// AppQueryPayByOutTradeNo App根据商户订单号查询支付结果
	AppQueryPayByOutTradeNo(req *AppQueryPayByOutTradeNoReq) (*AppQueryPayResp, error)
	// AppClosePay App关闭支付
	AppClosePay(req *AppClosePayReq) error
	// AppRefundPay App退款
	AppRefundPay(req *AppRefundPayReq) (*AppRefundPayResp, error)
	// AppQueryRefund App根据微信退款单号查询退款结果
	AppQueryRefund(req *AppQueryRefundReq) (*AppQueryRefundResp, error)
}

func NewClient

func NewClient(c *PayConfig) (PayManager, error)

type Payer

type Payer struct {
	Openid string `json:"openid,required"` // 用户在直连商户appid下的唯一标识。 下单前需获取到用户的Openid
}

Payer 支付者信息

type PemInfo

type PemInfo struct {
	Content []byte // pem私钥证书内容,使用V3接口必传,与Path参数二选一
	Path    string // pem私钥证书路径,使用V3接口必传,与Content参数二选一
}

type PromotionDetailByQuery

type PromotionDetailByQuery struct {
	CouponID            string // 券ID
	Name                string // 优惠名称
	Scope               string // 优惠范围
	Type                string // 优惠类型
	Currency            string // CNY:人民币,境内商户号仅支持人民币
	StockID             string // 活动ID
	Amount              int64  // 优惠券面额
	WechatPayContribute int64  // 微信出资,单位:分
	MerchantContribute  int64  // 商户出资,单位:分
	OtherContribute     int64  // 其他出资,单位:分
}

PromotionDetailByQuery 订单查询下的优惠功能

type PromotionDetailByRefund

type PromotionDetailByRefund struct {
	PromotionID  string                // 券或者立减优惠id
	Scope        string                // 优惠范围,GLOBAL:全场代金券,SINGLE:单品优惠
	Type         string                // 优惠类型,COUPON:充值型代金券,DISCOUNT:优惠券
	Amount       int64                 // 优惠券面额
	RefundAmount int64                 // 优惠退款金额
	GoodsDetail  []*GoodDetailByRefund // 优惠商品发生退款时返回商品信息
}

PromotionDetailByRefund 退款下的优惠功能

type SceneInfo

type SceneInfo struct {
	PayerClientIP string     `json:"payer_client_ip,omitempty"` // 用户终端IP
	DeviceID      string     `json:"device_id,omitempty"`       // 商户端设备号(门店号或收银设备ID)。
	StoreInfo     *StoreInfo `json:"store_info,omitempty"`      // 商户门店信息
}

SceneInfo 场景信息

type SettleInfo

type SettleInfo struct {
	ProfitSharing bool `json:"profit_sharing,omitempty"` // 是否指定分账
}

SettleInfo 结算信息

type StoreInfo

type StoreInfo struct {
	ID       string `json:"id,omitempty"`        // 门店编号,由商户自定义
	Name     string `json:"name,omitempty"`      // 门店名称 ,由商户自定义
	AreaCode string `json:"area_code,omitempty"` // 门店所在地行政区划码
	Address  string `json:"address,omitempty"`   // 门店详细地址 ,由商户自定义
}

StoreInfo 商户门店信息

Jump to

Keyboard shortcuts

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