You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
3.5 KiB
65 lines
3.5 KiB
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>"));
|
|
}
|
|
}
|
|
}
|
|
|