///<summary>Takes a credit card number and returns the issuer id from it to match PaySimple's expected values</summary> public static int GetCardType(string ccNum) { int retVal = 0; string cardTypeName = CreditCardUtils.GetCardType(ccNum); if (cardTypeName == "VISA") { retVal = 12; } else if (cardTypeName == "MASTERCARD") { retVal = 13; } else if (cardTypeName == "AMEX") { retVal = 14; } else if (cardTypeName == "DISCOVER") { retVal = 15; } else { throw new Exception("Unsupported Card Type"); } return(retVal); }
///<summary>For web services.</summary> public PayConnectResponse(PayConnectService.transResponse response, PayConnectService.creditCardRequest request) { if (response != null) { AuthCode = response.AuthCode; RefNumber = response.RefNumber; if (response.Status != null) { Description = response.Status.description; StatusCode = response.Status.code.ToString(); } if (response.PaymentToken != null) { PaymentToken = response.PaymentToken.TokenId; if (response.PaymentToken.Expiration != null) { TokenExpiration = new DateTime(response.PaymentToken.Expiration.year, response.PaymentToken.Expiration.month, 1); } } CardType = CreditCardUtils.GetCardType(request.CardNumber); } }
public static string BuildReceiptString(PayConnectService.transType transType, string refNum, string nameOnCard, string cardNumber, string magData, string authCode, string statusDescription, List <string> messages, decimal amount, int sigResponseStatusCode, long clinicNum) { string result = ""; cardNumber = cardNumber ?? ""; //Prevents null reference exceptions when PayConnectPortal transactions don't have an associated card number int xmin = 0; int xleft = xmin; int xright = 15; int xmax = 37; result += Environment.NewLine; result += CreditCardUtils.AddClinicToReceipt(clinicNum); //Print body result += "Date".PadRight(xright - xleft, '.') + DateTime.Now.ToString() + Environment.NewLine; result += Environment.NewLine; result += "Trans Type".PadRight(xright - xleft, '.') + transType + Environment.NewLine; result += Environment.NewLine; result += "Transaction #".PadRight(xright - xleft, '.') + refNum + Environment.NewLine; result += "Name".PadRight(xright - xleft, '.') + nameOnCard + Environment.NewLine; result += "Account".PadRight(xright - xleft, '.'); for (int i = 0; i < cardNumber.Length - 4; i++) { result += "*"; } if (cardNumber.Length >= 4) { result += cardNumber.Substring(cardNumber.Length - 4) + Environment.NewLine; //last 4 digits of card number only. } result += "Card Type".PadRight(xright - xleft, '.') + CreditCardUtils.GetCardType(cardNumber) + Environment.NewLine; result += "Entry".PadRight(xright - xleft, '.') + (String.IsNullOrEmpty(magData) ? "Manual" : "Swiped") + Environment.NewLine; result += "Auth Code".PadRight(xright - xleft, '.') + authCode + Environment.NewLine; result += "Result".PadRight(xright - xleft, '.') + statusDescription + Environment.NewLine; if (messages != null) { string label = "Message"; foreach (string m in messages) { result += label.PadRight(xright - xleft, '.') + m + Environment.NewLine; label = ""; } } result += Environment.NewLine + Environment.NewLine + Environment.NewLine; if (transType.In(PayConnectService.transType.RETURN, PayConnectService.transType.VOID)) { result += "Total Amt".PadRight(xright - xleft, '.') + (amount * -1) + Environment.NewLine; } else { result += "Total Amt".PadRight(xright - xleft, '.') + amount + Environment.NewLine; } result += Environment.NewLine + Environment.NewLine + Environment.NewLine; result += "I agree to pay the above total amount according to my card issuer/bank agreement." + Environment.NewLine; result += Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine; if (sigResponseStatusCode != 0) { result += "Signature X".PadRight(xmax - xleft, '_'); } else { result += "Electronically signed"; } return(result); }