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 = "2022101402" 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", }) 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 = "2022101403" CreateWeChatTradeReqReq.OrderDate = "20221013" CreateWeChatTradeReqReq.OrderTime = "175600" 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) }