public void CardTokenizationThenPayingWithToken_SingleToMultiUse()
        {
            var token = card.Tokenize(paymentMethodUsageMode: PaymentMethodUsageMode.Single);

            Assert.IsNotNull(token);

            var tokenizedCard = new CreditCardData
            {
                Token          = token,
                CardHolderName = "James Mason"
            };

            var response = tokenizedCard.Charge(17.01m)
                           .WithCurrency("USD")
                           .WithRequestMultiUseToken(true)

                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual(SUCCESS, response?.ResponseCode);
            Assert.AreEqual(GetMapping(TransactionStatus.Captured), response?.ResponseMessage);
            Assert.IsTrue(response.Token.StartsWith("PMT_"));

            tokenizedCard.Token = response.Token;
            tokenizedCard.Charge(10)
            .WithCurrency("USD")

            .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual(SUCCESS, response?.ResponseCode);
            Assert.AreEqual(GetMapping(TransactionStatus.Captured), response?.ResponseMessage);
        }
        public void CardTokenizationThenPayingWithToken_SingleToMultiUse()
        {
            var token = card.Tokenize(paymentMethodUsageMode: PaymentMethodUsageMode.Single);

            Assert.IsNotNull(token);

            var tokenizedCard = new CreditCardData {
                Token          = token,
                CardHolderName = "James Mason"
            };

            var response = tokenizedCard.Charge(AMOUNT)
                           .WithCurrency(CURRENCY)
                           .WithRequestMultiUseToken(true)
                           .Execute();

            AssertTransactionResponse(response, TransactionStatus.Captured);
            Assert.IsTrue(response.Token.StartsWith("PMT_"));

            tokenizedCard.Token = response.Token;
            var charge = tokenizedCard.Charge(AMOUNT)
                         .WithCurrency(CURRENCY)
                         .Execute();

            AssertTransactionResponse(charge, TransactionStatus.Captured);
        }
Beispiel #3
0
        public void AddRemoveConfigThreadSafe()
        {
            var card = new CreditCardData {
                Number      = "4263970000005262",
                ExpMonth    = 05,
                ExpYear     = 2025,
                Cvn         = "852",
                CardPresent = true
            };

            var configs = new List <GpApiConfig>();

            for (int i = 0; i < 100; i++)
            {
                configs.Add(new GpApiConfig {
                    AppId   = "rkiYguPfTurmGcVhkDbIGKn2IJe2t09M",
                    AppKey  = "6gFzVGf40S7ZpjJs",
                    Channel = Channel.CardNotPresent,
                    ChallengeNotificationUrl = "https://ensi808o85za.x.pipedream.net/",
                    MethodNotificationUrl    = "https://ensi808o85za.x.pipedream.net/",
                    MerchantContactUrl       = "https://enp4qhvjseljg.x.pipedream.net/",
                    DynamicHeaders           = new Dictionary <string, string> {
                        ["configname"] = "config" + i,
                    }
                });
            }

            Parallel.ForEach(configs, config => {
                ServicesContainer.ConfigureService(config, config.DynamicHeaders["configname"]);
            });

            Parallel.ForEach(configs, config => {
                var transaction = card.Charge(14m)
                                  .WithCurrency("USD")
                                  .WithAllowDuplicates(true)
                                  .Execute(config.DynamicHeaders["configname"]);
                Assert.IsNotNull(transaction);
                Assert.AreEqual("SUCCESS", transaction?.ResponseCode);
                Assert.AreEqual(EnumConverter.GetMapping(Target.GP_API, TransactionStatus.Captured), transaction?.ResponseMessage);
            });

            Parallel.ForEach(configs, config => {
                ServicesContainer.ConfigureService <GpApiConfig>(null, config.DynamicHeaders["configname"]);
            });

            Parallel.ForEach(configs, config => {
                try {
                    var transaction = card.Charge(14m)
                                      .WithCurrency("USD")
                                      .WithAllowDuplicates(true)
                                      .Execute(config.DynamicHeaders["configname"]);
                }
                catch (Exception ex) {
                    Assert.AreEqual("The specified configuration has not been configured for gateway processing.", ex.Message);
                }
            });
        }
        public void Sale_Manual()
        {
            var response = card.Charge(Amount)
                           .WithCurrency("USD")
                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode, response.ResponseMessage);
        }
        public void CreditSale()
        {
            var response = card.Charge(15m)
                           .WithCurrency("USD")
                           .WithAllowDuplicates(true)
                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode, response.ResponseMessage);
        }
