payment gateway for rpn cn
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.1KB

  1. package main
  2. import (
  3. "fmt"
  4. "net/http"
  5. "os"
  6. "text/template"
  7. )
  8. func StartPay(w http.ResponseWriter, r *http.Request) {
  9. if r.Method != "POST" {
  10. fmt.Fprintf(w, "invalid request")
  11. return
  12. }
  13. r.ParseForm()
  14. db.addRequest(r)
  15. if !isLeanworkFormValid(r.Form) {
  16. fmt.Fprintf(w, "invalid request")
  17. return
  18. }
  19. for key, value := range r.Form {
  20. fmt.Printf("%s= %s\n", key, value)
  21. //fmt.Fprintf(w, "%s= %s\n", key, value)
  22. }
  23. sign := md5LeanworkForm(r.Form)
  24. fmt.Printf("my md5=%s, valid = %t", sign, isLeanworkFormValid(r.Form))
  25. askForPaymentInfo(w, r)
  26. return
  27. // m := RpnReq{}
  28. // resp, err := m.SendReq(r.Form)
  29. // if err != nil {
  30. // fmt.Fprintf(w, "invalid response from RPN")
  31. // }
  32. // w.Header().Set("Content-Type", resp.Header.Get("Content-Type"))
  33. // w.Header().Set("Content-Length", resp.Header.Get("Content-Length"))
  34. // io.Copy(w, resp.Body)
  35. //fmt.Fprintf(w, "my md5=%s", sign)
  36. }
  37. func askForPaymentInfo(w http.ResponseWriter, r *http.Request) {
  38. t := template.Must(template.New("askForPaymentInfo").ParseGlob("form/*.tmpl"))
  39. t.ExecuteTemplate(os.Stdout, "rpnAskNameAndCard", r.Form)
  40. t.ExecuteTemplate(w, "rpnAskNameAndCard", r.Form)
  41. }