wxpay

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

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

Go to latest
Published: Nov 22, 2022 License: MIT Imports: 20 Imported by: 0

README

wxpay

微信支付(开发中)

Usage

go get -u github.com/nilorg/wxpay

Import

import "github.com/nilorg/wxpay"

文档

  1. 协议规范

功能

  1. 统一下单 ✅
  2. 查询订单
  3. 关闭订单
  4. 申请退款
  5. 查询退款
  6. 下载对账单
  7. 下载资金账单
  8. 支付结果通知
  9. 交易保障
  10. 退款结果通知
  11. 拉取订单评价数据
  12. 现金红包-发红包 ✅
  13. 现金红包-发裂变红包 ✅
  14. 现金红包-查红包记录
  15. 企业付款-企业向微信用户个人付款 ✅

Documentation

Index

Constants

View Source
const (
	Fail            = "FAIL"
	Success         = "SUCCESS"
	Ok              = "OK"
	HMACSHA256      = "HMAC-SHA256"
	MD5             = "MD5"
	TradeTypeJSApi  = "JSAPI"
	TradeTypeNative = "NATIVE"
	TradeTypeApp    = "APP"
)
View Source
const (
	// BaseURL ...
	BaseURL = "https://api.mch.weixin.qq.com"
	// Base2URL 备用域名
	Base2URL = "https://api2.mch.weixin.qq.com"
)

Variables

View Source
var (
	// ErrTypeIsNil ...
	ErrTypeIsNil = errors.New("类型为Nil")
	// ErrTypeUnknown ...
	ErrTypeUnknown = errors.New("未处理到的数据类型")
)
View Source
var (
	CallbackSuccessful = &ResponseReturn{Code: Success, Msg: Ok}
)
View Source
var (
	// ErrNotEqualStruct ...
	ErrNotEqualStruct = errors.New("参数不是Struct类型")
)

Functions

func SignHMACSHA256

func SignHMACSHA256(params Parameter, key []byte) string

SignHMACSHA256 生成Sign HMACS-HA256

func SignMD5

func SignMD5(params Parameter) string

SignMD5 生成signMD5

Types

type CDATA

type CDATA string

CDATA ...

func (CDATA) MarshalXML

func (c CDATA) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML ...

type Client

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

Client 客户端

func NewClient

func NewClient(conf *Config) (client *Client, err error)

NewClient ...

func (*Client) Config

func (c *Client) Config() Config

Config ...

func (*Client) PromotionTransfers

func (c *Client) PromotionTransfers(req *PromotionTransfersRequest) (resp *PromotionTransfersResponse, err error)

PromotionTransfers 企业向微信用户个人付款

func (*Client) SendGroupRedPack

func (c *Client) SendGroupRedPack(req *SendGroupRedPackRequest) (resp *SendGroupRedPackResponse, err error)

SendGroupRedPack 发裂变红包

func (*Client) SendRedPack

func (c *Client) SendRedPack(req *SendRedPackRequest) (resp *SendRedPackResponse, err error)

SendRedPack 发现金红包

func (*Client) UnifiedOrder

func (c *Client) UnifiedOrder(req *UnifiedOrderRequest) (resp *UnifiedOrderResponse, err error)

UnifiedOrder 统一下单

type Clienter

type Clienter interface {
	Config() Config

	UnifiedOrder(req *UnifiedOrderRequest) (resp *UnifiedOrderResponse, err error)
}

Clienter ...

type Config

type Config struct {
	BaseURL    string `json:"base_url"`
	AppID      string `json:"app_id"`
	MchID      string `json:"mch_id"`
	APIKey     string `json:"api_key"`
	SignType   string `json:"sign_type"`
	SignKey    string `json:"sign_key"`
	NotifyURL  string `json:"notify_url"`
	CaCertFile string `json:"ca_cert_file"`
	CaKeyFile  string `json:"ca_key_file"`
	HttpProxy  string `json:"http_proxy"`
}

Config ...

func NewConfig

func NewConfig(aid, mid string) *Config

NewConfig ...

type Parameter

