Ejemplo n.º 1
0
        private string BuildReceiptString(PayConnectService.creditCardRequest request, PayConnectService.transResponse response)
        {
            string result = "";
            int    xmin   = 0;
            int    xleft  = xmin;
            int    xright = 15;
            int    xmax   = 37;

            result += Environment.NewLine;
            //Print header/Practice information
            string practiceTitle = PrefC.GetString(PrefName.PracticeTitle);

            if (practiceTitle.Length > 0)
            {
                result += practiceTitle + Environment.NewLine;
            }
            string practiceAddress = PrefC.GetString(PrefName.PracticeAddress);

            if (practiceAddress.Length > 0)
            {
                result += practiceAddress + Environment.NewLine;
            }
            string practiceAddress2 = PrefC.GetString(PrefName.PracticeAddress2);

            if (practiceAddress2.Length > 0)
            {
                result += practiceAddress2 + Environment.NewLine;
            }
            string practiceCity  = PrefC.GetString(PrefName.PracticeCity);
            string practiceState = PrefC.GetString(PrefName.PracticeST);
            string practiceZip   = PrefC.GetString(PrefName.PracticeZip);

            if (practiceCity.Length > 0 || practiceState.Length > 0 || practiceZip.Length > 0)
            {
                string cityStateZip = practiceCity + " " + practiceState + " " + practiceZip;
                result += cityStateZip + Environment.NewLine;
            }
            string practicePhone = PrefC.GetString(PrefName.PracticePhone);

            if (practicePhone.Length == 10 &&
                (CultureInfo.CurrentCulture.Name == "en-US" ||
                 CultureInfo.CurrentCulture.Name.EndsWith("CA")))                 //Canadian. en-CA or fr-CA
            {
                result += "(" + practicePhone.Substring(0, 3) + ")" + practicePhone.Substring(3, 3) + "-" + practicePhone.Substring(6) + Environment.NewLine;
            }
            else if (practicePhone.Length > 0)
            {
                result += practicePhone + Environment.NewLine;
            }
            result += Environment.NewLine;
            //Print body
            result += "Date".PadRight(xright - xleft, '.') + DateTime.Now.ToString() + Environment.NewLine;
            result += Environment.NewLine;
            result += "Trans Type".PadRight(xright - xleft, '.') + request.TransType.ToString() + Environment.NewLine;
            result += Environment.NewLine;
            result += "Transaction #".PadRight(xright - xleft, '.') + response.RefNumber + Environment.NewLine;
            result += "Name".PadRight(xright - xleft, '.') + request.NameOnCard + Environment.NewLine;
            result += "Account".PadRight(xright - xleft, '.');
            for (int i = 0; i < request.CardNumber.Length - 4; i++)
            {
                result += "*";
            }
            result += request.CardNumber.Substring(request.CardNumber.Length - 4) + Environment.NewLine;      //last 4 digits of card number only.
            result += "Exp Date".PadRight(xright - xleft, '.') + request.Expiration.month.ToString().PadLeft(2, '0') + (request.Expiration.year % 100) + Environment.NewLine;
            result += "Card Type".PadRight(xright - xleft, '.') + CreditCardUtils.GetType(request.CardNumber) + Environment.NewLine;
            result += "Entry".PadRight(xright - xleft, '.') + (request.MagData == ""?"Manual":"Swiped") + Environment.NewLine;
            result += "Auth Code".PadRight(xright - xleft, '.') + response.AuthCode + Environment.NewLine;
            result += "Result".PadRight(xright - xleft, '.') + response.Status.description + Environment.NewLine;
            if (response.Messages != null)
            {
                string label = "Message";
                foreach (string m in response.Messages)
                {
                    result += label.PadRight(xright - xleft, '.') + m + Environment.NewLine;
                    label   = "";
                }
            }
            result += Environment.NewLine + Environment.NewLine + Environment.NewLine;
            result += "Total Amt".PadRight(xright - xleft, '.') + request.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;
            result += "Signature X".PadRight(xmax - xleft, '_');
            return(result);
        }