Exemple #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(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_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);
        }
Exemple #5
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);
            }
        }
Exemple #6
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);
            }
        }
        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);
        }