Beispiel #6
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.");
            }
        }
        public void EcomWithMoto()
        {
            Transaction response = card.Charge(9m)
                                   .WithCurrency("USD")
                                   .WithEcommerceInfo(new EcommerceInfo {
                Channel = EcommerceChannel.MOTO
            })
                                   .WithAllowDuplicates(true)
                                   .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
        }
        //You need a valid ApplePay token that it is valid only for 60 sec
        public void PayWithApplePayEncrypted()
        {
            card.Token      = "{\"version\":\"EC_v1\",\"data\":\"7RbOpd67lcBgPFDHwpVCtz1g9DSXIEz6h7XUhsWiVS3B5WpkpgJ3Mj/EKNuuHezpPmsJ6AZb72twHiR/6Ngs29X4jKcv3XvdrEgL+5S7dKZoU0sNN3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OwJr1PPz2nsG/BMcSPQh3IjN/LjjAiBrcFOzdt1bnjnuObziz9RAMinRSeCva839RLkpBF6QTgAAAAAAAA==\",\"header\":{\"ephemeralPublicKey\":\"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEeyyM++BjGrlaodphlJUvfTx4tQwn5Ci9IGpAI3RvbYqEshGX5cdkl0j7yNEu913OgT99r/MU1wqHnXn4p7qosA==\",\"publicKeyHash\":\"rEYX/7PdO7F7xL7rH0LZVak/iXTrkeU89Ck7E9dGFO4=\",\"transactionId\":\"38bb5ca49bc54c70e6ff5996bd087f1cce27f0f84fca2f6e71871fc7a56d877e\"}}";
            card.MobileType = EncyptedMobileType.APPLE_PAY;

            var transaction = card.Charge(10m)
                              .WithCurrency("EUR")
                              .WithModifier(TransactionModifier.EncryptedMobile)
                              .Execute();

            Assert.IsNotNull(transaction);
            Assert.AreEqual(GetMapping(TransactionStatus.Captured), transaction?.ResponseMessage);
            Assert.AreEqual(SUCCESS, transaction?.ResponseCode);
            Assert.IsFalse(string.IsNullOrEmpty(transaction.TransactionId));
        }
Beispiel #9
0
        public void Sale_Wallet()
        {
            var autoSubstantiation = new AutoSubstantiation {
                CopaySubTotal        = 1m,
                ClinicSubTotal       = 1m,
                DentalSubTotal       = 1m,
                PrescriptionSubTotal = 1m,
                VisionSubTotal       = 1m
            };

            var response = applePay.Charge()
                           .WithCurrency("USD")
                           .WithCashBack(1m)
                           .WithConvenienceAmount(1.25m)
                           //.WithTaxAmount(1m)
                           .WithAutoSubstantiation(autoSubstantiation)
                           .WithInvoiceNumber("INV123")
                           // PoNumber
                           // CustomerCode
                           .WithClientTransactionId("TX123")
                           .WithAllowPartialAuth(true)
                           .WithAllowDuplicates(true)
                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
        }
