支付模块
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

80 行
2.6 KiB

  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. }