Beispiel #1
0
        public void CardHolderEnrolled_v1_PostResult()
        {
            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)
                         .Execute();

            Assert.IsNotNull(secureEcom);
            Assert.AreEqual(AUTHENTICATION_SUCCESSFUL, secureEcom.Status);
        }
        public void CardHolderEnrolled_ChallengeRequired_v2_Initiate_AcsNotPerformed()
        {
            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)
                           .WithOrderCreateDate(DateTime.Now)
                           .WithAddress(shippingAddress, AddressType.Shipping)
                           .WithBrowserData(browserData)
                           .WithShippingMethod(ShippingMethod.DIGITAL_GOODS)
                           .WithShippingNameMatchesCardHolderName(true)
                           .WithShippingAddressCreateDate(DateTime.Now)
                           .WithShippingAddressUsageIndicator(AgeIndicator.LESS_THAN_THIRTY_DAYS)
                           .Execute();

            AssertThreeDSResponse(initAuth, CHALLENGE_REQUIRED);
            Assert.IsTrue(initAuth.ChallengeMandated);

            var getAuthData = Secure3dService.GetAuthenticationData()
                              .WithServerTransactionId(initAuth.ServerTransactionId)
                              .Execute();

            Assert.AreEqual(CHALLENGE_REQUIRED, getAuthData.Status);
        }
Beispiel #3
0
        public void CardHolderEnrolled_v1_PostResult_AcsNotPerformed()
        {
            var secureEcom = Secure3dService.CheckEnrollment(card)
                             .WithCurrency(Currency)
                             .WithAmount(Amount)
                             .WithAuthenticationSource(AuthenticationSource.BROWSER)
                             .Execute();

            AssertThreeDSResponse(secureEcom, CHALLENGE_REQUIRED);

            var exceptionCaught = false;

            try {
                Secure3dService.GetAuthenticationData()
                .WithServerTransactionId(secureEcom.ServerTransactionId)
                .Execute();
            }
            catch (GatewayException ex) {
                exceptionCaught = true;
                Assert.AreEqual("50027", ex.ResponseMessage);
                Assert.AreEqual("INVALID_REQUEST_DATA", ex.ResponseCode);
                Assert.AreEqual(
                    "Status Code: BadRequest - Undefined element in Message before PARes", ex.Message);
            }
            finally {
                Assert.IsTrue(exceptionCaught);
            }
        }
Beispiel #4
0
        public void OptionalMobileFields()
        {
            // 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
                                        .WithApplicationId("f283b3ec-27da-42a1-acea-f3f70e75bbdc")
                                        .WithSdkInterface(SdkInterface.BOTH)
                                        .WithSdkUiTypes(SdkUiType.TEXT, SdkUiType.SINGLE_SELECT, SdkUiType.MULTI_SELECT, SdkUiType.OOB, SdkUiType.HTML_OTHER)
                                        // .WithEphemeralPublicKey("{\"kty\":\"EC\",\"crv\":\"p-256\",\"x\":\"WWcpTjbOqiu_1aODllw5rYTq5oLXE_T0huCPjMIRbkI\",\"y\":\"Wz_7anIeadV8SJZUfr4drwjzuWoUbOsHp5GdRZBAAiw\"}")
                                        // .WithMaximumTimeout(5)
                                        .WithReferenceNumber("3DS_LOA_SDK_PPFU_020100_00007")
                                        .WithSdkTransactionId("b2385523-a66c-4907-ac3c-91848e8c0067")
                                        .WithEncodedData("ew0KCSJEViI6ICIxLjAiLA0KCSJERCI6IHsNCgkJIkMwMDEiOiAiQW5kcm9pZCIsDQoJCSJDMDAyIjogIkhUQyBPbmVfTTgiLA0KCQkiQzAwNCI6ICI1LjAuMSIsDQoJCSJDMDA1IjogImVuX1VTIiwNCgkJIkMwMDYiOiAiRWFzdGVybiBTdGFuZGFyZCBUaW1lIiwNCgkJIkMwMDciOiAiMDY3OTc5MDMtZmI2MS00MWVkLTk0YzItNGQyYjc0ZTI3ZDE4IiwNCgkJIkMwMDkiOiAiSm9obidzIEFuZHJvaWQgRGV2aWNlIg0KCX0sDQoJIkRQTkEiOiB7DQoJCSJDMDEwIjogIlJFMDEiLA0KCQkiQzAxMSI6ICJSRTAzIg0KCX0sDQoJIlNXIjogWyJTVzAxIiwgIlNXMDQiXQ0KfQ0K")

                                        .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.");
            }
        }
