Documentation
¶
Index ¶
- Constants
- func LoadCertificate(data string) (*x509.Certificate, error)
- func NewPrivateKey(data string) (*rsa.PrivateKey, error)
- func ParseNotifyRequest[RET any](r *NotifyRequest, c *Client) *RET
- type AppPrepayResponse
- type Client
- func (c *Client) AppPrepay(appId string, outTradeNo string, amount float64, description string, ...) (*AppPrepayResponse, error)
- func (c *Client) Close() error
- func (c *Client) Decrypt(algorithm string, associatedData string, nonce string, ciphertext string) string
- func (c *Client) H5Prepay(appId string, outTradeNo string, amount float64, description string, ...) (*H5PrepayResponse, error)
- func (c *Client) JsapiPayNew(appId string, prepayId string) *JsapiPayRequest
- func (c *Client) JsapiPrepay(appId string, outTradeNo string, amount float64, description string, ...) (*JsapiPrepayResponse, error)
- func (c *Client) LoadCertificates() error
- func (c *Client) MchId() string
- func (c *Client) NativePrepay(appId string, outTradeNo string, amount float64, description string, ...) (*NativePrepayResponse, error)
- func (c *Client) Refund(transactionId string, outTradeNo string, outRefundNo string, total float64, ...) (*RefundResponse, error)
- func (c *Client) VerifySignature(header http.Header, body []byte) error
- type H5PrepayResponse
- type H5PrepaySceneInfo
- type H5PrepayStoreInfo
- type JsapiPayRequest
- type JsapiPrepayResponse
- type NativePrepayResponse
- type NotifyRequest
- type NotifyResponse
- type PaySuccessData
- type RefundData
- type RefundResponse
Constants ¶
const ( NotifyEventTypeTransactionSuccess = "TRANSACTION.SUCCESS" NotifyEventTypeRefundSuccess = "REFUND.SUCCESS" NotifyEventTypeRefundAbnormal = "REFUND.ABNORMAL" NotifyEventTypeRefundClose = "REFUND.CLOSED" )
Variables ¶
This section is empty.
Functions ¶
func LoadCertificate ¶
func LoadCertificate(data string) (*x509.Certificate, error)
LoadCertificate 通过证书的文本内容加载证书 refer github.com/wechatpay-apiv3/wechatpay-go/utils
func NewPrivateKey ¶
func NewPrivateKey(data string) (*rsa.PrivateKey, error)
NewPrivateKey 通过私钥的文本内容加载私钥 refer github.com/wechatpay-apiv3/wechatpay-go/utils
func ParseNotifyRequest ¶
func ParseNotifyRequest[RET any](r *NotifyRequest, c *Client) *RET
Types ¶
type AppPrepayResponse ¶
type AppPrepayResponse struct {
PrepayId string `json:"prepay_id"`
}
type Client ¶
type Client struct {
AppId string
// contains filtered or unexported fields
}
Client 微信支付 API client https://pay.weixin.qq.com/doc/v3/merchant/4012062524
func NewClient ¶
func NewClient(hc *wsa.HttpClient, mchId string, certificateSerialNo string, privateKey *rsa.PrivateKey, apiV3Secret string) *Client
func (*Client) AppPrepay ¶
func (c *Client) AppPrepay(appId string, outTradeNo string, amount float64, description string, notifyUrl string, attach string, expire time.Time) (*AppPrepayResponse, error)
AppPrepay App支付下单 https://pay.weixin.qq.com/doc/v3/merchant/4013070347
func (*Client) Decrypt ¶
func (c *Client) Decrypt(algorithm string, associatedData string, nonce string, ciphertext string) string
Decrypt 解密回调报文和平台证书 https://pay.weixin.qq.com/doc/v3/merchant/4012071382
func (*Client) H5Prepay ¶
func (c *Client) H5Prepay(appId string, outTradeNo string, amount float64, description string, notifyUrl string, attach string, expire time.Time, sceneInfo *H5PrepaySceneInfo) (*H5PrepayResponse, error)
H5Prepay H5支付下单 https://pay.weixin.qq.com/doc/v3/merchant/4012791834
func (*Client) JsapiPayNew ¶
func (c *Client) JsapiPayNew(appId string, prepayId string) *JsapiPayRequest
JsapiPayNew JSAPI调起支付参数生成 https://pay.weixin.qq.com/doc/v3/merchant/4012791857
func (*Client) JsapiPrepay ¶
func (c *Client) JsapiPrepay(appId string, outTradeNo string, amount float64, description string, notifyUrl string, attach string, expire time.Time, payerOpenId string) (*JsapiPrepayResponse, error)
JsapiPrepay JSAPI支付下单 https://pay.weixin.qq.com/doc/v3/merchant/4012791856
func (*Client) LoadCertificates ¶
LoadCertificates 获取商户当前可用的平台证书列表 https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay5_1.shtml
func (*Client) NativePrepay ¶
func (c *Client) NativePrepay(appId string, outTradeNo string, amount float64, description string, notifyUrl string, attach string, expire time.Time) (*NativePrepayResponse, error)
NativePrepay Native支付下单 https://pay.weixin.qq.com/doc/v3/merchant/4012791874
func (*Client) Refund ¶
func (c *Client) Refund(transactionId string, outTradeNo string, outRefundNo string, total float64, amount float64, reason string, notifyUrl string) (*RefundResponse, error)
Refund 退款申请 https://pay.weixin.qq.com/doc/v3/merchant/4012791883
func (*Client) VerifySignature ¶
VerifySignature 验证签名, 请求响应 和 回调请求 https://pay.weixin.qq.com/doc/v3/merchant/4013053249
type H5PrepayResponse ¶
type H5PrepayResponse struct {
H5Url string `json:"h5_url"`
}
type H5PrepaySceneInfo ¶
type H5PrepaySceneInfo struct {
PayerClientIp string `json:"payer_client_ip"`
DeviceId string `json:"device_id,omitempty"`
StoreInfo *H5PrepayStoreInfo `json:"store_info,omitempty"`
H5Info struct {
Type string `json:"type"`
AppName string `json:"app_name,omitempty"`
AppUrl string `json:"app_url,omitempty"`
BundleId string `json:"bundle_id,omitempty"`
PackageName string `json:"package_name,omitempty"`
} `json:"h5_info"`
}
type H5PrepayStoreInfo ¶
type JsapiPayRequest ¶
type JsapiPrepayResponse ¶
type JsapiPrepayResponse struct {
PrepayId string `json:"prepay_id"`
}
type NativePrepayResponse ¶
type NativePrepayResponse struct {
CodeUrl string `json:"code_url"`
}
type NotifyRequest ¶
type NotifyRequest struct {
Id string `json:"id"`
CreateTime string `json:"create_time"`
ResourceType string `json:"resource_type"`
EventType string `json:"event_type"`
Summary string `json:"summary"`
Resource struct {
OriginalType string `json:"original_type"`
Algorithm string `json:"algorithm"`
Ciphertext string `json:"ciphertext"`
AssociatedData string `json:"associated_data"`
Nonce string `json:"nonce"`
} `json:"resource"`
}
func (*NotifyRequest) Decrypt ¶
func (r *NotifyRequest) Decrypt(c *Client) string
func (*NotifyRequest) PaySuccessData ¶
func (r *NotifyRequest) PaySuccessData(c *Client) *PaySuccessData
PaySuccessData 解密支付成功回调内容 https://pay.weixin.qq.com/doc/v3/merchant/4012791882
func (*NotifyRequest) RefundData ¶
func (r *NotifyRequest) RefundData(c *Client) *RefundData
RefundData 解密退款结果回调内容 https://pay.weixin.qq.com/doc/v3/merchant/4012791886
type NotifyResponse ¶
func NewFailNotifyResponse ¶
func NewFailNotifyResponse(message string) *NotifyResponse
type PaySuccessData ¶
type PaySuccessData struct {
Mchid string `json:"mchid"`
Appid string `json:"appid"`
OutTradeNo string `json:"out_trade_no"`
TransactionId string `json:"transaction_id"`
TradeType string `json:"trade_type"`
TradeState string `json:"trade_state"`
TradeStateDesc string `json:"trade_state_desc"`
BankType string `json:"bank_type"`
Attach string `json:"attach"`
SuccessTime string `json:"success_time"`
Payer struct {
Openid string `json:"openid"`
} `json:"payer"`
Amount struct {
Total int64 `json:"total"`
PayerTotal int64 `json:"payer_total"`
Currency string `json:"currency"`
PayerCurrency string `json:"payer_currency"`
} `json:"amount"`
}
type RefundData ¶
type RefundData struct {
Mchid string `json:"mchid"`
TransactionId string `json:"transaction_id"`
OutTradeNo string `json:"out_trade_no"`
RefundId string `json:"refund_id"`
OutRefundNo string `json:"out_refund_no"`
RefundStatus string `json:"refund_status"`
SuccessTime string `json:"success_time"`
UserReceivedAccount string `json:"user_received_account"`
Amount struct {
Total int64 `json:"total"`
Refund int64 `json:"refund"`
PayerTotal int64 `json:"payer_total"`
PayerRefund int64 `json:"payer_refund"`
} `json:"amount"`
}
type RefundResponse ¶
type RefundResponse struct {
RawData
RefundId string `json:"refund_id"`
OutRefundNo string `json:"out_refund_no"`
TransactionId string `json:"transaction_id"`
OutTradeNo string `json:"out_trade_no"`
Channel string `json:"channel"`
UserReceivedAccount string `json:"user_received_account"`
SuccessTime string `json:"success_time"`
CreateTime string `json:"create_time"`
Status string `json:"status"`
FundsAccount string `json:"funds_account"`
Amount *struct {
Total int `json:"total"`
Refund int `json:"refund"`
From []struct {
Account string `json:"account"`
Amount int `json:"amount"`
} `json:"from"`
PayerTotal int `json:"payer_total"`
PayerRefund int `json:"payer_refund"`
SettlementRefund int `json:"settlement_refund"`
SettlementTotal int `json:"settlement_total"`
DiscountRefund int `json:"discount_refund"`
Currency string `json:"currency"`
RefundFee int `json:"refund_fee"`
} `json:"amount"`
PromotionDetail []*struct {
PromotionId string `json:"promotion_id"`
Scope string `json:"scope"`
Type string `json:"type"`
Amount int `json:"amount"`
RefundAmount int `json:"refund_amount"`
GoodsDetail []*struct {
MerchantGoodsId string `json:"merchant_goods_id"`
WechatpayGoodsId string `json:"wechatpay_goods_id"`
GoodsName string `json:"goods_name"`
UnitPrice int `json:"unit_price"`
RefundAmount int `json:"refund_amount"`
RefundQuantity int `json:"refund_quantity"`
} `json:"goods_detail"`
} `json:"promotion_detail"`
}