|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- package test
-
- import (
- "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/boc"
- "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/md"
- zhios_pay_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/utils"
- "fmt"
- "github.com/shopspring/decimal"
- "testing"
- "time"
- )
-
- func TestJoinStringsInASCII(t *testing.T) {
- ascii := zhios_pay_utils.JoinStringsInASCII(map[string]string{"apam": "value1", "cpam": "value2", "Bpam": "value3"},
- "", "", false, false)
- fmt.Println(ascii)
- }
-
- func TestCreateBocPayAppTradeReq(t *testing.T) {
- var createBocPayAppTradeReq md.CreateBocPayAppTradeReq
- //按照接口类型选填信息
- createBocPayAppTradeReq.Amount = "100"
- createBocPayAppTradeReq.OriginalAmount = "100"
- createBocPayAppTradeReq.MercOrderNo = "2022102102"
- createBocPayAppTradeReq.OrderDate = time.Now().Format("20060102")
- createBocPayAppTradeReq.OrderTime = time.Now().Format("150105")
- createBocPayAppTradeReq.NotifyUrl = "/api/v1/mall/pay/ada/sub_callback"
- createBocPayAppTradeReq.Reserved1 = zhios_pay_utils.SerializeStr(map[string]string{
- "mid": "123456",
- })
- send, err := boc.CreateBocPayAppTradeReq(false, boc.PrivateKeyStr, boc.MerchantId, boc.TerminalNo, &createBocPayAppTradeReq)
- if err != nil {
- t.Error(err)
- }
- t.Logf("回调信息:%s", send)
- }
-
- func TestCreateWeChatTradeReq(t *testing.T) {
- var CreateWeChatTradeReqReq md.CreateWeChatTradeReq
- //按照接口类型选填信息
- CreateWeChatTradeReqReq.Amount = "100"
- CreateWeChatTradeReqReq.OriginalAmount = "100"
- CreateWeChatTradeReqReq.MercOrderNo = "2022101405"
- CreateWeChatTradeReqReq.OrderDate = time.Now().Format("20060102")
- CreateWeChatTradeReqReq.OrderTime = time.Now().Format("150105")
- CreateWeChatTradeReqReq.NotifyUrl = "/api/v1/mall/pay/ada/sub_callback"
- CreateWeChatTradeReqReq.SubAppId = "wx987580a9437354d1"
- CreateWeChatTradeReqReq.SubOpenId = "oEk7V5hNLxQXoTpOcvzRdGJQKnjM"
- CreateWeChatTradeReqReq.TransWay = "B3"
- CreateWeChatTradeReqReq.Reserved1 = zhios_pay_utils.SerializeStr(map[string]string{
- "mid": "123456",
- })
- send, err := boc.CreateWeChatTradeReq(false, boc.PrivateKeyStr, boc.MerchantId, boc.TerminalNo, &CreateWeChatTradeReqReq)
- if err != nil {
- t.Error(err)
- }
- t.Logf("回调信息:%s", send)
- }
-
- func TestCreateQRTradeReq(t *testing.T) {
- var createQRTradeReq md.CreateQRTradeReq
- //按照接口类型选填信息
- createQRTradeReq.Amount = "100"
- createQRTradeReq.OriginalAmount = "100"
- createQRTradeReq.PayChannel = "WECHATPAY"
- createQRTradeReq.ProductCode = "PCWEB"
- createQRTradeReq.MercOrderNo = "2022102101"
- createQRTradeReq.OrderDate = time.Now().Format("20060102")
- createQRTradeReq.OrderTime = time.Now().Format("150105")
- createQRTradeReq.NotifyUrl = "/api/v1/mall/pay/ada/sub_callback"
- createQRTradeReq.Reserved1 = zhios_pay_utils.SerializeStr(map[string]string{
- "mid": "123456",
- })
- createQRTradeReq.Supplier = "测试"
- createQRTradeReq.ReferUrl = "https://www.baidu.com"
- createQRTradeReq.BusinessType = "4"
- createQRTradeReq.GoodsInfo = "测试商品^1"
- createQRTradeReq.TotalQuantity = "1"
- send, err := boc.CreateQRTradeReq(false, boc.PrivateKeyStr, boc.MerchantId, boc.TerminalNo, &createQRTradeReq)
- if err != nil {
- t.Error(err)
- }
- t.Logf("回调信息:%s", send)
- }
- func TestOrderQueryReq(t *testing.T) {
- var orderQueryReq md.OrderQueryReq
- //按照接口类型选填信息
- orderQueryReq.QueryNo = "100173316661476707"
- send, err := boc.OrderQueryReq(false, boc.PrivateKeyStr, boc.MerchantId, boc.TerminalNo, &orderQueryReq)
- if err != nil {
- t.Error(err)
- }
- t.Logf("回调信息:%s", send)
- }
-
- func TestFloat(t *testing.T) {
- rateD, _ := decimal.NewFromString("155")
- rateD = rateD.Div(decimal.NewFromInt(100))
- rateF, exact := rateD.Float64()
- t.Logf("数目:%g", rateF)
- if !exact {
- rateF = 0.5
- }
- t.Logf("数目:%g", rateF)
- }
|