wechatpay

package module
v0.0.0-...-a4c143b Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2021 License: MIT Imports: 25 Imported by: 0

README

Wechatpay-V3 SDK for Golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Amount

type Amount struct {
	Total    uint   `json:"total"`
	Currency string `json:"currency,omitempty"`
}

type BodyParam

type BodyParam interface {
	Params(client *Client) BodyParam
}

type Central

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

Central 微信平台证书中控

type CertificateDriver

type CertificateDriver interface {
	// contains filtered or unexported methods
}

CertificateDriver 证书中控存放驱动

type CertificatesResult

type CertificatesResult struct {
	Data []struct {
		EffectiveTime      string `json:"effective_time"`
		EncryptCertificate struct {
			Algorithm      string `json:"algorithm"`
			AssociatedData string `json:"associated_data"`
			Ciphertext     string `json:"ciphertext"`
			Nonce          string `json:"nonce"`
		} `json:"encrypt_certificate"`
		ExpireTime string `json:"expire_time"`
		SerialNo   string `json:"serial_no"`
	} `json:"data"`
}

func (*CertificatesResult) IsSuccess

func (r *CertificatesResult) IsSuccess() bool

type Client

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

func New

func New(mchId string, apiKey string, logger logger) (*Client, error)

New 获取新实例

func (*Client) AesDecrypt

func (c *Client) AesDecrypt(crypted string, nonce string, additionalData string) ([]byte, error)

AesDecrypt 解密

func (*Client) CombineTransactionsJsapi

func (c *Client) CombineTransactionsJsapi(param *CombineTransactions) (*TransactionsResp, error)

CombineTransactionsJsapi 合单支付 JSAPI 下单

func (*Client) DoRequest

func (c *Client) DoRequest(method string, apiUri string, vs ...interface{}) error

DoRequest 发送请求

func (*Client) LoadCertCentral

func (c *Client) LoadCertCentral(driver CertificateDriver, pemDataArr [][]byte) error

LoadCertCentral 加载微信证书中控

func (*Client) LoadMerchantPrivateKey

func (c *Client) LoadMerchantPrivateKey(pemData []byte, serialNumber string) error

LoadMerchantPrivateKey 加载商户私钥

func (*Client) LoadMerchantPrivateKeyFromFile

func (c *Client) LoadMerchantPrivateKeyFromFile(filePath string, serialNumber string) error

LoadMerchantPrivateKeyFromFile 加载商户私钥

func (*Client) MediaUpload

func (c *Client) MediaUpload(param *FileParam) (*UploadResp, error)

MediaUpload 图片上传

func (*Client) TransactionsJsapi

func (c *Client) TransactionsJsapi(param *TransactionsJsapi) (*TransactionsResp, error)

TransactionsJsapi 基础支付 JSAPI 支付统一下单

type CombineAmount

type CombineAmount struct {
	TotalAmount uint   `json:"total_amount"`
	Currency    string `json:"currency"`
}

type CombineTransactions

type CombineTransactions struct {
	CombineAppid      string                         `json:"combine_appid"`
	CombineMchid      string                         `json:"combine_mchid"`
	CombineOutTradeNo string                         `json:"combine_out_trade_no"`
	SceneInfo         *CombineTransactionsSceneInfo  `json:"scene_info,omitempty"` // *注:该值在合单 H5 下单时为必填
	SubOrders         []*CombineTransactionsSubOrder `json:"sub_orders"`
	CombinePayerInfo  *Payer                         `json:"combine_payer_info"`
	TimeStart         string                         `json:"time_start,omitempty"`
	TimeExpire        string                         `json:"time_expire,omitempty"`
	NotifyUrl         string                         `json:"notify_url"`
}

func (*CombineTransactions) Params

func (p *CombineTransactions) Params(client *Client) BodyParam

type CombineTransactionsH5Info

type CombineTransactionsH5Info struct {
	InfoType    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"`
}

type CombineTransactionsSceneInfo

