core_v3

package
v1.1.9-beta.1 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const DEBUG bool = true
View Source
const (
	GATEWAY = "https://api.mch.weixin.qq.com"
)

Variables

View Source
var UserAgent string

Functions

This section is empty.

Types

type CertResponse

type CertResponse struct {
	Data []struct {
		SerialNo           string `json:"serial_no"`      // 证书序列号
		EffectiveTime      string `json:"effective_time"` // 生效时间
		ExpireTime         string `json:"expire_time"`    // 过期时间
		EncryptCertificate struct {
			Algorithm      string `json:"algorithm"`       // 算法
			Nonce          string `json:"nonce"`           // 随机串
			AssociatedData string `json:"associated_data"` // 附加数据包
			Ciphertext     string `json:"ciphertext"`      // 密文
		} `json:"encrypt_certificate"` // 证书内容
	} `json:"data"`
}

type Client

type Client struct {
	GateWay            string            // 网关
	MerchantId         string            // 商户id
	SerialNumber       string            // 商户序列号
	AppSecret          string            // 商户密钥 微信支付在回调通知和平台证书下载接口中,对关键信息进行了AES-256-GCM加密
	PrivateKey         *rsa.PrivateKey   // 商户API私钥
	Certificate        *tls.Certificate  // 商户证书
	WechatCertificate  *x509.Certificate // 平台证书
	WechatSerialNumber string            // 微信平台序列号
	// contains filtered or unexported fields
}
var Cli *Client // 默认客户端

func NewClient

func NewClient(merchantId, serialNumber, appSecret, certFile, keyFile string) (cli *Client, err error)

实例化一个客户端

func (*Client) DoGet

func (cli *Client) DoGet(url string, needVerify ...bool) (resp []byte, err error)

GET一个API

func (*Client) DoPost

func (cli *Client) DoPost(url, body string, needVerify ...bool) (resp []byte, httpCode int, err error)

POST一个API

func (*Client) GetWechatCertificate

func (cli *Client) GetWechatCertificate() (err error)

获取微信支付平台证书 平台证书会周期性更换。建议商户定时通过API下载新的证书 可以弄个Cronjob线程周期执行这个方法

func (*Client) ImageUpload

func (cli *Client) ImageUpload(content []byte, filename string) (mediaId string, err error)

图片上传 https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/tool/chapter3_1.shtml

func (*Client) SecretFieldEncrypt

func (cli *Client) SecretFieldEncrypt(plaintext []byte) (ciphertext string, err error)

敏感信息加密 https://wechatpay-api.gitbook.io/wechatpay-api-v3/qian-ming-zhi-nan-1/min-gan-xin-xi-jia-mi

func (*Client) Sign

func (cli *Client) Sign(method, url, body, nonce string) (sign string, err error)

加签 https://wechatpay-api.gitbook.io/wechatpay-api-v3/qian-ming-zhi-nan-1/qian-ming-sheng-cheng

Jump to

Keyboard shortcuts

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