支付模块
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

luso_pay_test.go 1.9 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package test
  2. import (
  3. luso "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/luso_bank"
  4. zhios_pay_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/utils"
  5. "crypto"
  6. "log"
  7. "testing"
  8. )
  9. func TestLusoPay(t *testing.T) {
  10. var (
  11. payParam luso.PayParam
  12. dataParam luso.DataParam
  13. )
  14. req := map[string]string{
  15. "mchtOrderId": "202211041102",
  16. "payScene ": "AS_MWEB",
  17. "mdseDesc ": "澳门世寶-自營購物",
  18. "transAmount ": "100",
  19. "transCur ": "MOP",
  20. "subMchtNm ": luso.MchtStoreNm,
  21. "notifyUrl ": "http://inapi.izhyin.cn:80/pay/boc/callback",
  22. "extMsg ": zhios_pay_utils.SerializeStr(map[string]string{
  23. "mid": "123456",
  24. "ord_type": "mall_goods",
  25. }),
  26. }
  27. dataParam.Head.MchtNo = luso.MerchantId
  28. dataParam.ReqBody = req
  29. client := payParam.SetData(dataParam)
  30. err := client.SetSign(luso.PrivateKeyStr)
  31. if err != nil {
  32. t.Error(err)
  33. }
  34. resp, err := client.PayParam.Send(false, false, "create")
  35. if err != nil {
  36. t.Error(err)
  37. }
  38. t.Logf("回調信息:%s", resp)
  39. }
  40. func TestRsa2Rsa2PriSign(t *testing.T) {
  41. //原内容
  42. str := "eyJoZWFkIjp7Im1jaHRObyI6IjMwMDExIiwicmVxVGltZSI6IjIwMjIxMTA5MTUwNjQ1IiwibXNnSWQiOiI1MjE0NTAxNjY3OTc3NjA1MzgyMDIyMTEwOTE1MDY0NSIsImF0dGFjaCI6IiIsImNlcnRJZCI6IjAxIiwidmVyc2lvbiI6IjEuMC4wIn0sInJlcUJvZHkiOnsiZXh0TXNnICI6IntcIm1pZFwiOlwiMTIzNDU2XCIsXCJvcmRfdHlwZVwiOlwibWFsbF9nb29kc1wifSIsIm1jaHRPcmRlcklkIjoiNTIxNDUwMTY2Nzk3NzYwNTM4IiwibWRzZURlc2MgIjoi5LiW5a+25ZWG5Z+OLeiHqueHn+izvOeJqSIsIm5vdGlmeVVybCAiOiJodHRwOi8vaW5hcGkuaXpoeWluLmNuOjgwL3BheS9sdXNvL2NhbGxiYWNrIiwicGF5U2NlbmUgIjoiQVNfTVdFQiIsInN1Yk1jaHRObSAiOiLkuJblr7bllYbln44iLCJ0cmFuc0Ftb3VudCAiOiIxMDAuMDAiLCJ0cmFuc0N1ciAiOiJNT1AifX0="
  43. //生成签名
  44. sig, _ := zhios_pay_utils.GetSignV2(luso.PrivateKeyStr, str, crypto.SHA1)
  45. log.Println(sig)
  46. //验证原内容与签名是否一致
  47. res := zhios_pay_utils.Rsa2PubCheckSign(str, sig, luso.PUBLICKEY, crypto.SHA1)
  48. log.Println(res)
  49. }