public override string GetTemplate(NBrightInfo cartInfo) { var info = ProviderUtils.GetProviderSettings("NBrightPayPalpayment"); var templ = ProviderUtils.GetTemplateData(info.GetXmlProperty("genxml/textbox/checkouttemplate")); return(templ); }
public static String GetBankRemotePost(OrderData orderData) { // use this class to build up the post html var rPost = new RemotePost(); // get the gateway settings which have been entered into the back office page (settings.html template) var settings = ProviderUtils.GetProviderSettings("NBrightPayPalpayment"); // 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 = rPost.GetPostHtml("/DesktopModules/NBright/NBrightPayPal/Themes/config/img/paypal.gif"); if (settings.GetXmlPropertyBool("genxml/checkbox/debug.mode")) { File.WriteAllText(PortalSettings.Current.HomeDirectoryMapPath + "\\debug_NBrightPayPalpost.html", rtnStr); } return(rtnStr); }
public void LoadSettings(OrderData oInfo) { var settings = ProviderUtils.GetProviderSettings("NBrightPayPalpayment"); var appliedtotal = oInfo.PurchaseInfo.GetXmlPropertyDouble("genxml/appliedtotal"); var alreadypaid = oInfo.PurchaseInfo.GetXmlPropertyDouble("genxml/alreadypaid"); ItemId = oInfo.PurchaseInfo.ItemID.ToString(""); PostUrl = settings.GetXmlProperty("genxml/textbox/paymenturl"); VerifyUrl = settings.GetXmlProperty("genxml/textbox/verifyurl"); PayPalId = settings.GetXmlProperty("genxml/textbox/paypalid"); CartName = "NBrightStore"; CurrencyCode = oInfo.PurchaseInfo.GetXmlProperty("genxml/currencycode"); if (CurrencyCode == "") { CurrencyCode = settings.GetXmlProperty("genxml/textbox/currencycode"); } var param = new string[3]; param[0] = "orderid=" + oInfo.PurchaseInfo.ItemID.ToString(""); param[1] = "status=1"; ReturnUrl = Globals.NavigateURL(StoreSettings.Current.PaymentTabId, "", param); param[0] = "orderid=" + oInfo.PurchaseInfo.ItemID.ToString(""); param[1] = "status=0"; ReturnCancelUrl = Globals.NavigateURL(StoreSettings.Current.PaymentTabId, "", param); NotifyUrl = Utils.ToAbsoluteUrl("/DesktopModules/NBright/NBrightPayPal/notify.ashx"); MerchantLanguage = Utils.GetCurrentCulture(); Amount = (appliedtotal - alreadypaid).ToString("0.00", CultureInfo.InvariantCulture); Email = oInfo.PurchaseInfo.GetXmlProperty("genxml/billaddress/textbox/billaddress"); if (!Utils.IsEmail(Email)) { Email = oInfo.PurchaseInfo.GetXmlProperty("genxml/extrainfo/textbox/cartemailaddress"); } // set shipping and tax to zero, these should be calculated by the store so the amount should always be correct. // for some reason paypal seem to add shipping and tax to the total. // Not sure if this is a new change by paypal, or if it's always been wrong!! //ShippingAmount = oInfo.PurchaseInfo.GetXmlPropertyDouble("genxml/shippingcost").ToString("0.00", CultureInfo.InvariantCulture); //TaxAmount = oInfo.PurchaseInfo.GetXmlPropertyDouble("genxml/taxcost").ToString("0.00", CultureInfo.InvariantCulture); const int zero = 0; ShippingAmount = zero.ToString("0.00", CultureInfo.InvariantCulture); TaxAmount = zero.ToString("0.00", CultureInfo.InvariantCulture); }
override protected void OnInit(EventArgs e) { base.OnInit(e); try { _ctrlkey = "nbrightpaypalpayment"; _info = ProviderUtils.GetProviderSettings(_ctrlkey); var rpDataHTempl = ProviderUtils.GetTemplateData("settings.html"); rpDataH.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataHTempl, StoreSettings.Current.Settings(), PortalSettings.HomeDirectory); } catch (Exception exc) { //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(); Controls.Add(l); } }
public void LoadSettings(OrderData oInfo) { var settings = ProviderUtils.GetProviderSettings("NBrightPayPalpayment"); var appliedtotal = oInfo.PurchaseInfo.GetXmlPropertyDouble("genxml/appliedsubtotal"); var alreadypaid = oInfo.PurchaseInfo.GetXmlPropertyDouble("genxml/alreadypaid"); ItemId = oInfo.PurchaseInfo.ItemID.ToString(""); PostUrl = settings.GetXmlProperty("genxml/textbox/paymenturl"); VerifyUrl = settings.GetXmlProperty("genxml/textbox/verifyurl"); PayPalId = settings.GetXmlProperty("genxml/textbox/paypalid"); CartName = "NBrightStore"; CurrencyCode = oInfo.PurchaseInfo.GetXmlProperty("genxml/currencycode"); if (CurrencyCode == "") { CurrencyCode = settings.GetXmlProperty("genxml/textbox/currencycode"); } var param = new string[3]; param[0] = "orderid=" + oInfo.PurchaseInfo.ItemID.ToString(""); param[1] = "status=1"; ReturnUrl = Globals.NavigateURL(StoreSettings.Current.PaymentTabId, "", param); param[0] = "orderid=" + oInfo.PurchaseInfo.ItemID.ToString(""); param[1] = "status=0"; ReturnCancelUrl = Globals.NavigateURL(StoreSettings.Current.PaymentTabId, "", param); NotifyUrl = Utils.ToAbsoluteUrl("/DesktopModules/NBright/NBrightPayPal/notify.ashx"); MerchantLanguage = Utils.GetCurrentCulture(); Amount = (appliedtotal - alreadypaid).ToString("0.00", CultureInfo.InvariantCulture); Email = oInfo.PurchaseInfo.GetXmlProperty("genxml/billaddress/textbox/billaddress"); if (!Utils.IsEmail(Email)) { Email = oInfo.PurchaseInfo.GetXmlProperty("genxml/extrainfo/textbox/cartemailaddress"); } ShippingAmount = oInfo.PurchaseInfo.GetXmlPropertyDouble("genxml/shippingcost").ToString("0.00", CultureInfo.InvariantCulture); TaxAmount = oInfo.PurchaseInfo.GetXmlPropertyDouble("genxml/taxcost").ToString("0.00", CultureInfo.InvariantCulture); }
/// <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 = ProviderUtils.GetProviderSettings("NBrightPayPalpayment"); try { var ipn = new PayPalIpnParameters(context.Request.Form); var debugMode = info.GetXmlPropertyBool("genxml/checkbox/debug.mode"); var debugMsg = "START CALL" + DateTime.Now.ToString("s") + " </br>"; debugMsg += "returnmessage: " + context.Request.Form.Get("returnmessage") + "</br>"; if (debugMode) { info.SetXmlProperty("genxml/debugmsg", debugMsg); modCtrl.Update(info); } debugMsg += "NBrightPayPal DEBUG: " + DateTime.Now.ToString("s") + " </br>" + context.Request.Form + "<br/>"; 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); if (ProviderUtils.VerifyPayment(ipn, validateUrl)) { if (debugMode) { info.SetXmlProperty("genxml/debugmsg", debugMsg); modCtrl.Update(info); } //set order status to Payed orderData.PaymentOk(); } else { if (ipn.IsValid) { info.SetXmlProperty("genxml/debugmsg", "NOT VALIDATED BY PAYPAL"); //set order status to Not verified orderData.PaymentOk("050"); } else { info.SetXmlProperty("genxml/debugmsg", "PAYMENT FAIL"); orderData.PaymentFail(); } } } else { debugMsg += "ORDER does not exists"; } if (debugMode) { info.SetXmlProperty("genxml/debugmsg", debugMsg); modCtrl.Update(info); } } } catch (Exception ex) { if (!ex.ToString().StartsWith("System.Threading.ThreadAbortException")) // we expect a thread abort from the End response. { info.SetXmlProperty("genxml/debugmsg", "NBrightPayPal ERROR: " + ex.ToString()); modCtrl.Update(info); } } }