payment gateway for rpn cn
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

52 lignes
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. }