public processor_cc_txn_response sp_refund_payment(int payment_id)
        {
            #region Check-for-Null-Values

            if (string_null_or_empty(_token_string))
            {
                log("sp_refund_payment null value detected for token, please authenticate", true);
                return null;
            }

            if (payment_id <= 0)
            {
                log("sp_refund_payment payment_id must be greater than zero", true);
                return null;
            }

            #endregion

            #region Variables

            rest_response refund_payment_rest_resp = new rest_response();
            response refund_payment_resp = new response();
            processor_cc_txn_response curr_resp = new processor_cc_txn_response();

            #endregion

            #region Process-Request

            refund_payment_rest_resp = rest_client<simple_payment>(
                _endpoint_url + "payment/refund/" + payment_id,
                "POST",
                null,
                null);

            if (refund_payment_rest_resp == null)
            {
                log("sp_refund_payment null response from rest_client for refund call", true);
                return null;
            }

            if (refund_payment_rest_resp.status_code != 200 &&
                refund_payment_rest_resp.status_code != 201)
            {
                log("sp_refund_payment rest_client returned status other than 200/201 for refund call", true);
                return null;
            }

            try
            {
                refund_payment_resp = deserialize_json<response>(refund_payment_rest_resp.output_body_string);
            }
            catch (Exception)
            {
                log("sp_refund_payment unable to deserialize response from server for refund call", true);
                return null;
            }

            if (!refund_payment_resp.success)
            {
                log("sp_refund_payment success false returned from server for refund call", true);
                return null;
            }

            try
            {
                curr_resp = deserialize_json<processor_cc_txn_response>(refund_payment_resp.data.ToString());
                log("sp_refund_payment response retrieved");
            }
            catch (Exception)
            {
                log("sp_refund_payment unable to deserialize processor response", true);
                return null;
            }

            #endregion

            #region Enumerate

            log("===============================================================================");
            log("Refund response received: " + curr_resp.is_approved);
            log("  " + curr_resp.cc_type + " " + curr_resp.cc_redacted_number + " " + curr_resp.cc_expiry_month + "/" + curr_resp.cc_expiry_year + " " + decimal_tostring(curr_resp.amount));
            log("  Approval " + curr_resp.approval_code + " Status " + curr_resp.status_code + " " + curr_resp.status_message + " " + curr_resp.transaction_state);
            log("  Response time " + curr_resp.processor_time_ms + "ms");

            if (curr_resp.is_approved)
            {
                log("  Payment ID " + curr_resp.payment_id);
                log("  Stored Payment GUID " + curr_resp.stored_payment_guid);
            }

            log("===============================================================================");

            #endregion

            return curr_resp;
        }
        public bool sp_delete_bank_account(int bank_account_id)
        {
            #region Check-for-Null-Values

            if (string_null_or_empty(_token_string))
            {
                log("sp_delete_bank_account null value detected for token, please authenticate", true);
                return false;
            }

            if (bank_account_id <= 0)
            {
                log("sp_delete_bank_account bank_account_id must be greater than zero", true);
                return false;
            }

            #endregion

            #region Variables

            rest_response get_bank_account_rest_resp = new rest_response();
            response get_bank_account_resp = new response();

            #endregion

            #region Process-Request

            get_bank_account_rest_resp = rest_client<string>(
                _endpoint_url + "bank_account/" + bank_account_id,
                "DELETE",
                null,
                null);

            if (get_bank_account_rest_resp == null)
            {
                log("sp_delete_bank_account null response from rest_client for bank_account deletion call", true);
                return false;
            }

            if (get_bank_account_rest_resp.status_code != 200)
            {
                log("sp_delete_bank_account rest_client returned status other than 200 for bank_account deletion call", true);
                return false;
            }

            try
            {
                get_bank_account_resp = deserialize_json<response>(get_bank_account_rest_resp.output_body_string);
            }
            catch (Exception)
            {
                log("sp_delete_bank_account unable to deserialize response from server for bank_account deletion call", true);
                return false;
            }

            if (!get_bank_account_resp.success)
            {
                log("sp_delete_bank_account success false returned from server for bank_account deletion call", true);
                return false;
            }

            log("sp_delete_bank_account success true returned from server for bank_account deletion");
            return true;

            #endregion
        }
        public stored_payment sp_create_stored_payment(
            int company_id,
            int location_id,
            string cc_number,
            string cc_expiry_month,
            string cc_expiry_year,
            string cc_name_on_card,
            string cc_billing_zip)
        {
            #region Check-for-Null-Values

            if (string_null_or_empty(_token_string))
            {
                log("sp_create_stored_payment null value detected for token, please authenticate", true);
                return null;
            }

            if (string_null_or_empty(cc_number) ||
                string_null_or_empty(cc_expiry_month) ||
                string_null_or_empty(cc_expiry_year) ||
                string_null_or_empty(cc_name_on_card) ||
                string_null_or_empty(cc_billing_zip))
            {
                log("sp_create_stored_payment null value detected in one of the input values", true);
                return null;
            }

            if (company_id <= 0)
            {
                log("sp_create_stored_payment company_id must be greater than zero", true);
                return null;
            }

            if (location_id <= 0)
            {
                log("sp_create_stored_payment location_id must be greater than zero", true);
                return null;
            }

            #endregion

            #region Variables

            stored_payment req = new stored_payment();
            rest_response sp_rest_resp = new rest_response();
            response sp_resp = new response();
            stored_payment ret = new stored_payment();

            #endregion

            #region Create-Request-Body

            req.company_id = company_id;
            req.location_id = location_id;
            req.method = "CreditCard";
            req.cc_number = cc_number;
            req.cc_redacted_number = redact(cc_number);
            req.cc_expiry_month = cc_expiry_month;
            req.cc_expiry_year = cc_expiry_year;
            req.cc_name_on_card = cc_name_on_card;
            req.cc_billing_zip = cc_billing_zip;

            #endregion

            #region Process-Request

            sp_rest_resp = rest_client<stored_payment>(
                _endpoint_url + "stored_payment",
                "POST",
                null,
                req);

            if (sp_rest_resp == null)
            {
                log("sp_create_stored_payment null response from rest_client for stored_payment call", true);
                return null;
            }

            if (sp_rest_resp.status_code != 200 &&
                sp_rest_resp.status_code != 201)
            {
                log("sp_create_stored_payment rest_client returned status other than 200/201 for stored_payment call", true);
                return null;
            }

            try
            {
                sp_resp = deserialize_json<response>(sp_rest_resp.output_body_string);
            }
            catch (Exception)
            {
                log("sp_create_stored_payment unable to deserialize response from server for stored_payment call", true);
                return null;
            }

            try
            {
                ret = deserialize_json<stored_payment>(sp_resp.data.ToString());
                log("sp_create_stored_payment response retrieved");
            }
            catch (Exception)
            {
                log("sp_create_stored_payment unable to deserialize processor response", true);
                return null;
            }

            #endregion

            #region Enumerate

            log("===============================================================================");
            log("Stored payment response received: ");
            log("  " + ret.stored_payment_id + ": " + ret.cc_type + " " + ret.cc_redacted_number + " guid " + ret.guid);
            log("===============================================================================");

            #endregion

            return ret;
        }
        public decimal? sp_ach_balance(int location_id)
        {
            #region Check-for-Null-Values

            if (string_null_or_empty(_token_string))
            {
                log("sp_ach_balance null value detected for token, please authenticate", true);
                return null;
            }

            if (location_id <= 0)
            {
                log("sp_ach_balance location_id must be greater than zero", true);
                return null;
            }

            #endregion

            #region Variables

            rest_response get_ach_balance_rest_resp = new rest_response();
            response get_ach_balance_resp = new response();
            decimal ret = 0m;

            #endregion

            #region Process-Request

            get_ach_balance_rest_resp = rest_client<report_request>(
                _endpoint_url + "settlement/balance/" + location_id,
                "POST",
                null,
                null);

            if (get_ach_balance_rest_resp == null)
            {
                log("sp_ach_balance null response from rest_client for ach balance retrieval call", true);
                return null;
            }

            if (get_ach_balance_rest_resp.status_code != 200)
            {
                log("sp_ach_balance rest_client returned status other than 200 for ach balance retrieval call", true);
                return null;
            }

            try
            {
                get_ach_balance_resp = deserialize_json<response>(get_ach_balance_rest_resp.output_body_string);
            }
            catch (Exception)
            {
                log("sp_ach_balance unable to deserialize response from server for ach balance retrieval call", true);
                return null;
            }

            if (!get_ach_balance_resp.success)
            {
                log("sp_ach_balance success false returned from server for ach balance retrieval call", true);
                return null;
            }

            try
            {
                ret = Convert.ToDecimal(get_ach_balance_resp.data.ToString());
                log("sp_ach_balance response retrieved");
            }
            catch (Exception)
            {
                log("sp_ach_balance unable to retrieve ach balance from response data object", true);
                return null;
            }

            #endregion

            #region Enumerate

            log("===============================================================================");
            log("sp_ach_balance: " + ret);
            log("===============================================================================");

            #endregion

            return ret;
        }
        public processor_cc_txn_response sp_stored_payment(
            string guid,
            string notes,
            decimal amount)
        {
            #region Check-for-Null-Values

            if (string_null_or_empty(_token_string))
            {
                log("sp_stored_payment null value detected for token, please authenticate", true);
                return null;
            }

            if (string_null_or_empty(guid) ||
                string_null_or_empty(notes))
            {
                log("sp_stored_payment null value detected in one of the input values", true);
                return null;
            }

            if (amount <= 0)
            {
                log("sp_stored_payment amount must be greater than zero", true);
                return null;
            }

            #endregion

            #region Variables

            rest_response key_payment_rest_resp = new rest_response();
            response key_payment_resp = new response();
            processor_cc_txn_response curr_resp = new processor_cc_txn_response();

            #endregion

            #region Create-Request-Body

            simple_payment curr = new simple_payment();
            curr.stored_payment_guid = guid;
            curr.notes = notes;
            curr.amount = amount;
            curr.method = "CreditCard";

            #endregion

            #region Process-Request

            key_payment_rest_resp = rest_client<simple_payment>(
                _endpoint_url + "payment/simple",
                "POST",
                null,
                curr);

            if (key_payment_rest_resp == null)
            {
                log("sp_stored_payment null response from rest_client for simple payment call", true);
                return null;
            }

            if (key_payment_rest_resp.status_code != 200 &&
                key_payment_rest_resp.status_code != 201)
            {
                log("sp_stored_payment rest_client returned status other than 200/201 for simple payment call", true);
                return null;
            }

            try
            {
                key_payment_resp = deserialize_json<response>(key_payment_rest_resp.output_body_string);
            }
            catch (Exception)
            {
                log("sp_stored_payment unable to deserialize response from server for simple payment call", true);
                return null;
            }

            try
            {
                curr_resp = deserialize_json<processor_cc_txn_response>(key_payment_resp.data.ToString());
                log("sp_stored_payment response retrieved");
            }
            catch (Exception)
            {
                log("sp_stored_payment unable to deserialize processor response", true);
                return null;
            }

            #endregion

            #region Enumerate

            log("===============================================================================");
            log("Payment response received: " + curr_resp.is_approved);
            log("  " + curr_resp.cc_type + " " + curr_resp.cc_redacted_number + " " + curr_resp.cc_expiry_month + "/" + curr_resp.cc_expiry_year + " " + decimal_tostring(curr_resp.amount));
            log("  Approval " + curr_resp.approval_code + " Status " + curr_resp.status_code + " " + curr_resp.status_message + " " + curr_resp.transaction_state);
            log("  Response time " + curr_resp.processor_time_ms + "ms");
            log("  Card present " + curr_resp.cc_present);

            if (curr_resp.is_approved)
            {
                log("  Payment ID " + curr_resp.payment_id);
                log("  Stored Payment GUID " + curr_resp.stored_payment_guid);
            }

            log("===============================================================================");

            #endregion

            return curr_resp;
        }
        public bank_account sp_create_bank_account(
            string account_type,
            string routing_number,
            string account_number,
            string company_name,
            string first_name,
            string last_name,
            string address,
            string city,
            string state,
            string postal_code,
            string phone,
            int is_settlement_account
            )
        {
            #region Check-for-Null-Values

            if (string_null_or_empty(_token_string))
            {
                log("sp_create_bank_account null value detected for token, please authenticate", true);
                return null;
            }

            if (string_null_or_empty(account_type) ||
                string_null_or_empty(routing_number) ||
                string_null_or_empty(account_number) ||
                string_null_or_empty(address) ||
                string_null_or_empty(city) ||
                string_null_or_empty(state) ||
                string_null_or_empty(postal_code) ||
                string_null_or_empty(phone))
            {
                log("sp_create_bank_account null values specified for a required field", true);
                return null;
            }

            if (is_settlement_account < 0 || is_settlement_account > 1)
            {
                log("sp_create_bank_account is_settlement_account must be either 0 or 1", true);
                return null;
            }

            if ((String.Compare(account_type, "Business Checking") != 0) &&
                (String.Compare(account_type, "Business Savings") != 0) &&
                (String.Compare(account_type, "Personal Checking") != 0) &&
                (String.Compare(account_type, "Personal Savings") != 0))
            {
                log("sp_create_bank_account invalid value for account_type, use 'Business Checking', 'Business Savings', 'Personal Checking', or 'Personal Savings'", true);
                return null;
            }

            #endregion

            #region Variables

            rest_response create_bank_account_rest_resp = new rest_response();
            response create_bank_account_resp = new response();
            bank_account request_bank_account = new bank_account();
            bank_account created_bank_account = new bank_account();

            #endregion

            #region Create-Object

            request_bank_account.company_id = _token.company_id;
            request_bank_account.location_id = _token.location_id;
            request_bank_account.account_address_1 = address;
            request_bank_account.account_city = city;
            request_bank_account.account_company_name = company_name;
            request_bank_account.account_country = "USA";
            request_bank_account.account_first_name = first_name;
            request_bank_account.account_last_name = last_name;
            request_bank_account.account_number = account_number;
            request_bank_account.account_phone_country_code = "1";
            request_bank_account.account_postal_code = postal_code;
            request_bank_account.account_state = state.ToUpper();
            request_bank_account.account_phone = phone;
            request_bank_account.is_settlement_account = is_settlement_account;
            request_bank_account.routing_number = routing_number;
            request_bank_account.type = account_type;

            #endregion

            #region Process-Request

            create_bank_account_rest_resp = rest_client<bank_account>(
                _endpoint_url + "bank_account/",
                "POST",
                null,
                request_bank_account);

            if (create_bank_account_rest_resp == null)
            {
                log("sp_create_bank_account null response from rest_client for bank_account creation call", true);
                return null;
            }

            if ((create_bank_account_rest_resp.status_code != 200) &&
                (create_bank_account_rest_resp.status_code != 201))
            {
                log("sp_create_bank_account rest_client returned status other than 200/201 for bank_account creation call", true);
                return null;
            }

            try
            {
                create_bank_account_resp = deserialize_json<response>(create_bank_account_rest_resp.output_body_string);
            }
            catch (Exception)
            {
                log("sp_create_bank_account unable to deserialize response from server for bank_account creation call", true);
                return null;
            }

            if (!create_bank_account_resp.success)
            {
                log("sp_create_bank_account success false returned from server for bank_account creation call", true);
                return null;
            }

            try
            {
                created_bank_account = deserialize_json<bank_account>(create_bank_account_resp.data.ToString());
                log("sp_create_bank_account response retrieved");
            }
            catch (Exception)
            {
                log("sp_create_bank_account unable to deserialize bank_account object", true);
                return null;
            }

            if (created_bank_account == null)
            {
                log("sp_create_bank_account null bank_account retrieved", true);
                return null;
            }

            #endregion

            #region Enumerate

            log("===============================================================================");
            log("bank_account created: " + created_bank_account.bank_account_id);
            log("  type " + created_bank_account.type + " routing " + created_bank_account.routing_number + " account " + created_bank_account.account_number);
            log("  is_settlement_account " + created_bank_account.is_settlement_account + " is_verified " + created_bank_account.is_verified);
            log("===============================================================================");

            #endregion

            return created_bank_account;
        }
        public List<payment> sp_get_all_payments()
        {
            #region Check-for-Null-Values

            if (string_null_or_empty(_token_string))
            {
                log("sp_get_all_payments null value detected for token, please authenticate", true);
                return null;
            }

            #endregion

            #region Variables

            rest_response get_payment_rest_resp = new rest_response();
            response get_payment_resp = new response();
            List<payment> curr_payment_list = new List<payment>();

            #endregion

            #region Process-Request

            get_payment_rest_resp = rest_client<simple_payment>(
                _endpoint_url + "payment/",
                "GET",
                null,
                null);

            if (get_payment_rest_resp == null)
            {
                log("sp_get_all_payments null response from rest_client for payment retrieval call", true);
                return null;
            }

            if (get_payment_rest_resp.status_code != 200)
            {
                log("sp_get_all_payments rest_client returned status other than 200 for payment retrieval call", true);
                return null;
            }

            try
            {
                get_payment_resp = deserialize_json<response>(get_payment_rest_resp.output_body_string);
            }
            catch (Exception)
            {
                log("sp_get_all_payments unable to deserialize response from server for payment retrieval call", true);
                return null;
            }

            if (!get_payment_resp.success)
            {
                log("sp_get_all_payments success false returned from server for payment retrieval call", true);
                return null;
            }

            try
            {
                curr_payment_list = deserialize_json<List<payment>>(get_payment_resp.data.ToString());
                log("sp_get_all_payments response retrieved");
            }
            catch (Exception)
            {
                log("sp_get_all_payments unable to deserialize payment list object", true);
                return null;
            }

            if (curr_payment_list == null)
            {
                log("sp_get_all_payments null payment list retrieved", true);
                return null;
            }

            if (curr_payment_list.Count < 1)
            {
                log("sp_get_all_payments no payments retrieved", true);
                return null;
            }

            #endregion

            #region Enumerate

            foreach (payment curr_payment in curr_payment_list)
            {
                log("===============================================================================");
                log("Payment retrieved: " + curr_payment.payment_id);
                log("  " + curr_payment.method + " " + curr_payment.cc_type + " " + curr_payment.cc_redacted_number + " " + curr_payment.cc_expiry_month + "/" + curr_payment.cc_expiry_year + " " + decimal_tostring(curr_payment.amount));
                log("  Approval " + curr_payment.provider_approval_code + " Status " + curr_payment.provider_status_code + " " + curr_payment.provider_status_message + " " + curr_payment.provider_transaction_state);
                log("  Response time " + curr_payment.processor_time_ms + "ms");
                log("  Stored Payment GUID " + curr_payment.stored_payment_guid);
                log("===============================================================================");
            }

            #endregion

            return curr_payment_list;
        }
        public account_report sp_account_report(int location_id)
        {
            #region Check-for-Null-Values

            if (string_null_or_empty(_token_string))
            {
                log("sp_account_report null value detected for token, please authenticate", true);
                return null;
            }

            if (location_id <= 0)
            {
                log("sp_account_report location_id must be greater than zero", true);
                return null;
            }

            #endregion

            #region Variables

            rest_response get_account_report_rest_resp = new rest_response();
            response get_account_report_resp = new response();
            account_report ret = new account_report();
            search_filter sf = new search_filter();
            List<search_filter> sf_list = new List<search_filter>();
            report_request report_req = new report_request();

            #endregion

            #region Build-Report-Request

            sf = new search_filter();
            sf.field = "location_id";
            sf.condition = "equals";
            sf.value = location_id.ToString();
            sf_list.Add(sf);

            report_req.csv = false;
            report_req.email_address = null;
            report_req.html = false;
            report_req.raw_data = true;
            report_req.sfa = sf_list.ToArray();

            #endregion

            #region Process-Request

            get_account_report_rest_resp = rest_client<report_request>(
                _endpoint_url + "report/account",
                "POST",
                null,
                report_req);

            if (get_account_report_rest_resp == null)
            {
                log("sp_account_report null response from rest_client for account report retrieval call", true);
                return null;
            }

            if (get_account_report_rest_resp.status_code != 200)
            {
                log("sp_account_report rest_client returned status other than 200 for account report retrieval call", true);
                return null;
            }

            try
            {
                get_account_report_resp = deserialize_json<response>(get_account_report_rest_resp.output_body_string);
            }
            catch (Exception)
            {
                log("sp_account_report unable to deserialize response from server for account report retrieval call", true);
                return null;
            }

            if (!get_account_report_resp.success)
            {
                log("sp_account_report success false returned from server for account report retrieval call", true);
                return null;
            }

            try
            {
                ret = deserialize_json<account_report>(get_account_report_resp.data.ToString());
                log("sp_account_report response retrieved");
            }
            catch (Exception)
            {
                log("sp_account_report unable to deserialize account report object", true);
                return null;
            }

            if (ret == null)
            {
                log("sp_account_report null account report retrieved", true);
                return null;
            }

            #endregion

            #region Enumerate

            log("===============================================================================");
            log("account_report retrieved: ");
            log("  " + ret.start_time + " to " + ret.end_time);

            if (ret.report_detail != null)
            {
                if (ret.report_detail.Count > 0)
                {
                    foreach (account_report_detail curr_detail in ret.report_detail)
                    {
                        log("-------------------------------------------------------------------------------");
                        log("  report for company_id " + curr_detail.company_id + " " + curr_detail.company_name);
                        log("             location_id " + curr_detail.location_id + " " + curr_detail.location_name);
                        log("             account_id " + curr_detail.account_id + " " + curr_detail.account_name);

                        log("  account details:");
                        if (curr_detail.account_record != null)
                        {
                            log("    " + curr_detail.account_record.account_type + " created " + curr_detail.account_record.created);
                            log("    " + curr_detail.account_record.description);
                            log("    reserve amount: " + curr_detail.account_record.reserve_amount);
                        }
                        else
                        {
                            log("    no account record to show (null)");
                        }

                        if (curr_detail.account_balance != null)
                        {
                            log("  account balance: " + curr_detail.account_balance.balance);
                        }
                        else
                        {
                            log("  no account balance to show (null)");
                        }

                        log("    commit_balance: " + curr_detail.commit_balance);
                        log("    reserve_amount: " + curr_detail.reserve_amount);
                        log("    available_balance: " + curr_detail.available_balance);
                        log("    pending_credits: " + curr_detail.pending_credits);
                        log("    pending_debits: " + curr_detail.pending_debits);
                        log("    pending_net: " + curr_detail.pending_net);
                        log("    pending_balance: " + curr_detail.pending_balance);

                        log("  ledger entries: ");
                        log("    (balance entries and entries that are newer than balance entry");

                        if (curr_detail.entries != null)
                        {
                            if (curr_detail.entries.Count > 0)
                            {
                                log("    ID: type / amount / committed / ledgered / date");
                                log("        notes");
                                foreach (account_ledger curr_ledger in curr_detail.entries)
                                {
                                    string log_string = "    " + curr_ledger.account_ledger_id + ": " + curr_ledger.entry_type + " / ";

                                    switch (curr_ledger.entry_type)
                                    {
                                        case "credit":
                                            log_string += curr_ledger.credit_amount + " / ";
                                            break;

                                        case "debit":
                                            log_string += "(" + curr_ledger.debit_amount + ") / ";
                                            break;

                                        case "balance":
                                            log_string += "NA / ";
                                            break;

                                        default:
                                            log_string += "unknown / ";
                                            break;
                                    }

                                    log_string += curr_ledger.transaction_status + " / " + curr_ledger.ledgered + " / " + Convert.ToDateTime(curr_ledger.created).ToString("MM/dd/yyyy");
                                    log(log_string);
                                    log("        " + curr_ledger.description);
                                }
                            }
                            else
                            {
                                log("    no account ledger records to show (empty)");
                            }
                        }
                        else
                        {
                            log("    no account ledger records to show (null)");
                        }
                    }
                }
                else
                {
                    log("  no account detail to show (empty)");
                }
            }
            else
            {
                log("  no account detail to show (null)");
            }

            log("===============================================================================");

            #endregion

            return ret;
        }
        public List<bank_account> sp_get_bank_account(int bank_account_id)
        {
            #region Check-for-Null-Values

            if (string_null_or_empty(_token_string))
            {
                log("sp_get_bank_account null value detected for token, please authenticate", true);
                return null;
            }

            if (bank_account_id <= 0)
            {
                log("sp_get_bank_account bank_account_id must be greater than zero", true);
                return null;
            }

            #endregion

            #region Variables

            rest_response get_bank_account_rest_resp = new rest_response();
            response get_bank_account_resp = new response();
            List<bank_account> curr_bank_account_list = new List<bank_account>();

            #endregion

            #region Process-Request

            get_bank_account_rest_resp = rest_client<bank_account>(
                _endpoint_url + "bank_account/" + bank_account_id,
                "GET",
                null,
                null);

            if (get_bank_account_rest_resp == null)
            {
                log("sp_get_bank_account null response from rest_client for bank_account retrieval call", true);
                return null;
            }

            if (get_bank_account_rest_resp.status_code != 200)
            {
                log("sp_get_bank_account rest_client returned status other than 200 for bank_account retrieval call", true);
                return null;
            }

            try
            {
                get_bank_account_resp = deserialize_json<response>(get_bank_account_rest_resp.output_body_string);
            }
            catch (Exception)
            {
                log("sp_get_bank_account unable to deserialize response from server for bank_account retrieval call", true);
                return null;
            }

            if (!get_bank_account_resp.success)
            {
                log("sp_get_bank_account success false returned from server for bank_account retrieval call", true);
                return null;
            }

            try
            {
                curr_bank_account_list = deserialize_json<List<bank_account>>(get_bank_account_resp.data.ToString());
                log("sp_get_bank_account response retrieved");
            }
            catch (Exception)
            {
                log("sp_get_bank_account unable to deserialize bank_account list object", true);
                return null;
            }

            if (curr_bank_account_list == null)
            {
                log("sp_get_bank_account null bank_account list retrieved", true);
                return null;
            }

            if (curr_bank_account_list.Count < 1)
            {
                log("sp_get_bank_account no bank_accounts retrieved", true);
                return null;
            }

            #endregion

            #region Enumerate

            foreach (bank_account curr_bank_account in curr_bank_account_list)
            {
                log("===============================================================================");
                log("bank_account retrieved: " + curr_bank_account.bank_account_id);
                log("  type " + curr_bank_account.type + " routing " + curr_bank_account.routing_number + " account " + curr_bank_account.account_number);
                log("  is_settlement_account " + curr_bank_account.is_settlement_account + " is_verified " + curr_bank_account.is_verified);
                log("===============================================================================");
            }

            #endregion

            return curr_bank_account_list;
        }
        public bool sp_find_endpoint()
        {
            #region Check-for-Null-Values

            if (string_null_or_empty(_email) || string_null_or_empty(_password))
            {
                log("sp_find_endpoint null value detected for either email or password", true);
                return false;
            }

            #endregion

            #region Variables

            rest_response rest_resp = new rest_response();
            response resp = new response();

            #endregion

            #region Process-Request

            rest_resp = rest_client<string>(
                _endpoint_discovery_url,
                "GET",
                null,
                null);

            if (rest_resp == null)
            {
                log("sp_find_endpoint null response from rest_client", true);
                return false;
            }

            if (rest_resp.status_code != 200)
            {
                log("sp_find_endpoint rest_client returned status other than 200", true);
                return false;
            }

            try
            {
                resp = deserialize_json<response>(rest_resp.output_body_string);
            }
            catch (Exception)
            {
                log("sp_find_endpoint unable to deserialize response from server", true);
                return false;
            }

            if (!resp.success)
            {
                log("sp_find_endpoint success false returned from server", true);
                return false;
            }

            _endpoint_url = resp.data.ToString();
            log("sp_find_endpoint endpoint URL found: " + _endpoint_url);
            return true;

            #endregion
        }
        public processor_ach_txn_response sp_ach_retrieval(
            int? company_id,
            int? location_id,
            int? user_master_id,
            int? bank_account_id,
            string bank_account_type,
            string bank_account_routing_number,
            string bank_account_account_number,
            string bank_account_company_name,  
            string bank_account_first_name,  
            string bank_account_last_name,  
            string bank_account_address_1,
            string bank_account_address_2,  
            string bank_account_city,
            string bank_account_state,
            string bank_account_postal_code,
            string bank_account_country,
            string bank_account_phone_country_code,
            string bank_account_phone,
            decimal? retrieval_amount,
            string notes
            )
        {
            #region Check-for-Null-Values

            if (string_null_or_empty(_token_string))
            {
                log("sp_ach_retrieval null value detected for token, please authenticate", true);
                return null;
            }

            if (company_id <= 0)
            {
                log("sp_ach_retrieval company_id must be greater than zero", true);
                return null;
            }

            if (location_id <= 0)
            {
                log("sp_ach_retrieval location_id must be greater than zero", true);
                return null;
            }

            if (user_master_id <= 0)
            {
                log("sp_ach_retrieval user_master_id must be greater than zero", true);
                return null;
            }

            if (string_null_or_empty(bank_account_type))
            {
                log("sp_ach_retrieval null value for bank_account_type");
                return null;
            }

            if (String.Compare(bank_account_type, "Personal Checking") != 0 &&
                String.Compare(bank_account_type, "Personal Savings") != 0 &&
                String.Compare(bank_account_type, "Business Checking") != 0 &&
                String.Compare(bank_account_type, "Business Savings") != 0)
            {
                log("sp_ach_retrieval invalid bank_account_type.  Use Personal||Business Checking||Savings");
                return null;
            }

            if (string_null_or_empty(bank_account_routing_number))
            {
                log("sp_ach_retrieval null value for bank_account_routing_number");
                return null;
            }

            if (string_null_or_empty(bank_account_account_number))
            {
                log("sp_ach_retrieval null value for bank_account_account_number");
                return null;
            }

            if (retrieval_amount == null)
            {
                log("sp_ach_retrieval retrieval_amount cannot be null and must be greater than zero");
                return null;
            }

            if (retrieval_amount <= 0)
            {
                log("sp_ach_retrieval retrieval_amount must be greater than zero");
                return null;
            }

            #endregion

            #region Variables

            retrieval req = new retrieval();
            rest_response ach_retrieval_rest_resp = new rest_response();
            response ach_retrieval_resp = new response();
            processor_ach_txn_response ret = new processor_ach_txn_response();

            #endregion

            #region Build-Request-Body

            req.company_id = company_id;
            req.location_id = location_id;
            req.user_master_id = user_master_id;
            req.bank_account_id = bank_account_id;
            req.bank_account_type = bank_account_type;
            req.bank_account_routing_number = bank_account_routing_number;
            req.bank_account_account_number = bank_account_account_number;
            req.bank_account_company_name = bank_account_company_name;
            req.bank_account_first_name = bank_account_first_name;
            req.bank_account_last_name = bank_account_last_name;
            req.bank_account_address_1 = bank_account_address_1;
            req.bank_account_address_2 = bank_account_address_2;
            req.bank_account_city = bank_account_city;
            req.bank_account_state = bank_account_state;
            req.bank_account_postal_code = bank_account_postal_code;
            req.bank_account_country = bank_account_country;
            req.bank_account_phone_country_code = bank_account_phone_country_code;
            req.bank_account_phone = bank_account_phone;
            req.retrieval_amount = retrieval_amount;
            req.notes = notes;

            #endregion

            #region Process-Request

            ach_retrieval_rest_resp = rest_client<retrieval>(
                _endpoint_url + "retrieval/manual",
                "POST",
                null,
                req);

            if (ach_retrieval_rest_resp == null)
            {
                log("sp_ach_retrieval null response from rest_client forach retrievalcall", true);
                return null;
            }

            if (ach_retrieval_rest_resp.status_code != 200)
            {
                log("sp_ach_retrieval rest_client returned status other than 200 forach retrievalcall", true);
                return null;
            }

            try
            {
                ach_retrieval_resp = deserialize_json<response>(ach_retrieval_rest_resp.output_body_string);
            }
            catch (Exception)
            {
                log("sp_ach_retrieval unable to deserialize response from server forach retrievalcall", true);
                return null;
            }

            if (!ach_retrieval_resp.success)
            {
                log("sp_ach_retrieval success false returned from server forach retrievalcall", true);
                return null;
            }

            try
            {
                ret = deserialize_json<processor_ach_txn_response>(ach_retrieval_resp.data.ToString());
                log("sp_ach_retrieval response retrieved");
            }
            catch (Exception)
            {
                log("sp_ach_retrieval unable to deserialize settlement response list object", true);
                return null;
            }

            if (ret == null)
            {
                log("sp_ach_retrieval null settlement response list retrieved", true);
                return null;
            }

            #endregion

            #region Enumerate

            log("===============================================================================");
            log("sp_ach_retrieval:");
            log("  ID: amount / routing / account");
            log("      status / transaction_token");
            log("  " + ret.settlement_id + ": " + ret.amount + " / " + ret.routing_number + " / " + ret.account_number);
            log("      " + ret.provider_status + " / " + ret.settlement_transaction_token);
            log("===============================================================================");

            #endregion

            return ret;
        }
        public List<processor_ach_txn_response> sp_ach_settlement(
            int company_id,
            int location_id,
            List<manual_settlement_entry> settlement_list,
            string notes)
        {
            #region Check-for-Null-Values

            if (string_null_or_empty(_token_string))
            {
                log("sp_ach_settlement null value detected for token, please authenticate", true);
                return null;
            }

            if (company_id <= 0)
            {
                log("sp_ach_settlement company_id must be greater than zero", true);
                return null;
            }

            if (location_id <= 0)
            {
                log("sp_ach_settlement location_id must be greater than zero", true);
                return null;
            }

            if (settlement_list == null)
            {
                log("sp_ach_settlement null value for settlement_list");
                return null;
            }

            if (settlement_list.Count < 1)
            {
                log("sp_ach_settlement no entries in settlement_list");
                return null;
            }

            #endregion

            #region Variables

            manual_settlement req = new manual_settlement();
            rest_response get_ach_settlement_rest_resp = new rest_response();
            response get_ach_settlement_resp = new response();
            List<processor_ach_txn_response> ret = new List<processor_ach_txn_response>();

            #endregion

            #region Build-Request-Body

            req.company_id = company_id;
            req.location_id = location_id;
            req.notes = notes;
            req.settlement_list = settlement_list;

            #endregion

            #region Process-Request

            get_ach_settlement_rest_resp = rest_client<manual_settlement>(
                _endpoint_url + "settlement/manual",
                "POST",
                null,
                req);

            if (get_ach_settlement_rest_resp == null)
            {
                log("sp_ach_settlement null response from rest_client for manual settlement call", true);
                return null;
            }

            if (get_ach_settlement_rest_resp.status_code != 200)
            {
                log("sp_ach_settlement rest_client returned status other than 200 for manual settlement call", true);
                return null;
            }

            try
            {
                get_ach_settlement_resp = deserialize_json<response>(get_ach_settlement_rest_resp.output_body_string);
            }
            catch (Exception)
            {
                log("sp_ach_settlement unable to deserialize response from server for manual settlement call", true);
                return null;
            }

            if (!get_ach_settlement_resp.success)
            {
                log("sp_ach_settlement success false returned from server for manual settlement call", true);
                return null;
            }

            try
            {
                ret = deserialize_json<List<processor_ach_txn_response>>(get_ach_settlement_resp.data.ToString());
                log("sp_ach_settlement response retrieved");
            }
            catch (Exception)
            {
                log("sp_ach_settlement unable to deserialize settlement response list object", true);
                return null;
            }

            if (ret == null)
            {
                log("sp_ach_settlement null settlement response list retrieved", true);
                return null;
            }

            if (ret.Count < 1)
            {
                log("sp_ach_settlement empty settlement response list retrieved", true);
                return null;
            }

            #endregion

            #region Enumerate

            log("===============================================================================");
            log("sp_ach_settlement: " + ret.Count + " entries");
            log("  ID: amount / routing / account");
            log("      status / transaction_token");

            foreach (processor_ach_txn_response curr in ret)
            {
                log("  " + curr.settlement_id + ": " + curr.amount + " / " + curr.routing_number + " / " + curr.account_number);
                log("      " + curr.provider_status + " / " + curr.settlement_transaction_token);
            }

            log("===============================================================================");

            #endregion

            return ret;
        }
        public List<stored_payment> sp_get_all_stored_payments()
        {
            #region Check-for-Null-Values

            if (string_null_or_empty(_token_string))
            {
                log("sp_get_all_stored_payments null value detected for token, please authenticate", true);
                return null;
            }

            #endregion

            #region Variables

            rest_response get_sp_rest_resp = new rest_response();
            response get_sp_resp = new response();
            List<stored_payment> ret = new List<stored_payment>();

            #endregion

            #region Process-Request

            get_sp_rest_resp = rest_client<List<simple_payment>>(
                _endpoint_url + "stored_payment",
                "GET",
                null,
                null);

            if (get_sp_rest_resp == null)
            {
                log("sp_get_all_stored_payments null response from rest_client for stored payment retrieval call", true);
                return null;
            }

            if (get_sp_rest_resp.status_code != 200)
            {
                log("sp_get_all_stored_payments rest_client returned status other than 200 for stored payment retrieval call", true);
                return null;
            }

            try
            {
                get_sp_resp = deserialize_json<response>(get_sp_rest_resp.output_body_string);
            }
            catch (Exception)
            {
                log("sp_get_all_stored_payments unable to deserialize response from server for stored payment retrieval call", true);
                return null;
            }

            if (!get_sp_resp.success)
            {
                log("sp_get_all_stored_payments success false returned from server for stored payment retrieval call", true);
                return null;
            }

            try
            {
                ret = deserialize_json<List<stored_payment>>(get_sp_resp.data.ToString());
                log("sp_get_all_stored_payments response retrieved");
            }
            catch (Exception)
            {
                log("sp_get_all_stored_payments unable to deserialize stored payment list object", true);
                return null;
            }

            if (ret == null)
            {
                log("sp_get_all_stored_payments null stored payment list retrieved", true);
                return null;
            }

            if (ret.Count < 1)
            {
                log("sp_get_all_stored_payments empty stored payment list retrieved", true);
                return null;
            }

            #endregion

            #region Enumerate

            log("===============================================================================");
            log("Stored payment response received: " + ret.Count + " entries");
            foreach (stored_payment curr in ret)
            {
                log("  " + curr.stored_payment_id + ": " + curr.cc_type + " " + curr.cc_redacted_number + " guid " + curr.guid);
            }
            log("===============================================================================");

            #endregion

            return ret;
        }
        public bool sp_login()
        {
            #region Check-for-Null-Values

            if (string_null_or_empty(_email) || string_null_or_empty(_password))
            {
                log("sp_login null value detected for either email or password", true);
                return false;
            }

            if (string_null_or_empty(_endpoint_url))
            {
                log("sp_login null value detected for endpoint URL", true);
                return false;
            }

            #endregion

            #region Variables

            rest_response login_rest_resp = new rest_response();
            response login_resp = new response();

            rest_response detail_rest_resp = new rest_response();
            response detail_resp = new response();

            #endregion

            #region Process-Login

            login_rest_resp = rest_client<string>(
                _endpoint_url + "login",
                "GET",
                null,
                null);

            if (login_rest_resp == null)
            {
                log("sp_login null response from rest_client for login call", true);
                return false;
            }

            if (login_rest_resp.status_code != 200)
            {
                log("sp_login rest_client returned status other than 200 for login call", true);
                return false;
            }

            try
            {
                login_resp = deserialize_json<response>(login_rest_resp.output_body_string);
            }
            catch (Exception)
            {
                log("sp_login unable to deserialize response from server for login call", true);
                return false;
            }

            if (!login_resp.success)
            {
                log("sp_login success false returned from server for login call", true);
                return false;
            }

            _token_string = login_resp.data.ToString();
            log("sp_login token retrieved: " + _token_string);

            #endregion

            #region Retrieve-Token-Details

            detail_rest_resp = rest_client<string>(
                _endpoint_url + "token/detail",
                "GET",
                null,
                null);

            if (detail_rest_resp == null)
            {
                log("sp_login null response from rest_client for token detail call", true);
                return false;
            }

            if (detail_rest_resp.status_code != 200)
            {
                log("sp_login rest_client returned status other than 200 for token detail call", true);
                return false;
            }

            try
            {
                detail_resp = deserialize_json<response>(detail_rest_resp.output_body_string);
            }
            catch (Exception)
            {
                log("sp_login unable to deserialize response from server for token detail call", true);
                return false;
            }

            if (!detail_resp.success)
            {
                log("sp_login success false returned from server for token detail call", true);
                return false;
            }

            try
            {
                log("sp_login retrieved token detail: " + detail_resp.data.ToString());
                _token = deserialize_json<token>(detail_resp.data.ToString());
                _token_created = DateTime.Now;
                log("sp_login token detail retrieved");
            }
            catch (Exception)
            {
                log("sp_login unable to deserialize token detail", true);
                return false;
            }

            #endregion

            log("sp_login login successful for email " + _email);
            return true;
        }
        public payment_report sp_payment_report(int location_id, DateTime start_time, DateTime end_time)
        {
            #region Check-for-Null-Values

            if (string_null_or_empty(_token_string))
            {
                log("sp_payment_report null value detected for token, please authenticate", true);
                return null;
            }

            if (location_id <= 0)
            {
                log("sp_payment_report location_id must be greater than zero", true);
                return null;
            }

            #endregion

            #region Variables

            rest_response get_payment_report_rest_resp = new rest_response();
            response get_payment_report_resp = new response();
            payment_report ret = new payment_report();
            search_filter sf = new search_filter();
            List<search_filter> sf_list = new List<search_filter>();
            report_request report_req = new report_request();

            #endregion

            #region Build-Report-Request

            sf = new search_filter();
            sf.field = "location_id";
            sf.condition = "equals";
            sf.value = location_id.ToString();
            sf_list.Add(sf);

            sf = new search_filter();
            sf.field = "created";
            sf.condition = "greater_than";
            sf.value = start_time.ToString("MM/dd/yyyy hh:mm:ss tt");
            sf_list.Add(sf);

            sf = new search_filter();
            sf.field = "created";
            sf.condition = "less_than";
            sf.value = end_time.ToString("MM/dd/yyyy hh:mm:ss tt");
            sf_list.Add(sf);

            report_req.csv = false;
            report_req.email_address = null;
            report_req.html = false;
            report_req.raw_data = true;
            report_req.sfa = sf_list.ToArray();

            #endregion

            #region Process-Request

            get_payment_report_rest_resp = rest_client<report_request>(
                _endpoint_url + "report/payment",
                "POST",
                null,
                report_req);

            if (get_payment_report_rest_resp == null)
            {
                log("sp_payment_report null response from rest_client for payment report retrieval call", true);
                return null;
            }

            if (get_payment_report_rest_resp.status_code != 200)
            {
                log("sp_payment_report rest_client returned status other than 200 for payment report retrieval call", true);
                return null;
            }

            try
            {
                get_payment_report_resp = deserialize_json<response>(get_payment_report_rest_resp.output_body_string);
            }
            catch (Exception)
            {
                log("sp_payment_report unable to deserialize response from server for payment report retrieval call", true);
                return null;
            }

            if (!get_payment_report_resp.success)
            {
                log("sp_payment_report success false returned from server for bank_account retrieval call", true);
                return null;
            }

            try
            {
                ret = deserialize_json<payment_report>(get_payment_report_resp.data.ToString());
                log("sp_payment_report response retrieved");
            }
            catch (Exception)
            {
                log("sp_payment_report unable to deserialize bank_account list object", true);
                return null;
            }

            if (ret == null)
            {
                log("sp_payment_report null payment report retrieved", true);
                return null;
            }

            #endregion

            #region Enumerate

            log("===============================================================================");
            log("payment_report retrieved: ");
            log("  " + ret.company_name + " / " + ret.location_name);
            log("  " + ret.start_time + " to " + ret.end_time);
            log("-------------------------------------------------------------------------------");
            log("  sales: " + ret.sales + "  tips: " + ret.tips);
            log("  refunds: " + ret.refunds + "  fees: " + ret.fees);
            log("  net: " + ret.net);
            log("-------------------------------------------------------------------------------");
            log("  fees_credit: " + ret.fees_credit + "  fees_visa: " + ret.fees_visa);
            log("  fees_mc: " + ret.fees_mc + "  fees_discover: " + ret.fees_discover);
            log("  fees_amex: " + ret.fees_amex + "  fees_other: " + ret.fees_other);
            log("-------------------------------------------------------------------------------");
            log("  num_txn: " + ret.num_txn + "  num_txn_sales: " + ret.num_txn_sales);
            log("  num_txn_refunds: " + ret.num_txn_refunds + "  avg_txn_size: " + ret.avg_txn_size);
            log("  cash:");
            log("    num_txn_cash: " + ret.num_txn_cash + "  num_txn_cash_sales: " + ret.num_txn_cash_sales);
            log("    num_txn_cash_tips: " + ret.num_txn_cash_tips + "  num_txn_cash_refunds: " + ret.num_txn_cash_refunds);
            log("    cash_sales: " + ret.cash_sales + "  cash_tips: " + ret.cash_tips);
            log("    cash_refunds: " + ret.cash_refunds + "  cash_net: " + ret.cash_net);
            log("  credit:");
            log("    num_txn_credit: " + ret.num_txn_credit + "  num_txn_credit_sales: " + ret.num_txn_credit_sales);
            log("    num_txn_credit_tips: " + ret.num_txn_credit_tips + "  num_txn_credit_refunds: " + ret.num_txn_credit_refunds);
            log("    credit_sales: " + ret.credit_sales + "  credit_tips: " + ret.credit_tips);
            log("    credit_refunds: " + ret.credit_refunds + "  credit_net: " + ret.credit_net);
            log("    credit/visa:");
            log("      num_txn_cc_visa: " + ret.num_txn_cc_visa + "  num_txn_cc_visa_sales: " + ret.num_txn_cc_visa_sales);
            log("      num_txn_cc_visa_tips: " + ret.num_txn_cc_visa_tips + "  num_txn_cc_visa_refunds: " + ret.num_txn_cc_visa_refunds);
            log("      cc_visa_sales: " + ret.cc_visa_sales + "  cc_visa_tips: " + ret.cc_visa_tips);
            log("      cc_visa_refunds: " + ret.cc_visa_refunds + "  cc_visa_net: " + ret.cc_visa_net);
            log("    credit/mc:");
            log("      num_txn_cc_mc: " + ret.num_txn_cc_mc + "  num_txn_cc_mc_sales: " + ret.num_txn_cc_mc_sales);
            log("      num_txn_cc_mc_tips: " + ret.num_txn_cc_mc_tips + "  num_txn_cc_mc_refunds: " + ret.num_txn_cc_mc_refunds);
            log("      cc_mc_sales: " + ret.cc_mc_sales + "  cc_mc_tips: " + ret.cc_mc_tips);
            log("      cc_mc_refunds: " + ret.cc_mc_refunds + "  cc_mc_net: " + ret.cc_mc_net);
            log("    credit/amex:");
            log("      num_txn_cc_amex: " + ret.num_txn_cc_amex + "  num_txn_cc_amex_sales: " + ret.num_txn_cc_amex_sales);
            log("      num_txn_cc_amex_tips: " + ret.num_txn_cc_amex_tips + "  num_txn_cc_amex_refunds: " + ret.num_txn_cc_amex_refunds);
            log("      cc_amex_sales: " + ret.cc_amex_sales + "  cc_amex_tips: " + ret.cc_amex_tips);
            log("      cc_amex_refunds: " + ret.cc_amex_refunds + "  cc_amex_net: " + ret.cc_amex_net);
            log("    credit/discover:");
            log("      num_txn_cc_discover: " + ret.num_txn_cc_discover + "  num_txn_cc_discover_sales: " + ret.num_txn_cc_discover_sales);
            log("      num_txn_cc_discover_tips: " + ret.num_txn_cc_discover_tips + "  num_txn_cc_discover_refunds: " + ret.num_txn_cc_discover_refunds);
            log("      cc_discover_sales: " + ret.cc_discover_sales + "  cc_discover_tips: " + ret.cc_discover_tips);
            log("      cc_discover_refunds: " + ret.cc_discover_refunds + "  cc_discover_net: " + ret.cc_discover_net);
            log("    credit/other:");
            log("      num_txn_cc_other: " + ret.num_txn_cc_other + "  num_txn_cc_other_sales: " + ret.num_txn_cc_other_sales);
            log("      num_txn_cc_other_tips: " + ret.num_txn_cc_other_tips + "  num_txn_cc_other_refunds: " + ret.num_txn_cc_other_refunds);
            log("      cc_other_sales: " + ret.cc_other_sales + "  cc_other_tips: " + ret.cc_other_tips);
            log("      cc_other_refunds: " + ret.cc_other_refunds + "  cc_other_net: " + ret.cc_other_net);
            log("  coupon:");
            log("    num_txn_coupon: " + ret.num_txn_coupon + "  num_txn_coupon_sales: " + ret.num_txn_coupon_sales);
            log("    num_txn_coupon_tips: " + ret.num_txn_coupon_tips + "  num_txn_coupon_refunds: " + ret.num_txn_coupon_refunds);
            log("    coupon_sales: " + ret.coupon_sales + "  coupon_tips: " + ret.coupon_tips);
            log("    coupon_refunds: " + ret.coupon_refunds + "  coupon_net: " + ret.coupon_net);
            log("  gift_certificate:");
            log("    num_txn_gift_certificate: " + ret.num_txn_gift_certificate + "  num_txn_gift_certificate_sales: " + ret.num_txn_gift_certificate_sales);
            log("    num_txn_gift_certificate_tips: " + ret.num_txn_gift_certificate_tips + "  num_txn_gift_certificate_refunds: " + ret.num_txn_gift_certificate_refunds);
            log("    gift_certificate_sales: " + ret.gift_certificate_sales + "  gift_certificate_tips: " + ret.gift_certificate_tips);
            log("    gift_certificate_refunds: " + ret.gift_certificate_refunds + "  gift_certificate_net: " + ret.gift_certificate_net);
            log("  check:");
            log("    num_txn_check: " + ret.num_txn_check + "  num_txn_check_sales: " + ret.num_txn_check_sales);
            log("    num_txn_check_tips: " + ret.num_txn_check_tips + "  num_txn_check_refunds: " + ret.num_txn_check_refunds);
            log("    check_sales: " + ret.check_sales + "  check_tips: " + ret.check_tips);
            log("    check_refunds: " + ret.check_refunds + "  check_net: " + ret.check_net);
            log("  deal_redemption:");
            log("    num_txn_deal_redemption: " + ret.num_txn_deal_redemption + "  num_txn_deal_redemption_sales: " + ret.num_txn_deal_redemption_sales);
            log("    num_txn_deal_redemption_tips: " + ret.num_txn_deal_redemption_tips + "  num_txn_deal_redemption_refunds: " + ret.num_txn_deal_redemption_refunds);
            log("    deal_redemption_sales: " + ret.deal_redemption_sales + "  deal_redemption_tips: " + ret.deal_redemption_tips);
            log("    deal_redemption_refunds: " + ret.deal_redemption_refunds + "  deal_redemption_net: " + ret.deal_redemption_net);
            log("  other:");
            log("    num_txn_other: " + ret.num_txn_other + "  num_txn_other_sales: " + ret.num_txn_other_sales);
            log("    num_txn_other_tips: " + ret.num_txn_other_tips + "  num_txn_other_refunds: " + ret.num_txn_other_refunds);
            log("    other_sales: " + ret.other_sales + "  other_tips: " + ret.other_tips);
            log("    other_refunds: " + ret.other_refunds + "  other_net: " + ret.other_net);
            log("-------------------------------------------------------------------------------");

            if (ret.payment_list != null)
            {
                if (ret.payment_list.Count > 0)
                {
                    log("  payment_detail: " + ret.payment_list.Count + " records");
                    log("  ID: type / cc_type / cc_last_four / amount / date");
                    foreach (payment_report_detail curr_detail in ret.payment_list)
                    {
                        string log_string = "  " + curr_detail.payment_id + ": " + curr_detail.method + " ";
                        if (String.Compare(curr_detail.method, "CreditCard") == 0)
                        {
                            log_string += "/ " + curr_detail.cc_type + " / " + curr_detail.cc_redacted_number + " ";
                        }

                        log_string += "/ " + curr_detail.amount + " / " + curr_detail.created.ToString("MM/dd/yyyy");
                        log(log_string);
                    }
                }
                else
                {
                    log("  payment_detail: no records");
                }
            }
            else
            {
                log("  payment_detail: null records");
            }

            log("===============================================================================");

            #endregion

            return ret;
        }