Beispiel #5
0
        public void FullCycle_v2()
        {
            card = new CreditCardData {
                Number         = "4012001038488884",
                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.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)
                                        .Execute();
                Assert.IsNotNull(initAuth);

                // Get authentication data
                secureEcom = Secure3dService.GetAuthenticationData()
                             .WithServerTransactionId(initAuth.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_ChallengeRequired_v2(string cardNumber)
        {
            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(CHALLENGE_REQUIRED, initAuth.Status);
            Assert.IsTrue(initAuth.ChallengeMandated);
            Assert.IsNotNull(initAuth.IssuerAcsUrl);
            Assert.IsNotNull(initAuth.PayerAuthenticationRequest);

            // Perform ACS authentication
            GpApi3DSecureAcsClient acsClient = new GpApi3DSecureAcsClient(initAuth.IssuerAcsUrl);
            string authResponse = acsClient.Authenticate_v2(initAuth);

            Assert.AreEqual("{\"success\":true}", authResponse);

            // Get authentication data
            secureEcom = Secure3dService.GetAuthenticationData()
                         .WithServerTransactionId(initAuth.ServerTransactionId)
                         .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_v2_With_MobileData()
        {
            card.Number = GpApi3DSTestCards.CARD_AUTH_SUCCESSFUL_V2_1;

            var secureEcom = Secure3dService.CheckEnrollment(card)
                             .WithCurrency(Currency)
                             .WithAmount(Amount)
                             .WithAuthenticationSource(AuthenticationSource.MOBILE_SDK)
                             .Execute(Secure3dVersion.Two);

            Assert.IsNotNull(secureEcom);
            AssertThreeDSResponse(secureEcom, AVAILABLE);
            Assert.AreEqual(ENROLLED, secureEcom.Enrolled);
            Assert.AreEqual(Secure3dVersion.Two, secureEcom.Version);

            ThreeDSecure initAuth =
                Secure3dService
                .InitiateAuthentication(card, secureEcom)
                .WithAmount(Amount)
                .WithCurrency(Currency)
                .WithAuthenticationSource(AuthenticationSource.MOBILE_SDK)
                .WithMobileData(mobileData)
                .WithMethodUrlCompletion(MethodUrlCompletion.YES)
                .WithOrderCreateDate(DateTime.Now)
                .WithAddress(shippingAddress, AddressType.Shipping)
                .Execute(Secure3dVersion.Two);

            Assert.IsNotNull(initAuth);
            Assert.AreEqual(ENROLLED, initAuth.Enrolled);
            Assert.AreEqual(Secure3dVersion.Two, initAuth.Version);
            Assert.AreEqual(SUCCESS_AUTHENTICATED, initAuth.Status);
            Assert.AreEqual("YES", initAuth.LiabilityShift);
            Assert.IsFalse(initAuth.ChallengeMandated);
            Assert.IsNotNull(initAuth.IssuerAcsUrl);
            Assert.IsNotNull(initAuth.PayerAuthenticationRequest);
            Assert.AreEqual("05", initAuth.Eci);

            // Get authentication data
            secureEcom =
                Secure3dService
                .GetAuthenticationData()
                .WithServerTransactionId(initAuth.ServerTransactionId)
                .Execute(Secure3dVersion.Two);

            card.ThreeDSecure = secureEcom;

            // Create transaction
            Transaction response =
                card
                .Charge(Amount)
                .WithCurrency(Currency)
                .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual(SUCCESS, response.ResponseCode);
            Assert.AreEqual(TransactionStatus.Captured.ToString().ToUpper(), 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_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);
        }
Beispiel #10
0
        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.");
            }
        }
Beispiel #11
0
        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);
        }
Beispiel #12
0
        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.");
            }
        }
Beispiel #13
0
        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 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);
        }
Beispiel #15
0
        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.");
            }
        }
Beispiel #16
0
        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.");
            }
        }
Beispiel #17
0
        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.");
            }
        }
Beispiel #18
0
        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 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);
        }
Beispiel #20
0
        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.");
            }
        }
Beispiel #21
0
        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);
            }
        }
Beispiel #22
0
        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.");
            }
        }
Beispiel #23
0
        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.");
            }
        }
