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.

rpn.go 1.6KB

il y a 5 ans
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package main
  2. import (
  3. "fmt"
  4. "log"
  5. "net/http"
  6. )
  7. func rpnNotify(w http.ResponseWriter, r *http.Request) {
  8. if r.Method != "POST" {
  9. errPage(w, http.StatusMethodNotAllowed, "invalid request")
  10. return
  11. }
  12. ri, err := GetRpnInFromHTTPRequest(r) //ParseForm called
  13. if err != nil {
  14. errPage(w, http.StatusBadRequest, "invalid parameters")
  15. return
  16. }
  17. ro, _ := getRpnOutByOrderId(ri.Order_id)
  18. ri.Leanwork = ro.Leanwork
  19. _, err = ri.add2db() //TODO:check error add
  20. if err != nil {
  21. log.Printf("failed to add rpnIn %+v , error is %s", ri, err.Error())
  22. }
  23. fmt.Fprintf(w, "[SUCCESS]")
  24. return
  25. }
  26. //receive RPN user name and card number
  27. func rpnNameAndCard(w http.ResponseWriter, r *http.Request) {
  28. if r.Method != "POST" {
  29. errPage(w, http.StatusMethodNotAllowed, "invalid request")
  30. return
  31. }
  32. r.ParseForm()
  33. id := r.FormValue("id")
  34. sign := r.FormValue("sign")
  35. user_name := r.FormValue("name")
  36. user_card := r.FormValue("card")
  37. rpn_type := r.FormValue("rpnType")
  38. if !(id != "" && sign != "" && user_name != "" && user_card != "") {
  39. errPage(w, http.StatusBadRequest, "missing parameters")
  40. return
  41. }
  42. row, err := getRequestRowByIdAndSign(id, sign)
  43. if err != nil {
  44. w.WriteHeader(http.StatusBadRequest)
  45. fmt.Fprintf(w, "bad parameters")
  46. return
  47. }
  48. ro := RpnOut{}
  49. ro.Ip4 = getClientIPLong(r)
  50. ro.Leanwork = row.Id
  51. if rpn_type == "rpnp2p" {
  52. ro.buildReqByLeanworkINP2P(row, user_name, user_card)
  53. } else {
  54. ro.buildReqByLeanworkINFAT(row, user_name, user_card)
  55. }
  56. //create db record
  57. db.addRpnOut(ro)
  58. //build rpn redirect page and send it
  59. ro.sendRedirect(w, row)
  60. }