Beispiel #10
0
        public void CreditCardReauthorizeTransaction()
        {
            var card = new CreditCardData {
                Number         = "5425230000004415",
                ExpMonth       = DateTime.Now.Month,
                ExpYear        = DateTime.Now.Year + 1,
                Cvn            = "123",
                CardHolderName = "John Smith"
            };

            Transaction chargeTransaction = card.Charge(1.25m)
                                            .WithCurrency("USD")
                                            .Execute();

            Assert.IsNotNull(chargeTransaction);
            Assert.AreEqual(SUCCESS, chargeTransaction?.ResponseCode);
            Assert.AreEqual(GetMapping(TransactionStatus.Captured), chargeTransaction?.ResponseMessage);

            Transaction reverseTransaction = chargeTransaction.Reverse(1.25m)
                                             .Execute();

            Assert.IsNotNull(reverseTransaction);
            Assert.AreEqual(SUCCESS, reverseTransaction?.ResponseCode);
            Assert.AreEqual(GetMapping(TransactionStatus.Reversed), reverseTransaction?.ResponseMessage);

            Transaction reauthTransaction = chargeTransaction.Reauthorize()
                                            .Execute();

            Assert.IsNotNull(reauthTransaction);
            Assert.AreEqual(SUCCESS, reauthTransaction?.ResponseCode);
            Assert.AreEqual(GetMapping(TransactionStatus.Captured), reauthTransaction?.ResponseMessage);
            Assert.AreEqual("00", reauthTransaction.AuthorizationCode);
        }
Beispiel #11
0
        public void Ecomm_007_Verify_Visa()
        {
            var address = new Address {
                StreetAddress1 = "6860 Dallas Pkwy", PostalCode = "75024"
            };
            var manual_card = TestCards.VisaManual();

            var response = manual_card.Verify()
                           .WithRequestMultiUseToken(true)
                           .Execute("ecomm");

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);

            var token = new CreditCardData {
                Token = response.Token
            };

            var saleResponse = token.Charge(25m)
                               .WithCurrency("USD")
                               .WithAddress(address)
                               .WithAllowDuplicates(true)
                               .Execute("ecomm");

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
        }
Beispiel #12
0
        public void CountryIsGB_NoStreetAddress1()
        {
            Address address = new Address {
                Country    = "GB",
                PostalCode = "E77 4Qj"
            };

            Assert.IsNotNull(address.CountryCode);
            Assert.IsTrue(address.IsCountry("GB"));

            var card = new CreditCardData {
                Number         = "4111111111111111",
                ExpMonth       = 12,
                ExpYear        = 2025,
                Cvn            = "123",
                CardHolderName = "Joe Smith"
            };

            ServicesContainer.ConfigureService(new GatewayConfig {
                MerchantId     = "heartlandgpsandbox",
                AccountId      = "api",
                SharedSecret   = "secret",
                RebatePassword = "******",
                RefundPassword = "******",
                ServiceUrl     = "https://api.sandbox.realexpayments.com/epage-remote.cgi"
            });

            var response = card.Charge(10m)
                           .WithCurrency("USD")
                           .WithAddress(address)
                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
        }
Beispiel #13
0
        public void Charge_UsingTokenizedCreditCard_ReturnsSuccessfulTransaction()
        {
            var service  = new BillPayService();
            var response = clearTextCredit.Verify()
                           .WithAddress(new Address {
                PostalCode = "12345"
            })
                           .WithRequestMultiUseToken(true)
                           .Execute();

            Assert.IsFalse(string.IsNullOrWhiteSpace(response.Token));

            var token = response.Token;
            var fee   = service.CalculateConvenienceAmount(clearTextCredit, bill.Amount);

            var paymentMethod = new CreditCardData()
            {
                Token    = token,
                ExpMonth = clearTextCredit.ExpMonth,
                ExpYear  = clearTextCredit.ExpYear
            };

            Assert.IsFalse(string.IsNullOrWhiteSpace(token));

            RunAndValidateTransaction(() => {
                return(paymentMethod
                       .Charge(bill.Amount)
                       .WithAddress(address)
                       .WithBills(bill)
                       .WithConvenienceAmount(fee)
                       .WithCurrency("USD")
                       .Execute());
            });
        }
