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 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); }
public void Amex_Manual_ShouldVerify() { var creditSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig()); var response = creditSvc.Verify(TestCreditCard.ValidAmex, TestCardHolder.CertCardHolderShortZip, true); Assert.AreEqual("00", response.ResponseCode); }
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); }
/// <summary> /// Refunds a payment /// </summary> /// <param name="refundPaymentRequest">Request</param> /// <returns>Result</returns> public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest) { var result = new RefundPaymentResult(); var config = new HpsServicesConfig(); config.SecretApiKey = _secureSubmitPaymentSettings.SecretApiKey; config.DeveloperId = "002914"; config.VersionNumber = "1513"; var creditService = new HpsCreditService(config); try { creditService.Refund( refundPaymentRequest.AmountToRefund, _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode, Int32.Parse(refundPaymentRequest.Order.CaptureTransactionId)); var isOrderFullyRefunded = (refundPaymentRequest.AmountToRefund + refundPaymentRequest.Order.RefundedAmount == refundPaymentRequest.Order.OrderTotal); result.NewPaymentStatus = isOrderFullyRefunded ? PaymentStatus.Refunded : PaymentStatus.PartiallyRefunded; } catch (HpsException ex) { result.AddError(ex.Message); } return(result); }
/// <summary> /// Voids a payment /// </summary> /// <param name="voidPaymentRequest">Request</param> /// <returns>Result</returns> public VoidPaymentResult Void(VoidPaymentRequest voidPaymentRequest) { var result = new VoidPaymentResult(); var config = new HpsServicesConfig(); config.SecretApiKey = _secureSubmitPaymentSettings.SecretApiKey; config.DeveloperId = "002914"; config.VersionNumber = "1513"; var creditService = new HpsCreditService(config); try { if (string.IsNullOrEmpty(voidPaymentRequest.Order.CaptureTransactionId)) { creditService.Void(Convert.ToInt32(voidPaymentRequest.Order.AuthorizationTransactionId)); } else { creditService.Void(Convert.ToInt32(voidPaymentRequest.Order.CaptureTransactionId)); } result.NewPaymentStatus = PaymentStatus.Voided; } catch (HpsException ex) { result.AddError(ex.Message); } return(result); }
public void CreditChargeWithConvenienceAmt() { 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.Charge(10m, "usd", token_reponse.token_value, null, false, null, false, null, 0, null, 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); }
/// <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 CreditOfflineChargeWithTagData() { 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 = "9F4005F000F0A0019F02060000000001219F03060000000000009F260816AC7EB8C0DFC40982027C005F3401019F360203869F0702FF009F0802008C9F0902008C8A0259319F34031E03009F2701409F0D05F0400088009F0E0500100000009F0F05F0400098005F280208409F390105FFC605DC4000A800FFC7050010000000FFC805DC4004F8009F3303E0B8C89F1A0208409F350122950500000800005F2A0208409A031409029B02E8009F21031145219C01009F3704BEBD49924F07A00000000310109F0607A00000000310108407A00000000310109F100706010A039000029F410400000001", Source = TagDataTypeTagValuesSource.chip }; var response = creditService.OfflineCharge(10m, "usd", trackData, null, 0, 0, null, tagData, 0, 0); Assert.IsNotNull(response); Assert.AreEqual("00", response.ResponseCode); }
public void Amex_WhenCardIsOk_ShouldCharge() { var creditSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig()); var response = creditSvc.Charge(50).WithCard(TestCreditCard.ValidAmex).AllowPartialAuth(true).WithClientTransactionId(12345).Execute(); Assert.IsNotNull(response); StringAssert.Matches(response.ResponseCode, new Regex("00")); }
public void CreditVerifyWithTagData() { 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.Verify(trackData, null, false, null, tagData); Assert.IsNotNull(response); Assert.AreEqual("85", response.ResponseCode); }
public void List_WhenConfigValidNoTxn_ShouldListCharges() { var chargeSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig()); var items = chargeSvc.List(DateTime.UtcNow.AddDays(-10), DateTime.UtcNow); Assert.IsNotNull(items); }
public void Discover_Verify_ShouldReturnOk() { var creditSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig()); var response = creditSvc.Verify(TestCreditCard.ValidDiscover, TestCardHolder.ValidCardHolder); Assert.AreEqual("85", 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 Amex_Avs_ShouldBe_Ok() { var chargeSvc = new HpsCreditService(_certConfig); var response = chargeSvc.Verify(TestCreditCard.ValidAmex, TestCardHolder.CertCardHolderShortZipNoStreet); Assert.IsNotNull(response); StringAssert.Matches(response.ResponseCode, new Regex("^00$")); }
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 Amex_WhenCardIsOk_ShouldCharge() { var creditSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig()); var response = creditSvc.Charge(50).WithCard(TestCreditCard.ValidAmex).AllowPartialAuth(true).WithClientTransactionId(12345).Execute(); Assert.IsNotNull(response); StringAssert.Matches(response.ResponseCode, new Regex("00")); }
public void Mastercard_Return_ShouldBe_Ok() { var chargeSvc = new HpsCreditService(_certConfig); var response = chargeSvc.Refund(15.15m, "usd", TestCreditCard.ValidMasterCard, TestCardHolder.CertCardHolderShortZip); Assert.IsNotNull(response); StringAssert.Matches(response.ResponseCode, new Regex("^00$")); }
public void MasterCard_ShouldRefund_Ok() { var creditSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig()); var creditResponse = creditSvc.Charge(25.00m, "usd", TestCreditCard.ValidMasterCard, TestCardHolder.CertCardHolderShortZipNoStreet); var refundResponse = creditSvc.Refund(25.00m, "usd", creditResponse.TransactionId); StringAssert.Matches(refundResponse.ResponseCode, new Regex("^00$")); }
public void Discover_ShouldVerify_Ok() { var chargeSvc = new HpsCreditService(_certConfig); var response = chargeSvc.Verify(TestCreditCard.ValidDiscover); Assert.IsNotNull(response); StringAssert.Matches(response.ResponseCode, new Regex("^85$")); }
public void Visa_ShouldReverse_Ok() { var chargeSvc = new HpsCreditService(_certConfig); var response = chargeSvc.Reverse(17.01m, "usd", TestCreditCard.ValidVisa); Assert.IsNotNull(response); StringAssert.Matches(response.ResponseCode, new Regex("^00$")); }
public void Cc_ShouldOfflineCharge_Ok() { var chargeSvc = new HpsCreditService(TestServicesConfig.ValidServicesConfig()); var charge = chargeSvc.OfflineCharge(20, "usd", TestCreditCard.ValidVisa, "654321", true); Assert.IsNotNull(charge); StringAssert.Matches(charge.ResponseCode, new Regex("^00$")); }
public void Discover_ShouldVoid_Ok() { var creditSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig()); var creditResponse = creditSvc.Charge(25.00m, "usd", TestCreditCard.ValidDiscover, TestCardHolder.CertCardHolderShortZipNoStreet); var voidResponse = creditSvc.Void(creditResponse.TransactionId).Execute(); StringAssert.Matches(voidResponse.ResponseCode, new Regex("^00$")); }
public void List_WhenConfigValid_ShouldListTransactions() { var chargeSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig()); List <HpsReportTransactionSummary> items = chargeSvc.List(DateTime.Today.AddDays(-10), DateTime.Today); Assert.IsNotNull(items); }
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 MasterCard_ShouldCharge_Ok() { var chargeSvc = new HpsCreditService(_certConfig); var response = chargeSvc.Charge(17.02m, "usd", TestCreditCard.ValidMasterCard, TestCardHolder.CertCardHolderShortZipNoStreet, false, TestDescriptor); Assert.IsNotNull(response); StringAssert.Matches(response.ResponseCode, new Regex("^00$")); }
public void MasterCard_PresentManual_ShouldCharge() { var service = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig()); var response = service.Charge(16.02m, "usd", TestCreditCard.ValidMasterCard, TestCardHolder.CertCardHolderShortZipNoStreet, false, TestDescriptor); Assert.IsNotNull(response); StringAssert.Matches(response.ResponseCode, new Regex("^00$")); }
public void Discover_ShouldCharge_Ok() { var chargeSvc = new HpsCreditService(_certConfig); var response = chargeSvc.Charge(17.03m, "usd", TestCreditCard.ValidDiscover, TestCardHolder.CertCardHolderLongZipNoStreet, false, TestDescriptor); Assert.IsNotNull(response); StringAssert.Matches(response.ResponseCode, new Regex("^00$")); }
public void Jcb_NotPresentManual_ShouldCharge() { var service = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig()); var response = service.Charge(17.05m, "usd", TestCreditCard.ValidJcb, TestCardHolder.CertCardHolderLongZip, false, TestDescriptor); Assert.IsNotNull(response); StringAssert.Matches(response.ResponseCode, new Regex("^00$")); }
public void Batch_WhenOpen_ShouldClose() { var creditSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig()); creditSvc.Charge(50).WithCard(TestCreditCard.ValidAmex).AllowDuplicates().Execute(); var batchSvc = new HpsBatchService(TestServicesConfig.ValidSecretKeyConfig()); var response = batchSvc.Close().WithClientTransactionId(12345).Execute(); Assert.IsNotNull(response); }
public void Integration_WhenTokenIsAcquired_ShouldBeAbleToCharge() { var response = _tokenService.GetToken(_card); var chargeService = new HpsCreditService(new HpsServicesConfig { SecretApiKey = "skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A" }); var charge = chargeService.Charge(1, "usd", response.token_value, TestCardHolder.ValidCardHolder); Assert.IsNotNull(charge.AuthorizationCode); }
public void Cc_ShouldPartialReverse_Ok() { var chargeSvc = new HpsCreditService(TestServicesConfig.ValidServicesConfig()); var charge = chargeSvc.Charge(20, "usd", TestCreditCard.ValidVisa, TestCardHolder.CertCardHolderShortZip); var response = chargeSvc.Reverse(charge.TransactionId, 20, "usd", null, 10); Assert.IsNotNull(response); StringAssert.Matches(response.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); }
public void Batch_WhenOpen_ShouldClose() { var creditSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig()); creditSvc.Charge(50).WithCard(TestCreditCard.ValidAmex).AllowDuplicates().Execute(); var batchSvc = new HpsBatchService(TestServicesConfig.ValidSecretKeyConfig()); var response = batchSvc.Close().WithClientTransactionId(12345).Execute(); Assert.IsNotNull(response); }
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 Charge_WhenAmountIsLessThanZero_ShouldThrowArgumentOutOfRange() { const decimal ChargeAmount = -5; var chargeSvc = new HpsCreditService(); try { chargeSvc.Charge(ChargeAmount, "usd", TestCreditCard.ValidVisa, TestCardHolder.ValidCardHolder); } catch (HpsInvalidRequestException e) { Assert.AreEqual(e.Code, HpsExceptionCodes.InvalidAmount); Assert.AreEqual(e.ParamName, "amount"); return; } Assert.Fail("No exception was thrown."); }
public void Charge_WhenCurrencyIsNotUsd_ShouldThrowArgumentException() { const decimal ChargeAmount = 50; const string Currency = "eur"; var chargeSvc = new HpsCreditService(); try { chargeSvc.Charge(ChargeAmount, Currency, TestCreditCard.ValidVisa, TestCardHolder.ValidCardHolder); } catch (HpsInvalidRequestException e) { Assert.AreEqual(e.Code, HpsExceptionCodes.InvalidCurrency); Assert.AreEqual(e.ParamName, "currency"); return; } Assert.Fail("No exception was thrown."); }
public void MasterCard_WhenCardIsOkAndIncludesDetails_ShouldReturnValidResult() { var service = new HpsCreditService(TestServicesConfig.ValidServicesConfig()); var charge = service.Charge(50, "usd", TestCreditCard.ValidMasterCard, TestCardHolder.ValidCardHolder, false, "descriptor", true, new HpsTransactionDetails { Memo = "memo", InvoiceNumber = "1234", CustomerId = "customerID", ClientTransactionId = 12345678 }); Assert.IsNotNull(charge); StringAssert.Matches(charge.ResponseCode, new Regex("00")); var transaction = service.Get(charge.TransactionId); Assert.IsNotNull(transaction); StringAssert.Matches(transaction.Memo, new Regex("memo")); StringAssert.Matches(transaction.InvoiceNumber, new Regex("1234")); StringAssert.Matches(transaction.CustomerId, new Regex("customerID")); Assert.AreEqual(charge.ClientTransactionId, 12345678); }
public void List_WhenConfigValid_ShouldListTransactions() { var chargeSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig()); List<HpsReportTransactionSummary> items = chargeSvc.List(DateTime.Today.AddDays(-10), DateTime.Today); Assert.IsNotNull(items); }
public void List_WhenConfigValidNoTxn_ShouldListCharges() { var chargeSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig()); var items = chargeSvc.List(DateTime.UtcNow.AddDays(-10), DateTime.UtcNow); Assert.IsNotNull(items); }
/// <summary>Charge a MC with a valid config and valid MC info.</summary> /// <param name="amt">Amount to charge</param> /// <returns>The HPS Charge.</returns> private HpsCharge ChargeValidMasterCard(decimal amt) { var creditSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig()); var response = creditSvc.Charge(amt, "usd", TestCreditCard.ValidMasterCard, TestCardHolder.ValidCardHolder); if (response == null) { Assert.Fail("Response is null."); } return response; }
public void Cc_ShouldPartialReverse_Ok() { var chargeSvc = new HpsCreditService(TestServicesConfig.ValidServicesConfig()); var charge = chargeSvc.Charge(20, "usd", TestCreditCard.ValidVisa, TestCardHolder.CertCardHolderShortZip); var response = chargeSvc.Reverse(charge.TransactionId, 20, "usd", null, 10); Assert.IsNotNull(response); StringAssert.Matches(response.ResponseCode, new Regex("^00$")); }
public void ManageTokens() { var service = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig()); var response = service.Verify(new HpsCreditCard { Number = "4111111111111111", ExpMonth = 12, ExpYear = 2015, Cvv = "123" }, null, true); Assert.IsNotNull(response); Assert.IsNotNull(response.TokenData); Assert.AreEqual("85", response.ResponseCode); Assert.AreEqual(0, response.TokenData.TokenRspCode); var token = response.TokenData.TokenValue; var updateRepsonse = service.UpdateTokenExpiration(token, 12, 2025); Assert.IsNotNull(updateRepsonse); Assert.AreEqual("0", updateRepsonse.ResponseCode); }
public void Discover_ShouldVerify_Ok() { var chargeSvc = new HpsCreditService(_certConfig); var response = chargeSvc.Verify(TestCreditCard.ValidDiscover); Assert.IsNotNull(response); StringAssert.Matches(response.ResponseCode, new Regex("^85$")); }
public void Mastercard_Return_ShouldBe_Ok() { var chargeSvc = new HpsCreditService(_certConfig); var response = chargeSvc.Refund(15.15m, "usd", TestCreditCard.ValidMasterCard, TestCardHolder.CertCardHolderShortZip); Assert.IsNotNull(response); StringAssert.Matches(response.ResponseCode, new Regex("^00$")); }
public void Charge_WhenHpsConfigIsInvalid_ShouldThrowHpsException() { const decimal ChargeAmount = 50; const string Currency = "usd"; var chargeSvc = new HpsCreditService(); try { chargeSvc.Charge(ChargeAmount, Currency, TestCreditCard.ValidVisa, TestCardHolder.ValidCardHolder); } catch (HpsAuthenticationException e) { StringAssert.Contains(e.Message, Resource.Exception_Message_InvalidConfig); return; } Assert.Fail("No exception was thrown."); }
public void Mastercard_Verify_ShouldReturnOk() { var creditSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig()); var response = creditSvc.Verify(TestCreditCard.ValidMasterCard, TestCardHolder.ValidCardHolder); Assert.AreEqual("85", response.ResponseCode); }
public void Amex_WhenValidTrackData_ShouldReturnValidResult() { var service = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig()); var charge = service.Charge(50, "usd", new HpsTrackData { Value = "%B3727 006992 51018^AMEX TEST CARD^2512990502700?;372700699251018=2512990502700?", Method = HpsTrackDataMethod.Swipe }); Assert.IsNotNull(charge); StringAssert.Matches(charge.ResponseCode, new Regex("00")); }
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 GetFirst_WhenConfigValid_ShouldGetTheFirstCharge() { var chargeSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig()); var items = chargeSvc.List(DateTime.Today.AddDays(-10), DateTime.Today); if (items.Count <= 0) return; var charge = chargeSvc.Get(items[0].TransactionId); Assert.IsNotNull(charge); }
public void Charge_WhenCardNumberIsInvalid_ShouldThrowHpsException() { const decimal ChargeAmount = 50; const string Currency = "usd"; var chargeSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig()); try { chargeSvc.Charge(ChargeAmount, Currency, TestCreditCard.InvalidCard, TestCardHolder.ValidCardHolder); } catch (HpsGatewayException e) { Assert.AreEqual(HpsExceptionCodes.InvalidNumber, e.Code); return; } Assert.Fail("No exception was thrown."); }
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 Visa_ShouldReverse_Ok() { var chargeSvc = new HpsCreditService(_certConfig); var response = chargeSvc.Reverse(17.01m, "usd", TestCreditCard.ValidVisa); Assert.IsNotNull(response); StringAssert.Matches(response.ResponseCode, new Regex("^00$")); }
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 Amex_Avs_ShouldBe_Ok() { var chargeSvc = new HpsCreditService(_certConfig); var response = chargeSvc.Verify(TestCreditCard.ValidAmex, TestCardHolder.CertCardHolderShortZipNoStreet); Assert.IsNotNull(response); StringAssert.Matches(response.ResponseCode, new Regex("^00$")); }
public void MasterCard_ShouldVoid_Ok() { var creditSvc = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig()); var creditResponse = creditSvc.Charge(25.00m, "usd", TestCreditCard.ValidMasterCard, TestCardHolder.CertCardHolderShortZipNoStreet); var voidResponse = creditSvc.Void(creditResponse.TransactionId).Execute(); StringAssert.Matches(voidResponse.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); }
public void Mastercard_WhenValidTrackData_ShouldReturnValidResult() { var r = new Random(); var service = new HpsCreditService(TestServicesConfig.ValidSecretKeyConfig()); var charge = service.Charge(r.Next(1, 50), "usd", new HpsTrackData { Value = "%B5473500000000014^MC TEST CARD^251210199998888777766665555444433332?;5473500000000014=25121019999888877776?", Method = HpsTrackDataMethod.Swipe }); Assert.IsNotNull(charge); StringAssert.Matches(charge.ResponseCode, new Regex("00")); }
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); }
public void Cc_ShouldOfflineCharge_Ok() { var chargeSvc = new HpsCreditService(TestServicesConfig.ValidServicesConfig()); var charge = chargeSvc.OfflineCharge(20, "usd", TestCreditCard.ValidVisa, "654321", true); Assert.IsNotNull(charge); StringAssert.Matches(charge.ResponseCode, new Regex("^00$")); }