type CombineTransactionsSceneInfo struct {
	DeviceId      string                     `json:"device_id,omitempty"`
	PayerClientIp string                     `json:"payer_client_ip"`
	H5Info        *CombineTransactionsH5Info `json:"h5_info,omitempty"`
}

type CombineTransactionsSettleInfo

type CombineTransactionsSettleInfo struct {
	ProfitSharing bool  `json:"profit_sharing,omitempty"`
	SubsidyAmount int64 `json:"subsidy_amount,omitempty"`
}

type CombineTransactionsSubOrder

type CombineTransactionsSubOrder struct {
	Mchid       string                         `json:"mchid"`
	Attach      string                         `json:"attach"`
	Amount      *CombineAmount                 `json:"amount"`
	OutTradeNo  string                         `json:"out_trade_no"`
	SubMchId    string                         `json:"sub_mchid"`
	Description string                         `json:"description"`
	SettleInfo  *CombineTransactionsSettleInfo `json:"settle_info,omitempty"`
}

type ErrorResult

type ErrorResult struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

type FileLogger

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

FileLogger 文件日志

func NewFileLogger

func NewFileLogger(file *os.File) *FileLogger

NewFileLogger 获取 FileLogger 实例

type FileParam

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

func NewFileParam

func NewFileParam(file *os.File) (*FileParam, error)

type MemoryDriver

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

MemoryDriver 内存驱动,使用 sync.Map 存放

type Payer

type Payer struct {
	Openid string `json:"openid"`
}

type QueryParam

type QueryParam interface {
	Params(client *Client) map[string]interface{}
}

type Result

type Result interface {
	IsSuccess() bool
}

type TransactionsDetail

type TransactionsDetail struct {
	CostPrice   uint                     `json:"cost_price,omitempty"`
	InvoiceId   string                   `json:"invoice_id,omitempty"`
	GoodsDetail *TransactionsGoodsDetail `json:"goods_detail,omitempty"`
}

type TransactionsGoodsDetail

type TransactionsGoodsDetail struct {
	MerchantGoodsId  string `json:"merchant_goods_id"`
	WechatpayGoodsId string `json:"wechatpay_goods_id,omitempty"`
	GoodsName        string `json:"goods_name,omitempty"`
	Quantity         uint   `json:"quantity"`
	UnitPrice        uint   `json:"unit_price"`
}

type TransactionsJsapi

type TransactionsJsapi struct {
	Appid       string                 `json:"appid"`
	Mchid       string                 `json:"mchid"`
	Description string                 `json:"description"`
	OutTradeNo  string                 `json:"out_trade_no"`
	TimeExpire  string                 `json:"time_expire,omitempty"`
	Attach      string                 `json:"attach,omitempty"`
	NotifyUrl   string                 `json:"notify_url"`
	GoodsTag    string                 `json:"goods_tag,omitempty"`
	Amount      *Amount                `json:"amount"`
	Payer       *Payer                 `json:"payer"`
	Detail      *TransactionsDetail    `json:"detail,omitempty"`
	SceneInfo   *TransactionsSceneInfo `json:"scene_info,omitempty"`
}

func (*TransactionsJsapi) Params

func (p *TransactionsJsapi) Params(client *Client) BodyParam

type TransactionsResp

type TransactionsResp struct {
	PrepayId string `json:"prepay_id"`
}

func (*TransactionsResp) IsSuccess

func (*TransactionsResp) IsSuccess() bool

type TransactionsSceneInfo

type TransactionsSceneInfo struct {
	PayerClientIp string `json:"payer_client_ip"`
	DeviceId      string `json:"device_id,omitempty"`
	StoreInfo     struct {
		Id       string `json:"id"`
		Name     string `json:"name,omitempty"`
		AreaCode string `json:"area_code,omitempty"`
		Address  string `json:"address,omitempty"`
	} `json:"store_info,omitempty"`
}

type UploadResp

type UploadResp struct {
	MediaId string `json:"media_id"`
}

func (*UploadResp) IsSuccess

func (u *UploadResp) IsSuccess() bool

Jump to

Keyboard shortcuts

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