1 Star 0 Fork 138

miracle_yao / go支付合集

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

golang支付合集(包括微信支付,支付宝,后期会加入聚合支付)

  • golang支付库 想必gopher们都会抱怨go成熟的包太少,特别是go语言支付这块,网上的代码基本没有能用的,要么不全,要么有硬伤,所以结合网上和自己经验,抽出时间写的一部分代码,封装下分享出来,希望能给大家一点借鉴意义。

  • 支持的支付方式 目前支持微信app,支付宝网页版,支付宝app。要是谁有新的支付方式也可以合并。

  • 项目开源协议:MIT

  • github地址:https://github.com/shirdonliao/pays_with_go

  • 使用方法

  • #####1. git clone https://gitee.com/shirdonl/pays_with_go.git 或者 go get gitee.com/shirdonl/pays_with_go

  • #####2. 在自己的项目里调用,示例代码如下,确保填入自己的配置参数,开发中有问题欢迎留言或者关注公众号:codebigdata

package main

import (
    "fmt"
    "gitee.com/shirdonl/pays_with_go"
	"gitee.com/shirdonl/pays_with_go/client"
	"gitee.com/shirdonl/pays_with_go/common"
	"gitee.com/shirdonl/pays_with_go/constant"
	"net/http"
)
func main() {
	//设置支付宝账号信息
	initClient()
	//设置回调函数
	initHandle()

	//支付
	charge := new(common.Charge)
	charge.PayMethod = constant.ALI_APP                              //支付方式
	charge.MoneyFee = 1                                   // 支付钱单位分
	charge.Describe = "测试订单"                                    //支付描述
	charge.TradeNum = "88888888"                                  //交易号
	charge.CallbackURL = "http://127.0.0.1/callback/aliappcallback" //回调地址必须跟下面一样
    //导入包
	fdata, err := pays_with_go.Pay(charge)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(fdata)
}

//
func initClient() {
	client.InitAliAppClient(&client.AliAppClient{
		PartnerID:  "xxx",
		SellerID:   "xxxx",
		AppID:      "xxx",
		PrivateKey: nil,
		PublicKey:  nil,
	})
}


func initHandle() {
	http.HandleFunc("callback/aliappcallback", func(w http.ResponseWriter, r *http.Request) {
		//返回支付结果
		aliResult, err := pays_with_go.AliAppCallback(w, r)
		if err != nil {
			fmt.Println(err)
			//log.xxx
			return
		}
		//接下来处理自己的逻辑
		fmt.Println(aliResult)
	})
}
MIT License =========== Copyright (c) 2018, Shirdon Liao Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

golang支付库开源啦,亲测有效!欢迎star!~欢迎大家一起共享!~打造顶级优质golang支付合集~ 展开 收起
Go
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Go
1
https://gitee.com/miracle_yao_admin/pays_with_go.git
git@gitee.com:miracle_yao_admin/pays_with_go.git
miracle_yao_admin
pays_with_go
go支付合集
master

搜索帮助

14c37bed 8189591 565d56ea 8189591