wx-go

command module
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

README

wx-go - 微信开发 Golang SDK(开发工具包)

travis-image License

本项目从 WxJava 转化而来。

支持包括微信支付、公众号、小程序等微信功能的后端开发。

使用方式

注意:最新版本(包括测试版)为 GitHub release

go get -u github.com/cliod/wx-go
  • 微信小程序:ma
  • 微信支付:pay
  • 公众号(包括订阅号和服务号):mp

使用Demo

公众号使用例子

conf := mp.NewWxMpConfig("<appId>", "<secret>")
service := mp.NewWxMpService(conf)

da, err := service.CreateJsapiSignature("https://www.xxx.com")
if err == nil {
    // todo ...
} else {
    fmt.Println(err.Error())
}

小程序使用例子

conf := mp.NewWxMaConfig("<appId>", "<secret>")
service := ma.NewWxMaService(conf)

uc := service.GetWxMaUserService()

res, err := uc.GetSessionInfo("<js_code>")
if err == nil {
    // todo ...
} else {
    fmt.Println(err.Error())
}

微信支付使用例子

conf := mp.NewWxPayV2Config("<appId>", "<secret>", "<mchId>", "mchKey", "<notifyUrl>", "keyPath")
service := ma.NewWxPayService(conf)

res, err := service.UnifyPay(&pay.WxPayUnifiedOrderRequest{
    TotalFee:   100,
    Openid:     c.Openid,
    OutTradeNo: s,
    Body:       "测试数据",
})
if err != nil {
    fmt.Println(err.Error())
} else {
    // todo...
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
微信小程序接口
微信小程序接口
微信公众号接口
微信公众号接口

Jump to

Keyboard shortcuts

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