支付模块
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fb_pay_test.go 5.3 KiB

1 年之前
1 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. package test
  2. import (
  3. fb "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/fb_pay"
  4. zhios_pay_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/utils"
  5. "testing"
  6. "time"
  7. )
  8. func TestFBPayUnification(t *testing.T) {
  9. unification := fb.GetUnificationByVendorSn("2022120518415543840a")
  10. var ordCreat fb.OrderCreateParameters
  11. ordCreat.OrderCreateMustParameters.MerchantOrderSn = "202212061833-01"
  12. ordCreat.OrderCreateMustParameters.TotalAmount = 0.1
  13. ordCreat.OrderCreateMustParameters.PayType = "alipay"
  14. ordCreat.OrderCreateMustParameters.UserId = "userid"
  15. ordCreat.OrderCreateMustParameters.MerchantId = 1979251
  16. unification.Nonce = ordCreat.OrderCreateMustParameters.MerchantOrderSn + time.Now().Format("20060102150405")
  17. param := zhios_pay_utils.Struct2Map(ordCreat)
  18. for key, value := range param {
  19. if value == "" {
  20. delete(param, key)
  21. }
  22. }
  23. unification.SetBizContent(param)
  24. unification.SetSign("c5d47b9e515594313d80fb9903ece2d8")
  25. send, err := unification.Send(false)
  26. if err != nil {
  27. t.Error(err)
  28. }
  29. t.Logf("回调数据:%s\n", send)
  30. }
  31. func TestFBPayOrderQrcode(t *testing.T) {
  32. unification := fb.GetOrderQrcodeByVendorSn("2022120518415543840a")
  33. var orderQrcode fb.OrderQrcodeParameters
  34. orderQrcode.OrderQrcodeMustParameters.MerchantOrderSn = "20221208-02"
  35. orderQrcode.OrderQrcodeMustParameters.TotalAmount = 0.1
  36. orderQrcode.OrderQrcodeMustParameters.PayType = "alipay"
  37. orderQrcode.OrderQrcodeMustParameters.StoreId = 1331462
  38. unification.Nonce = orderQrcode.OrderQrcodeMustParameters.MerchantOrderSn + time.Now().Format("20060102150405")
  39. param := zhios_pay_utils.Struct2Map(orderQrcode)
  40. for key, value := range param {
  41. if value == "" {
  42. delete(param, key)
  43. }
  44. }
  45. unification.SetBizContent(param)
  46. unification.SetSign("c5d47b9e515594313d80fb9903ece2d8")
  47. send, err := unification.Send(false)
  48. if err != nil {
  49. t.Error(err)
  50. }
  51. t.Logf("回调数据:%s\n", send)
  52. }
  53. func TestFBPayOrderWxconfig(t *testing.T) {
  54. requestParameters := fb.GetRequestParametersByVendorSn("2022120518415543840a")
  55. requestParameters.Method = "fbpay.order.wxconfig"
  56. requestParameters.SignMethod = "md5"
  57. requestParameters.Nonce = time.Now().Format("20060102150405")
  58. param := make(map[string]interface{})
  59. param["merchant_id"] = 1979251
  60. param["store_id"] = 1331462
  61. param["sub_appid"] = "wx43207c79f84a14ca"
  62. param["account_type"] = "01"
  63. for key, value := range param {
  64. if value == "" {
  65. delete(param, key)
  66. }
  67. }
  68. requestParameters.SetBizContent(param)
  69. requestParameters.SetSign("c5d47b9e515594313d80fb9903ece2d8")
  70. send, err := requestParameters.Send(false)
  71. if err != nil {
  72. t.Error(err)
  73. }
  74. t.Logf("回调数据:%s\n", send)
  75. }
  76. func TestFBAccreditQuery(t *testing.T) {
  77. requestParameters := fb.GetRequestParametersByVendorSn("2022120518415543840a")
  78. requestParameters.Method = "openapi.share.accredit.query"
  79. requestParameters.SignMethod = "md5"
  80. requestParameters.Nonce = time.Now().Format("20060102150405")
  81. param := make(map[string]interface{})
  82. param["merchant_id"] = 1989190
  83. for key, value := range param {
  84. if value == "" {
  85. delete(param, key)
  86. }
  87. }
  88. requestParameters.SetBizContent(param)
  89. requestParameters.SetSign("c5d47b9e515594313d80fb9903ece2d8")
  90. send, err := requestParameters.Send(false)
  91. if err != nil {
  92. t.Error(err)
  93. }
  94. t.Logf("回调数据:%s\n", send)
  95. }
  96. func TestFBAccountOrderSwitch(t *testing.T) {
  97. requestParameters := fb.GetRequestParametersByVendorSn("2022120518415543840a")
  98. requestParameters.Method = "openapi.agent.account.order.switch"
  99. requestParameters.SignMethod = "md5"
  100. requestParameters.Nonce = time.Now().Format("20060102150405")
  101. param := make(map[string]interface{})
  102. param["merchant_id"] = 1989190
  103. param["state"] = 1
  104. param["share_percent"] = 60
  105. for key, value := range param {
  106. if value == "" {
  107. delete(param, key)
  108. }
  109. }
  110. requestParameters.SetBizContent(param)
  111. requestParameters.SetSign("c5d47b9e515594313d80fb9903ece2d8")
  112. send, err := requestParameters.Send(false)
  113. if err != nil {
  114. t.Error(err)
  115. }
  116. t.Logf("回调数据:%s\n", send)
  117. }
  118. func TestFBMerchantIncomeSuccess(t *testing.T) {
  119. requestParameters := fb.GetRequestParametersByVendorSn("2022120518415543840a")
  120. requestParameters.Method = "openapi.merchant.income.status.query"
  121. requestParameters.SignMethod = "md5"
  122. requestParameters.Nonce = time.Now().Format("20060102150405")
  123. param := make(map[string]interface{})
  124. param["merchant_code"] = "139334168531126"
  125. for key, value := range param {
  126. if value == "" {
  127. delete(param, key)
  128. }
  129. }
  130. requestParameters.SetBizContent(param)
  131. requestParameters.SetSign("c5d47b9e515594313d80fb9903ece2d8")
  132. send, err := requestParameters.Send(false)
  133. if err != nil {
  134. t.Error(err)
  135. }
  136. t.Logf("回调数据:%s\n", send)
  137. }
  138. func TestFBUrlSet(t *testing.T) {
  139. requestParameters := fb.GetRequestParametersByVendorSn("2022120518415543840a")
  140. requestParameters.Method = "fbpay.pay.callback.config"
  141. requestParameters.SignMethod = "md5"
  142. requestParameters.Nonce = time.Now().Format("20060102150405")
  143. param := make(map[string]interface{})
  144. param["second_callback_url"] = "http://api.zhiyingos.com/api/v1/comm/pay/fb/callback"
  145. for key, value := range param {
  146. if value == "" {
  147. delete(param, key)
  148. }
  149. }
  150. requestParameters.SetBizContent(param)
  151. requestParameters.SetSign("c5d47b9e515594313d80fb9903ece2d8")
  152. send, err := requestParameters.Send(false)
  153. if err != nil {
  154. t.Error(err)
  155. }
  156. t.Logf("回调数据:%s\n", send)
  157. }