public void TestInsertDupMerchantThrowsEx() { MerchantMBE merchant = new MerchantMBE() { merchant_id = _merchantTestsGlobal.MERCHANT_ID, merchant_name = @"Tom's Pet Shop", primary_contact = new ContactMBE() { first_name = @"Tom", last_name = @"Bruns", phone_no = _merchantTestsGlobal.PHONE_NO, email_address = @"*****@*****.**" }, setup_options = new SetupOptionsMBE() { is_host_data_capture_enabled = true, auto_close_hh_mm = new TimeSpan(19, 0, 0), is_fast_funding_enabled = true }, terminals = new List <TerminalMBE>() { new TerminalMBE() { terminal_id = "TID-001", terminal_type = @"610", terminal_desc = @"Checkout 1" }, new TerminalMBE() { terminal_id = "TID-002", terminal_type = @"610", terminal_desc = @"Checkout 2" }, } }; // this tests our unique index Assert.Throws <MongoWriteException>(() => MongoDBContext.InsertMerchant(merchant)); }
public static string BuildWelcomeMessage(MerchantMBE merchant) { var welcomeMsg = $"Welcome {merchant.merchant_name } to IQ Buzz\n" + $"Reply YES to confirm enrollment in {GeneralConstants.APP_NAME}. Msg&Data rates may appy. Msg freq varies by acct and prefs."; return(welcomeMsg); }
public async Task <ActionResult <MerchantMBE> > AddMerchant([FromBody] NewMerchantMBE newMerchant) { // validate request data if (string.IsNullOrEmpty(newMerchant.MerchantName)) { return(BadRequest(new ArgumentNullException(nameof(newMerchant.MerchantName), @"You must supply a non blank value for the Merchant Name."))); } // validate the input params /*if (!Uri.IsWellFormedUriString(newMerchant.MerchantUrl.ToString(), UriKind.Absolute)) * { * * return BadRequest(new ArgumentException(nameof(newMerchant.MerchantUrl), @"The merchant url is incorrect. Make sure the url has https:// or http://")); * }*/ var merchant = new MerchantMBE { MerchantGuid = GeneralConstants.MERCHANT_1_GUID, MerchantName = newMerchant.MerchantName, MerchantUrl = new Uri("https://www.testmerchant.com"), IsSupportsTips = newMerchant.IsSupportsTips }; await Task.Delay(100); return(CreatedAtAction(nameof(GetMerchant), new { merchantGuid = merchant.MerchantGuid }, merchant)); }
public static void InsertMerchant(MerchantMBE merchant) { (string serverName, int portNumber, string dbName) = GetMongoDBConnectionInfo(); var client = new MongoClient($"mongodb://{serverName}:{portNumber}"); var db = client.GetDatabase(dbName); var collection = db.GetCollection <MerchantMBE>(MerchantMBE.COLLECTION_NAME); collection.InsertOne(merchant); }
public static void UpdateMerchant(MerchantMBE merchant) { (string serverName, int portNumber, string dbName) = GetMongoDBConnectionInfo(); var client = new MongoClient($"mongodb://{serverName}:{portNumber}"); var db = client.GetDatabase(dbName); var collection = db.GetCollection <MerchantMBE>(MerchantMBE.COLLECTION_NAME); var filter = new BsonDocument("_id", merchant.ID); collection.ReplaceOne(filter, merchant); }
public static string BuildSummaryMessage(int merchantId, DateTime xctPostingDate) { MerchantMBE merchant = MongoDBContext.FindMerchantById(merchantId); XctDailySummaryBE xctSummary = MerchantController.GetXctDailySummary(merchantId, xctPostingDate); StringBuilder sb = new StringBuilder(); sb.AppendLine($"Merchant Account Summary for: {xctPostingDate:ddd MMM dd, yyyy} as of {DateTime.Now.ToString("h:mm tt")} "); sb.AppendLine("\n"); if (xctSummary != null) { foreach (var xctType in xctSummary.SummaryByXctType) { sb.AppendLine($"{xctType.XctTypeDesc}:"); sb.AppendLine($"{xctType.XctTotalValue:C} [{xctType.XctCount} txns]"); if (xctType.XctType == Enums.TRANSACTION_TYPE.chargeback) { sb.AppendLine(" (text CBACK for details)"); } sb.AppendLine("\n"); } sb.AppendLine($"Net Total: {xctSummary.SummaryByXctType.Sum(x => x.XctTotalValue):C}"); sb.AppendLine("(all Card Transactions)"); sb.AppendLine("\n"); sb.AppendLine($"Final settlement amount will be deposited into your checking account ending in {merchant.setup_options.debit_card_no.Substring(1,4)} on {DateTime.Now.AddBusinessDays(2).ToString("ddd MMM dd, yyyy")} -- to" + " receive these funds tomorrow morning reply FAF"); } else { sb.AppendLine(@"No activity yet for today."); } return(sb.ToString()); }
public static MerchantMBE CreateMerchant(int merchantId) { MerchantMBE merchant = null; try { merchant = MongoDBContext.FindMerchantById(merchantId); MongoDBContext.DeleteMerchant(merchantId); merchant = null; } catch { } switch (merchantId) { case 1: merchant = new MerchantMBE() { merchant_id = merchantId, merchant_name = @"Tom's Deli", primary_contact = new ContactMBE() { first_name = @"Tom", last_name = @"Bruns", phone_no = GeneralConstants.TOMS_PHONE_NO, email_address = @"*****@*****.**" }, setup_options = new SetupOptionsMBE() { is_host_data_capture_enabled = true, auto_close_hh_mm = new TimeSpan(19, 0, 0), is_fast_funding_enabled = true, debit_card_no = @"1234567890123401" }, terminals = new List <TerminalMBE>() { new TerminalMBE() { terminal_id = "TID-001", terminal_type = @"610", terminal_desc = @"Checkout 1" }, new TerminalMBE() { terminal_id = "TID-002", terminal_type = @"610", terminal_desc = @"Checkout 2" }, } }; break; case 2: merchant = new MerchantMBE() { merchant_id = merchantId, merchant_name = @"Marcos Canoe Livery", primary_contact = new ContactMBE() { first_name = @"Marco", last_name = @"Fernandes", phone_no = GeneralConstants.MARCOS_PHONE_NO, email_address = @"*****@*****.**" }, setup_options = new SetupOptionsMBE() { is_host_data_capture_enabled = true, auto_close_hh_mm = new TimeSpan(19, 0, 0), is_fast_funding_enabled = true, debit_card_no = @"1234567890126702" }, terminals = new List <TerminalMBE>() { new TerminalMBE() { terminal_id = "TID-001", terminal_type = @"610", terminal_desc = @"Checkout 1" }, new TerminalMBE() { terminal_id = "TID-002", terminal_type = @"610", terminal_desc = @"Checkout 2" }, } }; break; case 3: merchant = new MerchantMBE() { merchant_id = merchantId, merchant_name = @"Dusty's Cookies", primary_contact = new ContactMBE() { first_name = @"Dusty", last_name = @"Gomez", phone_no = GeneralConstants.DUSTYS_PHONE_NO, email_address = @"*****@*****.**" }, setup_options = new SetupOptionsMBE() { is_host_data_capture_enabled = true, auto_close_hh_mm = new TimeSpan(19, 0, 0), is_fast_funding_enabled = true, debit_card_no = @"1234567890125203" }, terminals = new List <TerminalMBE>() { new TerminalMBE() { terminal_id = "TID-001", terminal_type = @"610", terminal_desc = @"Checkout 1" }, new TerminalMBE() { terminal_id = "TID-002", terminal_type = @"610", terminal_desc = @"Checkout 2" }, } }; break; case 4: merchant = new MerchantMBE() { merchant_id = merchantId, merchant_name = @"Byrne's Bar & Grill", primary_contact = new ContactMBE() { first_name = @"Josh", last_name = @"Byrne", phone_no = GeneralConstants.JOSHS_PHONE_NO, email_address = @"*****@*****.**" }, setup_options = new SetupOptionsMBE() { is_host_data_capture_enabled = true, auto_close_hh_mm = new TimeSpan(19, 0, 0), is_fast_funding_enabled = true, debit_card_no = @"1234567890122704" }, terminals = new List <TerminalMBE>() { new TerminalMBE() { terminal_id = "TID-001", terminal_type = @"610", terminal_desc = @"Checkout 1" }, new TerminalMBE() { terminal_id = "TID-002", terminal_type = @"610", terminal_desc = @"Checkout 2" }, } }; break; case 5: merchant = new MerchantMBE() { merchant_id = merchantId, merchant_name = @"Dr. Boeding", primary_contact = new ContactMBE() { first_name = @"Alex", last_name = @"Boeding", phone_no = GeneralConstants.ALEXS_PHONE_NO, email_address = @"*****@*****.**" }, setup_options = new SetupOptionsMBE() { is_host_data_capture_enabled = true, auto_close_hh_mm = new TimeSpan(19, 0, 0), is_fast_funding_enabled = true, debit_card_no = @"1234567890129905" }, terminals = new List <TerminalMBE>() { new TerminalMBE() { terminal_id = "TID-001", terminal_type = @"610", terminal_desc = @"Checkout 1" }, new TerminalMBE() { terminal_id = "TID-002", terminal_type = @"610", terminal_desc = @"Checkout 2" }, } }; break; case 6: merchant = new MerchantMBE() { merchant_id = merchantId, merchant_name = @"Pallavi's Robot Hobby Shop", primary_contact = new ContactMBE() { first_name = @"Pallavi", last_name = @"TBD", phone_no = GeneralConstants.PALLAVI_PHONE_NO, email_address = @"*****@*****.**" }, setup_options = new SetupOptionsMBE() { is_host_data_capture_enabled = true, auto_close_hh_mm = new TimeSpan(19, 0, 0), is_fast_funding_enabled = true, debit_card_no = @"1234567890121106" }, terminals = new List <TerminalMBE>() { new TerminalMBE() { terminal_id = "TID-001", terminal_type = @"610", terminal_desc = @"Checkout 1" }, new TerminalMBE() { terminal_id = "TID-002", terminal_type = @"610", terminal_desc = @"Checkout 2" }, } }; break; case 7: merchant = new MerchantMBE() { merchant_id = merchantId, merchant_name = @"Joe's Java Hut", primary_contact = new ContactMBE() { first_name = @"Joe", last_name = @"Pellar", phone_no = GeneralConstants.JOES_PHONE_NO, email_address = @"*****@*****.**" }, setup_options = new SetupOptionsMBE() { is_host_data_capture_enabled = true, auto_close_hh_mm = new TimeSpan(19, 0, 0), is_fast_funding_enabled = true, debit_card_no = @"1234567890121107" }, terminals = new List <TerminalMBE>() { new TerminalMBE() { terminal_id = "TID-001", terminal_type = @"610", terminal_desc = @"Checkout 1" }, new TerminalMBE() { terminal_id = "TID-002", terminal_type = @"610", terminal_desc = @"Checkout 2" }, } }; break; case 8: merchant = new MerchantMBE() { merchant_id = merchantId, merchant_name = @"Jake's State Farm", primary_contact = new ContactMBE() { first_name = @"Jianan", last_name = @"Hou", phone_no = GeneralConstants.JAKES_PHONE_NO, email_address = @"*****@*****.**" }, setup_options = new SetupOptionsMBE() { is_host_data_capture_enabled = true, auto_close_hh_mm = new TimeSpan(19, 0, 0), is_fast_funding_enabled = true, debit_card_no = @"1234567890122208" }, terminals = new List <TerminalMBE>() { new TerminalMBE() { terminal_id = "TID-001", terminal_type = @"610", terminal_desc = @"Checkout 1" }, new TerminalMBE() { terminal_id = "TID-002", terminal_type = @"610", terminal_desc = @"Checkout 2" }, } }; break; } ; MongoDBContext.InsertMerchant(merchant); return(merchant); }
public TwiMLResult Index(SmsRequest incomingMessage) { #region early stuff // Step 1: Fixed Text //var messagingResponse = new MessagingResponse(); //messagingResponse.Message("The copy cat says: " + incomingMessage.Body); // Step 2: Media // respond with media //var message = new Message(); //message.Body("The Robots are coming! Head for the hills!"); //message.Media(new Uri(@"https://farm8.staticflickr.com/7090/6941316406_80b4d6d50e_z_d.jpg")); //var messagingResponse = new MessagingResponse(); //messagingResponse.Message(message); //messagingResponse.Append(message); #endregion // Step 3: Variable Reponse string requestBody = incomingMessage.Body.ToLower().Trim(); string requestBody2 = Regex.Replace(requestBody, @"\s+", string.Empty); if (requestBody2.StartsWith(@"saleshttps://")) { requestBody = "sales_alexa"; } // format of sending phoen no is: "+15134986016" string fromPhoneNumber = incomingMessage.From; var response = new MessagingResponse(); // lookup the merchant using the incoming phone number MerchantMBE merchant = MerchantController.LookupMerchant(fromPhoneNumber); if (requestBody == @"help" || requestBody == @"help?" || requestBody == @"???" || requestBody == @"?") { StringBuilder helpMsg = new StringBuilder(); helpMsg.AppendLine(" Available Commands"); helpMsg.AppendLine("------------------------------"); helpMsg.AppendLine("Summary: Today's Summary"); helpMsg.AppendLine("Sales: Today's Sales"); helpMsg.AppendLine("Cback: Pending Chargebacks"); helpMsg.AppendLine("Returns: Today's Returns"); helpMsg.AppendLine("Stop: Unsubscribe"); helpMsg.AppendLine("FAF: Sign-up for Fast Access"); helpMsg.AppendLine("help?: this list"); helpMsg.AppendLine("join: resend welcome message"); //helpMsg.AppendLine("unjoin: reverse join (for testing)"); helpMsg.AppendLine("Settings: view/update alert settings"); helpMsg.AppendLine("User: Account Details"); response.Message(helpMsg.ToString()); } else if (requestBody == @"summary") { DateTime xctPostingDate = DateTime.Today; string salesInfo = MerchantController.BuildSummaryMessage(merchant.merchant_id, xctPostingDate); response.Message(salesInfo); } else if (requestBody == @"sales") { DateTime xctPostingDate = DateTime.Today; string salesInfo = MerchantController.BuildSalesSummaryMessage(merchant.merchant_id, xctPostingDate); response.Message(salesInfo); } else if (requestBody == @"cback" || requestBody == @"chargeback" || requestBody == @"chargebacks") { DateTime xctPostingDate = DateTime.Today; string salesInfo = MerchantController.BuildChargebackDetails(merchant.merchant_id, xctPostingDate); response.Message(salesInfo); } else if (requestBody == @"returns" || requestBody == @"refunds") { DateTime xctPostingDate = DateTime.Today; string refundsInfo = MerchantController.BuildReturnsSummaryMessage(merchant.merchant_id, xctPostingDate); response.Message(refundsInfo); } else if (requestBody == @"faf") { DateTime xctPostingDate = DateTime.Today; string faf = MerchantController.BuildFAFMessage(merchant.merchant_id, xctPostingDate); response.Message(faf); } else if (requestBody == @"confirm") { DateTime xctPostingDate = DateTime.Today; string fafMsg = MerchantController.BuildConfirmFAFMessage(merchant.merchant_id, xctPostingDate); response.Message(fafMsg); } else if (requestBody == @"undo") { DateTime xctPostingDate = DateTime.Today; string fafMsg = MerchantController.BuildUndoFAFMessage(merchant.merchant_id, xctPostingDate); response.Message(fafMsg); } else if (requestBody == @"join") { string welcomeMsg = MerchantController.BuildWelcomeMessage(merchant); string configMsg = MerchantController.BuildConfigMessage(merchant.merchant_id); response.Message($"{welcomeMsg}\n{configMsg}"); } else if (requestBody == @"unjoin") { string unjoinMsg = MerchantController.ResetAcceptedJoin(merchant.merchant_id); response.Message(unjoinMsg); } else if (requestBody == @"config" || requestBody == @"settings") { string msg = MerchantController.BuildConfigMessage(merchant.merchant_id); response.Message(msg); } else if (requestBody == @"user" || requestBody == @"whoami") { string msg = $"Hi {merchant.primary_contact.first_name} !\n{merchant.merchant_name} [id: {merchant.merchant_id}]\np: {merchant.primary_contact.phone_no}"; response.Message(msg); } else if (requestBody == @"sales_alexa") { response.Message("Getting Closer to WOW"); } else if (requestBody == @"yes") // welcome accept { string msg = MerchantController.AcceptWelcomeMessage(merchant.merchant_id, true); response.Message(msg); } else if (requestBody == @"status") { response.Message(@"not closed"); } else if (requestBody == @"testurl") { string msg = @"https://www.google.com"; response.Message(msg); } else if (requestBody == @"testnew") { string welcomeMsg = MerchantController.BuildWelcomeMessage(merchant); response.Message(welcomeMsg); } else if (requestBody == @"testaccept") { string welcomeMsg = MerchantController.TestWelcomeAccept(merchant.merchant_id); response.Message(welcomeMsg); } else { response.Message($"Sorry I do not understand [{requestBody}], text help? to see a list of the available commmands."); } return(TwiML(response)); }