package alipaycli import ( "context" "fmt" "os" "service/app/mix/conf" "service/bizcommon/util" "service/library/configcenter" "service/library/idgenerator" "testing" ) func TestMain(m *testing.M) { cfg := new(conf.ConfigSt) err := configcenter.LoadConfig("/Users/erwin/wishpalv2/service/etc/mix/mix-local.yaml", cfg) if err != nil { fmt.Printf("%v\n", err) } err = InitMulti(cfg.Alipay, cfg.AlipayMYTS) if err != nil { fmt.Println(err) os.Exit(1) } m.Run() } func TestAlipayClient_WapPay(t *testing.T) { cli := GetDefaultAlipayClient() paramStr, err := cli.WapPay(context.Background(), &WapPayParam{ OutTradeNo: idgenerator.GenOrderId(), Subject: "哈哈", TotalAmount: 1, TimeOutSeconds: 0, }) if err != nil { fmt.Println(err) return } fmt.Println(paramStr) } func TestAlipayClient_QueryOrder(t *testing.T) { cli := GetDefaultAlipayClient() resp, err := cli.QueryOrder(context.Background(), &QueryOrderParam{ OutTradeNo: "1750539072771731456", }) if err != nil { fmt.Println(err.Error()) return } fmt.Println(util.ToJson(resp)) } func TestAlipayClient_RefundOne(t *testing.T) { cli := GetAlipayClientByAppId(AppIdXinYiDaoLe) resp, err := cli.RefundOne(context.Background(), &RefundOneParam{ OutTradeNo: "1744218982338015232", RefundAmount: 100, RefundReason: "测试退款", }) if err != nil { fmt.Println(err.Error()) return } fmt.Println(util.ToJson(resp)) } func TestAlipayClient_UniTransfer(t *testing.T) { cli := GetAlipayClientByAppId(AppIdXinYiDaoLe) resp, err := cli.UniTransfer(context.Background(), &UniTransferParam{ OutBizNo: idgenerator.GenWithdrawOrderId(), Amount: 10, Title: "提现测试", AlipayLoginId: "lwl0608@foxmail.com", AlipayName: "李旺林", }) if err != nil { fmt.Println(err.Error()) return } fmt.Println(util.ToJson(resp)) }