public void CardHolderEnrolled_ChallengeRequired_AuthenticationSuccessful_FullCycle_v1() { card.Number = GpApi3DSTestCards.CARDHOLDER_ENROLLED_V1; var secureEcom = Secure3dService.CheckEnrollment(card) .WithCurrency(Currency) .WithAmount(Amount) .WithAuthenticationSource(AuthenticationSource.BROWSER) .WithChallengeRequestIndicator(ChallengeRequestIndicator.CHALLENGE_MANDATED) .WithStoredCredential(new StoredCredential { Initiator = StoredCredentialInitiator.CardHolder, Type = StoredCredentialType.Unscheduled, Sequence = StoredCredentialSequence.First, Reason = StoredCredentialReason.NoShow }) .Execute(); Assert.IsNotNull(secureEcom); Assert.AreEqual(ENROLLED, secureEcom.Enrolled, "Card not enrolled"); Assert.AreEqual(Secure3dVersion.One, secureEcom.Version); Assert.AreEqual(CHALLENGE_REQUIRED, secureEcom.Status); Assert.IsTrue(secureEcom.ChallengeMandated); Assert.IsNotNull(secureEcom.IssuerAcsUrl); Assert.IsNotNull(secureEcom.PayerAuthenticationRequest); Assert.IsNotNull(secureEcom.ChallengeReturnUrl); Assert.IsNotNull(secureEcom.MessageType); Assert.IsNotNull(secureEcom.SessionDataFieldName); // Perform ACS authentication GpApi3DSecureAcsClient acsClient = new GpApi3DSecureAcsClient(secureEcom.IssuerAcsUrl); string payerAuthenticationResponse; string authResponse = acsClient.Authenticate_v1(secureEcom, out payerAuthenticationResponse); Assert.AreEqual("{\"success\":true}", authResponse); // Get authentication data secureEcom = Secure3dService.GetAuthenticationData() .WithServerTransactionId(secureEcom.ServerTransactionId) .WithPayerAuthenticationResponse(payerAuthenticationResponse) .Execute(); Assert.IsNotNull(secureEcom); Assert.AreEqual(SUCCESS_AUTHENTICATED, secureEcom.Status); Assert.AreEqual("YES", secureEcom.LiabilityShift); card.ThreeDSecure = secureEcom; // Create transaction var response = card.Charge(Amount) .WithCurrency(Currency) .Execute(); Assert.IsNotNull(response); Assert.AreEqual(SUCCESS, response?.ResponseCode); Assert.AreEqual(GetMapping(TransactionStatus.Captured), response?.ResponseMessage); }
public void CardHolderEnrolled_ChallengeRequired_AuthenticationSuccessful_FullCycle_v1_WithTokenizedPaymentMethod() { card.Number = GpApi3DSTestCards.CARDHOLDER_ENROLLED_V1; // Tokenize payment method var tokenizedCard = new CreditCardData { Token = card.Tokenize() }; Assert.IsNotNull(tokenizedCard.Token); // Check enrollment var secureEcom = Secure3dService.CheckEnrollment(tokenizedCard) .WithCurrency(Currency) .WithAmount(Amount) .Execute(); Assert.IsNotNull(secureEcom); Assert.AreEqual(ENROLLED, secureEcom.Enrolled, "Card not enrolled"); Assert.AreEqual(Secure3dVersion.One, secureEcom.Version); Assert.AreEqual(CHALLENGE_REQUIRED, secureEcom.Status); Assert.IsTrue(secureEcom.ChallengeMandated); Assert.IsNotNull(secureEcom.IssuerAcsUrl); Assert.IsNotNull(secureEcom.PayerAuthenticationRequest); Assert.IsNotNull(secureEcom.ChallengeReturnUrl); Assert.IsNotNull(secureEcom.MessageType); Assert.IsNotNull(secureEcom.SessionDataFieldName); // Perform ACS authentication GpApi3DSecureAcsClient acsClient = new GpApi3DSecureAcsClient(secureEcom.IssuerAcsUrl); string payerAuthenticationResponse; string authResponse = acsClient.Authenticate_v1(secureEcom, out payerAuthenticationResponse); Assert.AreEqual("{\"success\":true}", authResponse); // Get authentication data secureEcom = Secure3dService.GetAuthenticationData() .WithServerTransactionId(secureEcom.ServerTransactionId) .WithPayerAuthenticationResponse(payerAuthenticationResponse) .Execute(); Assert.IsNotNull(secureEcom); Assert.AreEqual(SUCCESS_AUTHENTICATED, secureEcom.Status); Assert.AreEqual("YES", secureEcom.LiabilityShift); tokenizedCard.ThreeDSecure = secureEcom; // Create transaction var response = tokenizedCard.Charge(Amount) .WithCurrency(Currency) .Execute(); Assert.IsNotNull(response); Assert.AreEqual(SUCCESS, response?.ResponseCode); Assert.AreEqual(GetMapping(TransactionStatus.Captured), response?.ResponseMessage); }
public void CardHolderEnrolled_ChallengeRequired_v2_Refund() { var secureEcom = Secure3dService.CheckEnrollment(card) .WithCurrency(Currency) .WithAmount(Amount) .WithTransactionType(TransactionType.Refund) .Execute(); AssertThreeDSResponse(secureEcom, AVAILABLE); }
public void CardHolderEnrolled_ChallengeRequired_v1() { var secureEcom = Secure3dService.CheckEnrollment(card) .WithCurrency(Currency) .WithAmount(Amount) .WithAuthenticationSource(AuthenticationSource.BROWSER) .Execute(); AssertThreeDSResponse(secureEcom, CHALLENGE_REQUIRED); }
public void CardHolderEnrolled_ChallengeRequired_v2_AllEntryModes() { var secureEcom = Secure3dService.CheckEnrollment(card) .WithCurrency(Currency) .WithAmount(Amount) .Execute(); AssertThreeDSResponse(secureEcom, AVAILABLE); Assert.IsFalse(secureEcom.ChallengeMandated); }
public void FrictionlessFullCycle_v2_WithTokenizedPaymentMethod() { card.Number = GpApi3DSTestCards.CARD_AUTH_SUCCESSFUL_V2_1; // Tokenize payment method var tokenizedCard = new CreditCardData() { Token = card.Tokenize() }; Assert.IsNotNull(tokenizedCard.Token); // Check enrollment var secureEcom = Secure3dService.CheckEnrollment(tokenizedCard) .WithCurrency(Currency) .WithAmount(Amount) .Execute(); Assert.IsNotNull(secureEcom); Assert.AreEqual(ENROLLED, secureEcom.Enrolled, "Card not enrolled"); Assert.AreEqual(Secure3dVersion.Two, secureEcom.Version); Assert.AreEqual(AVAILABLE, secureEcom.Status); // Initiate authentication var initAuth = Secure3dService.InitiateAuthentication(tokenizedCard, secureEcom) .WithAmount(Amount) .WithCurrency(Currency) .WithAuthenticationSource(AuthenticationSource.BROWSER) .WithMethodUrlCompletion(MethodUrlCompletion.YES) .WithOrderCreateDate(DateTime.Now) .WithAddress(shippingAddress, AddressType.Shipping) .WithBrowserData(browserData) .Execute(); Assert.IsNotNull(initAuth); Assert.AreEqual(SUCCESS_AUTHENTICATED, initAuth.Status); // Get authentication data secureEcom = Secure3dService.GetAuthenticationData() .WithServerTransactionId(initAuth.ServerTransactionId) .Execute(); Assert.AreEqual(SUCCESS_AUTHENTICATED, secureEcom.Status); tokenizedCard.ThreeDSecure = secureEcom; // Create transaction Transaction response = tokenizedCard.Charge(Amount) .WithCurrency(Currency) .Execute(); Assert.IsNotNull(response); Assert.AreEqual(SUCCESS, response?.ResponseCode); Assert.AreEqual(GetMapping(TransactionStatus.Captured), response?.ResponseMessage); }
public void OptionalPriorAuthenticationData() { // check enrollment ThreeDSecure secureEcom = Secure3dService.CheckEnrollment(card) .Execute(Secure3dVersion.Two); Assert.IsNotNull(secureEcom); if (secureEcom.Enrolled.Equals("True")) { Assert.AreEqual(Secure3dVersion.Two, secureEcom.Version); // initiate authentication ThreeDSecure initAuth = Secure3dService.InitiateAuthentication(card, secureEcom) .WithAmount(250m) .WithCurrency("USD") .WithOrderCreateDate(DateTime.Now) .WithAddress(billingAddress, AddressType.Billing) .WithAddress(shippingAddress, AddressType.Shipping) .WithBrowserData(browserData) .WithMethodUrlCompletion(MethodUrlCompletion.NO) // optionals .WithPriorAuthenticationMethod(PriorAuthenticationMethod.FRICTIONLESS_AUTHENTICATION) .WithPriorAuthenticationTransactionId("26c3f619-39a4-4040-bf1f-6fd433e6d615") .WithPriorAuthenticationTimestamp(DateTime.Parse("2019-01-10T12:57:33.333Z")) .WithPriorAuthenticationData("string") .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 failed."); } } else { Assert.Fail("Card not enrolled."); } }
public void OptionalRecurringData() { // check enrollment ThreeDSecure secureEcom = Secure3dService.CheckEnrollment(card) .Execute(Secure3dVersion.Two); Assert.IsNotNull(secureEcom); if (secureEcom.Enrolled.Equals("True")) { Assert.AreEqual(Secure3dVersion.Two, secureEcom.Version); // initiate authentication ThreeDSecure initAuth = Secure3dService.InitiateAuthentication(card, secureEcom) .WithAmount(250m) .WithCurrency("USD") .WithOrderCreateDate(DateTime.Now) .WithAddress(billingAddress, AddressType.Billing) .WithAddress(shippingAddress, AddressType.Shipping) .WithBrowserData(browserData) .WithMethodUrlCompletion(MethodUrlCompletion.NO) // optionals .WithMaxNumberOfInstallments(5) .WithRecurringAuthorizationFrequency(25) .WithRecurringAuthorizationExpiryDate(DateTime.Parse("2019-08-25")) .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 failed."); } } else { Assert.Fail("Card not enrolled."); } }
public void OptionalPayerLoginData() { // check enrollment ThreeDSecure secureEcom = Secure3dService.CheckEnrollment(card) .Execute(Secure3dVersion.Two); Assert.IsNotNull(secureEcom); if (secureEcom.Enrolled.Equals("True")) { Assert.AreEqual(Secure3dVersion.Two, secureEcom.Version); // initiate authentication ThreeDSecure initAuth = Secure3dService.InitiateAuthentication(card, secureEcom) .WithAmount(250m) .WithCurrency("USD") .WithOrderCreateDate(DateTime.Now) .WithAddress(billingAddress, AddressType.Billing) .WithAddress(shippingAddress, AddressType.Shipping) .WithBrowserData(browserData) .WithMethodUrlCompletion(MethodUrlCompletion.NO) // optionals .WithCustomerAuthenticationData("string") .WithCustomerAuthenticationTimestamp(DateTime.Parse("2019-01-28T12:57:33.333Z")) //, DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"))) .WithCustomerAuthenticationMethod(CustomerAuthenticationMethod.MERCHANT_SYSTEM_AUTHENTICATION) .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 failed."); } } else { Assert.Fail("Card not enrolled."); } }
public void FrictionlessFullCycle_v2_DifferentAmount() { card.Number = GpApi3DSTestCards.CARD_AUTH_SUCCESSFUL_V2_2; // Check enrollment var secureEcom = Secure3dService.CheckEnrollment(card) .WithCurrency(Currency) .WithAmount(15) .Execute(); Assert.IsNotNull(secureEcom); Assert.AreEqual(ENROLLED, secureEcom.Enrolled, "Card not enrolled"); Assert.AreEqual(Secure3dVersion.Two, secureEcom.Version); Assert.AreEqual(AVAILABLE, secureEcom.Status); // Assert.AreEqual(1500, secureEcom.Amount); // Initiate authentication var initAuth = Secure3dService.InitiateAuthentication(card, secureEcom) .WithAmount(10) .WithCurrency("EUR") .WithAuthenticationSource(AuthenticationSource.BROWSER) .WithMethodUrlCompletion(MethodUrlCompletion.YES) .WithOrderCreateDate(DateTime.Now) .WithAddress(shippingAddress, AddressType.Shipping) .WithBrowserData(browserData) .Execute(); Assert.IsNotNull(initAuth); Assert.AreEqual(SUCCESS_AUTHENTICATED, initAuth.Status); Assert.AreEqual("YES", secureEcom.LiabilityShift); // Assert.AreEqual(1500, secureEcom.Amount); // Assert.AreEqual(Currency, secureEcom.Currency); // Get authentication data secureEcom = Secure3dService.GetAuthenticationData() .WithServerTransactionId(initAuth.ServerTransactionId) .Execute(); Assert.AreEqual(SUCCESS_AUTHENTICATED, secureEcom.Status); Assert.AreEqual("YES", secureEcom.LiabilityShift); // Assert.AreEqual(1500, secureEcom.Amount); // Assert.AreEqual(Currency, secureEcom.Currency); card.ThreeDSecure = secureEcom; // Create transaction var response = card.Charge(15) .WithCurrency(Currency) .Execute(); Assert.IsNotNull(response); Assert.AreEqual(SUCCESS, response?.ResponseCode); Assert.AreEqual(GetMapping(TransactionStatus.Captured), response?.ResponseMessage); }
public void FullCycle_v2() { // check enrollment ThreeDSecure secureEcom = Secure3dService.CheckEnrollment(card) .Execute(); Assert.IsNotNull(secureEcom); // create card data card.ExpMonth = 12; card.ExpYear = 2025; card.CardHolderName = "John Smith"; if (secureEcom.Enrolled.Equals("True")) { Assert.AreEqual(Secure3dVersion.Two, secureEcom.Version); // initiate authentication ThreeDSecure initAuth = Secure3dService.InitiateAuthentication(card, secureEcom) .WithAmount(10.01m) .WithCurrency("GBP") //.WithChallengeRequestIndicator(ChallengeRequestIndicator.NO_PREFERENCE) .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 { Assert.Fail("Card not enrolled."); } }
public void CardHolderEnrolled_Frictionless_v2() { card.Number = GpApi3DSTestCards.CARD_AUTH_SUCCESSFUL_V2_1; var secureEcom = Secure3dService.CheckEnrollment(card) .WithCurrency(Currency) .WithAmount(Amount) .Execute(); AssertThreeDSResponse(secureEcom, AVAILABLE); Assert.IsFalse(secureEcom.ChallengeMandated); }
public void FullCycle_v2_EOS_ApplyExemption() { // check enrollment ThreeDSecure secureEcom = Secure3dService.CheckEnrollment(card) .Execute(Secure3dVersion.Two); Assert.IsNotNull(secureEcom); if (secureEcom.Enrolled.Equals("True")) { Assert.AreEqual(Secure3dVersion.Two, secureEcom.Version); // initiate authentication ThreeDSecure initAuth = Secure3dService.InitiateAuthentication(card, secureEcom) .WithAmount(10.01m) .WithCurrency("EUR") .WithOrderCreateDate(DateTime.Now) .WithAddress(billingAddress, AddressType.Billing) .WithAddress(shippingAddress, AddressType.Shipping) .WithBrowserData(browserData) .WithEnableExemptionOptimization(true) .Execute(); Assert.IsNotNull(initAuth); Assert.AreEqual(ExemptReason.APPLY_EXEMPTION.ToString(), initAuth.ExemptReason); Assert.AreEqual(ExemptStatus.TRANSACTION_RISK_ANALYSIS, initAuth.ExemptStatus); // 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("EUR") .Execute(); Assert.IsNotNull(response); Assert.AreEqual("00", response.ResponseCode); } else { Assert.Fail("Signature verification Assert.Failed."); } } else { Assert.Fail("Card not enrolled."); } }
public void CardHolderEnrolled_ChallengeRequired_v1_AllSourceValues() { foreach (AuthenticationSource source in Enum.GetValues(typeof(AuthenticationSource))) { var secureEcom = Secure3dService.CheckEnrollment(card) .WithCurrency(Currency) .WithAmount(Amount) .WithAuthenticationSource(source) .Execute(); AssertThreeDSResponse(secureEcom, CHALLENGE_REQUIRED); } }
public void CardHolderEnrolled_ChallengeRequired_v2_Initiate_With_IdempotencyKey() { var idempotencyKey = Guid.NewGuid().ToString(); var secureEcom = Secure3dService.CheckEnrollment(card) .WithCurrency(Currency) .WithAmount(Amount) .Execute(); AssertThreeDSResponse(secureEcom, AVAILABLE); var initAuth = Secure3dService.InitiateAuthentication(card, secureEcom) .WithAmount(Amount) .WithCurrency(Currency) .WithAuthenticationSource(AuthenticationSource.BROWSER) .WithMethodUrlCompletion(MethodUrlCompletion.YES) .WithIdempotencyKey(idempotencyKey) .WithOrderCreateDate(DateTime.Now) .WithAddress(shippingAddress, AddressType.Shipping) .WithBrowserData(browserData) .Execute(); AssertThreeDSResponse(initAuth, CHALLENGE_REQUIRED); Assert.IsTrue(initAuth.ChallengeMandated); var exceptionCaught = false; try { Secure3dService.InitiateAuthentication(card, secureEcom) .WithAmount(Amount) .WithCurrency(Currency) .WithAuthenticationSource(AuthenticationSource.BROWSER) .WithMethodUrlCompletion(MethodUrlCompletion.YES) .WithIdempotencyKey(idempotencyKey) .WithOrderCreateDate(DateTime.Now) .WithAddress(shippingAddress, AddressType.Shipping) .WithBrowserData(browserData) .Execute(); } catch (GatewayException ex) { exceptionCaught = true; Assert.AreEqual("40039", ex.ResponseMessage); Assert.AreEqual("DUPLICATE_ACTION", ex.ResponseCode); Assert.AreEqual( "Status Code: Conflict - Idempotency Key seen before: id=" + secureEcom.ServerTransactionId + ", status=CHALLENGE_REQUIRED", ex.Message); } finally { Assert.IsTrue(exceptionCaught); } }
public void FrictionlessFullCycle_v2_Failed(string cardNumber, string status) { card.Number = cardNumber; // Check enrollment var secureEcom = Secure3dService.CheckEnrollment(card) .WithCurrency(Currency) .WithAmount(Amount) .Execute(); Assert.IsNotNull(secureEcom); Assert.AreEqual(ENROLLED, secureEcom.Enrolled, "Card not enrolled"); Assert.AreEqual(Secure3dVersion.Two, secureEcom.Version); Assert.AreEqual(AVAILABLE, secureEcom.Status); // Initiate authentication var initAuth = Secure3dService.InitiateAuthentication(card, secureEcom) .WithAmount(Amount) .WithCurrency(Currency) .WithAuthenticationSource(AuthenticationSource.BROWSER) .WithMethodUrlCompletion(MethodUrlCompletion.YES) .WithOrderCreateDate(DateTime.Now) .WithAddress(shippingAddress, AddressType.Shipping) .WithBrowserData(browserData) .Execute(); Assert.IsNotNull(initAuth); Assert.AreEqual(status, initAuth.Status); // Get authentication data secureEcom = Secure3dService.GetAuthenticationData() .WithServerTransactionId(initAuth.ServerTransactionId) .Execute(); Assert.AreEqual(status, secureEcom.Status); string liabilityShift = status == "SUCCESS_ATTEMPT_MADE" ? "YES" : "NO"; Assert.AreEqual(liabilityShift, secureEcom.LiabilityShift); card.ThreeDSecure = secureEcom; // Create transaction var response = card.Charge(Amount) .WithCurrency(Currency) .Execute(); Assert.IsNotNull(response); Assert.AreEqual(SUCCESS, response?.ResponseCode); Assert.AreEqual(GetMapping(TransactionStatus.Captured), response?.ResponseMessage); }
public void CardHolderEnrolled_ChallengeRequired_v2_AllPreferenceValues() { foreach (ChallengeRequestIndicator preference in Enum.GetValues(typeof(ChallengeRequestIndicator))) { var secureEcom = Secure3dService.CheckEnrollment(card) .WithCurrency(Currency) .WithAmount(Amount) .WithChallengeRequestIndicator(preference) .Execute(); AssertThreeDSResponse(secureEcom, AVAILABLE); Assert.IsFalse(secureEcom.ChallengeMandated); } }
public void CardHolderEnrolled_v1_PostResult_WithIdempotencyKey() { var idempotencyKey = Guid.NewGuid().ToString(); var secureEcom = Secure3dService.CheckEnrollment(card) .WithCurrency(Currency) .WithAmount(Amount) .WithAuthenticationSource(AuthenticationSource.BROWSER) .Execute(); AssertThreeDSResponse(secureEcom, CHALLENGE_REQUIRED); // Perform ACS authetication var acsClient = new GpApi3DSecureAcsClient(secureEcom.IssuerAcsUrl); string payerAuthenticationResponse; string authResponse = acsClient.Authenticate_v1(secureEcom, out payerAuthenticationResponse); Assert.AreEqual("{\"success\":true}", authResponse); // Get authentication data secureEcom = Secure3dService.GetAuthenticationData() .WithServerTransactionId(secureEcom.ServerTransactionId) .WithPayerAuthenticationResponse(payerAuthenticationResponse) .WithIdempotencyKey(idempotencyKey) .Execute(); Assert.IsNotNull(secureEcom); Assert.AreEqual(AUTHENTICATION_SUCCESSFUL, secureEcom.Status); var exceptionCaught = false; try { secureEcom = Secure3dService.GetAuthenticationData() .WithServerTransactionId(secureEcom.ServerTransactionId) .WithPayerAuthenticationResponse(payerAuthenticationResponse) .WithIdempotencyKey(idempotencyKey) .Execute(); } catch (GatewayException ex) { exceptionCaught = true; Assert.AreEqual("40039", ex.ResponseMessage); Assert.AreEqual("DUPLICATE_ACTION", ex.ResponseCode); Assert.AreEqual( "Status Code: Conflict - Idempotency Key seen before: id=" + secureEcom.ServerTransactionId + ", status=AUTHENTICATION_SUCCESSFUL", ex.Message); } finally { Assert.IsTrue(exceptionCaught); } }
public void CardHolderEnrolled_ChallengeRequired_v2_AllSources() { foreach (AuthenticationSource source in Enum.GetValues(typeof(AuthenticationSource))) { var secureEcom = Secure3dService.CheckEnrollment(card) .WithCurrency(Currency) .WithAmount(Amount) .WithAuthenticationSource(source) .Execute(); AssertThreeDSResponse(secureEcom, AVAILABLE); Assert.IsFalse(secureEcom.ChallengeMandated); } }
public void FullCycle_v2_with_phone_number_validation() { // check enrollment ThreeDSecure secureEcom = Secure3dService.CheckEnrollment(card) .Execute(Secure3dVersion.Two); Assert.IsNotNull(secureEcom); if (secureEcom.Enrolled.Equals("True")) { Assert.AreEqual(Secure3dVersion.Two, secureEcom.Version); // initiate authentication ThreeDSecure initAuth = Secure3dService.InitiateAuthentication(card, secureEcom) .WithAmount(10.01m) .WithCurrency("USD") .WithMobileNumber("+54", "(0341) 156-123456") .WithHomeNumber("+54", "(0341) 156-456789") .WithWorkNumber("+54", "(0341) 156-654321") .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 { Assert.Fail("Card not enrolled."); } }
public void CardHolderEnrolled_ChallengeRequired_v1_TokenizedCard() { var tokenizedCard = new CreditCardData { Token = card.Tokenize() }; Assert.IsNotNull(tokenizedCard.Token); var secureEcom = Secure3dService.CheckEnrollment(tokenizedCard) .WithCurrency(Currency) .WithAmount(Amount) .Execute(); AssertThreeDSResponse(secureEcom, CHALLENGE_REQUIRED); }
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_v2_OTB_StoredCard() { // check enrollment ThreeDSecure secureEcom = Secure3dService.CheckEnrollment(stored) .Execute(Secure3dVersion.Two); Assert.IsNotNull(secureEcom); if (secureEcom.Enrolled.Equals("True")) { Assert.AreEqual(Secure3dVersion.Two, secureEcom.Version); // 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) .WithMethodUrlCompletion(MethodUrlCompletion.NO) .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 = stored.Verify() .WithCurrency("USD") .Execute(); Assert.IsNotNull(response); Assert.AreEqual("00", response.ResponseCode); } else { Assert.Fail("Signature verification failed."); } } else { Assert.Fail("Card not enrolled."); } }
public void CardHolderEnrolled_ChallengeRequired_AuthenticationFailed_v1_WrongAcsValue() { card.Number = GpApi3DSTestCards.CARDHOLDER_ENROLLED_V1; // Check enrollment var secureEcom = Secure3dService.CheckEnrollment(card) .WithCurrency(Currency) .WithAmount(Amount) .Execute(); Assert.IsNotNull(secureEcom); Assert.AreEqual(ENROLLED, secureEcom.Enrolled, "Card not enrolled"); Assert.AreEqual(Secure3dVersion.One, secureEcom.Version); Assert.AreEqual(CHALLENGE_REQUIRED, secureEcom.Status); Assert.IsTrue(secureEcom.ChallengeMandated); Assert.IsNotNull(secureEcom.IssuerAcsUrl); Assert.IsNotNull(secureEcom.PayerAuthenticationRequest); Assert.IsNotNull(secureEcom.ChallengeReturnUrl); Assert.IsNotNull(secureEcom.MessageType); Assert.IsNotNull(secureEcom.SessionDataFieldName); // Perform ACS authetication GpApi3DSecureAcsClient acsClient = new GpApi3DSecureAcsClient(secureEcom.IssuerAcsUrl); string authResponse = acsClient.Authenticate_v1(secureEcom, out var payerAuthenticationResponse, AuthenticationResultCode.Successful); Assert.AreEqual("{\"success\":true}", authResponse); var exceptionCaught = false; try { Secure3dService.GetAuthenticationData() .WithServerTransactionId(secureEcom.ServerTransactionId) .WithPayerAuthenticationResponse(Guid.NewGuid().ToString()) .Execute(); } catch (GatewayException ex) { exceptionCaught = true; Assert.AreEqual("50020", ex.ResponseMessage); Assert.AreEqual("INVALID_REQUEST_DATA", ex.ResponseCode); Assert.AreEqual( "Status Code: BadRequest - Unable to decompress the PARes.", ex.Message); } finally { Assert.IsTrue(exceptionCaught); } }
public void CardHolderEnrolled_ChallengeRequired_v2_WithTokenizedCard() { var tokenizedCard = new CreditCardData { Token = card.Tokenize(), CardHolderName = "Jason Mason" }; Assert.IsNotNull(tokenizedCard.Token); var secureEcom = Secure3dService.CheckEnrollment(tokenizedCard) .WithCurrency(Currency) .WithAmount(Amount) .Execute(); AssertThreeDSResponse(secureEcom, AVAILABLE); Assert.IsFalse(secureEcom.ChallengeMandated); }
public void CardHolderEnrolled_ChallengeRequired_v1_StoredCredential() { var secureEcom = Secure3dService.CheckEnrollment(card) .WithCurrency(Currency) .WithAmount(Amount) .WithAuthenticationSource(AuthenticationSource.BROWSER) .WithStoredCredential(new StoredCredential { Initiator = StoredCredentialInitiator.CardHolder, Type = StoredCredentialType.Unscheduled, Sequence = StoredCredentialSequence.First, Reason = StoredCredentialReason.NoShow }) .Execute(); AssertThreeDSResponse(secureEcom, CHALLENGE_REQUIRED); }
public void CardHolderEnrolled_ChallengeRequired_v2_StoredCredentials() { var secureEcom = Secure3dService.CheckEnrollment(card) .WithCurrency(Currency) .WithAmount(Amount) .WithStoredCredential(new StoredCredential { Initiator = StoredCredentialInitiator.CardHolder, Type = StoredCredentialType.Unscheduled, Sequence = StoredCredentialSequence.First, Reason = StoredCredentialReason.NoShow }) .Execute(); AssertThreeDSResponse(secureEcom, AVAILABLE); Assert.IsFalse(secureEcom.ChallengeMandated); }
public void CardHolderEnrolled_Frictionless_v2_AllPreferenceValues() { card.Number = GpApi3DSTestCards.CARD_AUTH_SUCCESSFUL_V2_1; foreach (ChallengeRequestIndicator preference in Enum.GetValues(typeof(ChallengeRequestIndicator))) { var secureEcom = Secure3dService.CheckEnrollment(card) .WithCurrency(Currency) .WithAmount(Amount) .WithChallengeRequestIndicator(preference) .Execute(); AssertThreeDSResponse(secureEcom, AVAILABLE); Assert.IsFalse(secureEcom.ChallengeMandated); } }
public void FullCycle_v1() { card = new CreditCardData { Number = "4012001037141112", ExpMonth = 12, ExpYear = 2025, CardHolderName = "John Doe", }; // Check enrollment ThreeDSecure secureEcom = Secure3dService.CheckEnrollment(card) .WithCurrency("USD") .WithAmount(10.01m) .Execute(Secure3dVersion.Any); Assert.IsNotNull(secureEcom); if (secureEcom.Enrolled.Equals("ENROLLED")) { Assert.AreEqual(Secure3dVersion.One, secureEcom.Version); // Get authentication data secureEcom = Secure3dService.GetAuthenticationData() .WithServerTransactionId(secureEcom.ServerTransactionId) .Execute(); card.ThreeDSecure = secureEcom; if (secureEcom.Status.Equals("SUCCESS_AUTHENTICATED")) { Transaction response = card.Charge(10.01m) .WithCurrency("USD") .Execute(); Assert.IsNotNull(response); Assert.AreEqual(SUCCESS, response?.ResponseCode); Assert.AreEqual(GetMapping(TransactionStatus.Captured), response?.ResponseMessage); } else { Assert.Fail("Signature verification Assert.Failed."); } } else { Assert.Fail("Card not enrolled."); } }
public void CardHolderEnrolled_Frictionless_v2_WithTokenizedCard() { card.Number = GpApi3DSTestCards.CARD_AUTH_SUCCESSFUL_V2_1; var tokenizedCard = new CreditCardData { Token = card.Tokenize(), CardHolderName = "Jason Mason" }; Assert.IsNotNull(tokenizedCard.Token); var secureEcom = Secure3dService.CheckEnrollment(tokenizedCard) .WithCurrency(Currency) .WithAmount(Amount) .Execute(); AssertThreeDSResponse(secureEcom, AVAILABLE); Assert.IsFalse(secureEcom.ChallengeMandated); }