type Parameter map[string]interface{}

Parameter 参数

func SignStructToParameter

func SignStructToParameter(value interface{}) (params Parameter, err error)

SignStructToParameter ...

type PromotionTransfersRequest

type PromotionTransfersRequest struct {
	XMLName        xml.Name `xml:"xml"`
	MchAppID       string   `xml:"mch_appid"`
	MchID          string   `xml:"mchid"`
	DeviceInfo     string   `xml:"device_info"`
	NonceStr       string   `xml:"nonce_str"`
	Sign           string   `xml:"sign"`
	PartnerTradeNo string   `xml:"partner_trade_no"`
	OpenID         string   `xml:"openid"`
	CheckName      string   `xml:"check_name"`
	ReUserName     string   `xml:"re_user_name"`
	Amount         int      `xml:"amount"`
	Desc           string   `xml:"desc"`
	SpbillCreateIP string   `xml:"spbill_create_ip"`
}

PromotionTransfersRequest 企业向微信用户个人付款请求

func NewPromotionTransfersRequest

func NewPromotionTransfersRequest() *PromotionTransfersRequest

NewPromotionTransfersRequest 创建企业向微信用户个人付款请求

func (*PromotionTransfersRequest) SignMD5

func (req *PromotionTransfersRequest) SignMD5(apiKey string) error

SignMD5 md5

type PromotionTransfersResponse

type PromotionTransfersResponse struct {
	ResponseStatus
	MchAppID       string `xml:"mch_appid"`
	MchID          string `xml:"mchid"`
	DeviceInfo     string `xml:"device_info"`
	NonceStr       string `xml:"nonce_str"`
	PartnerTradeNo string `xml:"partner_trade_no"`
	PaymentNo      string `xml:"payment_no"`
	PaymentTime    string `xml:"payment_time"`
}

PromotionTransfersResponse 企业向微信用户个人付款响应

type ResponseReturn

type ResponseReturn struct {
	XMLName xml.Name `xml:"xml"`
	Code    CDATA    `xml:"return_code"`
	Msg     CDATA    `xml:"return_msg"`
}

ResponseReturn 成功

type ResponseStatus

type ResponseStatus struct {
	ReturnCode string `xml:"return_code"`
	ReturnMsg  string `xml:"return_msg"`
	ResultCode string `xml:"result_code"`
	ErrCode    string `xml:"err_code"`
	ErrCodeDes string `xml:"err_code_des"`
}

ResponseStatus 响应状态

type SceneInfo

type SceneInfo struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	AreaCode string `json:"area_code"`
	Address  string `json:"address"`
}

SceneInfo 场景信息

type SendGroupRedPackRequest

type SendGroupRedPackRequest struct {
	XMLName     xml.Name `xml:"xml"`
	NonceStr    string   `xml:"nonce_str"`
	Sign        string   `xml:"sign"`
	MchBillno   string   `xml:"mch_billno"`
	MchID       string   `xml:"mch_id"`
	WxAppID     string   `xml:"wxappid"`
	SendName    string   `xml:"send_name"`
	ReOpenID    string   `xml:"re_openid"`
	TotalAmount uint     `xml:"total_amount"`
	TotalNum    uint     `xml:"total_num"`
	AmtType     string   `xml:"amt_type"`
	Wishing     string   `xml:"wishing"`
	ActName     string   `xml:"act_name"`
	Remark      string   `xml:"remark"`
	SceneID     string   `xml:"scene_id"`
	RiskInfo    string   `xml:"risk_info"`
}

SendGroupRedPackRequest 发裂变红包

func NewSendGroupRedPackRequest

func NewSendGroupRedPackRequest() *SendGroupRedPackRequest

NewSendGroupRedPackRequest 创建裂变红包

func (*SendGroupRedPackRequest) SignMD5

func (req *SendGroupRedPackRequest) SignMD5(apiKey string) error

SignMD5 md5

type SendGroupRedPackResponse

