|
- package main
-
- import (
- "fmt"
- "net/http"
- "os"
- "text/template"
- )
-
- func StartPay(w http.ResponseWriter, r *http.Request) {
- if r.Method != "POST" {
- fmt.Fprintf(w, "invalid request")
- return
- }
- r.ParseForm()
- db.addRequest(r)
- if !isLeanworkFormValid(r.Form) {
- fmt.Fprintf(w, "invalid request")
- return
- }
-
- for key, value := range r.Form {
- fmt.Printf("%s= %s\n", key, value)
- //fmt.Fprintf(w, "%s= %s\n", key, value)
- }
- sign := md5LeanworkForm(r.Form)
- fmt.Printf("my md5=%s, valid = %t", sign, isLeanworkFormValid(r.Form))
-
- askForPaymentInfo(w, r)
- return
-
- // m := RpnReq{}
- // resp, err := m.SendReq(r.Form)
- // if err != nil {
- // fmt.Fprintf(w, "invalid response from RPN")
- // }
-
- // w.Header().Set("Content-Type", resp.Header.Get("Content-Type"))
- // w.Header().Set("Content-Length", resp.Header.Get("Content-Length"))
- // io.Copy(w, resp.Body)
-
- //fmt.Fprintf(w, "my md5=%s", sign)
-
- }
-
- 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)
- }
|