service

package
v3.0.0-...-8a73552 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeJSON = "application/json"
	ContentTypeXML  = "application/xml;charset=utf-8"
)

Variables

This section is empty.

Functions

func ImageExt

func ImageExt(name string) (contentType string, err error)

ImageExt 获取图片后缀名(图片格式)

func VideoExt

func VideoExt(name string) (contentType string, err error)

VideoExt 获取视频的后缀名(视频格式)

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(opts ...Option) *Config

func (*Config) AddCertificate

func (c *Config) AddCertificate(serialNo string, cert *x509.Certificate)

func (*Config) Download

func (c *Config) Download(url string) (data []byte, err error)

Download 下载URL对应的数据流

func (*Config) GetApiKey

func (c *Config) GetApiKey() string

func (*Config) GetAppId

func (c *Config) GetAppId() string

func (*Config) GetDomain

func (c *Config) GetDomain() string

func (*Config) GetHTTPClient

func (c *Config) GetHTTPClient() *http.Client

func (*Config) GetMchId

func (c *Config) GetMchId() string

func (*Config) GetMerchantCipher

func (c *Config) GetMerchantCipher() secret.Cipher

func (*Config) GetRSAPublicKey

func (c *Config) GetRSAPublicKey(serialNo string) *rsa.PublicKey

func (*Config) GetSecret

func (c *Config) GetSecret() string

func (*Config) GetSerialNo

func (c *Config) GetSerialNo() string

func (*Config) GetSyncCertificateTag

func (c *Config) GetSyncCertificateTag() bool

func (*Config) GetValidPublicKey

func (c *Config) GetValidPublicKey() (serialNo string, publicKey *rsa.PublicKey)

func (*Config) GetWechatCipher

func (c *Config) GetWechatCipher() secret.Cipher

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

func (*Config) UploadMedia

func (c *Config) UploadMedia(url string, contentType string, fileName string, fileData []byte) (response *http.Response, err error)

UploadMedia 上传多媒体文件到微信服务器

func (*Config) VerifyHashValue

func (c *Config) VerifyHashValue(hashType crypto.Hash, data interface{}, hashValue string) (err error)

VerifyHashValue 校验hash值

type Option

type Option func(*Config)

func WithApiV3Key

func WithApiV3Key(apiKey string) Option

func WithAppId

func WithAppId(appId string) Option

func WithAppSecret

func WithAppSecret(secret string) Option

func WithHttpClient

func WithHttpClient(client *http.Client) Option

func WithMchId

func WithMchId(mchId string) Option

func WithPrivateKey

func WithPrivateKey(file string) Option

func WithPublicKey

func WithPublicKey(file string) Option

func WithSerialNo

func WithSerialNo(serialNo string) Option

func WithSyncCertificate

func WithSyncCertificate() Option

Jump to

Keyboard shortcuts

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