Beispiel #14
0
        public void Charge_UsingTokenFromPreviousPayment_ReturnsSuccessfulTransaction()
        {
            var service = new BillPayService();
            var fee     = service.CalculateConvenienceAmount(clearTextCredit, bill.Amount);

            var transaction = RunAndValidateTransaction(() => {
                return(clearTextCredit
                       .Charge(bill.Amount)
                       .WithAddress(address)
                       .WithBills(bill)
                       .WithConvenienceAmount(fee)
                       .WithCurrency("USD")
                       .WithRequestMultiUseToken(true)
                       .Execute());
            });

            Assert.IsFalse(string.IsNullOrWhiteSpace(transaction.Token));

            var transaction2 = RunAndValidateTransaction(() => {
                var tokenizedCard = new CreditCardData()
                {
                    Token    = transaction.Token,
                    ExpYear  = clearTextCredit.ExpYear,
                    ExpMonth = clearTextCredit.ExpMonth
                };
                return(tokenizedCard.Charge(bill.Amount)
                       .WithBills(bill)
                       .WithConvenienceAmount(fee)
                       .WithCurrency("USD")
                       .Execute());
            });
        }
Beispiel #15
0
        public void Ecomm_08b_Verify_Master_Card()
        {
            var address = new Address {
                StreetAddress1 = "6860 Dallas Pkwy", PostalCode = "75024"
            };
            var manual_card = TestCards.MasterCardSeries2Manual();

            var response = manual_card.Verify()
                           .WithRequestMultiUseToken(true)
                           .Execute("ecomm");

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);

            var token = new CreditCardData {
                Token = response.Token
            };

            var chargeResponse = token.Charge(26m)
                                 .WithCurrency("USD")
                                 .WithAddress(address)
                                 .WithInvoiceNumber("123456")
                                 .WithAllowDuplicates(true)
                                 .Execute("ecomm");

            Assert.IsNotNull(chargeResponse);
            Assert.AreEqual("00", chargeResponse.ResponseCode);
        }
Beispiel #16
0
        public void ChargeCard_WithLimitedPermissions()
        {
            var permissions = new[] { "TRN_POST_Capture" };

            gpApiConfig.Permissions     = permissions;
            gpApiConfig.SecondsToExpire = 60;
            GpApiService.GenerateTransactionKey(gpApiConfig);

            ServicesContainer.ConfigureService(gpApiConfig, "GpApiConfig_2");

            var exceptionCaught = false;

            try {
                card.Charge()
                .WithAmount(1.00m)
                .WithCurrency("USD")
                .Execute("GpApiConfig_2");
            }
            catch (GatewayException ex) {
                exceptionCaught = true;
                Assert.AreEqual("ACTION_NOT_AUTHORIZED", ex.ResponseCode);
                Assert.AreEqual("40212", ex.ResponseMessage);
                Assert.AreEqual("Status Code: Forbidden - Permission not enabled to execute action", ex.Message);
            } finally {
                Assert.IsTrue(exceptionCaught);
            }
        }
        public void CloseBatch_WithCardNumberDetails_DeclinedTransaction()
        {
            var card = new CreditCardData {
                Number      = "4263970000005262",
                ExpMonth    = expMonth,
                ExpYear     = expYear,
                Cvn         = "852",
                CardPresent = true
            };

            var chargeTransaction = card.Charge(AMOUNT)
                                    .WithCurrency(CURRENCY)
                                    .Execute();

            Assert.IsNotNull(chargeTransaction);
            Assert.AreEqual(DECLINED, chargeTransaction?.ResponseCode);
            Assert.AreEqual(GetMapping(TransactionStatus.Declined), chargeTransaction?.ResponseMessage);

            //TODO - remove when api fix polling issue
            waitForGpApiReplication();

            var batchSummary = BatchService.CloseBatch(chargeTransaction.BatchSummary.BatchReference);

            Assert.IsNotNull(batchSummary);
            Assert.AreEqual(CLOSED, batchSummary?.Status);
            Assert.AreEqual(0, batchSummary?.TransactionCount);
            Assert.AreEqual(0, batchSummary?.TotalAmount);
        }
