添加网站文件
This commit is contained in:
54
vendor/alipaysdk/easysdk/csharp/UnitTest/Payment/App/ClientTest.cs
vendored
Normal file
54
vendor/alipaysdk/easysdk/csharp/UnitTest/Payment/App/ClientTest.cs
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
using NUnit.Framework;
|
||||
using Alipay.EasySDK.Factory;
|
||||
using Alipay.EasySDK.Payment.App.Models;
|
||||
using System.Collections.Generic;
|
||||
using Alipay.EasySDK.Kernel.Util;
|
||||
|
||||
namespace UnitTest.Payment.App
|
||||
{
|
||||
public class ClientTest
|
||||
{
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
Factory.SetOptions(TestAccount.Mini.CONFIG);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPay()
|
||||
{
|
||||
AlipayTradeAppPayResponse response = Factory.Payment.App().Pay("iPhone6 16G",
|
||||
"f4833085-0c46-4bb0-8e5f-622a02a4cffc", "0.10");
|
||||
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.IsTrue(response.Body.Contains("app_id=2019022663440152&biz_content=%7b%22subject%22%3a%22iPhone6+16G%22%2c%22" +
|
||||
"out_trade_no%22%3a%22f4833085-0c46-4bb0-8e5f-622a02a4cffc%22%2c%22total_amount%22%3a%220.10%22%7d&charset=UTF-8&" +
|
||||
"format=json&method=alipay.trade.app.pay¬ify_url=https%3a%2f%2fwww.test.com%2fcallback&sign="));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPayWithOptional()
|
||||
{
|
||||
AlipayTradeAppPayResponse response = Factory.Payment.App()
|
||||
.Agent("ca34ea491e7146cc87d25fca24c4cD11")
|
||||
.Optional("extend_params", GetHuabeiConfig())
|
||||
.Pay("iPhone6 16G", "f4833085-0c46-4bb0-8e5f-622a02a4cffc", "0.10");
|
||||
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.IsTrue(response.Body.Contains("app_auth_token=ca34ea491e7146cc87d25fca24c4cD11&app_id=2019022663440152&biz_content=%7b%22subject%22%3a%22iPhone6+16G%22%2c"
|
||||
+ "%22out_trade_no%22%3a%22f4833085-0c46-4bb0-8e5f-622a02a4cffc%22%2c%22total_amount%22%3a%220"
|
||||
+ ".10%22%2c%22extend_params%22%3a%7b%22hb_fq_num%22%3a%223%22%2c%22hb_fq_seller_percent%22%3a%22100%22%7d%7d&charset=UTF"
|
||||
+ "-8&format=json&method=alipay.trade.app.pay¬ify_url=https%3a%2f%2fwww.test.com%2fcallback&sign="));
|
||||
}
|
||||
|
||||
private Dictionary<string, string> GetHuabeiConfig()
|
||||
{
|
||||
Dictionary<string, string> extendParams = new Dictionary<string, string>
|
||||
{
|
||||
{ "hb_fq_num", "3" },
|
||||
{ "hb_fq_seller_percent", "100" }
|
||||
};
|
||||
return extendParams;
|
||||
}
|
||||
}
|
||||
}
|
||||
154
vendor/alipaysdk/easysdk/csharp/UnitTest/Payment/Common/ClientTest.cs
vendored
Normal file
154
vendor/alipaysdk/easysdk/csharp/UnitTest/Payment/Common/ClientTest.cs
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
using NUnit.Framework;
|
||||
using Alipay.EasySDK.Factory;
|
||||
using Alipay.EasySDK.Payment.Common.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Alipay.EasySDK.Kernel.Util;
|
||||
|
||||
namespace UnitTest.Payment.Common
|
||||
{
|
||||
public class ClientTest
|
||||
{
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
Factory.SetOptions(TestAccount.Mini.CONFIG);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreate()
|
||||
{
|
||||
string outTradeNo = Guid.NewGuid().ToString();
|
||||
AlipayTradeCreateResponse response = Factory.Payment.Common().Create("iPhone6 16G",
|
||||
outTradeNo, "88.88", "2088002656718920");
|
||||
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "10000");
|
||||
Assert.AreEqual(response.Msg, "Success");
|
||||
Assert.Null(response.SubCode);
|
||||
Assert.Null(response.SubMsg);
|
||||
Assert.NotNull(response.HttpBody);
|
||||
Assert.AreEqual(response.OutTradeNo, outTradeNo);
|
||||
Assert.True(response.TradeNo.StartsWith("202"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateWithOptional()
|
||||
{
|
||||
string outTradeNo = Guid.NewGuid().ToString();
|
||||
AlipayTradeCreateResponse response = Factory.Payment.Common().Optional("goods_detail", GetGoodsDetail())
|
||||
.Create("iPhone6 16G", outTradeNo, "0.01", "2088002656718920");
|
||||
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "10000");
|
||||
Assert.AreEqual(response.Msg, "Success");
|
||||
Assert.Null(response.SubCode);
|
||||
Assert.Null(response.SubMsg);
|
||||
Assert.NotNull(response.HttpBody);
|
||||
Assert.AreEqual(response.OutTradeNo, outTradeNo);
|
||||
Assert.True(response.TradeNo.StartsWith("202"));
|
||||
}
|
||||
|
||||
private List<object> GetGoodsDetail()
|
||||
{
|
||||
List<object> goodsDetail = new List<object>();
|
||||
Dictionary<string, object> goodDetail = new Dictionary<string, object>();
|
||||
goodDetail.Add("goods_id", "apple-01");
|
||||
goodDetail.Add("goods_name", "iPhone6 16G");
|
||||
goodDetail.Add("quantity", 1);
|
||||
goodDetail.Add("price", "0.01");
|
||||
goodsDetail.Add(goodDetail);
|
||||
return goodsDetail;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestQuery()
|
||||
{
|
||||
AlipayTradeQueryResponse response = Factory.Payment.Common().Query("6f149ddb-ab8c-4546-81fb-5880b4aaa318");
|
||||
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "10000");
|
||||
Assert.AreEqual(response.Msg, "Success");
|
||||
Assert.Null(response.SubCode);
|
||||
Assert.Null(response.SubMsg);
|
||||
Assert.NotNull(response.HttpBody);
|
||||
Assert.AreEqual(response.OutTradeNo, "6f149ddb-ab8c-4546-81fb-5880b4aaa318");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCancel()
|
||||
{
|
||||
AlipayTradeCancelResponse response = Factory.Payment.Common().Cancel(CreateNewAndReturnOutTradeNo());
|
||||
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "10000");
|
||||
Assert.AreEqual(response.Msg, "Success");
|
||||
Assert.Null(response.SubCode);
|
||||
Assert.Null(response.SubMsg);
|
||||
Assert.NotNull(response.HttpBody);
|
||||
Assert.AreEqual(response.Action, "close");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestClose()
|
||||
{
|
||||
AlipayTradeCloseResponse response = Factory.Payment.Common().Close(CreateNewAndReturnOutTradeNo());
|
||||
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "10000");
|
||||
Assert.AreEqual(response.Msg, "Success");
|
||||
Assert.Null(response.SubCode);
|
||||
Assert.Null(response.SubMsg);
|
||||
Assert.NotNull(response.HttpBody);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRefund()
|
||||
{
|
||||
AlipayTradeRefundResponse response = Factory.Payment.Common().Refund(CreateNewAndReturnOutTradeNo(), "0.01");
|
||||
|
||||
Assert.IsFalse(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "40004");
|
||||
Assert.AreEqual(response.Msg, "Business Failed");
|
||||
Assert.AreEqual(response.SubCode, "ACQ.TRADE_STATUS_ERROR");
|
||||
Assert.AreEqual(response.SubMsg, "交易状态不合法");
|
||||
Assert.NotNull(response.HttpBody);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestQueryRefund()
|
||||
{
|
||||
AlipayTradeFastpayRefundQueryResponse response = Factory.Payment.Common().QueryRefund(
|
||||
"64628156-f784-4572-9540-485b7c91b850", "64628156-f784-4572-9540-485b7c91b850");
|
||||
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "10000");
|
||||
Assert.AreEqual(response.Msg, "Success");
|
||||
Assert.IsNull(response.SubCode);
|
||||
Assert.IsNull(response.SubMsg);
|
||||
Assert.NotNull(response.HttpBody);
|
||||
Assert.AreEqual(response.RefundAmount, "0.01");
|
||||
Assert.AreEqual(response.TotalAmount, "0.01");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDownloadBill()
|
||||
{
|
||||
AlipayDataDataserviceBillDownloadurlQueryResponse response = Factory.Payment.Common().DownloadBill("trade", "2020-01");
|
||||
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "10000");
|
||||
Assert.AreEqual(response.Msg, "Success");
|
||||
Assert.IsNull(response.SubCode);
|
||||
Assert.IsNull(response.SubMsg);
|
||||
Assert.NotNull(response.HttpBody);
|
||||
Assert.IsTrue(response.BillDownloadUrl.StartsWith("http://dwbillcenter.alipay.com/"));
|
||||
}
|
||||
|
||||
private string CreateNewAndReturnOutTradeNo()
|
||||
{
|
||||
return Factory.Payment.Common().Create("iPhone6 16G", Guid.NewGuid().ToString(),
|
||||
"88.88", "2088002656718920").OutTradeNo;
|
||||
}
|
||||
}
|
||||
}
|
||||
51
vendor/alipaysdk/easysdk/csharp/UnitTest/Payment/FaceToFace/ClientTest.cs
vendored
Normal file
51
vendor/alipaysdk/easysdk/csharp/UnitTest/Payment/FaceToFace/ClientTest.cs
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
using NUnit.Framework;
|
||||
using Alipay.EasySDK.Factory;
|
||||
using Alipay.EasySDK.Payment.FaceToFace.Models;
|
||||
using System;
|
||||
using Alipay.EasySDK.Kernel.Util;
|
||||
|
||||
namespace UnitTest.Payment.FaceToFace
|
||||
{
|
||||
public class ClientTest
|
||||
{
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
Factory.SetOptions(TestAccount.Mini.CONFIG);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPay()
|
||||
{
|
||||
AlipayTradePayResponse response = Factory.Payment.FaceToFace().Pay("Iphone6 16G", CreateNewAndReturnOutTradeNo(), "0.01", "1234567890");
|
||||
|
||||
Assert.IsFalse(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "40004");
|
||||
Assert.AreEqual(response.Msg, "Business Failed");
|
||||
Assert.AreEqual(response.SubCode, "ACQ.PAYMENT_AUTH_CODE_INVALID");
|
||||
Assert.AreEqual(response.SubMsg, "支付失败,获取顾客账户信息失败,请顾客刷新付款码后重新收款,如再次收款失败,请联系管理员处理。[SOUNDWAVE_PARSER_FAIL]");
|
||||
Assert.NotNull(response.HttpBody);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPreCreate()
|
||||
{
|
||||
AlipayTradePrecreateResponse response = Factory.Payment.FaceToFace().PreCreate("iPhone6 16G",
|
||||
CreateNewAndReturnOutTradeNo(), "0.10");
|
||||
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "10000");
|
||||
Assert.AreEqual(response.Msg, "Success");
|
||||
Assert.IsNull(response.SubCode);
|
||||
Assert.IsNull(response.SubMsg);
|
||||
Assert.NotNull(response.HttpBody);
|
||||
Assert.IsTrue(response.QrCode.StartsWith("https://qr.alipay.com/"));
|
||||
}
|
||||
|
||||
private string CreateNewAndReturnOutTradeNo()
|
||||
{
|
||||
return Factory.Payment.Common().Create("Iphone6 16G", Guid.NewGuid().ToString(),
|
||||
"88.88", "2088002656718920").OutTradeNo;
|
||||
}
|
||||
}
|
||||
}
|
||||
39
vendor/alipaysdk/easysdk/csharp/UnitTest/Payment/Huabei/ClientTest.cs
vendored
Normal file
39
vendor/alipaysdk/easysdk/csharp/UnitTest/Payment/Huabei/ClientTest.cs
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
using NUnit.Framework;
|
||||
using Alipay.EasySDK.Factory;
|
||||
using Alipay.EasySDK.Payment.Huabei.Models;
|
||||
using System;
|
||||
using Alipay.EasySDK.Kernel.Util;
|
||||
|
||||
namespace UnitTest.Payment.HuaBei
|
||||
{
|
||||
public class ClientTest
|
||||
{
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
Factory.SetOptions(TestAccount.Mini.CONFIG);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCrate()
|
||||
{
|
||||
string outTradeNo = Guid.NewGuid().ToString();
|
||||
HuabeiConfig config = new HuabeiConfig()
|
||||
{
|
||||
HbFqNum = "3",
|
||||
HbFqSellerPercent = "0"
|
||||
};
|
||||
AlipayTradeCreateResponse response = Factory.Payment.Huabei().Create("Iphone6 16G",
|
||||
outTradeNo, "88.88", "2088002656718920", config);
|
||||
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "10000");
|
||||
Assert.AreEqual(response.Msg, "Success");
|
||||
Assert.Null(response.SubCode);
|
||||
Assert.Null(response.SubMsg);
|
||||
Assert.NotNull(response.HttpBody);
|
||||
Assert.AreEqual(response.OutTradeNo, outTradeNo);
|
||||
Assert.True(response.TradeNo.StartsWith("202"));
|
||||
}
|
||||
}
|
||||
}
|
||||
50
vendor/alipaysdk/easysdk/csharp/UnitTest/Payment/Page/ClientTest.cs
vendored
Normal file
50
vendor/alipaysdk/easysdk/csharp/UnitTest/Payment/Page/ClientTest.cs
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
using NUnit.Framework;
|
||||
using Alipay.EasySDK.Factory;
|
||||
using Alipay.EasySDK.Payment.Page.Models;
|
||||
using Alipay.EasySDK.Kernel.Util;
|
||||
|
||||
namespace UnitTest.Payment.Page
|
||||
{
|
||||
public class ClientTest
|
||||
{
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
Factory.SetOptions(TestAccount.Mini.CONFIG);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPay()
|
||||
{
|
||||
AlipayTradePagePayResponse response = Factory.Payment.Page().Pay("iPhone6 16G",
|
||||
"e5b5bd79-8310-447d-b63b-0fe3a393324d", "0.10", "https://www.taobao.com");
|
||||
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.IsTrue(response.Body.Contains("<form name=\"punchout_form\" method=\"post\" action=\"https://openapi.alipay.com/gateway.do?"));
|
||||
Assert.IsTrue(response.Body.Contains("notify_url"));
|
||||
Assert.IsTrue(response.Body.Contains("return_url"));
|
||||
Assert.IsTrue(response.Body.Contains("<input type=\"hidden\" name=\"biz_content\" value=\"{"subject":"iPhone6 16G",""
|
||||
+ "out_trade_no":"e5b5bd79-8310-447d-b63b-0fe3a393324d","total_amount":"0.10",""
|
||||
+ "product_code":"FAST_INSTANT_TRADE_PAY"}\">"));
|
||||
Assert.IsTrue(response.Body.Contains("<input type=\"submit\" value=\"立即支付\" style=\"display:none\" >"));
|
||||
Assert.IsTrue(response.Body.Contains("<script>document.forms[0].submit();</script>"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPayWithOptionalNotify()
|
||||
{
|
||||
AlipayTradePagePayResponse response = Factory.Payment.Page().AsyncNotify("https://www.test2.com/newCallback")
|
||||
.Pay("iPhone6 16G", "e5b5bd79-8310-447d-b63b-0fe3a393324d", "0.10", "https://www.taobao.com");
|
||||
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.IsTrue(response.Body.Contains("<form name=\"punchout_form\" method=\"post\" action=\"https://openapi.alipay.com/gateway.do?"));
|
||||
Assert.IsTrue(response.Body.Contains("notify_url=https%3a%2f%2fwww.test2.com%2fnewCallback"));
|
||||
Assert.IsTrue(response.Body.Contains("return_url"));
|
||||
Assert.IsTrue(response.Body.Contains("<input type=\"hidden\" name=\"biz_content\" value=\"{"subject":"iPhone6 16G","out_trade_no":""
|
||||
+ "e5b5bd79-8310-447d-b63b-0fe3a393324d","total_amount":"0.10","product_code":""
|
||||
+ "FAST_INSTANT_TRADE_PAY"}\">"));
|
||||
Assert.IsTrue(response.Body.Contains("<input type=\"submit\" value=\"立即支付\" style=\"display:none\" >"));
|
||||
Assert.IsTrue(response.Body.Contains("<script>document.forms[0].submit();</script>"));
|
||||
}
|
||||
}
|
||||
}
|
||||
65
vendor/alipaysdk/easysdk/csharp/UnitTest/Payment/Wap/ClientTest.cs
vendored
Normal file
65
vendor/alipaysdk/easysdk/csharp/UnitTest/Payment/Wap/ClientTest.cs
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
using NUnit.Framework;
|
||||
using Alipay.EasySDK.Factory;
|
||||
using Alipay.EasySDK.Payment.Wap.Models;
|
||||
using Alipay.EasySDK.Kernel.Util;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnitTest.Payment.Wap
|
||||
{
|
||||
public class ClientTest
|
||||
{
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
Factory.SetOptions(TestAccount.Mini.CONFIG);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPay()
|
||||
{
|
||||
AlipayTradeWapPayResponse response = Factory.Payment.Wap().Pay("iPhone6 16G",
|
||||
"b7f4bc7d-ea4b-4efd-9072-d8ea913c8946", "0.10",
|
||||
"https://www.taobao.com", "https://www.taobao.com");
|
||||
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.IsTrue(response.Body.Contains("<form name=\"punchout_form\" method=\"post\" action=\"https://openapi.alipay.com/gateway.do?"));
|
||||
Assert.IsTrue(response.Body.Contains("notify_url"));
|
||||
Assert.IsTrue(response.Body.Contains("return_url"));
|
||||
Assert.IsTrue(response.Body.Contains("<input type=\"hidden\" name=\"biz_content\" value=\"{"subject":"iPhone6 16G",""
|
||||
+ "out_trade_no":"b7f4bc7d-ea4b-4efd-9072-d8ea913c8946",""
|
||||
+ "total_amount":"0.10","quit_url":"https://www.taobao.com",""
|
||||
+ "product_code":"QUICK_WAP_WAY"}\">"));
|
||||
Assert.IsTrue(response.Body.Contains("<input type=\"submit\" value=\"立即支付\" style=\"display:none\" >"));
|
||||
Assert.IsTrue(response.Body.Contains("<script>document.forms[0].submit();</script>"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPayWithOptional()
|
||||
{
|
||||
Dictionary<string, object> optionalArgs = new Dictionary<string, object>
|
||||
{
|
||||
{ "timeout_express", "10m" },
|
||||
{ "body", "iPhone6 16G"}
|
||||
};
|
||||
AlipayTradeWapPayResponse response = Factory.Payment.Wap()
|
||||
.Agent("ca34ea491e7146cc87d25fca24c4cD11").BatchOptional(optionalArgs)
|
||||
.Pay("iPhone6 16G", "b7f4bc7d-ea4b-4efd-9072-d8ea913c8946", "0.10",
|
||||
"https://www.taobao.com", "https://www.taobao.com");
|
||||
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.IsTrue(response.Body.Contains("<form name=\"punchout_form\" method=\"post\" "
|
||||
+ "action=\"https://openapi.alipay.com/gateway.do?"));
|
||||
Assert.IsTrue(response.Body.Contains("notify_url"));
|
||||
Assert.IsTrue(response.Body.Contains("return_url"));
|
||||
Assert.IsTrue(response.Body.Contains("app_auth_token"));
|
||||
Assert.IsTrue(response.Body.Contains("timeout_express"));
|
||||
Assert.IsTrue(response.Body.Contains("body"));
|
||||
Assert.IsTrue(response.Body.Contains("<input type=\"hidden\" name=\"biz_content\" value=\"{"subject":"iPhone6 16G","out_trade_no":""
|
||||
+ "b7f4bc7d-ea4b-4efd-9072-d8ea913c8946","total_amount":"0.10","quit_url":""
|
||||
+ "https://www.taobao.com","product_code":"QUICK_WAP_WAY","timeout_express":""
|
||||
+ "10m","body":"iPhone6 16G"}\">"));
|
||||
Assert.IsTrue(response.Body.Contains("<input type=\"submit\" value=\"立即支付\" style=\"display:none\" >"));
|
||||
Assert.IsTrue(response.Body.Contains("<script>document.forms[0].submit();</script>"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user