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.

53 lignes
1.2KB

  1. package main
  2. import (
  3. "crypto/md5"
  4. "fmt"
  5. "io"
  6. "net/url"
  7. )
  8. func md5str(s string) string {
  9. h := md5.New()
  10. io.WriteString(h, s)
  11. return fmt.Sprintf("%x", h.Sum(nil))
  12. }
  13. func md5LeanworkForm(form url.Values) string {
  14. s := ""
  15. if _, ok := form["pickupUrl"]; ok {
  16. s += form["pickupUrl"][0]
  17. s += form["receiveUrl"][0]
  18. s += form["signType"][0]
  19. s += form["orderNo"][0]
  20. s += form["orderAmount"][0]
  21. s += form["orderCurrency"][0]
  22. s += form["customerId"][0]
  23. s += md5key
  24. }
  25. return md5str(s)
  26. }
  27. func isLeanworkFormValid(form url.Values) bool {
  28. r := md5LeanworkForm(form)
  29. sign := form["sign"][0]
  30. return r == sign
  31. }
  32. func md5RpnForm(form url.Values) string {
  33. s := ""
  34. if _, ok := form["version"]; ok {
  35. s += "sign_type=" + form["sign_type"][0] + "|"
  36. s += "mid=" + form["mid"][0] + "|"
  37. s += "notify_url=" + form["notify_url"][0] + "|"
  38. s += "order_id=" + form["order_id"][0] + "|"
  39. s += "order_amount=" + form["order_amount"][0] + "|"
  40. s += "order_time=" + form["order_time"][0] + "|"
  41. s += "user_id=" + form["user_id"][0] + "|"
  42. s += "user_name=" + form["user_name"][0] + "|"
  43. s += "user_cardno=" + form["user_cardno"][0] + "|"
  44. s += "key=" + md5key
  45. }
  46. return md5str(s)
  47. }