Esempio n. 1
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);
        }
Esempio n. 2
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);
        }
Esempio 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.");
            }
        }
Esempio 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.");
            }
        }
Esempio n. 5
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"));
        }