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.

71 lignes
1.6KB

  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 MD5LeanworkFormP2P(form url.Values) string {
  14. return md5LeanworkForm(form, Config.LeanWork.MD5P2P)
  15. }
  16. func MD5LeanworkFormFAT(form url.Values) string {
  17. return md5LeanworkForm(form, Config.LeanWork.MD5FAT)
  18. }
  19. func md5LeanworkForm(form url.Values, key string) string {
  20. s := ""
  21. if _, ok := form["pickupUrl"]; ok {
  22. s += form["pickupUrl"][0]
  23. s += form["receiveUrl"][0]
  24. s += form["signType"][0]
  25. s += form["orderNo"][0]
  26. s += form["orderAmount"][0]
  27. s += form["orderCurrency"][0]
  28. s += form["customerId"][0]
  29. s += key
  30. }
  31. //fmt.Println("leanwork form: " + s)
  32. return md5str(s)
  33. }
  34. func isLeanworkFormValid(form url.Values, md5key string) bool {
  35. r := md5LeanworkForm(form, md5key)
  36. sign := form["sign"][0]
  37. return r == sign
  38. }
  39. func md5RpnFormP2P(r RpnOut) string {
  40. return md5RpnForm(r, Config.Rpn.MD5P2P)
  41. }
  42. func md5RpnFormFAT(r RpnOut) string {
  43. return md5RpnForm(r, Config.Rpn.MD5FAT)
  44. }
  45. func md5RpnForm(r RpnOut, md5key string) string {
  46. s := ""
  47. s += "version=" + r.Version + "|"
  48. s += "sign_type=" + r.Sign_type + "|"
  49. s += "mid=" + r.Mid + "|"
  50. s += "notify_url=" + r.Notify_url + "|"
  51. s += "order_id=" + r.Order_id + "|"
  52. s += "order_amount=" + r.Order_amount + "|"
  53. s += "order_time=" + r.Order_time + "|"
  54. s += "user_id=" + r.User_id + "|"
  55. s += "user_name=" + r.User_name + "|"
  56. s += "user_cardno=" + r.User_cardno + "|"
  57. s += "key=" + md5key
  58. // fmt.Println(s)
  59. // fmt.Println(md5str(s))
  60. return md5str(s)
  61. }