Exemplo n.º 1
0
        public void CardHolderIsEnrolledACSUnavailable()
        {
            var card = new CreditCardData {
                Number         = "4012001037484447",
                ExpMonth       = 12,
                ExpYear        = 2025,
                CardHolderName = "John Smith"
            };

            var enrolled = card.VerifyEnrolled(10m, "USD");

            Assert.IsTrue(enrolled);

            // authenticate
            var secureEcom   = card.ThreeDSecure;
            var authClient   = new ThreeDSecureAcsClient(secureEcom.IssuerAcsUrl);
            var authResponse = authClient.Authenticate(secureEcom.PayerAuthenticationRequest, secureEcom.MerchantData.ToString());

            // expand return data
            string payerAuthenticationResponse = authResponse.pares;
            MerchantDataCollection md          = MerchantDataCollection.Parse(authResponse.md);

            // verify signature
            var verified = card.VerifySignature(payerAuthenticationResponse, md);

            Assert.IsFalse(verified);
            Assert.AreEqual("U", card.ThreeDSecure.Status);
            Assert.AreEqual("7", card.ThreeDSecure.Eci);

            // complete the charge anyways
            var response = card.Charge().Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
        }
Exemplo n.º 2
0
        public void CardHolderIsEnrolledACSInvalid()
        {
            var card = new CreditCardData {
                Number         = "4012001037490006",
                ExpMonth       = 12,
                ExpYear        = 2025,
                CardHolderName = "John Smith"
            };

            var enrolled = card.VerifyEnrolled(10m, "USD");

            Assert.IsTrue(enrolled);

            // authenticate
            var secureEcom   = card.ThreeDSecure;
            var authClient   = new ThreeDSecureAcsClient(secureEcom.IssuerAcsUrl);
            var authResponse = authClient.Authenticate(secureEcom.PayerAuthenticationRequest, secureEcom.MerchantData.ToString());

            // expand return data
            string payerAuthenticationResponse = authResponse.pares;
            MerchantDataCollection md          = MerchantDataCollection.Parse(authResponse.md);

            // verify signature
            card.VerifySignature(payerAuthenticationResponse, md);
        }
Exemplo n.º 3
0
        public void FullCycleWithMerchantData()
        {
            var card = new CreditCardData {
                Number         = "4012001037141112",
                ExpMonth       = 12,
                ExpYear        = 2025,
                CardHolderName = "John Smith"
            };

            var enrolled = card.VerifyEnrolled(1m, "USD");

            if (enrolled)
            {
                var secureEcom = card.ThreeDSecure;
                if (secureEcom != null)
                {
                    // reset merchant data
                    secureEcom.MerchantData = new MerchantDataCollection {
                        { "client_txn_id", "123456" }
                    };

                    // authenticate
                    var authClient   = new ThreeDSecureAcsClient(secureEcom.IssuerAcsUrl);
                    var authResponse = authClient.Authenticate(secureEcom.PayerAuthenticationRequest, secureEcom.MerchantData.ToString());

                    // expand return data
                    string payerAuthenticationResponse = authResponse.pares;
                    MerchantDataCollection md          = MerchantDataCollection.Parse(authResponse.md);

                    // verify signature
                    if (card.VerifySignature(payerAuthenticationResponse, md))
                    {
                        var response = card.Charge()
                                       .Execute();
                        Assert.IsNotNull(response);
                        Assert.AreEqual("00", response.ResponseCode);
                    }
                    else
                    {
                        Assert.Fail("Signature verification failed.");
                    }
                }
                else
                {
                    Assert.Fail("Secure3Data was null.");
                }
            }
            else
            {
                Assert.Fail("Card not enrolled.");
            }
        }
Exemplo n.º 4
0
        public void FullCycleWithNoMerchantData()
        {
            var card = new CreditCardData {
                Number         = "4012001037141112",
                ExpMonth       = 12,
                ExpYear        = 2025,
                CardHolderName = "John Smith"
            };

            var amount   = 10m;
            var currency = "USD";
            var orderId  = GenerationUtils.GenerateOrderId();

            var enrolled = card.VerifyEnrolled(amount, currency, orderId);

            if (enrolled)
            {
                var secureEcom = card.ThreeDSecure;
                if (secureEcom != null)
                {
                    // authenticate
                    var    authClient   = new ThreeDSecureAcsClient(secureEcom.IssuerAcsUrl);
                    var    authResponse = authClient.Authenticate(secureEcom.PayerAuthenticationRequest, secureEcom.MerchantData.ToString());
                    string payerAuthenticationResponse = authResponse.pares;
                    string md = authResponse.md;

                    // verify signature
                    if (card.VerifySignature(payerAuthenticationResponse, amount, currency, orderId))
                    {
                        var response = card.Charge(amount)
                                       .WithCurrency(currency)
                                       .WithOrderId(orderId)
                                       .Execute();
                        Assert.IsNotNull(response);
                        Assert.AreEqual("00", response.ResponseCode);
                    }
                    else
                    {
                        Assert.Fail("Signature verification failed.");
                    }
                }
                else
                {
                    Assert.Fail("Secure3Data was null.");
                }
            }
            else
            {
                Assert.Fail("Card not enrolled.");
            }
        }
