ソースを参照

ask payment info now contains rpn type.

tags/v0.5
patrick 5年前
コミット
65b26c5c5e
1個のファイルの変更34行の追加6行の削除
  1. +34
    -6
      purchase.go

+ 34
- 6
purchase.go ファイルの表示

import ( import (
"fmt" "fmt"
"net/http" "net/http"
"os"
"text/template"
) )


func StartPay(w http.ResponseWriter, r *http.Request) { func StartPay(w http.ResponseWriter, r *http.Request) {
tmpl.ExecuteTemplate(w, "StartPay", row) tmpl.ExecuteTemplate(w, "StartPay", row)
} }


func askForPaymentInfo(w http.ResponseWriter, r *http.Request) {
t := template.Must(template.New("askForPaymentInfo").ParseGlob("form/*.tmpl"))
t.ExecuteTemplate(os.Stdout, "rpnAskNameAndCard", r.Form)
t.ExecuteTemplate(w, "rpnAskNameAndCard", r.Form)
func askForPaymentInfo(w http.ResponseWriter, row LeanworkRequest, rpn_type string) {
var data struct {
Id int64
Sign string
RpnType string
}
data.Id = row.Id
data.Sign = row.Sign
data.RpnType = rpn_type
tmpl.ExecuteTemplate(w, "rpnAskNameAndCard", data)
}

func choosePayment(w http.ResponseWriter, r *http.Request) {
//get inform from form .
r.ParseForm()
id := r.FormValue("id")
sign := r.FormValue("sign")
rpn_type := r.FormValue("rpnType")

if id == "" || sign == "" {
w.WriteHeader(http.StatusMethodNotAllowed)
fmt.Fprintf(w, "invalid parameters")
return
}

row, err := getRequestRowByIdAndSign(id, sign)

if err != nil {
w.WriteHeader(http.StatusBadRequest)
fmt.Fprintf(w, "invalid signature")
return
}
//show redirect, and start payment
askForPaymentInfo(w, row, rpn_type)
} }

読み込み中…
キャンセル
保存