public void FullCycle_v1() { CreditCardData card = new CreditCardData { Number = "4012001037141112", ExpMonth = 12, ExpYear = 2025, CardHolderName = "John Smith" }; ThreeDSecure secureEcom = Secure3dService.CheckEnrollment(card) .WithAmount(1m) .WithCurrency("USD") .Execute(Secure3dVersion.One); Assert.AreEqual(Secure3dVersion.One, secureEcom.Version); if (secureEcom.Enrolled.Equals("Y")) { // authenticate ThreeDSecureAcsClient authClient = new ThreeDSecureAcsClient(secureEcom.IssuerAcsUrl); var authResponse = authClient.Authenticate(secureEcom.PayerAuthenticationRequest, secureEcom.MerchantData.ToString()); string payerAuthenticationResponse = authResponse.pares; MerchantDataCollection md = MerchantDataCollection.Parse(authResponse.md); // verify signature through the service and affix to the card object secureEcom = Secure3dService.GetAuthenticationData() .WithPayerAuthenticationResponse(payerAuthenticationResponse) .WithMerchantData(md) .Execute(); card.ThreeDSecure = secureEcom; if (secureEcom.Status.Equals("Y")) { Transaction response = card.Charge().Execute(); Assert.IsNotNull(response); Assert.AreEqual("00", response.ResponseCode); } else { Assert.Fail("Signature verification Assert.Failed."); } } else { Assert.Fail("Card not enrolled."); } }
public void FullCycle_Any() { ThreeDSecure secureEcom = Secure3dService.CheckEnrollment(card) .WithAmount(1m) .WithCurrency("USD") .Execute(Secure3dVersion.Any); Assert.IsNotNull(secureEcom); if (secureEcom.Enrolled.Equals("True")) { if (secureEcom.Version.Equals(Secure3dVersion.Two)) { // initiate authentication ThreeDSecure initAuth = Secure3dService.InitiateAuthentication(card, secureEcom) .WithAmount(10.01m) .WithCurrency("USD") .WithOrderCreateDate(DateTime.Now) .WithAddress(billingAddress, AddressType.Billing) .WithAddress(shippingAddress, AddressType.Shipping) .WithBrowserData(browserData) .Execute(); Assert.IsNotNull(initAuth); // get authentication data secureEcom = Secure3dService.GetAuthenticationData() .WithServerTransactionId(initAuth.ServerTransactionId) .Execute(); card.ThreeDSecure = secureEcom; if (secureEcom.Status.Equals("AUTHENTICATION_SUCCESSFUL")) { Transaction response = card.Charge(10.01m) .WithCurrency("USD") .Execute(); Assert.IsNotNull(response); Assert.AreEqual("00", response.ResponseCode); } else { Assert.Fail("Signature verification Assert.Failed."); } } else { // authenticate ThreeDSecureAcsClient authClient = new ThreeDSecureAcsClient(secureEcom.IssuerAcsUrl); var authResponse = authClient.Authenticate(secureEcom.PayerAuthenticationRequest, secureEcom.MerchantData.ToString()); string payerAuthenticationResponse = authResponse.getAuthResponse(); MerchantDataCollection md = MerchantDataCollection.Parse(authResponse.getMerchantData()); // verify signature through the service and affix to the card object secureEcom = Secure3dService.GetAuthenticationData() .WithPayerAuthenticationResponse(payerAuthenticationResponse) .WithMerchantData(md) .Execute(); card.ThreeDSecure = secureEcom; if (secureEcom.Status.Equals("Y")) { Transaction response = card.Charge().Execute(); Assert.IsNotNull(response); Assert.AreEqual("00", response.ResponseCode); } else { Assert.Fail("Signature verification Assert.Failed."); } } } else { Assert.Fail("Card not enrolled."); } }