public void PaymentOk(String orderStatus = "040", Boolean sendEmails = true) { NBrightBuyUtils.ProcessEventProvider(EventActions.BeforePaymentOK, PurchaseInfo); if (!PurchaseInfo.GetXmlPropertyBool("genxml/stopprocess")) { // only process this on waiting for bank, incomplete or cancelled. Cancel might be sent back from bank if client fails on first payment try. if (OrderStatus == "020" || OrderStatus == "010" || OrderStatus == "030") { var discountprov = DiscountCodeInterface.Instance(); if (discountprov != null) { PurchaseInfo = discountprov.UpdatePercentUsage(PortalId, UserId, PurchaseInfo); PurchaseInfo = discountprov.UpdateVoucherAmount(PortalId, UserId, PurchaseInfo); } PurchaseTypeCode = "ORDER"; CreatedDate = DateTime.Now.ToString("O"); ApplyModelTransQty(); OrderStatus = orderStatus; SavePurchaseData(); // Send emails if (sendEmails) { NBrightBuyUtils.SendOrderEmail("OrderCreatedClient", PurchaseInfo.ItemID, "ordercreatedemailsubject"); } } } NBrightBuyUtils.ProcessEventProvider(EventActions.AfterPaymentOK, PurchaseInfo); }
private void PageLoad() { if (UserId > 0 && _cartInfo.UserId == -1) // user may have just logged in. { _cartInfo.UserId = UserId; _cartInfo.Save(); } var orderid = Utils.RequestQueryStringParam(Context, "orderid"); if (_provList.Count == 0 && ModSettings.Get("orderingsystem") == "True") { #region "No Payment providers, so process as a ordering system" if (_cartInfo != null && _cartInfo.IsValidated()) { _cartInfo.SaveModelTransQty(); // move qty into trans _cartInfo.ConvertToOrder(DebugMode); _cartInfo.ApplyModelTransQty(); // Send emails NBrightBuyUtils.SendOrderEmail("OrderCreatedClient", _cartInfo.PurchaseInfo.ItemID, "ordercreatedemailsubject"); // update status to completed _orderData = new OrderData(PortalId, _cartInfo.PurchaseInfo.ItemID); _orderData.CreatedDate = DateTime.Now.ToString("O"); _orderData.SavePurchaseData(); var cartL = new List <NBrightInfo>(); cartL.Add(_cartInfo.GetInfo()); // display payment OK for order rpDetailDisplay.DataSource = cartL; rpDetailDisplay.DataBind(); } #endregion } else { #region "Payment Details" if (Utils.IsNumeric(orderid)) { // orderid exists, so must be return from bank; Process it!! _orderData = new OrderData(PortalId, Convert.ToInt32(orderid)); DoDetail(rpDetailDisplay, _orderData.PurchaseInfo); } else { // display return page DoDetail(rpDetailDisplay, _cartInfo.PurchaseInfo); DoDetail(rpPaymentGateways, _cartInfo.PurchaseInfo); DoDetail(rpDetailFooter, _cartInfo.PurchaseInfo); } #endregion } }
private static String OrderAdminEmail(HttpContext context) { try { if (UserController.Instance.GetCurrentUserInfo().UserID > 0) { //get uploaded params var ajaxInfo = NBrightBuyUtils.GetAjaxInfo(context); NBrightBuyUtils.SendOrderEmail(ajaxInfo.GetXmlProperty("genxml/hidden/emailtype"), ajaxInfo.GetXmlPropertyInt("genxml/hidden/selecteditemid"), ajaxInfo.GetXmlProperty("genxml/hidden/emailsubject"), "", ajaxInfo.GetXmlProperty("genxml/hidden/emailmessage"), true); } return(""); } catch (Exception ex) { return(ex.ToString()); } }
public override string RedirectForPayment(OrderData orderData) { orderData.OrderStatus = "020"; orderData.PurchaseInfo.SetXmlProperty("genxml/paymenterror", ""); orderData.PurchaseInfo.Lang = Utils.GetCurrentCulture(); orderData.SavePurchaseData(); try { var nonce = HttpContext.Current.Request.Cookies.Get("nonce") != null?HttpContext.Current.Request.Cookies.Get("nonce").Value : ""; if (string.IsNullOrWhiteSpace(nonce)) { HttpContext.Current.Request.Cookies.Get("nonce").Expires = DateTime.Now.AddDays(-1d); //No Nonce Return to Payment Tab with Failure message; var param = new string[2]; param[0] = "orderid=" + orderData.PurchaseInfo.ItemID.ToString(""); param[1] = "status=0"; return(Globals.NavigateURL(StoreSettings.Current.PaymentTabId, "", param)); } else { // 010 = Incomplete, 020 = Waiting for Bank,030 = Cancelled,040 = Payment OK,050 = Payment Not Verified,060 = Waiting for Payment,070 = Waiting for Stock,080 = Waiting,090 = Shipped,010 = Closed,011 = Archived HttpContext.Current.Response.Clear(); var response = ProviderUtils.GetChargeResponse(orderData, nonce); var param = new string[2]; param[0] = "orderid=" + orderData.PurchaseInfo.ItemID.ToString(""); if (response.Errors == null || response.Errors.Count == 0) { //add external order id, payment id & status to PurchaseInfo for dev reference orderData.PurchaseInfo.SetXmlProperty("genxml/externalorderid", response.Payment.OrderId); orderData.PurchaseInfo.SetXmlProperty("genxml/externalpaymentid", response.Payment.Id); orderData.PurchaseInfo.SetXmlProperty("genxml/externalstatus", response.Payment.Status); //also add the Square payment id to the audit log for admins/managers to reference orderData.AddAuditMessage("Square Payment ID " + response.Payment.Id, "notes", UserController.Instance.GetCurrentUserInfo().Username, "False"); // successful transaction if (response.Payment.SourceType == "BANK_ACCOUNT") { if (response.Payment.Status == "PENDING") { //ACH payments can take 3-5 days to clear //so set the status to Payment Not Verified 050 //and add an audit log entry for the Pending ACH Transfer orderData.AddAuditMessage("Pending ACH Transfer", "notes", UserController.Instance.GetCurrentUserInfo().Username, "False"); orderData.PaymentOk("050"); param[1] = "status=1"; } else { //ACH payments should not end up here //since all payments will intially //return a PENDING status orderData.OrderStatus = "030"; param[1] = "status=0"; orderData.AddAuditMessage("Unhandled payment status", "notes", UserController.Instance.GetCurrentUserInfo().Username, "False"); throw new Exception("Unhandled payment status"); } } else { // cc payments orderData.PaymentOk("040"); param[1] = "status=1"; } NBrightBuyUtils.SendOrderEmail("OrderCreatedClient", orderData.PurchaseInfo.ItemID, "ordercreatedemailsubject"); } else { // failed transaction orderData.OrderStatus = "030"; param[1] = "status=0"; // create error string for output to the order audit log var errorString = ""; if (response.Errors.Count > 0) { foreach (var e in response.Errors) { errorString += e.Detail; errorString += " "; } ; } //add message for admins to view in the order audit log orderData.AddAuditMessage(errorString, "notes", UserController.Instance.GetCurrentUserInfo().Username, "False"); } orderData.SavePurchaseData(); HttpContext.Current.Response.Redirect(Globals.NavigateURL(StoreSettings.Current.PaymentTabId, "", param), false); } } catch (Exception ex) { // rollback transaction // NOTE: The errors returned by the gateway are not shown to the user // DNN admin must be able to review the cart data for a user. orderData.PurchaseInfo.SetXmlProperty("genxml/paymenterror", "<div>ERROR: Invalid payment data </div><div>" + ex + "</div>"); orderData.PaymentFail(); var param = new string[2]; param[0] = "orderid=" + orderData.PurchaseInfo.ItemID.ToString(""); param[1] = "status=0"; HttpContext.Current.Response.Redirect(Globals.NavigateURL(StoreSettings.Current.PaymentTabId, "", param)); } try { HttpContext.Current.Response.End(); } catch (Exception) { // this try/catch to avoid sending error 'ThreadAbortException' } return(""); }