Exemplo n.º 5
0
        public void FullCycle_v1()
        {
            card.Number = "4012001037141112";

            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") || secureEcom.Status.Equals("A"))
                {
                    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.");
            }
        }
Exemplo n.º 6
0
        public void AcsClientTest()
        {
            var authClient = new ThreeDSecureAcsClient("https://pit.3dsecure.net/VbVTestSuiteService/pit1/acsService/paReq?summary=MTNmMzI4NzgtNTdmZi00OWEzLWJhZTAtYzFhNzAxMDJkMGNi");

            Assert.IsNotNull(authClient.Authenticate("eJxlUsFSwjAQvfsVTO82TSm0MNs4FVBwRkUF8ZomK1Rpimkr6NebYBEdc8jsy27evrwNnO3ydesddZkVKnao6zktVKKQmVrGznx2cRo5Z+wEZiuNOHxAUWtkcI1lyZfYymTs+KIjZYRt30tl0H2WPRpFIuQyDULsdTvoMJgm9/jGoOnCTBPXB3KAhk2LFVcVAy7ezic3LAgD2ouANBBy1JMh6zULyDcGxXNkK+S6WnMll5vS7GmxA7JPgChqVekPFgUekAOAWq/Zqqo2ZZ+Q7Xbr/r/visKtX4HYSiBHcdPaRqVh3mWSJcM7Nb7t0O1iGs6n7cXnI025N7hSk1EMxFaA5BUy36MhpX7Y8r1+J+hTI39/Djy3kqwZRl4DYGN7JE3GJn4fgDFfm+EcnnRAgLtNodBUGFd/YiBHwYOx9VZUxrVxdjEb1aPXy5f5k27Tmzo/v75N4ti6vS+wbJlxikb0m84CIJaCNIMkzfxN9OdffAF4VML9"));
        }
Exemplo n.º 7
0
        public void FullCycle_Any()
        {
            ThreeDSecure secureEcom = Secure3dService.CheckEnrollment(card)
                                      .WithAmount(1m)
                                      .WithCurrency("USD")
                                      .Execute(Secure3dVersion.Any);

            Assert.IsNotNull(secureEcom);

            if (secureEcom.Enrolled.Equals("True"))
            {
                if (secureEcom.Version.Equals(Secure3dVersion.Two))
                {
                    // initiate authentication
                    ThreeDSecure initAuth = Secure3dService.InitiateAuthentication(card, secureEcom)
                                            .WithAmount(10.01m)
                                            .WithCurrency("USD")
                                            .WithOrderCreateDate(DateTime.Now)
                                            .WithAddress(billingAddress, AddressType.Billing)
                                            .WithAddress(shippingAddress, AddressType.Shipping)
                                            .WithBrowserData(browserData)
                                            .Execute();
                    Assert.IsNotNull(initAuth);

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

                    if (secureEcom.Status.Equals("AUTHENTICATION_SUCCESSFUL"))
                    {
                        Transaction response = card.Charge(10.01m)
                                               .WithCurrency("USD")
                                               .Execute();
                        Assert.IsNotNull(response);
                        Assert.AreEqual("00", response.ResponseCode);
                    }
                    else
                    {
                        Assert.Fail("Signature verification Assert.Failed.");
                    }
                }
                else
                {
                    // authenticate
                    ThreeDSecureAcsClient authClient = new ThreeDSecureAcsClient(secureEcom.IssuerAcsUrl);
                    var authResponse = authClient.Authenticate(secureEcom.PayerAuthenticationRequest, secureEcom.MerchantData.ToString());

                    string payerAuthenticationResponse = authResponse.getAuthResponse();
                    MerchantDataCollection md          = MerchantDataCollection.Parse(authResponse.getMerchantData());

                    // verify signature through the service and affix to the card object
                    secureEcom = Secure3dService.GetAuthenticationData()
                                 .WithPayerAuthenticationResponse(payerAuthenticationResponse)
                                 .WithMerchantData(md)
                                 .Execute();
                    card.ThreeDSecure = secureEcom;

                    if (secureEcom.Status.Equals("Y"))
                    {
                        Transaction response = card.Charge().Execute();
                        Assert.IsNotNull(response);
                        Assert.AreEqual("00", response.ResponseCode);
                    }
                    else
                    {
                        Assert.Fail("Signature verification Assert.Failed.");
                    }
                }
            }
            else
            {
                Assert.Fail("Card not enrolled.");
            }
        }