public void SaleWithSignatureCapture() { _device.OnMessageSent += (message) => { Assert.IsNotNull(message); }; var card = new HpsCreditCard { Number = "4005554444444460", ExpMonth = 12, ExpYear = 17, Cvv = "123" }; var address = new HpsAddress { Address = "1 Heartland Way", Zip = "95124" }; var response = _device.CreditSale(1, 12m) .WithAllowDuplicates(true) .WithCard(card) .WithAddress(address) .WithSignatureCapture(true) .Execute(); Assert.IsNotNull(response); Assert.AreEqual("00", response.ResponseCode); }
public void Void() { _device.OnMessageSent += (message) => { Assert.IsNotNull(message); }; var card = new HpsCreditCard { Number = "4005554444444460", ExpMonth = 12, ExpYear = 17, Cvv = "123" }; var address = new HpsAddress { Address = "1 Heartland Way", Zip = "95124" }; var saleResponse = _device.CreditSale(1, 16m) .WithCard(card) .WithAddress(address) .WithAllowDuplicates(true) .WithRequestMultiUseToken(true) .Execute(); Assert.IsNotNull(saleResponse); Assert.AreEqual("00", saleResponse.ResponseCode); var voidResponse = _device.CreditVoid(1).WithTransactionId(saleResponse.TransactionId).Execute(); Assert.IsNotNull(voidResponse); Assert.AreEqual("00", voidResponse.ResponseCode); }
public void VerifyManual() { _device.OnMessageSent += (message) => { Assert.IsNotNull(message); }; var card = new HpsCreditCard { Number = "4005554444444460", ExpMonth = 12, ExpYear = 17, Cvv = "123" }; var address = new HpsAddress { Address = "1 Heartland Way", Zip = "95124" }; var response = _device.CreditVerify(1) .WithCard(card) .WithAddress(address) .Execute(); Assert.IsNotNull(response); Assert.AreEqual("85", response.ResponseCode); }
internal ConsumerInfoType HydrateConsumerInfo(HpsCheckHolder checkHolder) { var consumerInfo = new ConsumerInfoType(); if (checkHolder.Address != null) { HpsAddress address = checkHolder.Address; consumerInfo.Address1 = address.Address; consumerInfo.City = address.City; consumerInfo.State = address.State; consumerInfo.Zip = address.Zip; } consumerInfo.CheckName = checkHolder.CheckName; consumerInfo.CourtesyCard = checkHolder.CourtesyCard; consumerInfo.DLNumber = checkHolder.DlNumber; consumerInfo.DLState = checkHolder.DlState; consumerInfo.EmailAddress = checkHolder.Email; consumerInfo.FirstName = checkHolder.FirstName; consumerInfo.LastName = checkHolder.LastName; consumerInfo.PhoneNumber = checkHolder.Phone; if (checkHolder.Ssl4 != null || checkHolder.DobYear != null) { consumerInfo.IdentityInfo = new IdentityInfoType(); if (checkHolder.DobYear.HasValue) { consumerInfo.IdentityInfo.DOBYear = checkHolder.DobYear.Value.ToString(); } if (!string.IsNullOrEmpty(checkHolder.Ssl4)) { consumerInfo.IdentityInfo.SSNL4 = checkHolder.Ssl4; } } return(consumerInfo); }
private void ProcessPayment() { var details = GetOrderDetails(); var config = new HpsServicesConfig { // The following variables will be provided to you during certification SecretApiKey = "skapi_cert_MYl2AQAowiQAbLp5JesGKh7QFkcizOP2jcX9BrEMqQ", VersionNumber = "0000", DeveloperId = "000000" }; var chargeService = new HpsCreditService(config); var numbers = new Regex("^[0-9]+$"); var address = new HpsAddress { Address = details.Address, City = details.City, State = details.State, Country = "United States", Zip = numbers.Match(details.Zip ?? string.Empty).ToString() }; var validCardHolder = new HpsCardHolder { FirstName = details.FirstName, LastName = details.LastName, Address = address, Phone = numbers.Match(details.PhoneNumber ?? string.Empty).ToString() }; var suToken = new HpsTokenData { TokenValue = details.Token_value }; try { var authResponse = chargeService.Charge(15.15m, "usd", suToken.TokenValue, validCardHolder); SendEmail(); Response.Write("<h1>Success!</h1><p>Thank you, " + details.FirstName + ", for your order of $15.15.</p>" + "Transaction Id: " + authResponse.TransactionId); } catch (HpsInvalidRequestException e) { // handle error for amount less than zero dollars Response.Write("<h3>Error</h3>" + "<strong>amount less than zero dollars: " + e.Message + "</strong>"); } catch (HpsAuthenticationException e) { // handle errors related to your HpsServiceConfig Response.Write("<h3>Error</h3>" + "<strong>Bad Config: " + e.Message + "</strong>"); } catch (HpsCreditException e) { // handle card-related exceptions: card declined, processing error, etc Response.Write("<h3>Error</h3>" + "<strong>card declined, processing error, etc: " + e.Message + "</strong>"); } catch (HpsGatewayException e) { // handle gateway-related exceptions: invalid cc number, gateway-timeout, etc Response.Write("<h3>Error</h3>" + "<strong>invalid cc number, gateway-timeout, etc: " + e.Message + "</strong>"); } }
public CreditVerifyBuilder WithAddress(HpsAddress address) { this.address = address; return(this); }
public ActionResult ProcessPayment(OrderDetails details) { var config = new HpsServicesConfig { SecretApiKey = "skapi_cert_MYl2AQAowiQAbLp5JesGKh7QFkcizOP2jcX9BrEMqQ", // The following variables will be provided to you during certification VersionNumber = "0000", DeveloperId = "000000" }; var chargeService = new HpsCreditService(config); try { var address = new HpsAddress { Address = details.Address, City = details.City, State = details.State, Country = "United States", Zip = details.Zip ?? string.Empty }; var validCardHolder = new HpsCardHolder { FirstName = details.FirstName, LastName = details.LastName, Address = address, Phone = details.PhoneNumber ?? string.Empty }; var suToken = new HpsTokenData { TokenValue = details.Token_value }; var authResponse = chargeService.Charge(15.15m, "usd", suToken.TokenValue, validCardHolder); SendEmail(); return(View("Success", new SuccessModel { FirstName = details.FirstName, TransactionId = authResponse.TransactionId })); } catch (HpsInvalidRequestException e) { if (e.Code.ToString() == "InvalidAmount") { // handle error for amount less than zero dollars return(View("Error", model: "amount less than zero dollars: " + e.Message)); } return(View("Error", model: "Invalid Input: " + e.Message)); } catch (HpsAuthenticationException e) { // handle errors related to your HpsServiceConfig return(View("Error", model: "Bad Config: " + e.Message)); } catch (HpsCreditException e) { // handle card-related exceptions: card declined, processing error, etc return(View("Error", model: "card declined, processing error, etc: " + e.Message)); } catch (HpsGatewayException e) { // handle gateway-related exceptions: invalid cc number, gateway-timeout, etc return(View("Error", model: "invalid cc number, gateway-timeout, etc: " + e.Message)); } }
public CreditReturnBuilder WithAddress(HpsAddress value) { this.address = value; return(this); }