forked from ixre/go2o
-
Notifications
You must be signed in to change notification settings - Fork 0
/
payment_c.go
45 lines (38 loc) · 944 Bytes
/
payment_c.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* Copyright 2014 @ z3q.net.
* name :
* author : jarryliu
* date : 2014-02-11 21:33
* description :
* history :
*/
package ols
import (
"github.com/jsix/gof/web"
"go2o/src/core/infrastructure/alipay"
)
type paymentC struct {
}
func (this *paymentC) Create(ctx *web.Context) {
r, w := ctx.Request, ctx.Response
qs := r.URL.Query()
orderNo := qs.Get("order_no")
paymentOpt := qs.Get("pay_opt")
if len(orderNo) != 0 {
if paymentOpt == "alipay" {
html := "<html><body>" + alipay.CreatePaymentGateWay(orderNo, 0.01, "订单"+orderNo, "", "", "") + "</body></html>"
w.Write([]byte(html))
return
}
}
w.Write([]byte("订单不存在"))
}
func (this *paymentC) Return(ctx *web.Context) {
r, _ := ctx.Request, ctx.Response
alipay.ReturnFunc(r, nil)
ctx.Response.Write([]byte("支付完成"))
}
func (this *paymentC) Notify_post(ctx *web.Context) {
r, _ := ctx.Request, ctx.Response
alipay.NotifyFunc(r, nil)
}