示例#1
0
        public static void CaptureCard()
        {
            var chargeService = new HpsCreditService(
                new HpsServicesConfig {
                SecretApiKey = "<your secret api key goes here>"
            });

            var creditCard = new HpsCreditCard                  // Valid Visa
            {
                Cvv      = "123",
                ExpMonth = 12,
                ExpYear  = 2015,
                Number   = "4012002000060016"
            };

            var cardHolder = new HpsCardHolder
            {
                Email     = "*****@*****.**",
                FirstName = "First",
                LastName  = "Last",
                Phone     = "555-555-5555",
                Address   = new HpsAddress {
                    Zip = "47130"
                }                                             // Zip is the only required address field.
            };

            var authResponse = chargeService.Authorize(10, "usd", creditCard, cardHolder);

            chargeService.Capture(authResponse.TransactionId);
        }
        /// <summary>
        /// Captures payment
        /// </summary>
        /// <param name="capturePaymentRequest">Capture payment request</param>
        /// <returns>Capture payment result</returns>
        public CapturePaymentResult Capture(CapturePaymentRequest capturePaymentRequest)
        {
            var result = new CapturePaymentResult();

            var config = new HpsServicesConfig();

            config.SecretApiKey  = _secureSubmitPaymentSettings.SecretApiKey;
            config.DeveloperId   = "002914";
            config.VersionNumber = "1513";

            var creditService = new HpsCreditService(config);

            try
            {
                var response = creditService.Capture(Convert.ToInt32(capturePaymentRequest.Order.AuthorizationTransactionId), capturePaymentRequest.Order.OrderTotal);

                result.NewPaymentStatus         = PaymentStatus.Paid;
                result.CaptureTransactionId     = response.TransactionId.ToString();
                result.CaptureTransactionResult = response.ResponseText;
            }
            catch (HpsException ex)
            {
                result.AddError(ex.Message);
            }

            return(result);
        }
        public void Cc_ShouldTipEdit_Ok()
        {
            var creditSvc    = new HpsCreditService(TestServicesConfig.ValidServicesConfig());
            var authResponse = creditSvc.Authorize(50, "usd", TestCreditCard.ValidVisa, TestCardHolder.ValidCardHolder);

            Assert.AreEqual("00", authResponse.ResponseCode);

            var captureResponse = creditSvc.Capture(authResponse.TransactionId, null, 5);

            Assert.AreEqual("00", captureResponse.ResponseCode);
        }
示例#4
0
        public void Mastercard_Manual_ShouldPartiallyApproveAndCapture()
        {
            var service = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig());
            var auth    = service.Authorize(65, "usd", TestCreditCard.ValidMasterCard, TestCardHolder.CertCardHolderShortZip);

            Assert.AreEqual("00", auth.ResponseCode);

            var capture = service.Capture(auth.TransactionId, 145);

            Assert.IsNotNull(capture);
            StringAssert.Matches(capture.ResponseCode, new Regex("00"));
        }
示例#5
0
        public void Mastercard_ManualNotPresent_ShouldAuthorizeAndCapture()
        {
            var service = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig());
            var auth    = service.Authorize(17.09m, "usd", TestCreditCard.ValidMasterCard, TestCardHolder.CertCardHolderStreetNumberZipOnly);

            Assert.AreEqual("00", auth.ResponseCode);

            var capture = service.Capture(auth.TransactionId, null);

            Assert.IsNotNull(capture);
            StringAssert.Matches(capture.ResponseCode, new Regex("00"));
        }
        public void Discover_Capture_ShouldReturnOk()
        {
            // Authorize the card.
            var creditSvc    = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig());
            var authResponse = creditSvc.Authorize(50, "usd", TestCreditCard.ValidDiscover, TestCardHolder.ValidCardHolder);

            Assert.AreEqual("00", authResponse.ResponseCode);

            // Capture the authorization.
            var captureResponse = creditSvc.Capture(authResponse.TransactionId, null);

            Assert.AreEqual("00", captureResponse.ResponseCode);
        }
