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.

57 lignes
1.3KB

  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. w.WriteHeader(http.StatusMethodNotAllowed)
  11. fmt.Fprintf(w, "invalid method")
  12. return
  13. }
  14. r.ParseForm()
  15. row, err := db.addRequest(r)
  16. if err != nil {
  17. w.WriteHeader(http.StatusInternalServerError)
  18. w.Write([]byte("Cannot initiate database transaction"))
  19. return
  20. }
  21. if !isLeanworkFormValid(r.Form) {
  22. w.WriteHeader(http.StatusMethodNotAllowed)
  23. fmt.Fprintf(w, "invalid request")
  24. return
  25. }
  26. askForPaymentSelection(w, row)
  27. return
  28. // m := RpnReq{}
  29. // resp, err := m.SendReq(r.Form)
  30. // if err != nil {
  31. // fmt.Fprintf(w, "invalid response from RPN")
  32. // }
  33. // w.Header().Set("Content-Type", resp.Header.Get("Content-Type"))
  34. // w.Header().Set("Content-Length", resp.Header.Get("Content-Length"))
  35. // io.Copy(w, resp.Body)
  36. //fmt.Fprintf(w, "my md5=%s", sign)
  37. }
  38. func askForPaymentSelection(w http.ResponseWriter, row LeanworkRequest) {
  39. tmpl.ExecuteTemplate(w, "StartPay", row)
  40. }
  41. func askForPaymentInfo(w http.ResponseWriter, r *http.Request) {
  42. t := template.Must(template.New("askForPaymentInfo").ParseGlob("form/*.tmpl"))
  43. t.ExecuteTemplate(os.Stdout, "rpnAskNameAndCard", r.Form)
  44. t.ExecuteTemplate(w, "rpnAskNameAndCard", r.Form)
  45. }