public static string GetData(string lang, string razortemplate = "admin.cshtml") { var objCtrl = new NBrightBuyController(); var info = objCtrl.GetPluginSinglePageData("OS_PluginTemplateSIDATA", "OS_PluginTemplateSIDATA", lang); return(NBrightBuyUtils.RazorTemplRender(razortemplate, 0, "", info, "/DesktopModules/NBright/OS_PluginTemplateSI", "config", lang, StoreSettings.Current.Settings())); }
public override string ProcessCommand(string paramCmd, HttpContext context, string editlang = "") { var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context); var lang = NBrightBuyUtils.SetContextLangauge(ajaxInfo); // Ajax breaks context with DNN, so reset the context language to match the client. var objCtrl = new NBrightBuyController(); var strOut = "manualpayment Ajax Error"; if (PluginUtils.CheckPluginSecurity(PortalSettings.Current.PortalId, "manualpayment")) { switch (paramCmd) { case "manualpayment_savesettings": strOut = objCtrl.SavePluginSinglePageData(context); break; case "manualpayment_selectlang": objCtrl.SavePluginSinglePageData(context); var nextlang = ajaxInfo.GetXmlProperty("genxml/hidden/nextlang"); var info = objCtrl.GetPluginSinglePageData("manualpayment", "MANUALPAYMENT", nextlang); strOut = NBrightBuyUtils.RazorTemplRender("settingsfields.cshtml", 0, "", info, "/DesktopModules/NBright/NBrightBuy/Providers/ManualPaymentProvider", "config", nextlang, StoreSettings.Current.Settings()); break; } } return(strOut); }
public override string ProcessCommand(string paramCmd, HttpContext context, string editlang = "") { var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context); var lang = NBrightBuyUtils.SetContextLangauge(ajaxInfo); // Ajax breaks context with DNN, so reset the context language to match the client. var objCtrl = new NBrightBuyController(); var strOut = "OS_PaymentGateway Ajax Error"; // NOTE: The paramCmd MUST start with the plugin ref. in lowercase. (links ajax provider to cmd) switch (paramCmd) { case "os_paymentgateway_savesettings": strOut = objCtrl.SavePluginSinglePageData(context); break; case "os_paymentgateway_selectlang": objCtrl.SavePluginSinglePageData(context); var nextlang = ajaxInfo.GetXmlProperty("genxml/hidden/nextlang"); var info = objCtrl.GetPluginSinglePageData("OS_PaymentGatewaypayment", "OS_PaymentGatewayPAYMENT", nextlang); strOut = NBrightBuyUtils.RazorTemplRender("settingsfields.cshtml", 0, "", info, "/DesktopModules/NBright/OS_PaymentGateway", "config", nextlang, StoreSettings.Current.Settings()); break; } return(strOut); }
public static NBrightInfo GetProviderSettings() { var objCtrl = new NBrightBuyController(); var info = objCtrl.GetPluginSinglePageData("OSPayPalpayment", "OSPayPalPAYMENT", Utils.GetCurrentCulture()); return(info); }
private string GetReturnTemplate(OrderData orderData, bool paymentok, string paymenterror) { var displaytemplate = "payment_ok.cshtml"; if (!paymentok) { displaytemplate = "payment_fail.cshtml"; } var templ = ""; var objCtrl = new NBrightBuyController(); var info = objCtrl.GetPluginSinglePageData("manualpayment", "MANUALPAYMENT", Utils.GetCurrentCulture()); var passSettings = info.ToDictionary(); foreach (var s in StoreSettings.Current.Settings()) // copy store setting, otherwise we get a byRef assignement { if (passSettings.ContainsKey(s.Key)) { passSettings[s.Key] = s.Value; } else { passSettings.Add(s.Key, s.Value); } } if (passSettings.ContainsKey("paymenterror")) { passSettings.Add("paymenterror", paymenterror); } info.UserId = UserController.Instance.GetCurrentUserInfo().UserID; info.SetXmlProperty("genxml/ordernumber", orderData.OrderNumber); templ = NBrightBuyUtils.RazorTemplRender(displaytemplate, 0, "", info, "/DesktopModules/NBright/NBrightBuy/Providers/ManualPaymentProvider", "config", Utils.GetCurrentCulture(), passSettings); return(templ); }
public override string ProcessPaymentReturn(HttpContext context) { var orderid = Utils.RequestQueryStringParam(context, "orderid"); if (Utils.IsNumeric(orderid)) { var orderData = new OrderData(Convert.ToInt32(orderid)); var objCtrl = new NBrightBuyController(); var info = objCtrl.GetPluginSinglePageData("manualpayment", "MANUALPAYMENT", orderData.Lang); var neworderstatus = "060"; var settings = info.ToDictionary(); if (settings.ContainsKey("orderstatus")) { neworderstatus = settings["orderstatus"]; } if (neworderstatus == "") { neworderstatus = "060"; } orderData.PaymentOk(neworderstatus); return(GetReturnTemplate(orderData, true, "")); } return(""); }
public override string ProcessCommand(string paramCmd, HttpContext context, string editlang = "") { var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context); var lang = NBrightBuyUtils.SetContextLangauge(ajaxInfo); // Ajax breaks context with DNN, so reset the context language to match the client. var objCtrl = new NBrightBuyController(); var strOut = "OS_AllShipping Error"; switch (paramCmd) { case "os_allshipping_getsettings": var info1 = objCtrl.GetPluginSinglePageData("OS_AllShipping", "SHIPPING", lang); strOut = NBrightBuyUtils.RazorTemplRender("settingsfields.cshtml", 0, "", info1, "/DesktopModules/NBright/OS_AllShipping", "config", lang, StoreSettings.Current.Settings()); break; case "os_allshipping_savesettings": strOut = objCtrl.SavePluginSinglePageData(context); break; case "os_allshipping_selectlang": objCtrl.SavePluginSinglePageData(context); var nextlang = ajaxInfo.GetXmlProperty("genxml/hidden/nextlang"); var info2 = objCtrl.GetPluginSinglePageData("OS_AllShipping", "SHIPPING", nextlang); strOut = NBrightBuyUtils.RazorTemplRender("settingsfields.cshtml", 0, "", info2, "/DesktopModules/NBright/OS_AllShipping", "config", nextlang, StoreSettings.Current.Settings()); break; case "os_allshipping_getcarttotals": var cartd = new CartData(PortalSettings.Current.PortalId); cartd.PurchaseInfo.SetXmlProperty("genxml/OS_AllShippingmessage", ""); cartd.PurchaseInfo.SetXmlProperty("genxml/OS_AllShippinglistidx", ajaxInfo.GetXmlProperty("genxml/radiobuttonlist/list")); cartd.PurchaseInfo.SetXmlProperty("genxml/OS_AllShippinglistcode", ""); cartd.PurchaseInfo.SetXmlProperty("genxml/OS_AllShippingaddress", ""); cartd.Save(); strOut = NBrightBuyUtils.RazorTemplRender("CheckoutTotals.cshtml", 0, "", cartd, "/DesktopModules/NBright/NBrightBuy", "Default", Utils.GetCurrentCulture(), StoreSettings.Current.Settings()); break; case "os_allshipping_getlist": strOut = OrderAdminList(context); break; } return(strOut); }
public override string GetTemplate(NBrightInfo cartInfo) { var templ = ""; var objCtrl = new NBrightBuyController(); var info = objCtrl.GetPluginSinglePageData("manualpayment", "MANUALPAYMENT", Utils.GetCurrentCulture()); var templateName = info.GetXmlProperty("genxml/textbox/checkouttemplate"); templ = NBrightBuyUtils.RazorTemplRender(templateName, 0, "", info, "/DesktopModules/NBright/NBrightBuy/Providers/ManualPaymentProvider", "config", Utils.GetCurrentCulture(), StoreSettings.Current.Settings()); return(templ); }
public static String GetBankRemotePost(OrderData orderData) { var rPost = new RemotePost(); var objCtrl = new NBrightBuyController(); var settings = objCtrl.GetPluginSinglePageData("OSPayPalpayment", "OSPayPalPAYMENT", orderData.Lang); // get the order data var payData = new PayData(orderData); rPost.Url = payData.PostUrl; rPost.Add("cmd", "_xclick"); rPost.Add("item_number", payData.ItemId); rPost.Add("return", payData.ReturnUrl); rPost.Add("currency_code", payData.CurrencyCode); rPost.Add("cancel_return", payData.ReturnCancelUrl); rPost.Add("notify_url", payData.NotifyUrl); rPost.Add("custom", Utils.GetCurrentCulture()); rPost.Add("business", payData.PayPalId); rPost.Add("item_name", orderData.PurchaseInfo.GetXmlProperty("genxml/ordernumber")); rPost.Add("amount", payData.Amount); rPost.Add("shipping", payData.ShippingAmount); rPost.Add("tax", payData.TaxAmount); rPost.Add("lc", Utils.GetCurrentCulture().Substring(3, 2)); var extrafields = settings.GetXmlProperty("genxml/textbox/extrafields"); var fields = extrafields.Split(','); foreach (var f in fields) { var ary = f.Split('='); if (ary.Count() == 2) { var n = ary[0]; var v = ary[1]; var d = orderData.PurchaseInfo.GetXmlProperty(v); rPost.Add(n, d); } } //Build the re-direct html var rtnStr = ""; rtnStr = rPost.GetPostHtml(); if (settings.GetXmlPropertyBool("genxml/checkbox/debugmode")) { File.WriteAllText(PortalSettings.Current.HomeDirectoryMapPath + "\\debug_OSPayPalpost.html", rtnStr); } return(rtnStr); }
private void PageLoad() { if (NBrightBuyUtils.CheckRights()) { var objCtrl = new NBrightBuyController(); var info = objCtrl.GetPluginSinglePageData("OS_AllShipping", "SHIPPING", Utils.GetCurrentCulture()); var strOut = NBrightBuyUtils.RazorTemplRender("settings.cshtml", 0, "", info, ControlPath, "config", Utils.GetCurrentCulture(), StoreSettings.Current.Settings()); var l = new Literal(); l.Text = strOut; Controls.Add(l); } }
protected override void OnLoad(EventArgs e) { try { var orderid = Utils.RequestQueryStringParam(HttpContext.Current, "merchantReference"); if (orderid != "") { var modCtrl = new NBrightBuyController(); var info = modCtrl.GetPluginSinglePageData("OS_PaymentGatewaypayment", "OS_PaymentGatewayPAYMENT", Utils.GetCurrentCulture()); orderid = orderid.Split('_')[0]; var param = "?orderid=" + orderid; var lang = Utils.RequestQueryStringParam(HttpContext.Current, "shopperLocale"); if (lang != "") { param += "&language=" + lang; } var authResult = Utils.RequestQueryStringParam(HttpContext.Current, "authResult"); switch (authResult) { case "AUTHORISED": param += "&status=1"; break; case "CANCELLED": param += "&status=0"; break; case "REFUSED": param += "&status=0"; break; case "PENDING": param += "&status=0"; break; case "ERROR": param += "&status=0"; break; } Response.Redirect(info.GetXmlProperty("genxml/textbox/paymentreturn") + param); } } catch (Exception exc) //Module failed to load { //display the error on the template (don;t want to log it here, prefer to deal with errors directly.) var l = new Literal(); l.Text = exc.ToString(); phData.Controls.Add(l); } }
private NBrightInfo PurchaseNotify(NBrightInfo nbrightInfo) { var objCtrl = new NBrightBuyController(); var purhcaseNotifyInfo = objCtrl.GetPluginSinglePageData("OS_PurchaseNotificationDATA", "OS_PurchaseNotificationDATA", Utils.GetCurrentCulture()); if (purhcaseNotifyInfo.GetXmlPropertyBool("genxml/checkbox/turnoff")) { return(nbrightInfo); } var orderData = new OrderData(nbrightInfo.ItemID); // remove and products that have reached the client purchase limit var cartitemList = orderData.GetCartItemList(); var sendEmailFlag = false; foreach (var cartItemInfo in cartitemList) { var productid = cartItemInfo.GetXmlPropertyInt("genxml/productid"); if (productid > 0) { var modelid = cartItemInfo.GetXmlProperty("genxml/modelid"); var productData = new ProductData(productid, Utils.GetCurrentCulture(), true); var model = productData.GetModel(modelid); if (model != null) { var purchaseNotificationFlag = model.GetXmlPropertyBool("genxml/checkbox/purchasenotificationflag"); if (purchaseNotificationFlag) { sendEmailFlag = true; // Just put a flag, most of work done in Razor Template. } } } } if (sendEmailFlag) { var passSettings = new Dictionary <string, string>(); var emailBody = NBrightBuyUtils.RazorTemplRender("EmailHtmlOutput.cshtml", 0, "", orderData, "/DesktopModules/NBright/OS_PurchaseNotification", "config", orderData.Lang, passSettings); var emailList = StoreSettings.Current.ManagerEmail + ","; emailList += purhcaseNotifyInfo.GetXmlProperty("genxml/textbox/emailcsv"); emailList = emailList.TrimEnd(','); var emailSubject = purhcaseNotifyInfo.GetXmlProperty("genxml/textbox/emailsubject"); NBrightBuyUtils.SendEmail(emailBody, emailList, "", orderData.GetInfo(), emailSubject, "", orderData.Lang); } return(nbrightInfo); }
public override string Name() { var objCtrl = new NBrightBuyController(); var info = objCtrl.GetPluginSinglePageData("OS_ShippingProvider", "SHIPPING", Utils.GetCurrentCulture()); var rtn = info.GetXmlProperty("genxml/lang/genxml/textbox/name"); if (rtn == "") { rtn = info.GetXmlProperty("genxml/textbox/name"); } if (rtn == "") { rtn = "OS_ShippingProvider"; } return(rtn); }
private String GetTemplateData(String templatename, NBrightInfo cartInfo) { var nbCtrl = new NBrightBuyController(); var info = nbCtrl.GetPluginSinglePageData(Shippingkey, "SHIPPING", Utils.GetCurrentCulture()); if (info == null) { return(string.Empty); } string ctrlMapPath = HttpContext.Current.Server.MapPath("/DesktopModules/NBright/OS_AllShipping"); var templateCtrl = new NBrightCore.TemplateEngine.TemplateGetter(PortalSettings.Current.HomeDirectoryMapPath, ctrlMapPath, "Themes\\config", ""); string template = templateCtrl.GetTemplateData(templatename, Utils.GetCurrentCulture()); return(template); }
/// <summary> /// This function needs to process and returned message from the bank. /// This processing may vary widely between banks. /// </summary> /// <param name="context"></param> public void ProcessRequest(HttpContext context) { var modCtrl = new NBrightBuyController(); var info = modCtrl.GetPluginSinglePageData("OSPayPlugpayment", "OSPayPlugPAYMENT", Utils.GetCurrentCulture()); try { var orderid = Utils.RequestQueryStringParam(context, "oid"); if (Utils.IsNumeric(orderid)) { var orderData = new OrderData(Convert.ToInt32(orderid)); var paymentkey = orderData.PurchaseInfo.GetXmlProperty("genxml/paymentkey"); if (paymentkey != "") { var payPlugData = new PayPlugLimpet(orderData); var paymentData = payPlugData.RetrievePayment(paymentkey); if (paymentData != null && paymentData.ContainsKey("is_paid")) { if (paymentData["is_paid"]) { orderData.PaymentOk(); } else { orderData.PaymentFail(); } } } } HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Write("OK"); HttpContext.Current.Response.ContentType = "text/plain"; HttpContext.Current.Response.CacheControl = "no-cache"; HttpContext.Current.Response.Expires = -1; HttpContext.Current.Response.End(); } catch (Exception ex) { if (!ex.ToString().StartsWith("System.Threading.ThreadAbortException")) // we expect a thread abort from the End response. { info.SetXmlProperty("genxml/debugmsg", "OS_PayPlug ERROR: " + ex.ToString()); modCtrl.Update(info); } } }
public override string Name() { var objCtrl = new NBrightBuyController(); var info = objCtrl.GetPluginSinglePageData("OS_AllShipping", "SHIPPING", Utils.GetCurrentCulture()); //var rtn = info.GetXmlProperty("genxml/lang/genxml/textbox/name"); //if (rtn == "") rtn = info.GetXmlProperty("genxml/textbox/name"); //if (rtn == "") rtn = "OS_AllShipping"; var shippingName = string.Empty;; if (Merchant.IsEnable && Merchant.Type == "B") { shippingName = $"宅配( {NBrightBuyUtils.FormatToStoreCurrency(Merchant.HomeCost)} )"; } return(shippingName); }
public static string CallSipsExec(string sipsExecPath, string Params) { string strData = ""; string strErr = ""; // Set start information. ProcessStartInfo start_info = new ProcessStartInfo(sipsExecPath); start_info.Arguments = Params; start_info.UseShellExecute = false; start_info.CreateNoWindow = true; start_info.RedirectStandardOutput = true; start_info.RedirectStandardError = true; // Make the process and set its start information. Process proc = new Process(); proc.StartInfo = start_info; // Start the process. proc.Start(); // Attach to stdout and stderr. StreamReader stdOut = proc.StandardOutput; StreamReader stdErr = proc.StandardError; strData = stdOut.ReadToEnd(); strErr = stdErr.ReadToEnd(); // Clean up. stdOut.Close(); stdErr.Close(); proc.Close(); var objCtrl = new NBrightBuyController(); var settings = objCtrl.GetPluginSinglePageData("OS_Sipspayment", "OS_SipsPAYMENT", Utils.GetCurrentCulture()); if (settings.GetXmlPropertyBool("genxml/checkbox/debugmode")) { File.WriteAllText(PortalSettings.Current.HomeDirectoryMapPath + "\\debug_NBrightBuySipsData.html", strData + " Err:" + strErr + " Params:" + Params); } return(strData); }
public override string ProcessCommand(string paramCmd, HttpContext context, string editlang = "") { if (!LocalUtils.CheckRights()) { return("Security Error."); } var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context); var lang = NBrightBuyUtils.SetContextLangauge(ajaxInfo); // Ajax breaks context with DNN, so reset the context language to match the client. var objCtrl = new NBrightBuyController(); var strOut = "OS_PurchaseNotification Ajax Error"; // NOTE: The paramCmd MUST start with the plugin ref. in lowercase. (links ajax provider to cmd) switch (paramCmd) { case "os_purchasenotification_getdata": strOut = LocalUtils.GetData(editlang, "datafields.cshtml"); break; case "os_purchasenotification_deleterecord": var infoDel = objCtrl.GetPluginSinglePageData("OS_PurchaseNotificationDATA", "OS_PurchaseNotificationDATA", Utils.GetCurrentCulture()); objCtrl.Delete(infoDel.ItemID); break; case "os_purchasenotification_savedata": strOut = objCtrl.SavePluginSinglePageData(context); break; case "os_purchasenotification_selectlang": objCtrl.SavePluginSinglePageData(context); strOut = ""; break; case "os_purchasenotification_testemail": LocalUtils.OutputTestEmail(); strOut = LocalUtils.GetData(editlang, "datafields.cshtml"); break; } return(strOut); }
public static String GetBankRemotePost(OrderData orderData) { var rPost = new RemotePost(); var objCtrl = new NBrightBuyController(); var info = objCtrl.GetPluginSinglePageData("OS_PaymentGatewaypayment", "OS_PaymentGatewayPAYMENT", orderData.Lang); var param = new string[3]; param[0] = "orderid=" + orderData.PurchaseInfo.ItemID.ToString(""); param[1] = "status=1"; var pbxeffectue = Globals.NavigateURL(StoreSettings.Current.PaymentTabId, "", param); param[0] = "orderid=" + orderData.PurchaseInfo.ItemID.ToString(""); param[1] = "status=0"; var pbxrefuse = Globals.NavigateURL(StoreSettings.Current.PaymentTabId, "", param); var appliedtotal = orderData.PurchaseInfo.GetXmlPropertyDouble("genxml/appliedtotal").ToString("0.00").Replace(",", "").Replace(".", "");; var postUrl = info.GetXmlProperty("genxml/textbox/mainurl"); if (info.GetXmlPropertyBool("genxml/checkbox/preproduction")) { postUrl = info.GetXmlProperty("genxml/textbox/preprodurl"); } rPost.Url = postUrl; rPost.Add("SITE", info.GetXmlProperty("genxml/textbox/site")); rPost.Add("KEY", info.GetXmlProperty("genxml/textbox/key")); //Build the re-direct html var rtnStr = ""; rtnStr = rPost.GetPostHtml(); if (info.GetXmlPropertyBool("genxml/checkbox/debugmode")) { File.WriteAllText(PortalSettings.Current.HomeDirectoryMapPath + "\\debug_OS_PaymentGatewaypost.html", rtnStr); } return(rtnStr); }
public override string GetTemplate(NBrightInfo cartInfo) { var objCtrl = new NBrightBuyController(); var info = objCtrl.GetPluginSinglePageData("OS_Squarepayment", "OS_SquarePAYMENT", Utils.GetCurrentCulture()); var templateName = info.GetXmlProperty("genxml/textbox/checkouttemplate"); var passSettings = info.ToDictionary(); foreach (var s in StoreSettings.Current.Settings()) // copy store setting, otherwise we get a byRef assignement { if (passSettings.ContainsKey(s.Key)) { passSettings[s.Key] = s.Value; } else { passSettings.Add(s.Key, s.Value); } } var templ = NBrightBuyUtils.RazorTemplRender(templateName, 0, "", info, "/DesktopModules/i502Club/OS_Square", "config", Utils.GetCurrentCulture(), passSettings); return(templ); }
public static String GetBankRemotePost(OrderData orderData) { var rPost = new RemotePost(); var objCtrl = new NBrightBuyController(); var settings = objCtrl.GetPluginSinglePageData("OSPayPlugpayment", "OSPayPlugPAYMENT", orderData.Lang); // get the order data var payData = new PayData(orderData); rPost.Url = payData.PostUrl; //Build the re-direct html var rtnStr = ""; rtnStr = rPost.GetPostHtml(); if (settings.GetXmlPropertyBool("genxml/checkbox/debugmode")) { File.WriteAllText(PortalSettings.Current.HomeDirectoryMapPath + "\\debug_OSPayPlugpost.html", rtnStr); } return(rtnStr); }
/// <summary> /// This function needs to process and returned message from the bank. /// This processing may vary widely between banks. /// </summary> /// <param name="context"></param> public void ProcessRequest(HttpContext context) { var modCtrl = new NBrightBuyController(); var info = modCtrl.GetPluginSinglePageData("OS_WorldPaypayment", "OS_WorldPayPAYMENT", Utils.GetCurrentCulture()); try { var MD5secretKey = info.GetXmlProperty("genxml/textbox/secretkey"); var callbackpw = info.GetXmlProperty("genxml/textbox/callbackpw"); var result = new CallbackResult(context.Request.Form, MD5secretKey, callbackpw); var debugMode = info.GetXmlPropertyBool("genxml/checkbox/debugmode"); var debugMsg = "START CALL" + DateTime.Now.ToString("s") + " </br>"; var rtnMsg = "WorldPay return process. Uncompleted" + Environment.NewLine; // ------------------------------------------------------------------------ // In this case the payment provider passes back data via form POST. // Get the data we need. string returnmessage = ""; int OS_WorldPayStoreOrderID = 0; string OS_WorldPayCartID = ""; string OS_WorldPayClientLang = ""; var orderid = result.cartId; debugMsg += "orderid: " + orderid + "</br>"; if (Utils.IsNumeric(orderid)) { OS_WorldPayStoreOrderID = Convert.ToInt32(orderid); // ------------------------------------------------------------------------ debugMsg += "OrderId: " + orderid + " </br>"; debugMsg += "StatusCode: " + result.transStatus + " </br>"; var orderData = new OrderData(OS_WorldPayStoreOrderID); var transStatus = result.transStatus; if (transStatus == "Y") { rtnMsg = CreateServerResponseString(TransactionStatus.Successful); } else { rtnMsg = CreateServerResponseString(TransactionStatus.NotSpecified); } if (transStatus != "Y") { orderData.PaymentFail(); } else { if (transStatus == "Y") { orderData.PaymentOk(); } else { orderData.PaymentFail(); } } } if (debugMode) { debugMsg += "Return Message: " + rtnMsg; info.SetXmlProperty("genxml/debugmsg", debugMsg); modCtrl.Update(info); } HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Write(rtnMsg); HttpContext.Current.Response.ContentType = "text/plain"; HttpContext.Current.Response.CacheControl = "no-cache"; HttpContext.Current.Response.Expires = -1; HttpContext.Current.Response.End(); } catch (Exception ex) { if (!ex.ToString().StartsWith("System.Threading.ThreadAbortException")) // we expect a thread abort from the End response. { info.SetXmlProperty("genxml/debugmsg", "OS_WorldPay ERROR: " + ex.ToString()); modCtrl.Update(info); } } }
/// <summary> /// This function needs to process and returned message from the bank. /// This processing may vary widely between banks. /// </summary> /// <param name="context"></param> public void ProcessRequest(HttpContext context) { var modCtrl = new NBrightBuyController(); var info = modCtrl.GetPluginSinglePageData("OSPayPalpayment", "OSPayPalPAYMENT", Utils.GetCurrentCulture()); try { var ipn = new PayPalIpnParameters(context.Request); var debugMode = info.GetXmlPropertyBool("genxml/checkbox/debug.mode"); var debugMsg = "START CALL" + DateTime.Now.ToString("s") + " </br>"; var rtnMsg = "version=2" + Environment.NewLine + "cdr=1"; // ------------------------------------------------------------------------ // In this case the payment provider passes back data via form POST. // Get the data we need. string returnmessage = ""; int OSPayPalStoreOrderID = 0; string OSPayPalCartID = ""; string OSPayPalClientLang = ""; if (Utils.IsNumeric(ipn.item_number)) { var validateUrl = info.GetXmlProperty("genxml/textbox/paymenturl") + "?" + ipn.PostString; // check the record exists debugMsg += "OrderId: " + ipn.item_number + " </br>"; var nbi = modCtrl.Get(Convert.ToInt32(ipn.item_number), "ORDER"); if (nbi != null) { var orderData = new OrderData(nbi.ItemID); debugMsg += "validateUrl: " + validateUrl + " </br>"; if (ProviderUtils.VerifyPayment(ipn, validateUrl)) { //set order status to Payed debugMsg += "PaymentOK </br>"; orderData.PaymentOk(); } else { if (ipn.IsValid) { debugMsg += "NOT VALIDATED BY PAYPAL </br>"; //set order status to Not verified orderData.PaymentOk("050"); } else { if (orderData.OrderStatus == "020" || orderData.OrderStatus == "010" || orderData.OrderStatus == "030") { debugMsg += "PAYMENT FAIL </br>"; orderData.PaymentFail(); } else { debugMsg += "INVALID UPDATE ACTION</br>"; } } } } else { debugMsg += "ORDER does not exists"; } if (debugMode) { info.SetXmlProperty("genxml/debugmsg", debugMsg); modCtrl.Update(info); } } if (debugMode) { debugMsg += "Return Message: " + rtnMsg; info.SetXmlProperty("genxml/debugmsg", debugMsg); modCtrl.Update(info); } HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Write(rtnMsg); HttpContext.Current.Response.ContentType = "text/plain"; HttpContext.Current.Response.CacheControl = "no-cache"; HttpContext.Current.Response.Expires = -1; HttpContext.Current.Response.End(); } catch (Exception ex) { if (!ex.ToString().StartsWith("System.Threading.ThreadAbortException")) // we expect a thread abort from the End response. { info.SetXmlProperty("genxml/debugmsg", "OS_PayPal ERROR: " + ex.ToString()); modCtrl.Update(info); } } }
/// <summary> /// This function needs to process and returned message from the bank. /// This processing may vary widely between banks. /// </summary> /// <param name="context"></param> public void ProcessRequest(HttpContext context) { var modCtrl = new NBrightBuyController(); var info = modCtrl.GetPluginSinglePageData("OS_PayBoxpayment", "OS_PayBoxPAYMENT", Utils.GetCurrentCulture()); try { var debugMode = info.GetXmlPropertyBool("genxml/checkbox/debugmode"); var debugMsg = "START CALL" + DateTime.Now.ToString("s") + " </br>"; var rtnMsg = "version=2" + Environment.NewLine + "cdr=1"; // ------------------------------------------------------------------------ // In this case the payment provider passes back data via form POST. // Get the data we need. string returnmessage = ""; int OS_PayBoxStoreOrderID = 0; string OS_PayBoxCartID = ""; string OS_PayBoxClientLang = ""; var orderid = Utils.RequestQueryStringParam(context, "ref"); debugMsg += "orderid: " + orderid + "</br>"; if (Utils.IsNumeric(orderid)) { var authcode = Utils.RequestQueryStringParam(context, "auto"); var errcode = Utils.RequestQueryStringParam(context, "rtnerr"); var call = Utils.RequestQueryStringParam(context, "call"); var trans = Utils.RequestQueryStringParam(context, "trans"); OS_PayBoxStoreOrderID = Convert.ToInt32(orderid); // ------------------------------------------------------------------------ debugMsg += "OrderId: " + orderid + " </br>"; debugMsg += "errcode: " + errcode + " </br>"; debugMsg += "authcode: " + authcode + " </br>"; debugMsg += "trans: " + trans + " </br>"; debugMsg += "call: " + call + " </br>"; var orderData = new OrderData(OS_PayBoxStoreOrderID); if (info.GetXmlPropertyBool("genxml/checkbox/pbxautoseule")) { orderData.PurchaseInfo.SetXmlProperty("genxml/payboxrtn", ""); orderData.PurchaseInfo.SetXmlProperty("genxml/payboxrtn/call", call); orderData.PurchaseInfo.SetXmlProperty("genxml/payboxrtn/trans", trans); orderData.SavePurchaseData(); } if (authcode == "") { rtnMsg = "KO"; } else { rtnMsg = "OK"; } if (authcode == "") { orderData.PaymentFail(); } else { if (errcode == "00000") { orderData.PaymentOk(); } else if (errcode == "99999") { orderData.PaymentOk("050"); } else { orderData.PaymentFail(); } } if (debugMode) { orderData.PurchaseInfo.SetXmlProperty("genxml/payboxrtn/debugmsg", debugMsg); orderData.SavePurchaseData(); } } if (debugMode) { debugMsg += "Return Message: " + rtnMsg; info.SetXmlProperty("genxml/debugmsg", debugMsg); modCtrl.Update(info); } HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Write(rtnMsg); HttpContext.Current.Response.ContentType = "text/plain"; HttpContext.Current.Response.CacheControl = "no-cache"; HttpContext.Current.Response.Expires = -1; HttpContext.Current.Response.End(); } catch (Exception ex) { if (!ex.ToString().StartsWith("System.Threading.ThreadAbortException")) // we expect a thread abort from the End response. { Logging.LogException(ex); } } }
public static String GetBankRemotePost(OrderData orderData) { var rPost = new RemotePost(); var objCtrl = new NBrightBuyController(); var settings = objCtrl.GetPluginSinglePageData("OS_Sipspayment", "OS_SipsPAYMENT", Utils.GetCurrentCulture()); var appliedtotal = orderData.PurchaseInfo.GetXmlPropertyDouble("genxml/appliedtotal"); var alreadypaid = orderData.PurchaseInfo.GetXmlPropertyDouble("genxml/alreadypaid"); var orderTotal = Regex.Replace((appliedtotal - alreadypaid).ToString("0.00"), "[^0-9]", ""); var controlMapPath = HttpContext.Current.Server.MapPath("/DesktopModules/NBright/OS_Sips"); var pathfile = PortalSettings.Current.HomeDirectoryMapPath.TrimEnd('\\') + "\\" + settings.GetXmlProperty("genxml/textbox/paramfolder") + "\\pathfile"; var transid = Convert.ToDateTime(orderData.PurchaseInfo.ModifiedDate).Ticks.ToString(); transid = transid.Substring(transid.Length - 6); var parms = ""; parms = "pathfile=\"" + pathfile + "\" "; parms += "merchant_id=" + settings.GetXmlProperty("genxml/textbox/merchantid") + " "; parms += "merchant_country=" + settings.GetXmlProperty("genxml/textbox/merchantcountry") + " "; parms += "amount=" + orderTotal + " "; parms += "currency_code=" + settings.GetXmlProperty("genxml/textbox/currencycode") + " "; parms += "transaction_id=" + transid + " "; parms += "payment_means=" + settings.GetXmlProperty("genxml/textbox/paymentmeans") + " "; parms += "order_id=" + orderData.PurchaseInfo.ItemID.ToString("") + " "; var param = new string[3]; param[0] = "orderid=" + orderData.PurchaseInfo.ItemID.ToString(""); param[1] = "status=1"; var storeSettings = new StoreSettings(orderData.PortalId); var sUrlOk = Globals.NavigateURL(storeSettings.PaymentTabId, "", param); param[1] = "status=0"; var sUrlKo = Globals.NavigateURL(storeSettings.PaymentTabId, "", param); parms += "normal_return_url=" + sUrlOk + " "; parms += "cancel_return_url=" + sUrlKo + " "; if (settings.GetXmlProperty("genxml/textbox/ipn") != "") { parms += "automatic_response_url=" + settings.GetXmlProperty("genxml/textbox/ipn") + " "; } else { var baseUri = new Uri("https://" + PortalSettings.Current.PortalAlias.HTTPAlias); var absoluteUri = new Uri(baseUri, "/DesktopModules/NBright/OS_Sips/notify.ashx"); parms += "automatic_response_url=" + absoluteUri + " "; } parms += "language=" + orderData.Lang.Substring(0, 2) + " "; if (settings.GetXmlPropertyBool("genxml/checkbox/debugmode")) { File.WriteAllText(PortalSettings.Current.HomeDirectoryMapPath + "\\debug_SipsApiparams.html", parms); } var exepath = controlMapPath.TrimEnd('\\') + "\\sipsbin\\request.exe"; var sipsdata = CallSipsExec(exepath, parms); var tableau = sipsdata.Split('!'); string code = ""; code = tableau[1]; string errorMsg = tableau[2]; if (code.Equals("") | code.Equals("-1")) { return(errorMsg); } var htmlOutput = tableau[3]; var aryResult = htmlOutput.Split('"'); var sipsUrl = aryResult[1]; var sipsData = aryResult[5]; rPost.Url = sipsUrl; rPost.Add("DATA", sipsData); // must be uppercase. // just force CB payment. (CB must be in the list of payment_means) rPost.Add("CB.x", "5"); rPost.Add("CB.y", "5"); // save here (may chnage lang field) orderData.AddAuditMessage(transid, "sisptransid", "sipsapi", "True"); orderData.Save(); //Build the re-direct html var rtnStr = rPost.GetPostHtml(); if (settings.GetXmlPropertyBool("genxml/checkbox/debugmode")) { File.WriteAllText(PortalSettings.Current.HomeDirectoryMapPath + "\\debug_SipsApihtmlOutput.html", htmlOutput); File.WriteAllText(PortalSettings.Current.HomeDirectoryMapPath + "\\debug_SipsApipost.html", rtnStr); } return(rtnStr); }
public static String GetBankRemotePost(OrderData orderData) { var rPost = new RemotePost(); var objCtrl = new NBrightBuyController(); var info = objCtrl.GetPluginSinglePageData("NBrightPayBoxpayment", "NBrightPayBoxPAYMENT", orderData.Lang); var param = new string[3]; param[0] = "orderid=" + orderData.PurchaseInfo.ItemID.ToString(""); param[1] = "status=1"; var pbxeffectue = Globals.NavigateURL(StoreSettings.Current.PaymentTabId, "", param); param[0] = "orderid=" + orderData.PurchaseInfo.ItemID.ToString(""); param[1] = "status=0"; var pbxrefuse = Globals.NavigateURL(StoreSettings.Current.PaymentTabId, "", param); var appliedtotal = orderData.PurchaseInfo.GetXmlPropertyDouble("genxml/appliedtotal").ToString("0.00").Replace(",", "").Replace(".", "");; var postUrl = info.GetXmlProperty("genxml/textbox/mainurl"); WebRequest request = WebRequest.Create("https://tpeweb.paybox.com/load.html"); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); if (response == null || response.StatusCode != HttpStatusCode.OK) { postUrl = info.GetXmlProperty("genxml/textbox/backupurl"); } if (info.GetXmlPropertyBool("genxml/checkbox/preproduction")) { postUrl = info.GetXmlProperty("genxml/textbox/preprodurl"); } rPost.Url = postUrl; rPost.Add("PBX_SITE", info.GetXmlProperty("genxml/textbox/pbxsite")); rPost.Add("PBX_RANG", info.GetXmlProperty("genxml/textbox/pbxrang")); rPost.Add("PBX_DEVISE", info.GetXmlProperty("genxml/textbox/pbxdevise")); rPost.Add("PBX_TOTAL", appliedtotal); rPost.Add("PBX_IDENTIFIANT", info.GetXmlProperty("genxml/textbox/pbxidentifiant")); rPost.Add("PBX_CMD", orderData.PurchaseInfo.ItemID.ToString("")); rPost.Add("PBX_PORTEUR", orderData.GetClientEmail()); rPost.Add("PBX_RETOUR", info.GetXmlProperty("genxml/textbox/pbxretour")); rPost.Add("PBX_EFFECTUE", pbxeffectue); rPost.Add("PBX_REFUSE", pbxrefuse); rPost.Add("PBX_ANNULE", pbxrefuse); rPost.Add("PBX_REPONDRE_A", Utils.ToAbsoluteUrl("/DesktopModules/NBright/NBrightPayBox/notify.ashx")); rPost.Add("PBX_HASH", "SHA512"); rPost.Add("PBX_TIME", DateTime.UtcNow.ToString("o")); rPost.Add("PBX_HMAC", rPost.GetHmac(info.GetXmlProperty("genxml/textbox/hmackey")).ToUpper()); //Build the re-direct html var rtnStr = ""; rtnStr = rPost.GetPostHtml("/DesktopModules/NBright/NBrightPayBox/Themes/config/img/" + info.GetXmlProperty("genxml/dropdownlist")); if (info.GetXmlPropertyBool("genxml/checkbox/debugmode")) { File.WriteAllText(PortalSettings.Current.HomeDirectoryMapPath + "\\debug_NBrightPayBoxpost.html", rtnStr); } return(rtnStr); }
public static String GetBankRemotePost(OrderData orderData) { var objCtrl = new NBrightBuyController(); var info = objCtrl.GetPluginSinglePageData("OS_WorldPaypayment", "OS_WorldPayPAYMENT", orderData.Lang); var MD5secretKey = info.GetXmlProperty("genxml/textbox/secretkey"); var installid = info.GetXmlPropertyInt("genxml/textbox/installid"); var request = new HostedTransactionRequest(); var appliedtotal = orderData.PurchaseInfo.GetXmlPropertyRaw("genxml/appliedtotal"); request.amount = appliedtotal; request.currency = info.GetXmlProperty("genxml/textbox/currencycode"); request.testMode = 0; // Not sure what this should be. Only example I found was 100 for test system?? request.instId = installid; request.cartId = orderData.GetInfo().ItemID.ToString(); var postUrl = info.GetXmlProperty("genxml/textbox/liveurl"); if (info.GetXmlPropertyBool("genxml/checkbox/preproduction")) { request.testMode = 100; postUrl = info.GetXmlProperty("genxml/textbox/testurl"); } var requestInputs = request.ToNameValueCollection(); var rPost = new RemotePostPay(); rPost.Url = postUrl; var callbackhashInputs = new StringBuilder(); callbackhashInputs.Append(MD5secretKey); callbackhashInputs.Append(":"); callbackhashInputs.Append(request.currency); callbackhashInputs.Append(":"); callbackhashInputs.Append(request.cartId); callbackhashInputs.Append(":"); callbackhashInputs.Append(appliedtotal); var signaturehashInputs = new StringBuilder(); signaturehashInputs.Append(MD5secretKey); signaturehashInputs.Append(":"); signaturehashInputs.Append(request.currency); signaturehashInputs.Append(":"); signaturehashInputs.Append(request.cartId); signaturehashInputs.Append(":"); signaturehashInputs.Append(appliedtotal); byte[] callbackhashDigest = new MD5CryptoServiceProvider().ComputeHash(StringToByteArray(callbackhashInputs.ToString())); byte[] signaturehashDigest = new MD5CryptoServiceProvider().ComputeHash(StringToByteArray(signaturehashInputs.ToString())); rPost.Add("signature", ByteArrayToHexString(signaturehashDigest)); rPost.Add("MC_callbacksignature", ByteArrayToHexString(callbackhashDigest)); // add the rest of the form variables foreach (var k in requestInputs.AllKeys) { rPost.Add(k, requestInputs.GetValues(k)[0]); } //Build the re-direct html var rtnStr = ""; rtnStr = rPost.GetPostHtml(); if (info.GetXmlPropertyBool("genxml/checkbox/debugmode")) { File.WriteAllText(PortalSettings.Current.HomeDirectoryMapPath + "\\debug_OS_WorldPaypost.html", rtnStr + " signaturehashInputs:" + signaturehashInputs + " request.amount:" + request.amount + " appliedtotal:" + appliedtotal); } return(rtnStr); }
/// <summary> /// This function needs to process and returned message from the bank. /// Thsi processing may vary widely between banks. /// </summary> /// <param name="context"></param> public void ProcessRequest(HttpContext context) { var modCtrl = new NBrightBuyController(); var info = modCtrl.GetPluginSinglePageData("OS_Sipspayment", "OS_SipsPAYMENT", Utils.GetCurrentCulture()); try { var debugMode = info.GetXmlPropertyBool("genxml/checkbox/debugmode"); var rtnMsg = "version=2" + Environment.NewLine + "cdr=1"; // ------------------------------------------------------------------------ // In this case the payment provider passes back data via form POST. // Get the data we need. string returnmessage = ""; int NBrightBuySipsApiStoreOrderID = 0; string NBrightBuySipsApiCartID = ""; string NBrightBuySipsApiClientLang = ""; if ((context.Request.Form.Get("DATA") != null)) { returnmessage = "message=" + context.Request.Form.Get("DATA"); if (!string.IsNullOrEmpty(returnmessage)) { // ------------------------------------------------------------------------ //var settings = ProviderUtils.GetProviderSettings("NBrightBuySipsApipayment"); var controlMapPath = HttpContext.Current.Server.MapPath("/DesktopModules/NBright/OS_Sips"); var pathfile = "pathfile=" + PortalSettings.Current.HomeDirectoryMapPath.TrimEnd('\\') + "\\" + info.GetXmlProperty("genxml/textbox/paramfolder") + "\\pathfile"; var exepath = controlMapPath.TrimEnd('\\') + "\\sipsbin\\response.exe"; var sipsdata = ProviderUtils.CallSipsExec(exepath, pathfile + " " + returnmessage); if (debugMode) { info.SetXmlProperty("genxml/debugmsg", sipsdata); modCtrl.Update(info); } var tableau = sipsdata.Split('!'); string code = tableau[1]; string error_msg = tableau[2]; if (string.IsNullOrEmpty(code) | code == "-1") { info.SetXmlProperty("genxml/debugmsg", error_msg); modCtrl.Update(info); } else { // L'execution s'est bien deroulee // recuperation des donnees de la reponse string merchant_id = tableau[3]; string merchant_country = tableau[4]; string amount = tableau[5]; string transaction_id = tableau[6]; string payment_means = tableau[7]; string transmission_date = tableau[8]; string payment_time = tableau[9]; string payment_date = tableau[10]; string response_code = tableau[11]; string payment_certificate = tableau[12]; string authorisation_id = tableau[13]; string currency_code = tableau[14]; string card_number = tableau[15]; string cvv_flag = tableau[16]; string cvv_response_code = tableau[17]; string bank_response_code = tableau[18]; string complementary_code = tableau[19]; string complementary_info = tableau[20]; string return_context = tableau[21]; string caddie = tableau[22]; string receipt_complement = tableau[23]; string merchant_language = tableau[24]; string language = tableau[25]; string customer_id = tableau[26]; string order_id = tableau[27]; string customer_email = tableau[28]; string customer_ip_address = tableau[29]; string capture_day = tableau[30]; string capture_mode = tableau[31]; string data = tableau[32]; // Sauvegarde des champs de la reponse string Lmsg = null; Lmsg = merchant_id + ","; Lmsg += merchant_country + ","; Lmsg += amount + ","; Lmsg += transaction_id + ","; Lmsg += transmission_date + ","; Lmsg += payment_means + ","; Lmsg += payment_time + ","; Lmsg += payment_date + ","; Lmsg += response_code + ","; Lmsg += payment_certificate + ","; Lmsg += authorisation_id + ","; Lmsg += currency_code + ","; Lmsg += card_number + ","; Lmsg += cvv_flag + ","; Lmsg += cvv_response_code + ","; Lmsg += bank_response_code + ","; Lmsg += complementary_code + ","; Lmsg += complementary_info + ","; Lmsg += return_context + ","; Lmsg += caddie + ","; Lmsg += receipt_complement + ","; Lmsg += merchant_language + ","; Lmsg += language + ","; Lmsg += customer_id + ","; Lmsg += order_id + ","; Lmsg += customer_email + ","; Lmsg += customer_ip_address + ","; Lmsg += capture_day + ","; Lmsg += capture_mode + ","; Lmsg += data + ","; //update database stuff if (Utils.IsNumeric(order_id)) { var orderData = new OrderData(Convert.ToInt32(order_id)); orderData.AddAuditMessage(Lmsg, "payment", "sipsapi", info.GetXmlProperty("genxml/checkbox/debugmode")); // Status return "00" is payment successful if (response_code == "00") { //set order status to Payed orderData.PaymentOk(); } else { orderData.PaymentFail(); } } } } } } catch (Exception ex) { if (!ex.ToString().StartsWith("System.Threading.ThreadAbortException")) // we expect a thread abort from the End response. { info.SetXmlProperty("genxml/debugmsg", "NBrightBuySipsApi ERROR: " + ex.ToString()); modCtrl.Update(info); } } }