ClientTest.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using NUnit.Framework;
  2. using Alipay.EasySDK.Factory;
  3. using Alipay.EasySDK.Payment.FaceToFace.Models;
  4. using System;
  5. using Alipay.EasySDK.Kernel.Util;
  6. namespace UnitTest.Payment.FaceToFace
  7. {
  8. public class ClientTest
  9. {
  10. [SetUp]
  11. public void SetUp()
  12. {
  13. Factory.SetOptions(TestAccount.Mini.CONFIG);
  14. }
  15. [Test]
  16. public void TestPay()
  17. {
  18. AlipayTradePayResponse response = Factory.Payment.FaceToFace().Pay("Iphone6 16G", CreateNewAndReturnOutTradeNo(), "0.01", "1234567890");
  19. Assert.IsFalse(ResponseChecker.Success(response));
  20. Assert.AreEqual(response.Code, "40004");
  21. Assert.AreEqual(response.Msg, "Business Failed");
  22. Assert.AreEqual(response.SubCode, "ACQ.PAYMENT_AUTH_CODE_INVALID");
  23. Assert.AreEqual(response.SubMsg, "支付失败,获取顾客账户信息失败,请顾客刷新付款码后重新收款,如再次收款失败,请联系管理员处理。[SOUNDWAVE_PARSER_FAIL]");
  24. Assert.NotNull(response.HttpBody);
  25. }
  26. [Test]
  27. public void TestPreCreate()
  28. {
  29. AlipayTradePrecreateResponse response = Factory.Payment.FaceToFace().PreCreate("iPhone6 16G",
  30. CreateNewAndReturnOutTradeNo(), "0.10");
  31. Assert.IsTrue(ResponseChecker.Success(response));
  32. Assert.AreEqual(response.Code, "10000");
  33. Assert.AreEqual(response.Msg, "Success");
  34. Assert.IsNull(response.SubCode);
  35. Assert.IsNull(response.SubMsg);
  36. Assert.NotNull(response.HttpBody);
  37. Assert.IsTrue(response.QrCode.StartsWith("https://qr.alipay.com/"));
  38. }
  39. private string CreateNewAndReturnOutTradeNo()
  40. {
  41. return Factory.Payment.Common().Create("Iphone6 16G", Guid.NewGuid().ToString(),
  42. "88.88", "2088002656718920").OutTradeNo;
  43. }
  44. }
  45. }