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 static bool create_bank_account() { #region Variables string account_company_name = ""; string account_first_name = ""; string account_last_name = ""; string account_address_1 = ""; string account_city = ""; string account_state = ""; string account_postal_code = ""; string account_phone = ""; string account_type = ""; string routing_number = ""; string account_number = ""; int is_settlement_account = 0; bank_account resp_bank_account = new bank_account(); #endregion #region Populate-Variables Console.WriteLine("Answer the following questions using information found on your check."); Console.Write("Company Name (blank for personal account): "); account_company_name = Console.ReadLine(); Console.Write("First Name (blank for company account): "); account_first_name = Console.ReadLine(); Console.Write("Last Name (blank for company account): "); account_last_name = Console.ReadLine(); Console.Write("Address Line 1: "); account_address_1 = Console.ReadLine(); Console.Write("City: "); account_city = Console.ReadLine(); Console.Write("State: "); account_state = Console.ReadLine(); Console.Write("Postal Code: "); account_postal_code = Console.ReadLine(); Console.Write("Phone Number: "); account_phone = Console.ReadLine(); Console.WriteLine("Valid options: Business Checking, Business Savings"); Console.WriteLine(" Personal Checking, Personal Savings"); Console.Write("Type of Account: "); account_type = Console.ReadLine(); Console.Write("Routing Number: "); routing_number = Console.ReadLine(); Console.Write("Account Number: "); account_number = Console.ReadLine(); Console.Write("Use as Settlement Account? (1 for yes, 0 for no): "); is_settlement_account = Convert.ToInt32(Console.ReadLine()); #endregion #region Check-for-Null-or-Bad-Values if (string_null_or_empty(account_address_1) || string_null_or_empty(account_city) || string_null_or_empty(account_state) || string_null_or_empty(account_postal_code) || string_null_or_empty(account_phone) || string_null_or_empty(account_type) || string_null_or_empty(routing_number) || string_null_or_empty(account_number)) { Console.WriteLine("Please complete all required fields."); return false; } #endregion #region Process-Request resp_bank_account = slidepay.sp_create_bank_account( account_type, routing_number, account_number, account_company_name, account_first_name, account_last_name, account_address_1, account_city, account_state, account_postal_code, account_phone, is_settlement_account); if (resp_bank_account == null) { Console.WriteLine("Null response for bank_account retrieval request."); return false; } Console.WriteLine("==============================================================================="); Console.WriteLine("bank_account created: " + resp_bank_account.bank_account_id); Console.WriteLine(" type " + resp_bank_account.type + " routing " + resp_bank_account.routing_number + " account " + resp_bank_account.account_number); Console.WriteLine(" is_settlement_account " + resp_bank_account.is_settlement_account + " is_verified " + resp_bank_account.is_verified); Console.WriteLine("==============================================================================="); #endregion return true; }