Beispiel #18
0
        public void ProcessPayment(CreditCardData model)
        {
            // configure client & request settings
            ServicesContainer.ConfigureService(new GatewayConfig
            {
                MerchantId = "nutextileslondon",
                //MerchantId = "realexsandbox",
                AccountId    = "internet",
                SharedSecret = "secret",
                //SharedSecret = "Po8lRRT67a",
                ServiceUrl = "https://api.sandbox.realexpayments.com/epage-remote.cgi"
                             //ServiceUrl = "https://test.realexpayments.com/epage-remote.cgi"
            });

            try
            {
                // process an auto-settle authorization
                var response = model.Charge(129.99m)
                               .WithCurrency("EUR")
                               .Execute();

                var result  = response.ResponseCode;    // 00 == Success
                var message = response.ResponseMessage; // [ test system ] AUTHORISED

                // get the reponse details to save to the DB for future transaction management requests
                var orderId           = response.OrderId;
                var authCode          = response.AuthorizationCode;
                var paymentsReference = response.TransactionId; // pasref
            }

            catch (ApiException exce)
            {
                // TODO: add your error handling here
            }
        }
        public void Test_002_manual_sale()
        {
            //ProductData productData = new ProductData(ServiceLevel.FullServe, ProductCodeSet.IssuerSpecific);
            //productData.Add("01", UnitOfMeasure.Gallons, 1m, 10m, 10m);

            Transaction response = card.Charge(10m)
                                   .WithCurrency("USD")
                                   .WithProductData(productData)
                                   .WithFleetData(fleetData)
                                   .Execute();

            Assert.IsNotNull(response);
            System.Diagnostics.Debug.WriteLine(response.HostResponseDate);
            System.Diagnostics.Debug.WriteLine(response.SystemTraceAuditNumber);

            // check message data
            PriorMessageInformation pmi = response.MessageInformation;

            Assert.IsNotNull(pmi);
            Assert.AreEqual("1200", pmi.MessageTransactionIndicator);
            Assert.AreEqual("000900", pmi.ProcessingCode);
            Assert.AreEqual("200", pmi.FunctionCode);

            // check response
            Assert.AreEqual("000", response.ResponseCode);
        }
Beispiel #20
0
        public void CloseBatch_WithCardNumberDetails_DeclinedTransaction()
        {
            var card = new CreditCardData {
                Number   = "4263970000005262",
                ExpMonth = 05,
                ExpYear  = 2025,
                Cvn      = "852",
            };

            var chargeTransaction = card.Charge(1.99m)
                                    .WithCurrency(CURRENCY)
                                    .Execute();

            Assert.IsNotNull(chargeTransaction);
            Assert.AreEqual("DECLINED", chargeTransaction?.ResponseCode);
            Assert.AreEqual(GetMapping(TransactionStatus.Declined), chargeTransaction?.ResponseMessage);

            //TODO - remove when api fix polling issue
            Thread.Sleep(1000);

            var exceptionCaught = false;

            try {
                BatchService.CloseBatch(chargeTransaction.BatchSummary.BatchReference);
            }
            catch (GatewayException ex) {
                exceptionCaught = true;
                Assert.AreEqual("INVALID_BATCH_ACTION", ex.ResponseCode);
                Assert.AreEqual("40017", ex.ResponseMessage);
                Assert.AreEqual("Status Code: BadRequest - 9,No transaction associated with batch", ex.Message);
            }
            finally {
                Assert.IsTrue(exceptionCaught);
            }
        }
