Documentation ¶
Index ¶
- Constants
- func CloseWechatPaymentCallbackServiceImpl()
- func GenerateNonce() string
- func MakeNewPaymentSignature(privKey *rsa.PrivateKey, signParams *SignParams) (signature string, err error)
- func SetupWechatPaymentCallbackServiceImpl()
- type AckAsyncNotificationFromWeChatPay
- type AsyncNotificationFromWeChatPay
- type AsyncNotificationResourceFromWeChatPay
- type CommonReponse
- type NotificationResource
- type NotificationResourceAmount
- type NotificationResourcePayer
- type SignParams
- type WechatPaymentCallbackServiceImpl
- func (impl *WechatPaymentCallbackServiceImpl) CloseWxPrepayOrder(ctx context.Context, req *proto_gens.CloseWxPrepayOrderRequest) (resp *proto_gens.CloseWxPrepayOrderResponse, err error)
- func (impl *WechatPaymentCallbackServiceImpl) HomeHandler(ctx *gin.Context)
- func (impl *WechatPaymentCallbackServiceImpl) MakeNewPlatformTradeId(ctx context.Context, req *proto_gens.MakeNewPlatformTradeIdRequest) (resp *proto_gens.MakeNewPlatformTradeIdResponse, err error)
- func (impl *WechatPaymentCallbackServiceImpl) MakeNewWxPrepayOrder(ctx context.Context, req *proto_gens.MakeNewWxPrepayOrderRequest) (resp *proto_gens.MakeNewWxPrepayOrderResponse, err error)
- func (impl *WechatPaymentCallbackServiceImpl) NotifyHandler(ctx *gin.Context)
- func (impl *WechatPaymentCallbackServiceImpl) Ping(ctx context.Context, req *proto_gens.PingRequest) (resp *proto_gens.PongResponse, err error)
- func (impl *WechatPaymentCallbackServiceImpl) QueryWxPaymentStatus(ctx context.Context, req *proto_gens.QueryWxPaymentStatusRequest) (resp *proto_gens.QueryWxPaymentStatusResponse, err error)
Constants ¶
const ( NonceSymbols = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" NonceLength = 24 )
const (
SignTypeRSA = "RSA"
)
Variables ¶
This section is empty.
Functions ¶
func CloseWechatPaymentCallbackServiceImpl ¶
func CloseWechatPaymentCallbackServiceImpl()
func GenerateNonce ¶
func GenerateNonce() string
func MakeNewPaymentSignature ¶
func MakeNewPaymentSignature(privKey *rsa.PrivateKey, signParams *SignParams) (signature string, err error)
func SetupWechatPaymentCallbackServiceImpl ¶
func SetupWechatPaymentCallbackServiceImpl()
Types ¶
type AsyncNotificationFromWeChatPay ¶
type AsyncNotificationFromWeChatPay struct { /* 通知的唯一ID, 示例值:EV-2018022511223320873 */ Id string `json:"id"` /* 通知创建的时间, 示例值:2015-05-20T13:29:35+08:00 */ CreateTime string `json:"create_time"` /* 通知的事件类型, 支付成功通知为"TRANSACTION.SUCCESS" */ EventType string `json:"event_type"` /* 通知的资源类型, 支付成功通知为"encrypt-resource" */ ResourceType string `json:"resource_type"` /* 通知资源数据 */ Resource *AsyncNotificationResourceFromWeChatPay `json:"resource"` /* 回调摘要, 示例值:支付成功 */ Summary string `json:"summary"` }
type AsyncNotificationResourceFromWeChatPay ¶
type AsyncNotificationResourceFromWeChatPay struct { /* 原始回调类型, 为"transaction" */ OriginalType string `json:"original_type"` /* 加密算法类型, 目前只支持"AEAD_AES_256_GCM" */ Algorithm string `json:"algorithm"` /* 数据密文 */ Ciphertext string `json:"ciphertext"` /* 附加数据 */ AssociatedData string `json:"associated_data"` /* 随机串 */ Nonce string `json:"nonce"` }
type CommonReponse ¶
type NotificationResource ¶
type NotificationResource struct { /* 应用ID */ AppId string `json:"appid"` /* 商户号 */ MchId string `json:"mchid"` /* 商户订单号 */ OutTradeNo string `json:"out_trade_no"` /* 微信支付订单号 */ TransactionId string `json:"transaction_id"` /* 交易类型, JSAPI: 公众号支付; NATIVE: 扫码支付; APP: APP支付; MICROPAY: 付款码支付; MWEB: H5支付; FACEPAY: 刷脸支付 */ TradeType string `json:"trade_type"` /* 交易状态, SUCCESS: 支付成功; REFUND: 转入退款; NOTPAY: 未支付; CLOSED: 已关闭; REVOKED: 已撤销(付款码支付); USERPAYING: 用户支付中(付款码支付); PAYERROR: 支付失败(其他原因,如银行返回失败) */ TradeState string `json:"trade_state"` /* 交易状态描述 */ TradeStateDesc string `json:"trade_state_desc"` /* 付款银行 */ BankType string `json:"bank_type"` /* 支付完成时间 */ SuccessTime string `json:"success_time"` /* 支付者 */ Payer *NotificationResourcePayer `json:"payer"` /* 订单金额 */ Amount *NotificationResourceAmount `json:"amount"` }
type NotificationResourcePayer ¶
type NotificationResourcePayer struct { /* 用户标识 */ OpenId string `json:"openid"` }
type SignParams ¶
type WechatPaymentCallbackServiceImpl ¶
type WechatPaymentCallbackServiceImpl struct {
// contains filtered or unexported fields
}
func GetWechatPaymentCallbackServiceImpl ¶
func GetWechatPaymentCallbackServiceImpl() *WechatPaymentCallbackServiceImpl
func (*WechatPaymentCallbackServiceImpl) CloseWxPrepayOrder ¶
func (impl *WechatPaymentCallbackServiceImpl) CloseWxPrepayOrder( ctx context.Context, req *proto_gens.CloseWxPrepayOrderRequest) ( resp *proto_gens.CloseWxPrepayOrderResponse, err error)
关闭微信支付订单. 文档链接: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_5_3.shtml NOET: 以下情况需要调用关单接口: • 商户订单支付失败需要生成新单号重新发起支付,要对原订单号调用关单,避免重复支付。 • 系统下单后,用户支付超时,系统退出不再受理,避免用户继续,请调用关单接口。 备注: • 关单没有时间限制,建议在订单生成后间隔几分钟(最短5分钟)再调用关单接口,避免出现订单状态同步不及时导致关单失败。
func (*WechatPaymentCallbackServiceImpl) HomeHandler ¶
func (impl *WechatPaymentCallbackServiceImpl) HomeHandler(ctx *gin.Context)
func (*WechatPaymentCallbackServiceImpl) MakeNewPlatformTradeId ¶
func (impl *WechatPaymentCallbackServiceImpl) MakeNewPlatformTradeId( ctx context.Context, req *proto_gens.MakeNewPlatformTradeIdRequest) ( resp *proto_gens.MakeNewPlatformTradeIdResponse, err error)
生成平台订单交易ID, 用于标识平台订单.
func (*WechatPaymentCallbackServiceImpl) MakeNewWxPrepayOrder ¶
func (impl *WechatPaymentCallbackServiceImpl) MakeNewWxPrepayOrder( ctx context.Context, req *proto_gens.MakeNewWxPrepayOrderRequest) ( resp *proto_gens.MakeNewWxPrepayOrderResponse, err error)
创建平台订单和微信预支付订单, 其中平台订单用于标识交易, 微信预支付订单用于发起支付. 文档链接: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_5_1.shtml NOTE: 如何调用 MakeNewWxPrepayOrder 接口失败, 务必由调用端发起去调用 CloseWxPrepayOrder 接口来关闭微信预支付订单.
func (*WechatPaymentCallbackServiceImpl) NotifyHandler ¶
func (impl *WechatPaymentCallbackServiceImpl) NotifyHandler(ctx *gin.Context)
特别提醒: • 商户系统对于开启结果通知的内容一定要做签名验证,并校验通知的信息是否与商户侧的信息一致,防止数据泄露导致出现“假通知”,造成资金损失。
func (*WechatPaymentCallbackServiceImpl) Ping ¶
func (impl *WechatPaymentCallbackServiceImpl) Ping( ctx context.Context, req *proto_gens.PingRequest) ( resp *proto_gens.PongResponse, err error)
func (*WechatPaymentCallbackServiceImpl) QueryWxPaymentStatus ¶
func (impl *WechatPaymentCallbackServiceImpl) QueryWxPaymentStatus( ctx context.Context, req *proto_gens.QueryWxPaymentStatusRequest) ( resp *proto_gens.QueryWxPaymentStatusResponse, err error)
查询微信支付状态. 文档链接: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_5_2.shtml NOET: 以下情况需要调用查询接口: • 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知(N分钟后)。 • 调用支付接口后,返回系统错误或未知交易状态情况。 • 调用付款码支付API后,返回USERPAYING状态。 • 调用关单或撤销接口API之前,需确认支付状态。