Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aimuz/wechat-sdk
微信登录支付sdk,支持小程序,APP登录,正在重构。全新版本: https://github.com/aimuz/wgo
https://github.com/aimuz/wechat-sdk
golang wechat wechat-pay wechat-sdk weixin weixin-sdk
Last synced: 1 day ago
JSON representation
微信登录支付sdk,支持小程序,APP登录,正在重构。全新版本: https://github.com/aimuz/wgo
- Host: GitHub
- URL: https://github.com/aimuz/wechat-sdk
- Owner: aimuz
- License: apache-2.0
- Created: 2018-02-28T09:10:37.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-01-24T08:45:51.000Z (almost 5 years ago)
- Last Synced: 2024-06-20T17:53:12.804Z (5 months ago)
- Topics: golang, wechat, wechat-pay, wechat-sdk, weixin, weixin-sdk
- Language: Go
- Homepage:
- Size: 56.6 KB
- Stars: 78
- Watchers: 7
- Forks: 26
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# wechat-sdk
[![Go Report Card](https://goreportcard.com/badge/github.com/aimuz/wechat-sdk)](https://goreportcard.com/report/github.com/aimuz/wechat-sdk)
[![Build Status](https://travis-ci.org/aimuz/wechat-sdk.svg?branch=master)](https://travis-ci.org/aimuz/wechat-sdk)最全最好用的微信SDK,支持APP,小程序,H5,Web登录支付,企业付款等功能
## 快速开始
以下是APP和小程序支付简单例子
```go
import "github.com/aimuz/wechat-sdk/pay"wePay := &WePay{
AppId: "xxx",
MchId: "xxx",
PayKey: "xxx",
NotifyUrl: "xxx",
TradeType: "xxx", // APP支付填写`APP`,小程序支付填写`JSAPI`
Body: "xxx",
}# APP支付
results, outTradeNo, err := wePay.AppPay(100) // 金额,以分为单位# 小程序支付
results, outTradeNo, err := wePay.WaxPay(100, "open_id") // 金额,以分为单位;open_id为获取的用户的open_id
```## 使用
### 小程序支付通知
```go
waxNotify := pay.WaxPayNotifyReq{}
ctx.ReadXML(&waxNotify)
verifyParams := pay.WaxVerifyParams(waxNotify)
valid := pay.WaxpayVerifySign(verifyParams, appKey, waxNotify.Sign) //appKey 为自己在微信支付后台设置的API密钥resp := new(pay.WaxPayNotifyResp)
if valid {
// 业务处理逻辑···
resp.ReturnCode = "SUCCESS"
resp.ReturnMsg = "OK"
} else {
// 错误处理逻辑···
resp.ReturnCode = "FAIL"
resp.ReturnMsg = "Verify Failed"
}
```### 发送普通红包
```go
wx := &WePay{
AppID: "xx",
PayKey: "xx",
MchID: "xx",
TradeType: "xx",
CertFile: "xx", // 证书路径
keyFile: "xx", // 证书秘钥路径
RootCaFile: "xx", // 根证书路径
}billNO, redPackResp, err := wx.SendRedPack(totalAmount, openID, sendName, wishing, actName, remark)
```
#### APP支付
##### APP简单使用
## 讨论
[issues](https://github.com/aimuz/wechat-sdk/issues)
[论坛](https://kezhan.io/t/aimuz.wechat-sdk)
## 支持功能
- [x] APP支付
- [x] APP登录
- [x] H5登录
- [x] 小程序登录
- [x] 小程序支付
- [ ] Web登录
- [ ] 公众号支付
- [ ] 扫码支付
- [ ] 刷卡支付
- [ ] 企业付款
- [x] 现金红包
- [x] 发送红包
- [ ] 裂变红包