public void Discover_Authorize_ShouldReturnOk()
        {
            var creditSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig());
            var response  = creditSvc.Authorize(50, "usd", TestCreditCard.ValidDiscover, TestCardHolder.ValidCardHolder);

            Assert.AreEqual("00", response.ResponseCode);
        }
示例#2
0
        public void CreditAuthWithConvenienceAmt()
        {
            var card = new HpsCreditCard
            {
                Number   = "4111111111111111",
                ExpMonth = 12,
                ExpYear  = 2014,
                Cvv      = "123"
            };

            var tokenService  = new HpsTokenService("pkapi_cert_m0e9bI2WbBHk0ALyQL");
            var token_reponse = tokenService.GetToken(card);

            var creditService = new HpsCreditService(new HpsServicesConfig
            {
                SecretApiKey = "skapi_cert_MTeSAQAfG1UA9qQDrzl-kz4toXvARyieptFwSKP24w"
            });
            var response = creditService.Authorize(10m, "usd", token_reponse.token_value, null, false, null, false, null, 0, 12, 2025, 2m);

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

            var transactionDetails = creditService.Get(response.TransactionId);

            Assert.IsNotNull(transactionDetails);
            Assert.AreEqual(2m, transactionDetails.ConvenienceAmount);
        }
示例#3
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);
        }
示例#4
0
        public void CreditAuthWithTagData()
        {
            var card = new HpsCreditCard
            {
                Number   = "4111111111111111",
                ExpMonth = 12,
                ExpYear  = 2014,
                Cvv      = "123"
            };

            var tokenService  = new HpsTokenService("pkapi_cert_m0e9bI2WbBHk0ALyQL");
            var token_reponse = tokenService.GetToken(card);

            var creditService = new HpsCreditService(new HpsServicesConfig
            {
                SecretApiKey = "skapi_cert_MTeSAQAfG1UA9qQDrzl-kz4toXvARyieptFwSKP24w"
            });
            var trackData = new HpsTrackData {
                Value = ";4761739001010036=15122011184404889?"
            };
            var tagData = new HpsTagDataType
            {
                TagData = "9F4005F000F0A0019F02060000000025009F03060000000000009F2608D90A06501B48564E82027C005F3401019F360200029F0702FF009F0802008C9F0902008C9F34030403029F2701809F0D05F0400088009F0E0508000000009F0F05F0400098005F280208409F390105FFC605DC4000A800FFC7050010000000FFC805DC4004F8009F3303E0B8C89F1A0208409F350122950500000080005F2A0208409A031409109B02E8009F21030811539C01009F37045EED3A8E4F07A00000000310109F0607A00000000310108407A00000000310109F100706010A03A400029F410400000001",
                Source  = TagDataTypeTagValuesSource.chip
            };
            var response = creditService.Authorize(10m, "usd", trackData, null, 0, false, false, null, tagData, 0, 0);

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
        }
 public void Amex_WhenCardIsOk_ShouldAuthorize()
 {
     var creditSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig());
     var response = creditSvc.Authorize(50).WithCard(TestCreditCard.ValidAmex).Execute();
     Assert.IsNotNull(response);
     StringAssert.Matches(response.ResponseCode, new Regex("00"));
 }
示例#6
0
        public void Amex_WhenCardIsOk_ShouldAuthorize()
        {
            var creditSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig());
            var response  = creditSvc.Authorize(50).WithCard(TestCreditCard.ValidAmex).Execute();

            Assert.IsNotNull(response);
            StringAssert.Matches(response.ResponseCode, new Regex("00"));
        }
        public void Discover_AuthorizeAndRequestToken_ShouldGetTokenAndReturnOk()
        {
            var creditSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig());
            var response  = creditSvc.Authorize(50, "usd", TestCreditCard.ValidDiscover, TestCardHolder.ValidCardHolder, true);

            Assert.AreEqual(0, response.TokenData.TokenRspCode);
            Assert.AreEqual("00", response.ResponseCode);
        }
        public void Cc_ShouldOPartialApprove_Ok()
        {
            var chargeSvc = new HpsCreditService(TestServicesConfig.ValidServicesConfig());
            var charge    = chargeSvc.Authorize(20, "usd", TestCreditCard.ValidVisa, TestCardHolder.ValidCardHolder, false, null, true);

            Assert.IsNotNull(charge);
            StringAssert.Matches(charge.ResponseCode, new Regex("^00$"));
        }
        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);
        }
示例#10
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"));
        }
示例#11
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"));
        }
示例#12
0
        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);
        }
示例#13
0
        public void CreditAuthWithNegativeConvenienceAmt_1()
        {
            var card = new HpsCreditCard
            {
                Number   = "4111111111111111",
                ExpMonth = 12,
                ExpYear  = 2014,
                Cvv      = "123"
            };

            var creditService = new HpsCreditService(new HpsServicesConfig
            {
                SecretApiKey = "skapi_cert_MTeSAQAfG1UA9qQDrzl-kz4toXvARyieptFwSKP24w"
            });
            var response = creditService.Authorize(10m, "usd", card, null, false, null, false, null, 0, -2m);
        }
