Golang 实现的聚合支付 allpay
- 授权协议: GPL
- 开发语言: Google Go
- 操作系统: 跨平台
- 软件首页: https://github.com/runthinker/allpay
- 软件文档: https://github.com/runthinker/allpay
- 官方下载: https://github.com/runthinker/allpay
软件介绍
Golang实现的聚合支付,含微信支付和支付宝
特点
1、代码简单、灵活可靠。
2、可扩展性强:参数传递采用map[string]interface{},不需要定义复杂的结构,满足多变的参数需求。
3、支持服务商模式和非服务商模式。第三方包引用
1、httprouter
2、gorm微信支付调用:
func TestWxClient_Execute(t *testing.T) { cli := NewWxClient("你的apikey",true) cli.FillDefaultParams() cli.PutMapParams(map[string]string{ "appid": "您的appid", "mch_id": "您的商户号", }) cli.PutParam("body","test") cli.PutParam("out_trade_no","58867657575757") cli.PutParam("sub_mch_id","您好的子商户号") cli.PutParam("total_fee","101") cli.PutParam("spbill_create_ip","127.0.0.1") cli.PutParam("notify_url","http://test.xxx.com/notify") cli.PutParam("trade_type","JSAPI") resp,err := cli.Execute("unifiedorder") if err != nil { t.Log(err.Error()) return } t.Log(resp) }
支付宝调用:
func doWapPay() []byte { cli := NewaliClient(con_privatekey,con_pubickey,"https://openapi.alipaydev.com/gateway.do") cli.FillDefaultParams() cli.PutMapSysParams(map[string]string{ "app_id": "您的app_id", "notify_url": "http://test.xxx.com/notify", }) cli.PutMapAppParams(map[string]string{ "subject": "测试", "out_trade_no": "2000100001", "seller_id": "商户号", }) cli.PutAppAnyParams("total_amount",1.00) cli.PutAppAnyParams("extend_params",map[string]string{ "sys_service_provider_id": "服务商id", }) resp,err := cli.PageExecute("alipay.trade.wap.pay") if err != nil { return []byte("") } return resp } func TestAliClient_Execute(t *testing.T) { h := httprouter.New() h.GET("/api/wap", func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { body := doWapPay() w.Header().Set("Content-Type", "text/html; charset=utf-8") //WriteHeader一定放在Set后面 w.WriteHeader(http.StatusOK) w.Write(body) }) http.ListenAndServe("localhost:3000",h) }
聚合支付网页调用(javascript)
function callpay(method) { let domain = location.href; let urlobj = { method: method, mid: "100000", subject: "测试商品", total_amount: "101", out_trade_no: new Date().Format("yyMMddhhmmss"), return_url: domain + "result.html?method=" + method, } let url = "" for(let k in urlobj) { if(url == "") { url = "?" + k + "=" + encodeURI(urlobj[k]) } else { url += "&" + k + "=" + encodeURI(urlobj[k]) } } let openurl = domain + "payapi/wappay/sandbox" + url; if(method === "Ali.wappay"){ _AP.pay(openurl); }else { location.href = openurl; } }
使用到的数据库结构:
/*==============================================================*/ /* Table: ap_mchpay_options */ /*==============================================================*/ create table ap_mchpay_options ( mid bigint not null, paytype tinyint not null, attrname varchar(64) not null, attrvalue varchar(128) not null, primary key (mid, paytype) ); /*==============================================================*/ /* Table: ap_merchant_info */ /*==============================================================*/ create table ap_merchant_info ( mid bigint not null auto_increment, name varchar(128) not null, isdebug bool not null, apikey varchar(128) not null, parentid bigint not null default -1, mchclass int not null default 0, primary key (mid) ) auto_increment = 100000;
Java从入门到精通
李钟尉、马文强、陈丹丹 / 清华大学出版社 / 2008-9 / 59.80元
《Java从入门到精通》(软件开发视频大讲堂)从初学者角度出发,通过通俗易懂的语言、丰富多彩的实例,详细介绍了使用Java语言进行程序开发应该掌握的各方面技术。全书共分28章,包括:初识Java,熟悉Eclipse开发工具,Java语言基础,流程控制,字符串,数组,类和对象,包装类,数字处理类,接口、继承与多态,类的高级特性,异常处理,Swing程序设计,集合类,I/O输入输出,反射,枚举类型与泛......一起来看看 《Java从入门到精通》 这本书的介绍吧!