Beispiel #21
0
        public void CreditCard_JCB_Processing_Error()
        {
            ServicesContainer.ConfigureService(new GpApiConfig {
                AppId   = "Uyq6PzRbkorv2D4RQGlldEtunEeGNZll",
                AppKey  = "QDsW1ETQKHX6Y4TA",
                Channel = Channel.CardNotPresent,
            });

            var card = new CreditCardData {
                Number               = "3566000000002006",
                ExpMonth             = DateTime.Now.Month,
                ExpYear              = DateTime.Now.Year + 1,
                Cvn                  = "123",
                CvnPresenceIndicator = CvnPresenceIndicator.Present,
                CardHolderName       = "Mark Spencer"
            };

            try {
                var response = card.Charge(4.99m)
                               .WithCurrency("USD")
                               .WithDescription("CreditCard_JCB_Processing_Error")
                               .Execute();
            }
            catch (GatewayException ex) {
                Assert.AreEqual("50013", ex.ResponseMessage);
                Assert.AreEqual("SYSTEM_ERROR_DOWNSTREAM", ex.ResponseCode);
            }
        }
Beispiel #22
0
        public void CreditCard_JCB_Declined_103()
        {
            ServicesContainer.ConfigureService(new GpApiConfig {
                AppId   = "Uyq6PzRbkorv2D4RQGlldEtunEeGNZll",
                AppKey  = "QDsW1ETQKHX6Y4TA",
                Channel = Channel.CardNotPresent,
            });

            var card = new CreditCardData {
                Number               = "3566000000001032",
                ExpMonth             = DateTime.Now.Month,
                ExpYear              = DateTime.Now.Year + 1,
                Cvn                  = "123",
                CvnPresenceIndicator = CvnPresenceIndicator.Present,
                CardHolderName       = "Michael Smith"
            };

            var response = card.Charge(3.25m)
                           .WithCurrency("USD")
                           .WithDescription("CreditCard_JCB_Declined_103")
                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("JCB", response.CardType, true, "Card brand mismatch");
            Assert.AreEqual("103", response.AuthorizationCode);
            Assert.AreEqual(GetMapping(TransactionStatus.Declined), response.ResponseCode);
        }
Beispiel #23
0
        public void CreditCard_AmericanExpress_Success()
        {
            ServicesContainer.ConfigureService(new GpApiConfig {
                AppId   = "Uyq6PzRbkorv2D4RQGlldEtunEeGNZll",
                AppKey  = "QDsW1ETQKHX6Y4TA",
                Channel = Channel.CardNotPresent,
            });

            var card = new CreditCardData {
                Number               = "374101000000608",
                ExpMonth             = DateTime.Now.Month,
                ExpYear              = DateTime.Now.Year + 1,
                Cvn                  = "1234",
                CvnPresenceIndicator = CvnPresenceIndicator.Present,
                CardHolderName       = "Susan Jones"
            };

            var response = card.Charge(17.25m)
                           .WithCurrency("USD")
                           .WithDescription("CreditCard_AmericanExpress_Success")
                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("AMEX", response.CardType, true, "Card brand mismatch");
            Assert.AreEqual("00", response.AuthorizationCode);
            Assert.AreEqual(SUCCESS, response?.ResponseCode);
            Assert.AreEqual(GetMapping(TransactionStatus.Captured), response.ResponseMessage);
        }
Beispiel #24
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);
        }
