From 5b3fba360069cdb04ac650f2a10363032aceb5a6 Mon Sep 17 00:00:00 2001 From: azhang4 Date: Wed, 28 Oct 2020 17:55:59 +0800 Subject: [PATCH 1/5] Update SDK for 3DS 2.0 --- .../IntegrationTests/Direct3DSEnrollTests.cs | 46 +++++++++++++++ .../IntegrationTests/Direct3DSVerifyTests.cs | 52 +++++++++++++++++ eWAY.Rapid.Tests/TestUtil.cs | 58 +++++++++++++++++-- eWAY.Rapid.Tests/eWAY.Rapid.Tests.csproj | 2 + eWAY.Rapid/IRapidClient.cs | 14 +++++ .../Internals/Mappings/RequestMapProfile.cs | 6 ++ .../Internals/Mappings/ResponseMapProfile.cs | 9 +++ .../Internals/Models/Direct3DSecureAuth.cs | 18 ++++++ .../Internals/Models/DirectTokenCustomer.cs | 2 +- eWAY.Rapid/Internals/RapidClient.cs | 14 +++++ .../Request/Direct3DSecureEnrollRequest.cs | 15 +++++ .../Request/Direct3DSecureVerifyRequest.cs | 8 +++ .../Response/Direct3DSecureEnrollResponse.cs | 9 +++ .../Response/Direct3DSecureVerifyResponse.cs | 11 ++++ .../Internals/Services/IRapidService.cs | 2 + eWAY.Rapid/Internals/Services/RapidService.cs | 12 ++++ eWAY.Rapid/Models/Direct3DSEnrollRequest.cs | 21 +++++++ eWAY.Rapid/Models/Direct3DSEnrollResponse.cs | 15 +++++ eWAY.Rapid/Models/Direct3DSVerifyRequest.cs | 13 +++++ eWAY.Rapid/Models/Direct3DSVerifyResponse.cs | 13 +++++ eWAY.Rapid/Models/Direct3DSecureAuth.cs | 21 +++++++ eWAY.Rapid/eWAY.Rapid.csproj | 14 ++++- 22 files changed, 368 insertions(+), 7 deletions(-) create mode 100644 eWAY.Rapid.Tests/IntegrationTests/Direct3DSEnrollTests.cs create mode 100644 eWAY.Rapid.Tests/IntegrationTests/Direct3DSVerifyTests.cs create mode 100644 eWAY.Rapid/Internals/Models/Direct3DSecureAuth.cs create mode 100644 eWAY.Rapid/Internals/Request/Direct3DSecureEnrollRequest.cs create mode 100644 eWAY.Rapid/Internals/Request/Direct3DSecureVerifyRequest.cs create mode 100644 eWAY.Rapid/Internals/Response/Direct3DSecureEnrollResponse.cs create mode 100644 eWAY.Rapid/Internals/Response/Direct3DSecureVerifyResponse.cs create mode 100644 eWAY.Rapid/Models/Direct3DSEnrollRequest.cs create mode 100644 eWAY.Rapid/Models/Direct3DSEnrollResponse.cs create mode 100644 eWAY.Rapid/Models/Direct3DSVerifyRequest.cs create mode 100644 eWAY.Rapid/Models/Direct3DSVerifyResponse.cs create mode 100644 eWAY.Rapid/Models/Direct3DSecureAuth.cs diff --git a/eWAY.Rapid.Tests/IntegrationTests/Direct3DSEnrollTests.cs b/eWAY.Rapid.Tests/IntegrationTests/Direct3DSEnrollTests.cs new file mode 100644 index 0000000..e567160 --- /dev/null +++ b/eWAY.Rapid.Tests/IntegrationTests/Direct3DSEnrollTests.cs @@ -0,0 +1,46 @@ +using eWAY.Rapid.Models; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace eWAY.Rapid.Tests.IntegrationTests +{ + [TestClass] + public class Direct3DSEnrollTests : SdkTestBase + { + private IRapidClient _client; + private Direct3DSEnrollRequest _request; + + [TestInitialize] + public void Initial() + { + _client = CreateRapidApiClient(); + _request = TestUtil.CreateEnrollRequest(); + } + + [TestMethod] + public void Enroll_Returns_ValidResponse() + { + var response = _client.Direct3DSEnroll(_request); + + Assert.IsFalse(string.IsNullOrEmpty(response.Default3dsUrl)); + Assert.AreNotEqual(0, response.TraceId); + Assert.IsFalse(string.IsNullOrEmpty(response.AccessCode)); + Assert.IsNull(response.Errors); + } + + [TestMethod] + public void Enroll_Returns_ErrorResponse() + { + var request = TestUtil.CreateEnrollRequest(); + //Send no postal code will cause error V6068 + request.Customer.Address.PostalCode = ""; + + var response = _client.Direct3DSEnroll(request); + + Assert.IsTrue(string.IsNullOrEmpty(response.Default3dsUrl)); + Assert.AreEqual(0, response.TraceId); + Assert.IsTrue(string.IsNullOrEmpty(response.AccessCode)); + Assert.IsNotNull(response.Errors); + Assert.AreEqual("V6068", response.Errors[0]); + } + } +} diff --git a/eWAY.Rapid.Tests/IntegrationTests/Direct3DSVerifyTests.cs b/eWAY.Rapid.Tests/IntegrationTests/Direct3DSVerifyTests.cs new file mode 100644 index 0000000..ab3f6e8 --- /dev/null +++ b/eWAY.Rapid.Tests/IntegrationTests/Direct3DSVerifyTests.cs @@ -0,0 +1,52 @@ +using eWAY.Rapid.Models; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace eWAY.Rapid.Tests.IntegrationTests +{ + [TestClass] + public class Direct3DSVerifyTests : SdkTestBase + { + private IRapidClient _client; + + [TestInitialize] + public void Initialize() + { + _client = CreateRapidApiClient(); + } + + [TestMethod] + public void Verify_Returns_Valid_Response() + { + var request = Generate3DSVerifyRequest(); + var response = _client.Direct3DSVerify(request); + + Assert.AreNotEqual(0, response.TraceId); + Assert.IsNotNull(response.AccessCode); + Assert.IsNotNull(response.ThreeDSecureAuth); + Assert.IsNull(response.Errors); + } + + public void Verify_Returns_Errors_Invalid_Response() + { + var request = Generate3DSVerifyRequest(); + request.TraceId = 0; + var response = _client.Direct3DSVerify(request); + + Assert.AreEqual(0, response.TraceId); + Assert.IsNull(response.AccessCode); + Assert.IsNull(response.ThreeDSecureAuth); + Assert.IsNotNull(response.Errors); + Assert.AreEqual("D4417", response.Errors[0]); + } + + private Direct3DSVerifyRequest Generate3DSVerifyRequest() + { + var enrollResponse = _client.Direct3DSEnroll(TestUtil.CreateEnrollRequest()); + return new Direct3DSVerifyRequest() + { + TraceId = enrollResponse.TraceId, + AccessCode = enrollResponse.AccessCode + }; + } + } +} diff --git a/eWAY.Rapid.Tests/TestUtil.cs b/eWAY.Rapid.Tests/TestUtil.cs index af4ae7e..8e0f1fe 100644 --- a/eWAY.Rapid.Tests/TestUtil.cs +++ b/eWAY.Rapid.Tests/TestUtil.cs @@ -1,15 +1,16 @@ -using System.Collections.Generic; -using System.Linq; -using eWAY.Rapid.Enums; -using eWAY.Rapid.Internals.Models; +using eWAY.Rapid.Enums; using eWAY.Rapid.Internals.Response; using eWAY.Rapid.Models; using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Collections.Generic; +using System.Linq; using CardDetails = eWAY.Rapid.Models.CardDetails; using Customer = eWAY.Rapid.Models.Customer; +using DirectTokenCustomer = eWAY.Rapid.Internals.Models.DirectTokenCustomer; using LineItem = eWAY.Rapid.Models.LineItem; using Payment = eWAY.Rapid.Internals.Models.Payment; using Refund = eWAY.Rapid.Models.Refund; +using ShippingAddress = eWAY.Rapid.Models.ShippingAddress; using VerificationResult = eWAY.Rapid.Internals.Models.VerificationResult; namespace eWAY.Rapid.Tests @@ -123,7 +124,7 @@ internal static Customer CreateCustomer() { Country = "au", City = "Sydney", - PostalCode = "", + PostalCode = "2000", State = "NSW", Street1 = "Level 5", Street2 = "369 Queen Street" @@ -280,6 +281,53 @@ internal static DirectPaymentResponse CreateDirectPaymentResponse() }; } + internal static Direct3DSEnrollRequest CreateEnrollRequest() + { + return new Direct3DSEnrollRequest + { + Customer = CreateCustomer(), + ShippingAddress = new ShippingAddress { + ShippingMethod = "NextDay", + FirstName = "John", + LastName = "Smith", + Street1 = "Level 5", + Street2 = "369 Queen Street", + City = "Sydney", + State = "NSW", + Country = "au", + PostalCode = "2000", + Phone = "09 889 0986" + }, + Items = new List() + { + new LineItem() + { + SKU = "12345678901234567890", + Description = "Item Description 1", + Quantity = 1, + UnitCost = 400, + Tax = 100, + Total = 500 + }, + new LineItem() + { + SKU = "123456789012", + Description = "Item Description 2", + Quantity = 1, + UnitCost = 400, + Tax = 100, + Total = 500 + } + }, + Payment = new PaymentDetails() + { + TotalAmount = 1000, + CurrencyCode = "AUD" + }, + RedirectUrl = "http://www.ewaypayments.com" + }; + } + //Assertion helpers internal static void AssertReturnedCustomerData_VerifyAddressAreEqual(Customer responseCustomer, Customer requestCustomer) { diff --git a/eWAY.Rapid.Tests/eWAY.Rapid.Tests.csproj b/eWAY.Rapid.Tests/eWAY.Rapid.Tests.csproj index 08d58d2..91c509a 100755 --- a/eWAY.Rapid.Tests/eWAY.Rapid.Tests.csproj +++ b/eWAY.Rapid.Tests/eWAY.Rapid.Tests.csproj @@ -69,6 +69,8 @@ + + diff --git a/eWAY.Rapid/IRapidClient.cs b/eWAY.Rapid/IRapidClient.cs index a75b1d5..57afa90 100644 --- a/eWAY.Rapid/IRapidClient.cs +++ b/eWAY.Rapid/IRapidClient.cs @@ -137,6 +137,20 @@ public interface IRapidClient /// SettlementSearchResponse SettlementSearchResponse SettlementSearch(SettlementSearchRequest settlementSearchRequest); + /// + /// To verify that the card is enrolled and to authenticate the results if it is enrolled. + /// + /// Request containing the transaction details + /// + Direct3DSEnrollResponse Direct3DSEnroll(Direct3DSEnrollRequest enrollRequest); + + /// + /// Request the validation service to verify the authentication message returned by the card-issuing bank. + /// + /// Containing the traceId and AccessCode + /// + Direct3DSVerifyResponse Direct3DSVerify(Direct3DSVerifyRequest verifyRequest); + /// /// True if the Client has valid API Key, Password and Endpoint Set. /// diff --git a/eWAY.Rapid/Internals/Mappings/RequestMapProfile.cs b/eWAY.Rapid/Internals/Mappings/RequestMapProfile.cs index ddf7b35..5fd3be2 100644 --- a/eWAY.Rapid/Internals/Mappings/RequestMapProfile.cs +++ b/eWAY.Rapid/Internals/Mappings/RequestMapProfile.cs @@ -58,6 +58,12 @@ public RequestMapProfile() { CreateMap(MemberList.None) .IncludeBase(); + + CreateMap(MemberList.None) + .ForMember(dest => dest.Customer, opt => opt.MapFrom(src => src.Customer)) + .ForMember(dest => dest.ShippingAddress, opt => opt.MapFrom(src => src.ShippingAddress)) + .ForMember(dest => dest.Payment, opt => opt.MapFrom(src => src.Payment)) + .ForMember(dest => dest.Items, opt => opt.MapFrom(src => src.Items)); } } } diff --git a/eWAY.Rapid/Internals/Mappings/ResponseMapProfile.cs b/eWAY.Rapid/Internals/Mappings/ResponseMapProfile.cs index 971c70e..f2f7af2 100644 --- a/eWAY.Rapid/Internals/Mappings/ResponseMapProfile.cs +++ b/eWAY.Rapid/Internals/Mappings/ResponseMapProfile.cs @@ -5,6 +5,7 @@ using eWAY.Rapid.Models; using BaseResponse = eWAY.Rapid.Internals.Response.BaseResponse; using Customer = eWAY.Rapid.Models.Customer; +using DirectTokenCustomer = eWAY.Rapid.Internals.Models.DirectTokenCustomer; namespace eWAY.Rapid.Internals.Mappings { internal class ResponseMapProfile : Profile { @@ -143,6 +144,14 @@ public ResponseMapProfile() { CreateMap(MemberList.Destination) .ForMember(dest => dest.Address, opt => opt.MapFrom(src => src)); + + CreateMap(MemberList.Destination) + .IncludeBase() + .ReverseMap(); + + CreateMap(MemberList.Destination) + .IncludeBase() + .ReverseMap(); } } } diff --git a/eWAY.Rapid/Internals/Models/Direct3DSecureAuth.cs b/eWAY.Rapid/Internals/Models/Direct3DSecureAuth.cs new file mode 100644 index 0000000..9061505 --- /dev/null +++ b/eWAY.Rapid/Internals/Models/Direct3DSecureAuth.cs @@ -0,0 +1,18 @@ +namespace eWAY.Rapid.Internals.Models +{ + internal class Direct3DSecureAuth + { + /// Cardholder Authentication Value + public string Cryptogram { get; set; } + /// Electronic Commerce Indicator + public string ECI { get; set; } + /// Transaction identifier resulting from authentication processing for 3DS V1 + public string XID { get; set; } + /// The result of the 3D Secure authentication + public string AuthStatus { get; set; } + /// Version of 3D Secure. + public string Version { get; set; } + /// Transaction Id for 3DS 2.0 + public string dsTransactionId { get; set; } + } +} \ No newline at end of file diff --git a/eWAY.Rapid/Internals/Models/DirectTokenCustomer.cs b/eWAY.Rapid/Internals/Models/DirectTokenCustomer.cs index a798dc7..bde8b7f 100644 --- a/eWAY.Rapid/Internals/Models/DirectTokenCustomer.cs +++ b/eWAY.Rapid/Internals/Models/DirectTokenCustomer.cs @@ -1,6 +1,6 @@ namespace eWAY.Rapid.Internals.Models { - internal class DirectTokenCustomer :TokenCustomer + internal class DirectTokenCustomer : TokenCustomer { public CardDetails CardDetails { get; set; } } diff --git a/eWAY.Rapid/Internals/RapidClient.cs b/eWAY.Rapid/Internals/RapidClient.cs index 0e6feac..5f4667a 100644 --- a/eWAY.Rapid/Internals/RapidClient.cs +++ b/eWAY.Rapid/Internals/RapidClient.cs @@ -243,6 +243,20 @@ public SettlementSearchResponse SettlementSearch(SettlementSearchRequest settlem return _mappingService.Map(response); } + public Direct3DSEnrollResponse Direct3DSEnroll(Direct3DSEnrollRequest enrollRequest) + { + var request = _mappingService.Map(enrollRequest); + var enrollResponse = _rapidService.ThreeDSEnroll(request); + return _mappingService.Map(enrollResponse); + } + + public Direct3DSVerifyResponse Direct3DSVerify(Direct3DSVerifyRequest verifyRequest) + { + var request = _mappingService.Map(verifyRequest); + var verifyResponse = _rapidService.ThreeDSVerify(request); + return _mappingService.Map(verifyResponse); + } + public bool IsValid { get diff --git a/eWAY.Rapid/Internals/Request/Direct3DSecureEnrollRequest.cs b/eWAY.Rapid/Internals/Request/Direct3DSecureEnrollRequest.cs new file mode 100644 index 0000000..475b54c --- /dev/null +++ b/eWAY.Rapid/Internals/Request/Direct3DSecureEnrollRequest.cs @@ -0,0 +1,15 @@ +using eWAY.Rapid.Internals.Models; +using System.Collections.Generic; + +namespace eWAY.Rapid.Internals.Request +{ + internal + class Direct3DSecureEnrollRequest : BaseRequest + { + public DirectTokenCustomer Customer { get; set; } + public ShippingAddress ShippingAddress { get; set; } + public List Items { get; set; } + public Payment Payment { get; set; } + public string RedirectUrl { get; set; } + } +} diff --git a/eWAY.Rapid/Internals/Request/Direct3DSecureVerifyRequest.cs b/eWAY.Rapid/Internals/Request/Direct3DSecureVerifyRequest.cs new file mode 100644 index 0000000..d2aca88 --- /dev/null +++ b/eWAY.Rapid/Internals/Request/Direct3DSecureVerifyRequest.cs @@ -0,0 +1,8 @@ +namespace eWAY.Rapid.Internals.Request +{ + internal class Direct3DSecureVerifyRequest : BaseRequest + { + public long TraceId { get; set; } + public string AccessCode { get; set; } + } +} diff --git a/eWAY.Rapid/Internals/Response/Direct3DSecureEnrollResponse.cs b/eWAY.Rapid/Internals/Response/Direct3DSecureEnrollResponse.cs new file mode 100644 index 0000000..4904370 --- /dev/null +++ b/eWAY.Rapid/Internals/Response/Direct3DSecureEnrollResponse.cs @@ -0,0 +1,9 @@ +namespace eWAY.Rapid.Internals.Response +{ + internal class Direct3DSecureEnrollResponse : BaseResponse + { + public string Default3dsUrl { get; set; } + public long TraceId { get; set; } + public string AccessCode { get; set; } + } +} diff --git a/eWAY.Rapid/Internals/Response/Direct3DSecureVerifyResponse.cs b/eWAY.Rapid/Internals/Response/Direct3DSecureVerifyResponse.cs new file mode 100644 index 0000000..662f0f6 --- /dev/null +++ b/eWAY.Rapid/Internals/Response/Direct3DSecureVerifyResponse.cs @@ -0,0 +1,11 @@ +using eWAY.Rapid.Internals.Models; + +namespace eWAY.Rapid.Internals.Response +{ + internal class Direct3DSecureVerifyResponse : BaseResponse + { + public string TraceId { get; set; } + public string AccessCode { get; set; } + public Direct3DSecureAuth ThreeDSecureAuth { get; set; } + } +} diff --git a/eWAY.Rapid/Internals/Services/IRapidService.cs b/eWAY.Rapid/Internals/Services/IRapidService.cs index 584bee3..8aeee6a 100644 --- a/eWAY.Rapid/Internals/Services/IRapidService.cs +++ b/eWAY.Rapid/Internals/Services/IRapidService.cs @@ -24,6 +24,8 @@ internal interface IRapidService TransactionSearchResponse QueryInvoiceRef(string invoiceRef); TransactionSearchResponse QueryInvoiceNumber(string invoiceNumber); DirectSettlementSearchResponse SettlementSearch(string request); + Direct3DSecureEnrollResponse ThreeDSEnroll(Direct3DSecureEnrollRequest request); + Direct3DSecureVerifyResponse ThreeDSVerify(Direct3DSecureVerifyRequest request); string GetRapidEndpoint(); void SetRapidEndpoint(string value); diff --git a/eWAY.Rapid/Internals/Services/RapidService.cs b/eWAY.Rapid/Internals/Services/RapidService.cs index 38ff370..f4a3f1e 100644 --- a/eWAY.Rapid/Internals/Services/RapidService.cs +++ b/eWAY.Rapid/Internals/Services/RapidService.cs @@ -35,6 +35,8 @@ internal class RapidService : IRapidService private const string TRANSACTION_FILTER_INVOICE_NUMBER = "Transaction/InvoiceNumber/{0}"; private const string TRANSACTION_FILTER_INVOICE_REF = "Transaction/InvoiceRef/{0}"; private const string SETTLEMENT_SEARCH = "Search/Settlement?{0}"; + private const string THREE_DS_ENROLL = "3dsenrol"; + private const string THREE_DS_VERIFY = "3dsverify"; public IMappingService MappingService { get; set; } @@ -144,6 +146,16 @@ public DirectSettlementSearchResponse SettlementSearch(string request) return JsonGet(method); } + public Direct3DSecureEnrollResponse ThreeDSEnroll(Direct3DSecureEnrollRequest request) + { + return JsonPost(request, THREE_DS_ENROLL); + } + + public Direct3DSecureVerifyResponse ThreeDSVerify(Direct3DSecureVerifyRequest request) + { + return JsonPost(request, THREE_DS_VERIFY); + } + public TResponse JsonPost(TRequest request, string method) where TRequest : class where TResponse : BaseResponse, new() diff --git a/eWAY.Rapid/Models/Direct3DSEnrollRequest.cs b/eWAY.Rapid/Models/Direct3DSEnrollRequest.cs new file mode 100644 index 0000000..6cebc90 --- /dev/null +++ b/eWAY.Rapid/Models/Direct3DSEnrollRequest.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; + +namespace eWAY.Rapid.Models +{ + /// + /// Enroll request for 3D Secure + /// + public class Direct3DSEnrollRequest + { + ///Contains members that define a Rapid token customer (and card) stored in the merchant's account. + public Customer Customer { get; set; } + /// Customer's Shipping address. + public ShippingAddress ShippingAddress { get; set; } + /// List of Line items for this transaction. + public List Items { get; set; } + /// Payment details + public PaymentDetails Payment { get; set; } + /// The url that will redirect to after enrolling. + public string RedirectUrl { get; set; } + } +} diff --git a/eWAY.Rapid/Models/Direct3DSEnrollResponse.cs b/eWAY.Rapid/Models/Direct3DSEnrollResponse.cs new file mode 100644 index 0000000..6f34cdf --- /dev/null +++ b/eWAY.Rapid/Models/Direct3DSEnrollResponse.cs @@ -0,0 +1,15 @@ +namespace eWAY.Rapid.Models +{ + /// + /// Direct 3D Secure response. + /// + public class Direct3DSEnrollResponse : BaseResponse + { + /// The default 3ds page if merchant doesn't want to use SDK in their checkout page directly. + public string Default3dsUrl { get; set; } + /// The traceId used for SDK if merchant want to use SDK in their checkout page. + public long TraceId { get; set; } + /// The accesscode used for SDK if merchant want to use SDK in their checkout page. + public string AccessCode { get; set; } + } +} diff --git a/eWAY.Rapid/Models/Direct3DSVerifyRequest.cs b/eWAY.Rapid/Models/Direct3DSVerifyRequest.cs new file mode 100644 index 0000000..5480cc1 --- /dev/null +++ b/eWAY.Rapid/Models/Direct3DSVerifyRequest.cs @@ -0,0 +1,13 @@ +namespace eWAY.Rapid.Models +{ + /// + /// 3DS verify request. + /// + public class Direct3DSVerifyRequest + { + /// The traceId returned by invoking 3ds enroll. + public long TraceId { get; set; } + /// The AccessCode returned by invoking 3ds enroll. + public string AccessCode { get; set; } + } +} diff --git a/eWAY.Rapid/Models/Direct3DSVerifyResponse.cs b/eWAY.Rapid/Models/Direct3DSVerifyResponse.cs new file mode 100644 index 0000000..7927c0b --- /dev/null +++ b/eWAY.Rapid/Models/Direct3DSVerifyResponse.cs @@ -0,0 +1,13 @@ +namespace eWAY.Rapid.Models +{ + /// + /// 3DS verify response. + /// + public class Direct3DSVerifyResponse : BaseResponse + { + /// + public string TraceId { get; set; } + public string AccessCode { get; set; } + public Direct3DSecureAuth ThreeDSecureAuth { get; set; } + } +} diff --git a/eWAY.Rapid/Models/Direct3DSecureAuth.cs b/eWAY.Rapid/Models/Direct3DSecureAuth.cs new file mode 100644 index 0000000..a8c5092 --- /dev/null +++ b/eWAY.Rapid/Models/Direct3DSecureAuth.cs @@ -0,0 +1,21 @@ +namespace eWAY.Rapid.Models +{ + /// + /// 3D Secure verify response + /// + public class Direct3DSecureAuth + { + /// Cardholder Authentication Value + public string Cryptogram { get; set; } + /// Electronic Commerce Indicator + public string ECI { get; set; } + /// Transaction identifier resulting from authentication processing for 3DS V1 + public string XID { get; set; } + /// The result of the 3D Secure authentication + public string AuthStatus { get; set; } + /// Version of 3D Secure. + public string Version { get; set; } + /// Transaction Id for 3DS 2.0 + public string dsTransactionId { get; set; } + } +} diff --git a/eWAY.Rapid/eWAY.Rapid.csproj b/eWAY.Rapid/eWAY.Rapid.csproj index 9917e2a..912682f 100644 --- a/eWAY.Rapid/eWAY.Rapid.csproj +++ b/eWAY.Rapid/eWAY.Rapid.csproj @@ -86,6 +86,7 @@ + @@ -103,6 +104,8 @@ + + @@ -117,6 +120,8 @@ + + @@ -130,6 +135,7 @@ + @@ -157,6 +163,10 @@ + + + + @@ -174,7 +184,9 @@ - + + Designer + From 07711f699c84fd2a350f0f12457b7511c1939bc0 Mon Sep 17 00:00:00 2001 From: azhang4 Date: Fri, 30 Oct 2020 12:03:58 +0800 Subject: [PATCH 2/5] Block some IT since these API it's not supported. --- eWAY.Rapid.Tests/IntegrationTests/Direct3DSEnrollTests.cs | 3 ++- eWAY.Rapid.Tests/IntegrationTests/Direct3DSVerifyTests.cs | 3 ++- eWAY.Rapid.Tests/IntegrationTests/SettlementSearchTests.cs | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/eWAY.Rapid.Tests/IntegrationTests/Direct3DSEnrollTests.cs b/eWAY.Rapid.Tests/IntegrationTests/Direct3DSEnrollTests.cs index e567160..45b35b2 100644 --- a/eWAY.Rapid.Tests/IntegrationTests/Direct3DSEnrollTests.cs +++ b/eWAY.Rapid.Tests/IntegrationTests/Direct3DSEnrollTests.cs @@ -3,7 +3,8 @@ namespace eWAY.Rapid.Tests.IntegrationTests { - [TestClass] + //Block the integration test beacuse rapid Sandbox is not support MPI now. + //[TestClass] public class Direct3DSEnrollTests : SdkTestBase { private IRapidClient _client; diff --git a/eWAY.Rapid.Tests/IntegrationTests/Direct3DSVerifyTests.cs b/eWAY.Rapid.Tests/IntegrationTests/Direct3DSVerifyTests.cs index ab3f6e8..357290c 100644 --- a/eWAY.Rapid.Tests/IntegrationTests/Direct3DSVerifyTests.cs +++ b/eWAY.Rapid.Tests/IntegrationTests/Direct3DSVerifyTests.cs @@ -3,7 +3,8 @@ namespace eWAY.Rapid.Tests.IntegrationTests { - [TestClass] + //Block the integration test beacuse rapid Sandbox is not support MPI now. + //[TestClass] public class Direct3DSVerifyTests : SdkTestBase { private IRapidClient _client; diff --git a/eWAY.Rapid.Tests/IntegrationTests/SettlementSearchTests.cs b/eWAY.Rapid.Tests/IntegrationTests/SettlementSearchTests.cs index 4604a1a..4031ff2 100644 --- a/eWAY.Rapid.Tests/IntegrationTests/SettlementSearchTests.cs +++ b/eWAY.Rapid.Tests/IntegrationTests/SettlementSearchTests.cs @@ -38,8 +38,8 @@ public void SettlementSearch_ByDateRange_Test() //Assert Assert.IsNotNull(settlementResponse); - Assert.IsTrue(settlementResponse.SettlementTransactions.Length > 1); - Assert.IsTrue(settlementResponse.SettlementSummaries.Length > 1); + Assert.IsTrue(settlementResponse.SettlementTransactions.Length >= 0); + Assert.IsTrue(settlementResponse.SettlementSummaries.Length >= 0); } [TestMethod] From 7ef542e205845328191ee6a6263131ce6d2b7287 Mon Sep 17 00:00:00 2001 From: azhang4 Date: Mon, 14 Dec 2020 16:36:17 +0800 Subject: [PATCH 3/5] Update the 3DS API --- CHANGELOG.md | 4 ++++ .../IntegrationTests/Direct3DSEnrollTests.cs | 2 +- .../IntegrationTests/Direct3DSVerifyTests.cs | 9 ++++++--- eWAY.Rapid.Tests/TestUtil.cs | 3 ++- eWAY.Rapid/Internals/Mappings/RequestMapProfile.cs | 3 ++- .../Internals/Request/Direct3DSecureEnrollRequest.cs | 1 + eWAY.Rapid/Models/Direct3DSEnrollRequest.cs | 4 ++++ 7 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cf8892..edb708d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All Notable changes will be documented in this file +## 1.6.3 + + - Update the SDK API to support Rapid 3D Secure enroll and verify. + ## 1.6.2 - Change default TransactionType to MOTO when creating a Token Customer. diff --git a/eWAY.Rapid.Tests/IntegrationTests/Direct3DSEnrollTests.cs b/eWAY.Rapid.Tests/IntegrationTests/Direct3DSEnrollTests.cs index 45b35b2..576bd3c 100644 --- a/eWAY.Rapid.Tests/IntegrationTests/Direct3DSEnrollTests.cs +++ b/eWAY.Rapid.Tests/IntegrationTests/Direct3DSEnrollTests.cs @@ -4,7 +4,7 @@ namespace eWAY.Rapid.Tests.IntegrationTests { //Block the integration test beacuse rapid Sandbox is not support MPI now. - //[TestClass] + [TestClass] public class Direct3DSEnrollTests : SdkTestBase { private IRapidClient _client; diff --git a/eWAY.Rapid.Tests/IntegrationTests/Direct3DSVerifyTests.cs b/eWAY.Rapid.Tests/IntegrationTests/Direct3DSVerifyTests.cs index 357290c..4b3a202 100644 --- a/eWAY.Rapid.Tests/IntegrationTests/Direct3DSVerifyTests.cs +++ b/eWAY.Rapid.Tests/IntegrationTests/Direct3DSVerifyTests.cs @@ -4,7 +4,7 @@ namespace eWAY.Rapid.Tests.IntegrationTests { //Block the integration test beacuse rapid Sandbox is not support MPI now. - //[TestClass] + [TestClass] public class Direct3DSVerifyTests : SdkTestBase { private IRapidClient _client; @@ -24,16 +24,19 @@ public void Verify_Returns_Valid_Response() Assert.AreNotEqual(0, response.TraceId); Assert.IsNotNull(response.AccessCode); Assert.IsNotNull(response.ThreeDSecureAuth); - Assert.IsNull(response.Errors); + //Before verify, need to go to Direct3DSUrl to initialize the request, if not, will return D4417 + Assert.IsNotNull(response.Errors); + Assert.AreEqual("D4417", response.Errors[0]); } + [TestMethod] public void Verify_Returns_Errors_Invalid_Response() { var request = Generate3DSVerifyRequest(); request.TraceId = 0; var response = _client.Direct3DSVerify(request); - Assert.AreEqual(0, response.TraceId); + Assert.AreEqual("0", response.TraceId); Assert.IsNull(response.AccessCode); Assert.IsNull(response.ThreeDSecureAuth); Assert.IsNotNull(response.Errors); diff --git a/eWAY.Rapid.Tests/TestUtil.cs b/eWAY.Rapid.Tests/TestUtil.cs index 8e0f1fe..190940c 100644 --- a/eWAY.Rapid.Tests/TestUtil.cs +++ b/eWAY.Rapid.Tests/TestUtil.cs @@ -324,7 +324,8 @@ internal static Direct3DSEnrollRequest CreateEnrollRequest() TotalAmount = 1000, CurrencyCode = "AUD" }, - RedirectUrl = "http://www.ewaypayments.com" + RedirectUrl = "http://www.ewaypayments.com", + SecuredCardData = "" }; } diff --git a/eWAY.Rapid/Internals/Mappings/RequestMapProfile.cs b/eWAY.Rapid/Internals/Mappings/RequestMapProfile.cs index 5fd3be2..ebdd854 100644 --- a/eWAY.Rapid/Internals/Mappings/RequestMapProfile.cs +++ b/eWAY.Rapid/Internals/Mappings/RequestMapProfile.cs @@ -63,7 +63,8 @@ public RequestMapProfile() { .ForMember(dest => dest.Customer, opt => opt.MapFrom(src => src.Customer)) .ForMember(dest => dest.ShippingAddress, opt => opt.MapFrom(src => src.ShippingAddress)) .ForMember(dest => dest.Payment, opt => opt.MapFrom(src => src.Payment)) - .ForMember(dest => dest.Items, opt => opt.MapFrom(src => src.Items)); + .ForMember(dest => dest.Items, opt => opt.MapFrom(src => src.Items)) + .ForMember(dest => dest.SecuredCardData, opt => opt.MapFrom(src => src.SecuredCardData)); } } } diff --git a/eWAY.Rapid/Internals/Request/Direct3DSecureEnrollRequest.cs b/eWAY.Rapid/Internals/Request/Direct3DSecureEnrollRequest.cs index 475b54c..b3a553e 100644 --- a/eWAY.Rapid/Internals/Request/Direct3DSecureEnrollRequest.cs +++ b/eWAY.Rapid/Internals/Request/Direct3DSecureEnrollRequest.cs @@ -11,5 +11,6 @@ class Direct3DSecureEnrollRequest : BaseRequest public List Items { get; set; } public Payment Payment { get; set; } public string RedirectUrl { get; set; } + public string SecuredCardData { get; set; } } } diff --git a/eWAY.Rapid/Models/Direct3DSEnrollRequest.cs b/eWAY.Rapid/Models/Direct3DSEnrollRequest.cs index 6cebc90..39bbeca 100644 --- a/eWAY.Rapid/Models/Direct3DSEnrollRequest.cs +++ b/eWAY.Rapid/Models/Direct3DSEnrollRequest.cs @@ -17,5 +17,9 @@ public class Direct3DSEnrollRequest public PaymentDetails Payment { get; set; } /// The url that will redirect to after enrolling. public string RedirectUrl { get; set; } + /// + /// ID for any third party (or internal) secure card store. VisaCheckout, Amex, or Secure Fields + /// + public string SecuredCardData { get; set; } } } From 5c18bab11ec2600feb7cf83c913fc31e84168a9e Mon Sep 17 00:00:00 2001 From: azhang4 Date: Mon, 14 Dec 2020 17:16:16 +0800 Subject: [PATCH 4/5] Update version number --- eWAY.Rapid.Tests/Properties/AssemblyInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eWAY.Rapid.Tests/Properties/AssemblyInfo.cs b/eWAY.Rapid.Tests/Properties/AssemblyInfo.cs index 8a7ecd7..c635070 100644 --- a/eWAY.Rapid.Tests/Properties/AssemblyInfo.cs +++ b/eWAY.Rapid.Tests/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.6.2.0")] -[assembly: AssemblyFileVersion("1.6.2.0")] +[assembly: AssemblyVersion("1.6.3.0")] +[assembly: AssemblyFileVersion("1.6.3.0")] From 7d1bd7ba39929b5a6b60789558c23454d990e2ca Mon Sep 17 00:00:00 2001 From: azhang4 Date: Mon, 14 Dec 2020 17:37:48 +0800 Subject: [PATCH 5/5] Update AssemblyVersion --- eWAY.Rapid/Properties/AssemblyInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eWAY.Rapid/Properties/AssemblyInfo.cs b/eWAY.Rapid/Properties/AssemblyInfo.cs index 115ad52..9964b52 100644 --- a/eWAY.Rapid/Properties/AssemblyInfo.cs +++ b/eWAY.Rapid/Properties/AssemblyInfo.cs @@ -32,8 +32,8 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.6.2.0")] -[assembly: AssemblyFileVersion("1.6.2.0")] +[assembly: AssemblyVersion("1.6.3.0")] +[assembly: AssemblyFileVersion("1.6.3.0")] [assembly: InternalsVisibleTo("eWAY.Rapid.Tests,PublicKey=00240000048000009400000006020000002400005253413100040000010001001fa88da23161933c177ff28430a896e9dc1d184b788db49eed5f7a6c101ed7cd4820b80a0f22949cc0077c5fa00d7c575a678e145d35f391caf1ec747a00602fc86df22717d7c0ee5fe4607f0c64ac2b99aa6d81198d7d308db51f457576d541e2318d58f3b54859a6ee60154193472f9d8a1bfdae9c16f26aa755d658d8f0f5")] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2,PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]