Beispiel #24
0
        public void CardHolderEnrolled_ChallengeRequired_v2_Initiate_AcsNotPerformed()
        {
            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)
                           .WithOrderCreateDate(DateTime.Now)
                           .WithAddress(shippingAddress, AddressType.Shipping)
                           .WithBrowserData(browserData)
                           .WithShippingMethod(ShippingMethod.DIGITAL_GOODS)
                           .WithShippingNameMatchesCardHolderName(true)
                           .WithShippingAddressCreateDate(DateTime.Now)
                           .WithShippingAddressUsageIndicator(AgeIndicator.LESS_THAN_THIRTY_DAYS)
                           .Execute();

            AssertThreeDSResponse(initAuth, CHALLENGE_REQUIRED);
            Assert.IsTrue(initAuth.ChallengeMandated);

            var exceptionCaught = false;

            try {
                Secure3dService.GetAuthenticationData()
                .WithServerTransactionId(initAuth.ServerTransactionId)
                .Execute();
            }
            catch (GatewayException ex) {
                exceptionCaught = true;
                Assert.AreEqual("50027", ex.ResponseMessage);
                Assert.AreEqual("INVALID_REQUEST_DATA", ex.ResponseCode);
                Assert.AreEqual(
                    "Status Code: BadRequest - Undefined element in Message before PARes", ex.Message);
            }
            finally {
                Assert.IsTrue(exceptionCaught);
            }
        }
        public void CardHolderEnrolled_ChallengeRequired_AuthenticationFailed_v1(
            AuthenticationResultCode authenticationResultCode, string status)
        {
            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 authentication
            GpApi3DSecureAcsClient acsClient = new GpApi3DSecureAcsClient(secureEcom.IssuerAcsUrl);
            string payerAuthenticationResponse;
            string authResponse =
                acsClient.Authenticate_v1(secureEcom, out payerAuthenticationResponse, authenticationResultCode);

            Assert.AreEqual("{\"success\":true}", authResponse);

            // Get authentication data
            secureEcom = Secure3dService.GetAuthenticationData()
                         .WithServerTransactionId(secureEcom.ServerTransactionId)
                         .WithPayerAuthenticationResponse(payerAuthenticationResponse)
                         .Execute();

            Assert.IsNotNull(secureEcom);
            Assert.AreEqual(status, secureEcom.Status);
            string liabilityShift = status == "SUCCESS_ATTEMPT_MADE" ? "YES" : "NO";

            Assert.AreEqual(liabilityShift, secureEcom.LiabilityShift);
        }
Beispiel #26
0
        public void FullCycle_v2_EOS_ForceSecure()
        {
            // 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(550m)
                                        .WithCurrency("EUR")
                                        .WithOrderCreateDate(DateTime.Now)
                                        .WithAddress(billingAddress, AddressType.Billing)
                                        .WithAddress(shippingAddress, AddressType.Shipping)
                                        .WithBrowserData(browserData)
                                        .WithEnableExemptionOptimization(true)
                                        .Execute();

                Assert.IsNotNull(initAuth);
                Assert.AreEqual("CHALLENGE_REQUIRED", initAuth.Status);
                Assert.AreEqual(ExemptReason.FORCE_SECURE.ToString(), initAuth.ExemptReason);
                Assert.IsNull(initAuth.ExemptStatus);

                // get authentication data
                secureEcom = Secure3dService.GetAuthenticationData()
                             .WithServerTransactionId(initAuth.ServerTransactionId)
                             .Execute();

                Assert.IsNotNull(secureEcom);
                Assert.AreEqual("CHALLENGE_REQUIRED", secureEcom.Status);
            }
            else
            {
                Assert.Fail("Card not enrolled.");
            }
        }
Beispiel #27
0
        public void CardHolderEnrolled_v1_PostResult_NonExistentId()
        {
            var transId         = Guid.NewGuid().ToString();
            var exceptionCaught = false;

            try {
                Secure3dService.GetAuthenticationData()
                .WithServerTransactionId(transId)
                .Execute();
            }
            catch (GatewayException ex) {
                exceptionCaught = true;
                Assert.AreEqual("40118", ex.ResponseMessage);
                Assert.AreEqual("RESOURCE_NOT_FOUND", ex.ResponseCode);
                Assert.AreEqual(
                    "Status Code: NotFound - Authentication " + transId + " not found at this location.", ex.Message);
            }
            finally {
                Assert.IsTrue(exceptionCaught);
            }
        }