Beispiel #25
0
        public void CreatePayLink_ThenCharge_WithTokenizedCard()
        {
            var response = PayLinkService.Create(payLink, AMOUNT)
                           .WithCurrency(CURRENCY)
                           .WithClientTransactionId(GenerationUtils.GenerateRecurringKey())
                           .WithDescription("March and April Invoice")
                           .Execute();

            AssertTransactionResponse(response);

            ServicesContainer.ConfigureService(SetupTransactionConfig(), "createTransaction");

            var tokenizedCard = new CreditCardData {
                Token = card.Tokenize("createTransaction")
            };

            var charge = tokenizedCard.Charge(AMOUNT)
                         .WithCurrency(CURRENCY)
                         .WithPaymentLinkId(response.PayLinkResponse.Id)
                         .Execute("createTransaction");

            Assert.IsNotNull(charge);
            Assert.AreEqual(SUCCESS, charge?.ResponseCode);
            Assert.AreEqual(GetMapping(TransactionStatus.Captured), charge?.ResponseMessage);

            Thread.Sleep(2000);

            var getPayLinkById = PayLinkService.PayLinkDetail(response.PayLinkResponse.Id)
                                 .Execute();

            Assert.IsNotNull(getPayLinkById);
            Assert.IsInstanceOfType(getPayLinkById, typeof(PayLinkSummary));
            Assert.AreEqual(response.PayLinkResponse.Id, getPayLinkById.Id);
            Assert.AreEqual(1, getPayLinkById.Transactions.Count);
        }
        public void Test_004_manual_sale()
        {
            Transaction response = card.Charge(10m)
                                   .WithCurrency("USD")
                                   .Execute();

            Assert.IsNotNull(response);
            System.Diagnostics.Debug.WriteLine(response.HostResponseDate);
            System.Diagnostics.Debug.WriteLine(response.SystemTraceAuditNumber);
            // check message data
            PriorMessageInformation pmi = response.MessageInformation;

            Assert.IsNotNull(pmi);
            Assert.AreEqual("1200", pmi.MessageTransactionIndicator);
            Assert.AreEqual("003000", pmi.ProcessingCode);
            Assert.AreEqual("200", pmi.FunctionCode);

            // check response
            Assert.AreEqual("000", response.ResponseCode);

            Transaction reversal = response.Reverse(10m)
                                   .WithCurrency("USD")
                                   .Execute();

            Assert.IsNotNull(reversal);
            System.Diagnostics.Debug.WriteLine("Reversal:");
            System.Diagnostics.Debug.WriteLine(reversal.HostResponseDate);
            System.Diagnostics.Debug.WriteLine(reversal.SystemTraceAuditNumber);
        }
Beispiel #27
0
        public void Charge_UsingSingleUseToken_ReturnsSuccessfulTransactionWithToken()
        {
            var service = new BillPayService();
            var fee     = service.CalculateConvenienceAmount(clearTextCredit, bill.Amount);

            var paymentMethod = new CreditCardData()
            {
                Token    = "ENTER SINGLE USE TOKEN VALUE",
                ExpMonth = 01,
                ExpYear  = 25
            };

            var transaction = RunAndValidateTransaction(() => {
                return(paymentMethod
                       .Charge(bill.Amount)
                       .WithAddress(address)
                       .WithBills(bill)
                       .WithConvenienceAmount(fee)
                       .WithCurrency("USD")
                       .WithRequestMultiUseToken(true)
                       .WithPaymentMethodUsageMode(PaymentMethodUsageMode.Single)
                       .Execute());
            });

            Assert.IsNotNull(transaction.Token);
        }
Beispiel #28
0
        public void Dental()
        {
            var autoSub = new AutoSubstantiation {
                MerchantVerificationValue = "12345",
                RealTimeSubstantiation    = false,
                DentalSubTotal            = 150m
            };

            var response = card.Charge(215m)
                           .WithCurrency("USD")
                           .WithAllowDuplicates(true)
                           .WithAutoSubstantiation(autoSub)
                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
        }
Beispiel #29
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.");
            }
        }
Beispiel #30
0
        public void CreditSale()
        {
            var address = new Address {
                StreetAddress1 = "123 Main St.",
                City           = "Downtown",
                State          = "NJ",
                Country        = "US",
                PostalCode     = "12345"
            };
            var response = card.Charge(19.99m)
                           .WithCurrency("USD")
                           .WithAddress(address)
                           .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual(SUCCESS, response?.ResponseCode);
            Assert.AreEqual(GetMapping(TransactionStatus.Captured), response?.ResponseMessage);
        }