public ActionResult Payment(PaymentModel payment) { try { if (ModelState.IsValid) { order order = new order(); order.user_id = int.Parse(Session["id"].ToString()); order.display_name = payment.display_name; order.phone_number = payment.phone_number; order.address = payment.address; order.email = payment.email; order.start_time = DateTime.Now.Date; order.form_payments = payment.form_payments; order.form_delivery = payment.form_delivery; order.status = false; order.total_money = this.totalMoney(); db.orders.Add(order); db.SaveChanges(); try { var carts = this.getProductInCookie(); foreach (var item in carts) { order_details orderDetail = new order_details(); orderDetail.order_id = order.id; orderDetail.product_id = item.id; orderDetail.name = Server.UrlDecode(item.name); orderDetail.quantity = item.quantity; if (item.price_promotion > 0) { var giamGia = String.Format("{0:0}", item.price * ((100 - item.price_promotion) / 100)); orderDetail.price = Decimal.Parse(giamGia.ToString()); } else { orderDetail.price = item.price; } orderDetail.into_money = item.totalMoney; db.order_details.Add(orderDetail); db.SaveChanges(); } } catch (Exception e) { } Response.Cookies["CartCookie"].Expires = DateTime.Now.AddDays(-1); var content = db.order_details.Where(n => n.order_id == order.id).ToList(); var body = new PaymentSuccess().body(order.display_name, content); new Utils().SendEmail(payment.email, "Chúc mừng bạn đã mua sản phẩm thành công", body, "", ""); return(Redirect("~/Trang-Chu")); } }catch (Exception e) { } this.getFormPayment(); this.getFormDelivery(); return(View(payment)); }
public async Task SuccessShouldReturnViewWithModel() { var model = new PaymentSuccess { Title = _processedPayment.Title, ReceiptNumber = "123456", MetaDescription = _processedPayment.MetaDescription }; var result = await _paymentController.Success("slug", "123456", "00000") as ViewResult; result.Model.Should().BeEquivalentTo(model); }
public ActionResult PaymentPayPal(order data) { order order = new order(); order.user_id = int.Parse(Session["id"].ToString()); order.display_name = data.display_name; order.phone_number = data.phone_number; order.address = data.address; order.email = data.email; order.start_time = DateTime.Now.Date; order.form_payments = data.form_payments; order.form_delivery = data.form_delivery; order.status = false; order.total_money = this.totalMoney(); db.orders.Add(order); db.SaveChanges(); try { var carts = this.getProductInCookie(); foreach (var item in carts) { order_details orderDetail = new order_details(); orderDetail.order_id = order.id; orderDetail.product_id = item.id; orderDetail.name = Server.UrlDecode(item.name); orderDetail.quantity = item.quantity; if (item.price_promotion > 0) { var giamGia = String.Format("{0:0}", item.price * ((100 - item.price_promotion) / 100)); orderDetail.price = Decimal.Parse(giamGia.ToString()); } else { orderDetail.price = item.price; } orderDetail.into_money = item.totalMoney; db.order_details.Add(orderDetail); db.SaveChanges(); } var content = db.order_details.Where(n => n.order_id == order.id).ToList(); var body = new PaymentSuccess().body(order.display_name, content); new Utils().SendEmail(data.email, "Chúc mừng bạn đã mua sản phẩm thành công", body, "", ""); } catch (Exception e) { } //var body = new PaymentSuccess().body(); //new Utils().SendEmail(payment.email, "Chúc mừng bạn đã mua sản phẩm thành công", body, "", ""); return(View()); }
public async Task <IActionResult> Success([FromRoute] string slug, [FromQuery] string callingAppTxnRef, [FromQuery] string responseCode) { var pathIsServicePay = Request.Path.Value.Contains("service-pay-payment"); var response = pathIsServicePay ? await _repository.Get <ServicePayPayment>(slug) : await _repository.Get <Payment>(slug); if (!response.IsSuccessful()) { return(response); } dynamic payment; if (pathIsServicePay) { payment = response.Content as ProcessedServicePayPayment; } else { payment = response.Content as ProcessedPayment; } if (responseCode != "00000") { return(responseCode == "00022" || responseCode == "00023" ? pathIsServicePay ? View("../ServicePayPayment/Declined", slug) : View("Declined", slug) : pathIsServicePay?View("../ServicePayPayment/Failure", slug) : View("Failure", slug)); } var model = new PaymentSuccess { Title = payment.Title, ReceiptNumber = callingAppTxnRef, MetaDescription = payment.MetaDescription }; return(View(model)); }
/// <summary>微信支付异步回调 /// </summary> /// <param name="successAction">支付成功委托</param> /// <returns></returns> public ContentResult NotifyResult(Action <PaymentSuccess> successAction) { WxPayData resultPayData = new ResultNotify(_context, _appConfig).ProcessNotify(); if (resultPayData.GetValue("return_code").ToStr() == "SUCCESS") { PaymentSuccess success = new PaymentSuccess { Attach = resultPayData.GetValue("attach").ToStr(), OrderNum = resultPayData.GetValue("out_trade_no").ToStr(), TransactionId = resultPayData.GetValue("transaction_id").ToStr(), TotalFee = resultPayData.GetValue("total_fee").ToInt(), IsSubscribe = resultPayData.GetValue("is_subscribe").ToBoolean(), Openid = resultPayData.GetValue("openid").ToStr() }; successAction.Invoke(success); } return(new ContentResult { Content = resultPayData.ToXml() }); }
public IHttpActionResult Detail(PaymentSuccess vm) { return(Ok()); }