10

Go语言实现微信后端接口(支付、公众号、小程序)

 3 years ago
source link: https://studygolang.com/articles/32375
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Go语言实现微信后端接口(支付、公众号、小程序)

mb5fe5608dce902 · 大约23小时之前 · 122 次点击 · 预计阅读时间 2 分钟 · 不到1分钟之前 开始浏览    

图片

这是用Golang封装了微信支付的所有API接口的SDK,并自动生成和解析XML数据,还包括部分服务号、小程序、移动端的工具函数。
  • 支持境内普通商户和境内服务商(境外和银行服务商没有条件测试)。
  • 支持全局配置应用ID、商家ID等信息。
  • 全部参数和返回值均使用struct类型传递,而不是map类型。
  • 包含公众号网页授权码的相关操作。
  • 包含H5、小程序、移动端的支付签名生成方法。
下面是通用的接口,使用上面初始化时生成的实例client进行相应函数的调用:提交付款码支付:func (*Client) Micropay(MicropayBody) (MicropayResponse, error)统一下单:func (*Client) UnifiedOrder(UnifiedOrderBody) (UnifiedOrderResponse, error)查询订单:func (*Client) QueryOrder(QueryOrderBody) (QueryOrderResponse, error)关闭订单:func (*Client) CloseOrder(CloseOrderBody) (CloseOrderResponse, error)撤销订单:func (*Client) Reverse(ReverseBody) (ReverseResponse, error)申请退款:func (*Client) Refund(RefundBody) (RefundResponse, error)查询退款:func (*Client) QueryRefund(QueryRefundBody) (QueryRefundResponse, error)下载对账单:func (*Client) DownloadBill(DownloadBillBody) (string, *DownloadBillResponse, error)交易保障(JSAPI):func (*Client) ReportJsApi(ReportJsApiBody) (ReportJsApiResponse, error)交易保障(MICROPAY):func (*Client) ReportMicropay(ReportMicropayBody) (ReportMicropayResponse, error)下载资金账单:TODO,client.DownloadFundFlow()拉取订单评价数据:TODO,client.BatchQueryComment()企业付款到零钱:func (*Client) Change(ChangeBody) (ChangeResponse, error)授权码查询OpenId:func (*Client) OpenIdByAuthCode(OpenIdByAuthCodeBody) (OpenIdByAuthCodeResponse, error)获取AccessToken:func GetAccessToken(appId string, appSecret string) (AccessToken, error)获取用户基本信息(UnionId机制):func GetUserInfo(accessToken string, openId string, lang ...string) (UserInfo, error)获取小程序支付签名:func GetMiniPaySign(appId, nonceStr, prepayId, signType, timeStamp, apiKey string) (string)获取H5支付签名:func GetH5PaySign(appId, nonceStr, packages, signType, timeStamp, apiKey string) (string)获取APP支付签名:func GetAppPaySign(appId, nonceStr, partnerId, prepayId, signType, timeStamp, apiKey string) (string)其中带有(*Client)字样的接口,需要使用wechat.NewClient创建的实例对象来调用,而不带的接口,则可以直接使用wechat.XXX调用。

图片

源码下载地址,复制下载即可

https://gitee.com/cuckoopark/wechat.git

图片

(公众号)

图片

写作说明】以上内容分享给喜欢编程,有梦想的程序员,希望能帮助到你们。以上文章属于此公众号原创所有,如需转载请注明出处。

免责申明】本公众平台不是广告商,也没有为其他三方网站或者个人做广告宣传。此分享的源代码和文章是小编在项目中、学习中整理的一些认为不错的项目。用户产生的一些自愿下载或者付费行为。与平台没有直接关系

投稿邮箱[email protected]

 欢迎投稿分享你的优质源码或文章


有疑问加站长微信联系(非本文作者)

280

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:1006366459


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK