支付模块
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.

88 lines
3.3 KiB

  1. package test
  2. import (
  3. "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/boc"
  4. "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/md"
  5. zhios_pay_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/utils"
  6. "fmt"
  7. "github.com/syyongx/php2go"
  8. "testing"
  9. "time"
  10. )
  11. func TestJoinStringsInASCII(t *testing.T) {
  12. ascii := zhios_pay_utils.JoinStringsInASCII(map[string]string{"apam": "value1", "cpam": "value2", "Bpam": "value3"},
  13. "", "", false, false)
  14. fmt.Println(ascii)
  15. }
  16. func TestBocSend(t *testing.T) {
  17. var createBocPayAppTradeReq md.CreateBocPayAppTradeReq
  18. //基础信息,必填
  19. createBocPayAppTradeReq.Version = boc.Version
  20. createBocPayAppTradeReq.Service = boc.CreateBocPayAppTrade
  21. createBocPayAppTradeReq.SignType = boc.SignType
  22. createBocPayAppTradeReq.MerchantId = boc.MerchantId
  23. createBocPayAppTradeReq.TerminalNo = boc.TerminalNo
  24. createBocPayAppTradeReq.RequestId = "2022101401" + zhios_pay_utils.AnyToString(time.Now().Unix())
  25. //按照接口类型选填信息
  26. createBocPayAppTradeReq.Amount = "100"
  27. createBocPayAppTradeReq.OriginalAmount = "100"
  28. createBocPayAppTradeReq.MercOrderNo = "2022101401"
  29. createBocPayAppTradeReq.OrderDate = "20221013"
  30. createBocPayAppTradeReq.OrderTime = "175600"
  31. createBocPayAppTradeReq.NotifyUrl = "/api/v1/mall/pay/ada/sub_callback"
  32. createBocPayAppTradeReq.Reserved1 = zhios_pay_utils.SerializeStr(map[string]string{
  33. "mid": "123456",
  34. })
  35. param := make(map[string]string)
  36. zhios_pay_utils.Unserialize(zhios_pay_utils.Serialize(createBocPayAppTradeReq), &param)
  37. send, err := boc.Send(false, boc.PrivateKeyStr, param)
  38. if err != nil {
  39. t.Error(err)
  40. }
  41. t.Logf("回调信息1:%s", send)
  42. resp, _ := php2go.URLDecode(send)
  43. t.Logf("回调信息:%s", resp)
  44. }
  45. func TestCreateBocPayAppTradeReq(t *testing.T) {
  46. var createBocPayAppTradeReq md.CreateBocPayAppTradeReq
  47. //按照接口类型选填信息
  48. createBocPayAppTradeReq.Amount = "100"
  49. createBocPayAppTradeReq.OriginalAmount = "100"
  50. createBocPayAppTradeReq.MercOrderNo = "2022101402"
  51. createBocPayAppTradeReq.OrderDate = "20221013"
  52. createBocPayAppTradeReq.OrderTime = "175600"
  53. createBocPayAppTradeReq.NotifyUrl = "/api/v1/mall/pay/ada/sub_callback"
  54. createBocPayAppTradeReq.Reserved1 = zhios_pay_utils.SerializeStr(map[string]string{
  55. "mid": "123456",
  56. })
  57. send, err := boc.CreateBocPayAppTradeReq(false, boc.PrivateKeyStr, boc.MerchantId, boc.TerminalNo, &createBocPayAppTradeReq)
  58. if err != nil {
  59. t.Error(err)
  60. }
  61. t.Logf("回调信息:%s", send)
  62. }
  63. func TestCreateWeChatTradeReq(t *testing.T) {
  64. var CreateWeChatTradeReqReq md.CreateWeChatTradeReq
  65. //按照接口类型选填信息
  66. CreateWeChatTradeReqReq.Amount = "100"
  67. CreateWeChatTradeReqReq.OriginalAmount = "100"
  68. CreateWeChatTradeReqReq.MercOrderNo = "2022101403"
  69. CreateWeChatTradeReqReq.OrderDate = "20221013"
  70. CreateWeChatTradeReqReq.OrderTime = "175600"
  71. CreateWeChatTradeReqReq.NotifyUrl = "/api/v1/mall/pay/ada/sub_callback"
  72. CreateWeChatTradeReqReq.SubAppId = "wx987580a9437354d1"
  73. CreateWeChatTradeReqReq.SubOpenId = "oEk7V5hNLxQXoTpOcvzRdGJQKnjM"
  74. CreateWeChatTradeReqReq.TransWay = "B3"
  75. CreateWeChatTradeReqReq.Reserved1 = zhios_pay_utils.SerializeStr(map[string]string{
  76. "mid": "123456",
  77. })
  78. send, err := boc.CreateWeChatTradeReq(false, boc.PrivateKeyStr, boc.MerchantId, boc.TerminalNo, &CreateWeChatTradeReqReq)
  79. if err != nil {
  80. t.Error(err)
  81. }
  82. t.Logf("回调信息:%s", send)
  83. }