Beispiel #28
0
        public void CardHolderNotEnrolled_v1_PostResult()
        {
            card.Number = CARDHOLDER_NOT_ENROLLED_V1;

            var secureEcom = Secure3dService.CheckEnrollment(card)
                             .WithCurrency(Currency)
                             .WithAmount(Amount)
                             .WithAuthenticationSource(AuthenticationSource.BROWSER)
                             .Execute();

            Assert.IsNotNull(secureEcom);
            Assert.AreEqual(NOT_ENROLLED, secureEcom.Enrolled, "Card not enrolled");
            Assert.AreEqual(Secure3dVersion.One, secureEcom.Version);
            Assert.AreEqual(NOT_ENROLLED, secureEcom.Status);
            Assert.IsNotNull(secureEcom.IssuerAcsUrl);
            Assert.IsNotNull(secureEcom.PayerAuthenticationRequest);
            Assert.IsNotNull(secureEcom.ChallengeReturnUrl);
            Assert.IsNotNull(secureEcom.MessageType);
            Assert.IsNotNull(secureEcom.SessionDataFieldName);
            Assert.AreEqual(6, secureEcom.Eci);

            var exceptionCaught = false;

            try {
                Secure3dService.GetAuthenticationData()
                .WithServerTransactionId(secureEcom.ServerTransactionId)
                .Execute();
            }
            catch (GatewayException ex) {
                exceptionCaught = true;
                Assert.AreEqual("50027", ex.ResponseMessage);
                Assert.AreEqual("INVALID_REQUEST_DATA", ex.ResponseCode);
                Assert.AreEqual(
                    "Status Code: BadRequest - Undefined element in Message before PARes", ex.Message);
            }
            finally {
                Assert.IsTrue(exceptionCaught);
            }
        }
Beispiel #29
0
        public void OptionalOrderLevelFields()
        {
            // 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
                                        .WithGiftCardCount(1)
                                        .WithGiftCardCurrency("USD")
                                        .WithGiftCardAmount(250m)
                                        .WithDeliveryEmail("*****@*****.**")
                                        .WithDeliveryTimeFrame(DeliveryTimeFrame.ELECTRONIC_DELIVERY)
                                        .WithShippingMethod(ShippingMethod.ANOTHER_VERIFIED_ADDRESS)
                                        .WithShippingNameMatchesCardHolderName(true)
                                        .WithPreOrderIndicator(PreOrderIndicator.FUTURE_AVAILABILITY)
                                        .WithPreOrderAvailabilityDate(DateTime.Parse("2019-04-18"))
                                        .WithReorderIndicator(ReorderIndicator.REORDER)
                                        .WithOrderTransactionType(OrderTransactionType.GOODS_SERVICE_PURCHASE)

                                        .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.");
            }
        }
Beispiel #30
0
        public void OptionalPayerLevelFields()
        {
            // 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
                                        .WithCustomerAccountId("6dcb24f5-74a0-4da3-98da-4f0aa0e88db3")
                                        .WithAccountAgeIndicator(AgeIndicator.LESS_THAN_THIRTY_DAYS)
                                        .WithAccountCreateDate(DateTime.Parse("2019-01-10"))
                                        .WithAccountChangeDate(DateTime.Parse("2019-01-28"))
                                        .WithAccountChangeIndicator(AgeIndicator.THIS_TRANSACTION)
                                        .WithPasswordChangeDate(DateTime.Parse("2019-01-15"))
                                        .WithPasswordChangeIndicator(AgeIndicator.LESS_THAN_THIRTY_DAYS)
                                        .WithHomeNumber("44", "123456798")
                                        .WithWorkNumber("44", "1801555888")
                                        .WithPaymentAccountCreateDate(DateTime.Parse("2019-01-01"))
                                        .WithPaymentAccountAgeIndicator(AgeIndicator.LESS_THAN_THIRTY_DAYS)
                                        .WithPreviousSuspiciousActivity(false)
                                        .WithNumberOfPurchasesInLastSixMonths(3)
                                        .WithNumberOfTransactionsInLast24Hours(1)
                                        .WithNumberOfTransactionsInLastYear(5)
                                        .WithNumberOfAddCardAttemptsInLast24Hours(1)
                                        .WithShippingAddressCreateDate(DateTime.Parse("2019-01-28"))
                                        .WithShippingAddressUsageIndicator(AgeIndicator.THIS_TRANSACTION)

                                        .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.");
            }
        }