public static void sendPaymentMail(modal.Payment payment) { MembershipUser user = Functions.getLoginUser(); var m_content = ""; m_content += "Hi, Dear user " + user.UserName + ", <br /><br />"; m_content += "Thank for your expense in our store and buy our expensive art<br />"; m_content += "You have buy the folllowing art: <br /><table style=''>"; m_content += "<tr>"; m_content += "<th> Title </th>"; m_content += "<th> Quantity </th>"; m_content += "<th></th>"; m_content += "<th> Single Price </th>"; m_content += "</tr>"; foreach (PaymentDetail art in payment.PaymentDetails) { m_content += "<tr>"; m_content += "<td>" + art.Art.title + "</td>"; m_content += "<td>" + art.quantity + "</td>"; m_content += "<td> * </td>"; m_content += "<td>" + art.Art.price + "</td>"; m_content += "</tr>"; } m_content += "</table>" + "Total payment : " + payment.total_pay + "<br />"; m_content += "Paid By " + payment.PaymentMethod.name + " [ " + payment.payment_meta + " ]. <br />"; m_content += "<br /><br />Thak you so much !!"; bool sended = SendMail.send_mail( "Placed Payment", "This notice confirms that your has purchase our product in Art Salse.com !!", m_content, user.Email ); }
protected void Button1_Click(object sender, EventArgs e) { string name = this.CardName.Text; string pass = this.CardPass.Text; using (ArtShopEntities db = new ArtShopEntities()) { PublicBank database = db.PublicBanks.Find(name); modal.Payment payments = db.Payments.Find(paymentId); if (database == null) { Functions.EnqueueNewNotifications(new Notifications( Notifications.ERROR_TYPE, "Invalid card number!!", "Wrong card numbers")); return; } if (database.bank_username != name) { Functions.EnqueueNewNotifications(new Notifications( Notifications.ERROR_TYPE, "Unassessable!!", "Username not match")); return; } if (database.password != pass) { Functions.EnqueueNewNotifications(new Notifications( Notifications.ERROR_TYPE, "Unassessable!!", "Password not match")); return; } if ((double)database.amount < payments.total_pay) { Functions.EnqueueNewNotifications(new Notifications( Notifications.ERROR_TYPE, "Not enought amount!!", "Your card is only remain " + database.amount)); return; } Functions.EnqueueNewNotifications(new Notifications( Notifications.SUCCESS_TYPE, "Login sucessfull!!", "Welcome, " + database.bank_username)); Session[Constant.ACCOUNT_SESSION] = database.bank_account; Response.Redirect("~/pages/Payment/PublicBank.aspx?id=" + this.paymentId); } }
protected void Page_Load(object sender, EventArgs e) { Functions.checkValidPayment(Request.QueryString["id"]); paymentId = Guid.Parse(Request.QueryString["id"]); if (Session[Constant.ACCOUNT_SESSION] == null) { Response.Redirect("~"); return; } using (ArtShopEntities db = new ArtShopEntities()) { bank = db.PublicBanks.Find(Session[Constant.ACCOUNT_SESSION]); payments = db.Payments.Find(paymentId); CardName.Text = bank.bank_account; CardPass.Text = DateTime.Now.ToString(); Label1.Text = payments.total_pay.ToString(); } }
protected void confirmPayment(object sender, EventArgs e) { PayPal card = getData(); using (ArtShopEntities db = new ArtShopEntities()) { PayPal database = db.PayPals.Find(card.paypal_id); modal.Payment payments = db.Payments.Find(paymentId); if (database == null) { Functions.EnqueueNewNotifications(new Notifications( Notifications.ERROR_TYPE, "Invalid paypal account!!", "paypal account not corrects")); return; } if (database.paypal_id != card.paypal_id) { Functions.EnqueueNewNotifications(new Notifications( Notifications.ERROR_TYPE, "Unassessable!!", "Account is not match")); return; } if (database.name != card.name) { Functions.EnqueueNewNotifications(new Notifications( Notifications.ERROR_TYPE, "Unassessable!!", "Name is not match")); return; } if (database.password != card.password) { Functions.EnqueueNewNotifications(new Notifications( Notifications.ERROR_TYPE, "Unassessable!!", "Passwords is not match")); return; } modal.Payment pay = db.Payments.Find(paymentId); if ((double)database.amount < pay.total_pay) { Functions.EnqueueNewNotifications(new Notifications( Notifications.ERROR_TYPE, "Not enought amount!!", "Your accocunt only remain " + database.amount)); return; } database.amount -= (decimal)pay.total_pay; payments.payment_status = Guid.Parse("c595596d-8980-4138-bc20-a91056e1b1ce"); payments.payment_method = Guid.Parse("9244ee14-b4b5-4f2c-833b-3b3c18d68764"); payments.payment_meta = database.paypal_id; payments.customer_paid = payments.total_pay; payments.payment_date = DateTime.Now; db.Payments.AddOrUpdate(payments); db.PayPals.AddOrUpdate(database); try { db.SaveChanges(); Functions.EnqueueNewNotifications(new Notifications( 2, Notifications.SUCCESS_TYPE, "Payment sucessfull!!", "you have complete the payment with your paypal account: " + database.paypal_id + "")); Functions.sendPaymentMail(payments); } catch (Exception ex) { Functions.EnqueueNewNotifications(new Notifications( 2, Notifications.ERROR_TYPE, "Payment Failed!!", "you have following exception : " + ex.Message + " !!")); } } }
protected void btnCheckout_event(object sender, EventArgs e) { bool allvirtual = true; PaymentDetail pd; Painting paint; using (ArtShopEntities db = new ArtShopEntities()) { IQueryable <vw_customer_cart2> x = db.vw_customer_cart2.Where(s => s.user_id == id); vw_customer_cart2[] y = x.ToArray(); modal.Payment newPaynment = new modal.Payment(); newPaynment.PaymentStatu = db.PaymentStatus.Find(Guid.Parse("20bd9f32-b531-4b7f-a89a-80babe9aa707")); newPaynment.UserId = (Guid)Functions.getLoginUser().ProviderUserKey; newPaynment.payment_date = DateTime.Now; newPaynment.id = Guid.NewGuid(); newPaynment.notes = ""; newPaynment.payment_method = Guid.Parse("1c98a7a8-6449-4ca4-be81-8b21f1cc12e0"); newPaynment.payment_meta = ""; for (int i = 0; i < x.Count(); i++) { if (y[i].@virtual) { if (y[i].@checked ?? false) { total += Convert.ToDouble(y[i].price); checkedCount++; pd = new PaymentDetail(); pd.add_date = DateTime.Now; pd.@virtual = y[i].@virtual; pd.quantity = y[i].availability; pd.art_id = y[i].id; pd.payment_id = newPaynment.id; db.CartDetails.Remove(db.CartDetails.Find(cart_id, y[i].id)); newPaynment.PaymentDetails.Add(pd); } } else { if (y[i].@checked ?? false) { total += (Convert.ToDouble(y[i].price) * (double)y[i].availability); checkedCount++; pd = new PaymentDetail(); pd.add_date = DateTime.Now; pd.@virtual = y[i].@virtual; pd.quantity = y[i].availability; pd.payment_id = newPaynment.id; pd.delivery_fee = Functions.caculateDeliveryFees(y[i], y[i].availability ?? 1); Art xart = db.Arts.Find(y[i].id); xart.Painting.quantity -= y[i].availability ?? 0; db.Arts.AddOrUpdate(xart); db.CartDetails.Remove(db.CartDetails.Find(cart_id, y[i].id)); newPaynment.PaymentDetails.Add(pd); } allvirtual |= false; } } newPaynment.net_pay = total; newPaynment.tax_change = total * 0.06; newPaynment.total_pay = total * 1.06; newPaynment.destinations_id = null; db.Payments.Add(newPaynment); try { db.SaveChanges(); if (allvirtual) { //checkout not need fill address Response.Redirect("~/pages/Payment/SelectMethod.aspx?id=" + newPaynment.id); } else { //checkout need fill address Response.Redirect("~/pages/Payment/CheckOut.aspx?id=" + newPaynment.id); } } catch (DbEntityValidationException ex) { foreach (var eve in ex.EntityValidationErrors) { Functions.EnqueueNewNotifications(new Notifications( Notifications.ERROR_TYPE, "Error large!!", eve.Entry.Entity.GetType().Name + eve.Entry.State)); foreach (var ve in eve.ValidationErrors) { Functions.EnqueueNewNotifications(new Notifications( Notifications.ERROR_TYPE, "Error large!!", ve.PropertyName + ve.ErrorMessage)); } } } } }
protected void Button1_Click(object sender, EventArgs e) { Card card = getData(); using (ArtShopEntities db = new ArtShopEntities()) { Card database = db.Cards.Find(card.card_number); modal.Payment payments = db.Payments.Find(paymentId); if (database == null) { Functions.EnqueueNewNotifications(new Notifications( Notifications.ERROR_TYPE, "Invalid card number!!", "Wrong card numbers")); return; } if (database.ccv != card.ccv) { Functions.EnqueueNewNotifications(new Notifications( Notifications.ERROR_TYPE, "Unassessable!!", "CCV is not match")); return; } if (database.name != card.name) { Functions.EnqueueNewNotifications(new Notifications( Notifications.ERROR_TYPE, "Unassessable!!", "Name is not match")); return; } if (database.exp_date != card.exp_date) { Functions.EnqueueNewNotifications(new Notifications( Notifications.ERROR_TYPE, "Unassessable!!", "Exp date is not match")); return; } modal.Payment pay = db.Payments.Find(paymentId); if ((double)database.amount < pay.total_pay) { Functions.EnqueueNewNotifications(new Notifications( Notifications.ERROR_TYPE, "Not enought amount!!", "Your card is only remain " + database.amount)); return; } database.amount -= (decimal)pay.total_pay; payments.payment_status = Guid.Parse("c595596d-8980-4138-bc20-a91056e1b1ce"); payments.payment_method = Guid.Parse("9244ee14-b4b5-4f2c-833b-3b3c18d68764"); payments.payment_meta = database.card_number; payments.customer_paid = payments.total_pay; payments.payment_date = DateTime.Now; db.Payments.AddOrUpdate(payments); db.Cards.AddOrUpdate(database); try { db.SaveChanges(); Functions.EnqueueNewNotifications(new Notifications( Notifications.SUCCESS_TYPE, "Payment sucessfull!!", "you have used the card " + database.card_number + " complete the payment")); Functions.sendPaymentMail(payments); } catch (Exception ex) { Functions.EnqueueNewNotifications(new Notifications( Notifications.ERROR_TYPE, "Payment Failed!!", "you have following exception : " + ex.Message + " !!")); } } }