示例#7
0
        public void Visa_Swipe_ShouldPartiallyApproveAndCapture()
        {
            var service = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig());
            var auth    = service.Authorize(110, "usd", new HpsTrackData
            {
                Value  = "%B4012002000060016^VI TEST CREDIT^251210118039000000000396?;4012002000060016=25121011803939600000?",
                Method = HpsTrackDataMethod.Swipe
            });

            Assert.IsNotNull(auth);
            StringAssert.Matches(auth.ResponseCode, new Regex("00"));

            var capture = service.Capture(auth.TransactionId, 130);

            Assert.IsNotNull(capture);
            StringAssert.Matches(capture.ResponseCode, new Regex("00"));
        }
示例#8
0
        public void Discover_Swipe_ShouldPartiallyApproveAndCapture()
        {
            var service = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig());
            var auth    = service.Authorize(40, "usd", new HpsTrackData
            {
                Value  = "%B6011000990156527^DIS TEST CARD^25121011000062111401?;6011000990156527=25121011000062111401?",
                Method = HpsTrackDataMethod.Swipe
            });

            Assert.IsNotNull(auth);
            StringAssert.Matches(auth.ResponseCode, new Regex("00"));

            var capture = service.Capture(auth.TransactionId, 40);

            Assert.IsNotNull(capture);
            StringAssert.Matches(capture.ResponseCode, new Regex("00"));
        }
示例#9
0
        public void Mastercard_Swipe_ShouldAuthorizeAndCaptureWithTokenReq()
        {
            var service = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig());
            var auth    = service.Authorize(15.09m, "usd", new HpsTrackData
            {
                Value  = "%B5473500000000014^MC TEST CARD^251210199998888777766665555444433332?;5473500000000014=25121019999888877776?",
                Method = HpsTrackDataMethod.Swipe
            });

            Assert.IsNotNull(auth);
            StringAssert.Matches(auth.ResponseCode, new Regex("00"));

            var capture = service.Capture(auth.TransactionId, null);

            Assert.IsNotNull(capture);
            StringAssert.Matches(capture.ResponseCode, new Regex("00"));
        }
        public void Visa_Capture_ShouldReturnOk()
        {
            var random = new Random();
            var randomNumber = random.Next(10, 100);

            // Authorize the card.
            var creditSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig());
            var authResponse = creditSvc.Authorize(randomNumber)
                .WithCard(TestCreditCard.ValidVisa)
                .WithCardHolder(TestCardHolder.ValidCardHolder)
                .Execute();

            Assert.AreEqual("00", authResponse.ResponseCode);

            // Capture the authorization.
            var captureResponse = creditSvc.Capture(authResponse.TransactionId).Execute();
            Assert.AreEqual("00", captureResponse.ResponseCode);
        }
示例#11
0
        public void Visa_Capture_ShouldReturnOk()
        {
            var random       = new Random();
            var randomNumber = random.Next(10, 100);

            // Authorize the card.
            var creditSvc    = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig());
            var authResponse = creditSvc.Authorize(randomNumber)
                               .WithCard(TestCreditCard.ValidVisa)
                               .WithCardHolder(TestCardHolder.ValidCardHolder)
                               .Execute();

            Assert.AreEqual("00", authResponse.ResponseCode);

            // Capture the authorization.
            var captureResponse = creditSvc.Capture(authResponse.TransactionId).Execute();

            Assert.AreEqual("00", captureResponse.ResponseCode);
        }
        public void Mastercard_Capture_ShouldReturnOk()
        {
            // Authorize the card.
            var creditSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig());
            var authResponse = creditSvc.Authorize(50, "usd", TestCreditCard.ValidMasterCard, TestCardHolder.ValidCardHolder);
            Assert.AreEqual("00", authResponse.ResponseCode);

            // Capture the authorization.
            var captureResponse = creditSvc.Capture(authResponse.TransactionId, null);
            Assert.AreEqual("00", captureResponse.ResponseCode);
        }
        public void Cc_ShouldTipEdit_Ok()
        {
            var creditSvc = new HpsCreditService(TestServicesConfig.ValidServicesConfig());
            var authResponse = creditSvc.Authorize(50, "usd", TestCreditCard.ValidVisa, TestCardHolder.ValidCardHolder);
            Assert.AreEqual("00", authResponse.ResponseCode);

            var captureResponse = creditSvc.Capture(authResponse.TransactionId, null, 5);
            Assert.AreEqual("00", captureResponse.ResponseCode);
        }