示例#14
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"));
        }
示例#15
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"));
        }
示例#16
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);
        }
示例#18
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);
        }
示例#19
0
        public void CreditAuthWithNegativeConvenienceAmt()
        {
            var card = new HpsCreditCard
            {
                Number   = "4111111111111111",
                ExpMonth = 12,
                ExpYear  = 2014,
                Cvv      = "123"
            };

            var tokenService  = new HpsTokenService("pkapi_cert_m0e9bI2WbBHk0ALyQL");
            var token_reponse = tokenService.GetToken(card);

            var creditService = new HpsCreditService(new HpsServicesConfig
            {
                SecretApiKey = "skapi_cert_MTeSAQAfG1UA9qQDrzl-kz4toXvARyieptFwSKP24w"
            });
            var response = creditService.Authorize(10m, "usd", token_reponse.token_value, null, false, null, false, null, 0, 12, 2025, -2m);
        }
示例#20
0
        public void CreditAuthWithShippingAmt_1()
        {
            var card = new HpsCreditCard
            {
                Number   = "4111111111111111",
                ExpMonth = 12,
                ExpYear  = 2014,
                Cvv      = "123"
            };

            var creditService = new HpsCreditService(new HpsServicesConfig
            {
                SecretApiKey = "skapi_cert_MTeSAQAfG1UA9qQDrzl-kz4toXvARyieptFwSKP24w"
            });
            var response = creditService.Authorize(10m, "usd", card, null, false, null, false, null, 0, 0, 2m);

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
            var transactionDetails = creditService.Get(response.TransactionId);

            Assert.IsNotNull(transactionDetails);
            Assert.AreEqual(2m, transactionDetails.ShippingAmount);
        }
        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 Mastercard_AuthorizeAndRequestToken_ShouldGetTokenAndReturnOk()
 {
     var creditSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig());
     var response = creditSvc.Authorize(50, "usd", TestCreditCard.ValidMasterCard, TestCardHolder.ValidCardHolder, true);
     Assert.AreEqual(0, response.TokenData.TokenRspCode);
     Assert.AreEqual("00", response.ResponseCode);
 }
 public void Mastercard_Authorize_ShouldReturnOk()
 {
     var creditSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig());
     var response = creditSvc.Authorize(50, "usd", TestCreditCard.ValidMasterCard, TestCardHolder.ValidCardHolder);
     Assert.AreEqual("00", response.ResponseCode);
 }
        /// <summary>
        /// Process a payment
        /// </summary>
        /// <param name="processPaymentRequest">Payment info required for an order processing</param>
        /// <returns>Process payment result</returns>
        public ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest)
        {
            var result = new ProcessPaymentResult();
            var token  = (string)processPaymentRequest.CustomValues["token_value"];

            var config = new HpsServicesConfig();

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

            var creditService = new HpsCreditService(config);
            var customer      = _customerService.GetCustomerById(processPaymentRequest.CustomerId);

            var cardHolder = new HpsCardHolder();

            cardHolder.Address         = new HpsAddress();
            cardHolder.Address.Address = customer.BillingAddress.Address1;
            cardHolder.Address.City    = customer.BillingAddress.City;
            cardHolder.Address.State   =
                customer.BillingAddress.StateProvince != null
                ? customer.BillingAddress.StateProvince.Abbreviation
                : null;
            cardHolder.Address.Zip     = customer.BillingAddress.ZipPostalCode.Replace("-", "").Replace(" ", "");
            cardHolder.Address.Country = customer.BillingAddress.Country.ThreeLetterIsoCode;

            HpsAuthorization response = null;

            try
            {
                if (_secureSubmitPaymentSettings.TransactMode == TransactMode.Authorize)
                {
                    // auth
                    response = creditService.Authorize(
                        processPaymentRequest.OrderTotal,
                        _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode,
                        token,
                        cardHolder,
                        false);

                    result.NewPaymentStatus             = PaymentStatus.Authorized;
                    result.AuthorizationTransactionCode = response.AuthorizationCode;
                    result.AuthorizationTransactionId   = response.TransactionId.ToString();
                }
                else
                {
                    //capture
                    response = creditService.Charge(
                        processPaymentRequest.OrderTotal,
                        _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode,
                        token,
                        cardHolder,
                        false);

                    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);
        }
 public void Cc_ShouldOPartialApprove_Ok()
 {
     var chargeSvc = new HpsCreditService(TestServicesConfig.ValidServicesConfig());
     var charge = chargeSvc.Authorize(20, "usd", TestCreditCard.ValidVisa, TestCardHolder.ValidCardHolder, false, null, true);
     Assert.IsNotNull(charge);
     StringAssert.Matches(charge.ResponseCode, new Regex("^00$"));
 }