wechat

package
v0.0.0-...-1dec894 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Code2Session

func Code2Session(code string) (openID, sessionKey, unionID string, err error)

Code2Session 获取用户session信息

func GetAccessToken

func GetAccessToken() (string, error)

GetAccessToken 获取access_token

func GetMiniProgram

func GetMiniProgram() *miniprogram.MiniProgram

GetMiniProgram 获取小程序实例

func InitWeChat

func InitWeChat(cfg *config.WeChatConfig) error

InitWeChat 初始化微信SDK

func SendTemplateMessage

func SendTemplateMessage(msg *TemplateMessage) error

SendTemplateMessage 发送模板消息

Types

type PaymentNotifyData

type PaymentNotifyData struct {
	ReturnCode    string `xml:"return_code"`
	ReturnMsg     string `xml:"return_msg"`
	AppID         string `xml:"appid"`
	MchID         string `xml:"mch_id"`
	NonceStr      string `xml:"nonce_str"`
	Sign          string `xml:"sign"`
	ResultCode    string `xml:"result_code"`
	OpenID        string `xml:"openid"`
	TradeType     string `xml:"trade_type"`
	BankType      string `xml:"bank_type"`
	TotalFee      int    `xml:"total_fee"`
	CashFee       int    `xml:"cash_fee"`
	TransactionID string `xml:"transaction_id"`
	OutTradeNo    string `xml:"out_trade_no"`
	TimeEnd       string `xml:"time_end"`
}

PaymentNotifyData 支付回调数据

type RateLimitedSender

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

RateLimitedSender 限流发送器

func NewRateLimitedSender

func NewRateLimitedSender(ratePerSecond int) *RateLimitedSender

NewRateLimitedSender 创建限流发送器

func (*RateLimitedSender) Send

func (s *RateLimitedSender) Send(msg *TemplateMessage) error

Send 限流发送

func (*RateLimitedSender) Stop

func (s *RateLimitedSender) Stop()

Stop 停止限流器

type TemplateDataItem

type TemplateDataItem struct {
	Value string `json:"value"`
}

TemplateDataItem 模板消息数据项

type TemplateMessage

type TemplateMessage struct {
	ToUser           string                 `json:"touser"`
	TemplateID       string                 `json:"template_id"`
	Page             string                 `json:"page,omitempty"`
	Data             map[string]interface{} `json:"data"`
	MiniprogramState string                 `json:"miniprogram_state,omitempty"` // developer, trial, formal
}

TemplateMessage 模板消息

Jump to

Keyboard shortcuts

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