protected void lnkBtnViewTransactions_Click(object sender, EventArgs e) { //ValidateItemInformation(); //ViewTransaction.Visible = false; FundAccount.Visible = false; GetBalance.Visible = false; UpdateVirtualWallet.Visible = false; divViewTrans.Visible = true; if (!(UpdateInformationError.Count > 0)) { Merchant CurrMerchant = new Merchant(); APIKey CurrAPIKey = new APIKey(); CurrMerchant.MerchantID = "78735"; CurrAPIKey.Key = "7636"; VWHolder newVW = new VWHolder(); newVW.VWID = Session["userVWID"].ToString(); try { String url = "http://cis-iis2.temple.edu/Fall2019/CIS3342_tuf05666/WebAPI/api/service/PaymentGateway/GetTransactions"; url = url + "/" + newVW.VWID + "/" + CurrMerchant.MerchantID + "/" + CurrAPIKey.Key; WebRequest request = WebRequest.Create(url); WebResponse response = request.GetResponse(); Stream theDataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(theDataStream); String data = reader.ReadToEnd(); reader.Close(); response.Close(); JavaScriptSerializer js = new JavaScriptSerializer(); Transactions[] TransactionData = js.Deserialize <Transactions[]>(data); gvTransactions.DataSource = TransactionData; gvTransactions.DataBind(); } catch (Exception errorException) { Response.Write(errorException.Message); } } else { for (int i = 0; i < UpdateInformationError.Count; i++) { Response.Write(UpdateInformationError[i] + " <br/>"); } } }
public Boolean FundAccount([FromBody] VWHolder curVW, string MerchantID, string Key) { if ((MerchantID == "78735") && (Key == "7636")) { string VWID = curVW.VWID; int currentBal = curVW.GetCurrentBalance(); int AmountToAdd = curVW.FundsToAdd; int NewBalance = currentBal + AmountToAdd; DateTime dt = DateTime.Now; objCommand.Parameters.Clear(); //DataSet MyCurrentBalance = new DataSet(); objCommand.CommandType = CommandType.StoredProcedure; objCommand.CommandText = "TPAddToBalance"; objCommand.Parameters.AddWithValue("@VWID", VWID); objCommand.Parameters.AddWithValue("@NewBalance", NewBalance); int ResponseReceived; ResponseReceived = objDB.DoUpdateUsingCmdObj(objCommand); objCommand.Parameters.Clear(); objCommand.CommandType = CommandType.StoredProcedure; objCommand.CommandText = "TPAddTransaction"; objCommand.Parameters.AddWithValue("@VWIDReceiver", VWID); objCommand.Parameters.AddWithValue("@VWIDSender", VWID); objCommand.Parameters.AddWithValue("@Amount", AmountToAdd); objCommand.Parameters.AddWithValue("@Type", "Fund"); objCommand.Parameters.AddWithValue("@Date", dt); int responsereceived = objDB.DoUpdateUsingCmdObj(objCommand); if (ResponseReceived == 1) { return(true); } else { return(false); } } else { return(false); } }
public string CreateVW([FromBody] VWHolder newVW, string MerchantID, string Key) { string Result = "test"; if ((MerchantID == "78735") && (Key == "7636")) { Result = newVW.AddCustomer(); return(Result); } else { return(Result); } }
public void UpdatePaymentAccount([FromBody] VWHolder curVW, string MerchantID, string Key) { if ((MerchantID == "78735") && (Key == "7636")) { string VWID = curVW.VWID; objCommand.CommandType = CommandType.StoredProcedure; objCommand.CommandText = "TPUpdatePaymentAccount"; objCommand.Parameters.AddWithValue("@PaymentMethodName", curVW.PaymentMethodName); objCommand.Parameters.AddWithValue("@AccountNumber", curVW.AccountNumber); objCommand.Parameters.AddWithValue("@AccountType", curVW.AccountType); objCommand.Parameters.AddWithValue("@Balance", curVW.CurrentBalance); objCommand.Parameters.AddWithValue("@VWID", VWID); int ResponseReceived; ResponseReceived = objDB.DoUpdateUsingCmdObj(objCommand); } }
protected void btnUpdateInfo_Click(object sender, EventArgs e) { ValidatePaymentInformation(); if (!(UpdateInformationError.Count > 0)) { Merchant CurrMerchant = new Merchant(); APIKey CurrAPIKey = new APIKey(); CurrMerchant.MerchantID = "78735"; CurrAPIKey.Key = "7636"; VWHolder newVW = new VWHolder(); newVW.PaymentMethodName = txtPaymentMethodName.Text.ToString(); newVW.AccountNumber = txtAccountNumber.Text.ToString(); newVW.AccountType = ddlAccountType.SelectedValue.ToString(); newVW.CurrentBalance = int.Parse(txtInitialBalance.Text.ToString()); newVW.VWID = Session["userVWID"].ToString(); JavaScriptSerializer js = new JavaScriptSerializer(); //Converts Object into JSON String String jsonCreditCard = js.Serialize(newVW); try { String url = "http://cis-iis2.temple.edu/Fall2019/CIS3342_tuf05666/WebAPI/api/service/PaymentGateway/UpdatePaymentAccount"; url = url + "/" + CurrMerchant.MerchantID + "/" + CurrAPIKey.Key; WebRequest request = WebRequest.Create(url); request.Method = "PUT"; request.ContentLength = jsonCreditCard.Length; request.ContentType = "application/json"; StreamWriter writer = new StreamWriter(request.GetRequestStream()); writer.Write(jsonCreditCard); writer.Flush(); writer.Close(); WebResponse response = request.GetResponse(); Stream theDataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(theDataStream); String data = reader.ReadToEnd(); reader.Close(); response.Close(); if (data == "true") { Response.Write("Funds added"); } else { Response.Write("Error Occured on the database."); } } catch (Exception errorException) { Response.Write(errorException.Message); } } else { for (int i = 0; i < UpdateInformationError.Count; i++) { Response.Write(UpdateInformationError[i] + " <br/>"); } } }
public string ExecuteCallToWebAPI(VWHolder newVW, Merchant CurrMerchant, APIKey CurrAPIKey) { string Fname = txtFirstName.Text; string Lname = txtLastName.Text; string pword = txtPassword.Text; string emailadd = txtEmail.Text; newVW.Name = Fname + " " + Lname; newVW.Password = pword; newVW.Email = emailadd; JavaScriptSerializer js = new JavaScriptSerializer(); //Coverts Object into JSON String String jsonVWHolder = js.Serialize(newVW); try { CurrMerchant.MerchantID = "78735"; CurrAPIKey.Key = "7636"; String url = "http://cis-iis2.temple.edu/Fall2019/CIS3342_tuf05666/WebAPITest/api/service/PaymentGateway/CreateVW"; url = url + "/" + CurrMerchant.MerchantID + "/" + CurrAPIKey.Key; WebRequest request = WebRequest.Create(url); request.Method = "POST"; request.ContentLength = jsonVWHolder.Length; request.ContentType = "application/json"; // Write the JSON data to the Web Request StreamWriter writer = new StreamWriter(request.GetRequestStream()); writer.Write(jsonVWHolder); writer.Flush(); writer.Close(); // Create an HTTP Web Request and get the HTTP Web Response from the server. WebResponse response = request.GetResponse(); Stream theDataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(theDataStream); string data1 = reader.ReadToEnd(); reader.Close(); response.Close(); string data = data1.Trim('"'); lblText.Text = data; return(data); } catch (Exception ex) { string hi = "hello"; lblText.Text = "Error: " + ex.Message; return(hi); } }
protected void RegisterUserButton_Click(object sender, EventArgs e) { FullAddress = txtStreet.Text + "," + txtCity.Text + "," + txtState.Text + "," + txtZip.Text; FullBillingAddress = txtBillingStreet.Text + "," + txtBillingCity.Text + "," + txtBillingState.Text + "," + txtBillingZip.Text; string CustomerFirstName = txtFirstName.Text; string CustomerLastName = txtLastName.Text; string CustomerPhoneNumber = txtPhoneNumber.Text; string CustomerEmail = txtEmail.Text; string CustomerPassword = txtPassword.Text; string CustomerDeliveryAddress = FullAddress; string CustomerBillingAddress = FullBillingAddress; string RestaurantEmail = txtEmail.Text; string RestaurantPassword = txtPassword.Text; string RestaurantFirstName = txtFirstName.Text; string RestaurantLastName = txtLastName.Text; string RestaurantCuisine = ddlCuisine.SelectedValue.ToString(); string RestaurantImgUrl = txtImgUrl.Text; string RestaurantLocation = FullAddress; string restaurantName = txtRestuarantName.Text; string RestaurantPhoneNumber = txtPhoneNumber.Text; string SecurityQuestion = txtSecurityQuestion.Text; string SecurityAnswer = txtAnswer.Text; //Validate ValidateUserRegistration(); if ((UserRegistrationError.Count == 0) && (ddlUserTypeID.SelectedValue == "Customer")) { //Check if email already exist String UserEmail = txtEmail.Text; Boolean flag = CheckIfCustomerExists(UserEmail); if (flag == true) { Response.Write("Email already exist"); } else { Merchant m12 = new Merchant(); APIKey w12 = new APIKey(); VWHolder VW12 = new VWHolder(); VW12.Name = txtFirstName.ToString() + "" + txtLastName.ToString(); VW12.Password = txtPassword.ToString(); VW12.Email = txtEmail.ToString(); VW12.AccountNumber = "12345679023"; string test = ExecuteCallToWebAPI(VW12, m12, w12); //Register Customer newCustomer = new Customer { FirstName = CustomerFirstName, LastName = CustomerLastName, PhoneNumber = CustomerPhoneNumber, Email = CustomerEmail, Password = CustomerPassword, DeliveryAddress = CustomerDeliveryAddress, BillingAddress = CustomerBillingAddress, SecurityAnswer = SecurityAnswer, SecurityQuestion = SecurityQuestion, VWID = test }; var ResponseReceived = newCustomer.AddCustomer(); if (ResponseReceived == true) { //User Registered //Save UserEmail in Session Called UserEmail Session.Add("userEmail", txtEmail.Text.ToString()); Session.Add("userPassword", txtPassword.Text.ToString()); Session.Add("userVWID", test); RegisterUserDetails.Visible = false; PreferencesDiv.Visible = true; } else { Response.Write("Error Occured on the DATABASE"); } } } if ((UserRegistrationError.Count == 0) && (ddlUserTypeID.SelectedValue == "Restaurant")) { //Check if email already exist String UserEmail = txtEmail.Text; Boolean flag = CheckIfRestaurantExists(UserEmail); if (flag == true) { Response.Write("Email already exist"); } else { Merchant m12 = new Merchant(); APIKey w12 = new APIKey(); VWHolder VW12 = new VWHolder(); VW12.Name = txtFirstName.ToString() + "" + txtLastName.ToString(); VW12.Password = txtPassword.ToString(); VW12.Email = txtEmail.ToString(); VW12.AccountNumber = "12345679023"; string test = ExecuteCallToWebAPI(VW12, m12, w12); //Register Restaurants newRestaurants = new Restaurants { Email = RestaurantEmail, Password = RestaurantPassword, FirstName = RestaurantFirstName, LastName = RestaurantLastName, Cuisine = RestaurantCuisine, ImgURL = RestaurantImgUrl, PhoneNumber = RestaurantPhoneNumber, RestaurantName = restaurantName, Location = RestaurantLocation, SecurityAnswer = SecurityAnswer, SecurityQuestion = SecurityQuestion, VWID = test }; var ResponseReceived = newRestaurants.AddAddRestaurant(); if (ResponseReceived == true) { //User Registered //Save UserEmail in Session Called UserEmail Session.Add("userEmail", txtEmail.Text.ToString()); Session.Add("userPassword", txtPassword.Text.ToString()); Session.Add("userVWID", test); RegisterUserDetails.Visible = false; PreferencesDiv.Visible = true; Email objEmail = new Email(); String strTO = txtEmail.Text.ToString(); String strFROM = "*****@*****.**"; String strSubject = "Thank you for signing up to our website!"; String strMessage = "We hope that you are able to find many customers!"; try { objEmail.SendMail(strTO, strFROM, strSubject, strMessage); Response.Write("The email was sent."); } catch (Exception ex) { Response.Write("The email wasn't sent because one of the required fields was missing."); } } else { Response.Write("Error Occured on the DATABASE"); } } } else { for (int i = 0; i < UserRegistrationError.Count; i++) { Response.Write(UserRegistrationError[i] + "<br/>"); } } }