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"));
        }
        /// <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 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"));
        }
        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"));
        }
        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 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 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 = 2025,
                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);
        }