Documentation ¶
Index ¶
- Constants
- func ImageExt(name string) (contentType string, err error)
- func VideoExt(name string) (contentType string, err error)
- type Config
- func (c *Config) AddCertificate(serialNo string, cert *x509.Certificate)
- func (c *Config) Download(url string) (data []byte, err error)
- func (c *Config) GetApiKey() string
- func (c *Config) GetAppId() string
- func (c *Config) GetDomain() string
- func (c *Config) GetHTTPClient() *http.Client
- func (c *Config) GetMchId() string
- func (c *Config) GetMerchantCipher() secret.Cipher
- func (c *Config) GetRSAPublicKey(serialNo string) *rsa.PublicKey
- func (c *Config) GetSecret() string
- func (c *Config) GetSerialNo() string
- func (c *Config) GetSyncCertificateTag() bool
- func (c *Config) GetValidPublicKey() (serialNo string, publicKey *rsa.PublicKey)
- func (c *Config) GetWechatCipher() secret.Cipher
- func (c *Config) ParseWechatNotify(request *http.Request, dst interface{}) (notifyId string, err error)
- func (c *Config) ParseWechatResponse(response *http.Response, dst interface{}) (requestId string, err error)
- func (c *Config) Request(method, url, contentType string, data interface{}) (response *http.Response, err error)
- func (c *Config) RequestWithSign(method, url string, body interface{}, headers ...string) (response *http.Response, err error)
- func (c *Config) UploadMedia(url string, contentType string, fileName string, fileData []byte) (response *http.Response, err error)
- func (c *Config) VerifyHashValue(hashType crypto.Hash, data interface{}, hashValue string) (err error)
- type Option
- func WithApiV3Key(apiKey string) Option
- func WithAppId(appId string) Option
- func WithAppSecret(secret string) Option
- func WithHttpClient(client *http.Client) Option
- func WithMchId(mchId string) Option
- func WithPrivateKey(file string) Option
- func WithPublicKey(file string) Option
- func WithSerialNo(serialNo string) Option
- func WithSyncCertificate() Option
Constants ¶
View Source
const ( ContentTypeJSON = "application/json" ContentTypeXML = "application/xml;charset=utf-8" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
func (*Config) AddCertificate ¶
func (c *Config) AddCertificate(serialNo string, cert *x509.Certificate)
func (*Config) GetHTTPClient ¶
func (*Config) GetMerchantCipher ¶
func (*Config) GetSerialNo ¶
func (*Config) GetSyncCertificateTag ¶
func (*Config) GetValidPublicKey ¶
func (*Config) GetWechatCipher ¶
func (*Config) ParseWechatNotify ¶
func (c *Config) ParseWechatNotify(request *http.Request, dst interface{}) (notifyId string, err error)
ParseWechatNotify 验证微信服务器的通知,预支付、退款等请求后,微信回调的Request同样需要签名验证 微信(验证)签名方法详细介绍: https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay4_1.shtml
func (*Config) ParseWechatResponse ¶
func (c *Config) ParseWechatResponse(response *http.Response, dst interface{}) (requestId string, err error)
ParseWechatResponse 验证向微信服务器发送请求后从微信得到的应答签名 微信(验证)签名验证详细介绍: https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay4_1.shtml
func (*Config) Request ¶
func (c *Config) Request(method, url, contentType string, data interface{}) (response *http.Response, err error)
Request 发起普通的HTTP请求
func (*Config) RequestWithSign ¶
func (c *Config) RequestWithSign(method, url string, body interface{}, headers ...string) (response *http.Response, err error)
RequestWithSign 对发送给微信服务器的body进行SHA-256 with RSA签名, 返回*http.Request 参数说明: method: api方法类型, 如: GET、POST等 url: api接口除去域名的绝对URL, 如: /v3/pay/transactions/jsapi body: 请求主体,比如支付时为支付参数,调用方需要不序列化 返回参数说明: signResult: 返回用于签名的各个参数,包括签名结果 签名介绍详细介绍: https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay4_0.shtml
type Option ¶
type Option func(*Config)
func WithApiV3Key ¶
func WithAppSecret ¶
func WithHttpClient ¶
func WithPrivateKey ¶
func WithPublicKey ¶
func WithSerialNo ¶
func WithSyncCertificate ¶
func WithSyncCertificate() Option
Click to show internal directories.
Click to hide internal directories.