Coder Social home page Coder Social logo

gowe's Introduction

介绍

golang 多微信号SDK,readygo子项目 API文档

感谢 https://gitee.com/xiaochengtech/wechat 提供的基础代码

go get gitee.com/chunanyong/gowe 
  • 支持境内普通商户和境内服务商(境外和银行服务商没有条件测试)
  • 全部参数和返回值均使用struct类型传递
  • 缓存前置,使用项目现有的缓存体系
  • 原生支持多微信号
  • 支持跳板请求微信API服务.例如内网服务器没有网络出口权限,可以使用Nginx跳板请求微信API服务
  • 原生支持集群部署

初始化

type WxConfig struct {
	Id     string
	AppId  string
	Secret string
}

var wxConfig = &WxConfig{
	Id:     "test",
	AppId:  "XXXXXXXXXXXXXXxxx",
	Secret: "XXXXXXXXXXXXXXX",
}

func (wxConfig *WxConfig) GetId() string {
	return wxConfig.Id
}

func (wxConfig *WxConfig) GetAppId() string {
	return wxConfig.AppId
}

func (wxConfig *WxConfig) GetAccessToken() string {
	//从缓存中获取wxAccessToken,这里只是演示
	wxAccessToken, err := gowe.GetAccessToken(wxConfig)
	if err == nil && wxAccessToken.ErrCode == 0 {
		return wxAccessToken.AccessToken
	}
	return ""
}

func (wxConfig *WxConfig) GetSecret() string {
	return wxConfig.Secret
}

使用

以下是通用的接口,WxConfig 设置为全局变量,使用gowe.XXX调用

使用样例:

func TestGetAccessToken(t *testing.T)  {
	token, err := gowe.GetAccessToken(wx)
	if err != nil {
		t.Log("error:" ,err)
	}
	t.Log("token:",token)
}

微信支付

  • 提交付款码支付 WxPayMicropay
  • 统一下单:WxPayUnifiedOrder
  • 查询订单:WxPayQueryOrder
  • 关闭订单:WxPayCloseOrder
  • 撤销订单:WxPayReverse
  • 申请退款:WxPayRefund
  • 查询退款:WxPayQueryRefund
  • 下载对账单:WxPayDownloadBill
  • 交易保障(JSAPI):WxPayReportJsApi
  • 交易保障(MICROPAY):WxPayReportMicropay

微信红包

  • 发送现金红包 WxPaySendRedPack
  • 发送裂变红包 WxPaySendGroupRedPack
  • 发送小程序红包 WxPaySendMiniProgramHB
  • 查询红包记录 WxPayGetHBInfo

企业付款

  • 企业付款到零钱 WxPayPromotionMktTransfers
  • 查询企业付款 WxPayQueryMktTransfer

微信支付回调

  • 支付回调:WxPayNotifyPay
  • 退款回调:WxPayNotifyRefund

微信公众号

  • 获取基础支持的AccessToken:WxMpWebAuthAccessToken
  • 获取用户基本信息(UnionId机制):WxMpGetUserInfo
  • 获取H5支付签名:WxPayH5Sign
  • 临时二维码:WxMpQrCreateTemporary
  • 永久二维码:WxMpQrCreatePermanent
  • 发送模板消息:WxMpTemplateMsgSend
  • 发送订阅消息: WxMpSubscribeMsgSend

微信小程序

  • 获取小程序支付签名:WxPayMaSign
  • 获取小程序码:WxMaCodeGetUnlimited
  • 发送订阅消息:WxMaSubscribeMessageSend

文档

gowe's People

Contributors

springrain avatar light2001 avatar chinalixs avatar

Stargazers

 avatar brian avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.