type SendGroupRedPackResponse struct {
	ResponseStatus
	MchBillno   string `xml:"mch_billno"`
	MchID       string `xml:"mch_id"`
	WxAppID     string `xml:"wxappid"`
	ReOpenID    string `xml:"re_openid"`
	TotalAmount uint   `xml:"total_amount"`
	SendListID  string `xml:"send_listid"`
}

SendGroupRedPackResponse ...

type SendRedPackRequest

type SendRedPackRequest struct {
	XMLName     xml.Name `xml:"xml"`
	NonceStr    string   `xml:"nonce_str"`
	Sign        string   `xml:"sign"`
	MchBillno   string   `xml:"mch_billno"`
	MchID       string   `xml:"mch_id"`
	WxAppID     string   `xml:"wxappid"`
	SendName    string   `xml:"send_name"`
	ReOpenID    string   `xml:"re_openid"`
	TotalAmount uint     `xml:"total_amount"`
	TotalNum    uint     `xml:"total_num"`
	Wishing     string   `xml:"wishing"`
	ClientIP    string   `xml:"client_ip"`
	ActName     string   `xml:"act_name"`
	Remark      string   `xml:"remark"`
	SceneID     string   `xml:"scene_id"`
	RiskInfo    string   `xml:"risk_info"`
}

SendRedPackRequest 发红包

func NewSendRedPackRequest

func NewSendRedPackRequest() *SendRedPackRequest

NewSendRedPackRequest 创建现金红包

func (*SendRedPackRequest) SignMD5

func (req *SendRedPackRequest) SignMD5(apiKey string) error

SignMD5 md5

type SendRedPackResponse

type SendRedPackResponse struct {
	ResponseStatus
	MchBillno   string `xml:"mch_billno"`
	MchID       string `xml:"mch_id"`
	WxAppID     string `xml:"wxappid"`
	ReOpenID    string `xml:"re_openid"`
	TotalAmount uint   `xml:"total_amount"`
	SendListID  string `xml:"send_listid"`
}

SendRedPackResponse ...

type UnifiedOrderRequest

type UnifiedOrderRequest struct {
	XMLName        xml.Name `xml:"xml"`
	AppID          string   `xml:"appid"`
	MchID          string   `xml:"mch_id"`
	DeviceInfo     string   `xml:"device_info"`
	NonceStr       string   `xml:"nonce_str"`
	Sign           string   `xml:"sign"`
	SignType       string   `xml:"sign_type"`
	Body           string   `xml:"body"`
	Detail         CDATA    `xml:"detail"`
	Attach         string   `xml:"attach"`
	OutTradeNo     string   `xml:"out_trade_no"`
	FeeType        string   `xml:"fee_type"`
	TotalFee       uint64   `xml:"total_fee"`
	SpbillCreateIP string   `xml:"spbill_create_ip"`
	TimeStart      string   `xml:"time_start"`
	TimeExpire     string   `xml:"time_expire"`
	GoodsTag       string   `xml:"goods_tag"`
	NotifyURL      string   `xml:"notify_url"`
	TradeType      string   `xml:"trade_type"`
	ProductID      string   `xml:"product_id"`
	LimitPay       string   `xml:"limit_pay"`
	OpenID         string   `xml:"openid"`
	Receipt        string   `xml:"receipt"`
	SceneInfo      string   `xml:"scene_info"`
}

UnifiedOrderRequest 统一支付

func NewUnifiedOrderRequest

func NewUnifiedOrderRequest() *UnifiedOrderRequest

NewUnifiedOrderRequest 创建统一支付

func (*UnifiedOrderRequest) SignHMACSHA256

func (req *UnifiedOrderRequest) SignHMACSHA256(key []byte, apiKey string) error

SignHMACSHA256 HMACS-HA256

func (*UnifiedOrderRequest) SignMD5

func (req *UnifiedOrderRequest) SignMD5(apiKey string) error

SignMD5 md5

type UnifiedOrderResponse

type UnifiedOrderResponse struct {
	ResponseStatus
	TradeType string `xml:"trade_type"`
	PrepayID  string `xml:"prepay_id"`
	CodeURL   string `xml:"code_url"`
}

UnifiedOrderResponse ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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