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/syyongx/php2go" "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 TestBocSend(t *testing.T) { var createBocPayAppTradeReq md.CreateBocPayAppTradeReq //基础信息,必填 createBocPayAppTradeReq.Version = boc.Version createBocPayAppTradeReq.Service = boc.CreateBocPayAppTrade createBocPayAppTradeReq.SignType = boc.SignType createBocPayAppTradeReq.MerchantId = boc.MerchantId createBocPayAppTradeReq.TerminalNo = boc.TerminalNo createBocPayAppTradeReq.RequestId = "2022101401" + zhios_pay_utils.AnyToString(time.Now().Unix()) //按照接口类型选填信息 createBocPayAppTradeReq.Amount = "100" createBocPayAppTradeReq.OriginalAmount = "100" createBocPayAppTradeReq.MercOrderNo = "2022101401" createBocPayAppTradeReq.OrderDate = "20221013" createBocPayAppTradeReq.OrderTime = "175600" createBocPayAppTradeReq.NotifyUrl = "/api/v1/mall/pay/ada/sub_callback" createBocPayAppTradeReq.Reserved1 = zhios_pay_utils.SerializeStr(map[string]string{ "mid": "123456", }) param := make(map[string]string) zhios_pay_utils.Unserialize(zhios_pay_utils.Serialize(createBocPayAppTradeReq), ¶m) send, err := boc.Send(false, boc.PrivateKeyStr, param) if err != nil { t.Error(err) } t.Logf("回调信息1:%s", send) resp, _ := php2go.URLDecode(send) t.Logf("回调信息:%s", resp) } func TestCreateBocPayAppTradeReq(t *testing.T) { var createBocPayAppTradeReq md.CreateBocPayAppTradeReq //按照接口类型选填信息 createBocPayAppTradeReq.Amount = "100" createBocPayAppTradeReq.OriginalAmount = "100" createBocPayAppTradeReq.MercOrderNo = "2022101404" 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 = "2022101404" 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 = "2022101405" 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) }