public override string GetTemplate(NBrightInfo cartInfo)
        {
            var info  = ProviderUtils.GetProviderSettings("DnnCMolliepayment");
            var templ = ProviderUtils.GetTemplateMollieData(info.GetXmlProperty("genxml/textbox/checkouttemplate"), info);

            return(templ);
        }
        public static String GetTemplateMollieData(String templatename, NBrightInfo pluginInfo)
        {
            var templ = GetTemplateData(templatename, pluginInfo);

            #region "Get Mollie options from API"

            var info = ProviderUtils.GetProviderSettings("DnnCMolliepayment");

            var testMode   = info.GetXmlPropertyBool("genxml/checkbox/testmode");
            var testApiKey = info.GetXmlProperty("genxml/textbox/testapikey");
            var liveApiKey = info.GetXmlProperty("genxml/textbox/liveapikey");


            // Check to see if the test api keys is filled in, stops the error with the settings in the backoffice
            if (testApiKey != "")
            {
                var apiKey = testApiKey;

                if (!testMode)
                {
                    apiKey = liveApiKey;
                }

                MollieClient mollieClient = new MollieClient();
                mollieClient.setApiKey(apiKey);

                var            strPayOptions = "";
                PaymentMethods methods       = mollieClient.GetPaymentMethods();
                Issuers        issuers       = mollieClient.GetIssuers();

                foreach (PaymentMethod method in methods.data)
                {
                    strPayOptions += "<tr>";
                    strPayOptions += "<td><input type='radio' id='" + method.id + "' value='" + method.id + "' name='group1' class='rdoBanks' /></td>";
                    strPayOptions += "<td><img src='" + method.image.normal + "' /></td>";
                    strPayOptions += "<td><strong>" + method.description + "</strong></td>";

                    strPayOptions += "</tr>";
                    if (method.id == "ideal")
                    {
                        strPayOptions += "<tr><td colspan='3'><div id='bank-holder' class='hidden'>";
                        strPayOptions += "<select id='mollieidealgatewaybankselectordropdown' name='mollieidealgatewaybankselectordropdown' class='bankSelector'>";
                        strPayOptions += "<option>" + info.GetXmlProperty("genxml/textbox/bankdropdowntext") + "</option>";
                        foreach (Issuer issuer in issuers.data)
                        {
                            strPayOptions += string.Format("<option value=\"{0}\">{1}</option>", issuer.id, issuer.name);
                        }
                        strPayOptions += "</select>";
                        strPayOptions += "</div></td></tr>";
                    }


                    strPayOptions += "<tr><td colspan='3'><hr/></td></tr>";
                }
                templ = templ.Replace("[PAYMENTMETHODS]", strPayOptions);
            }
            #endregion

            return(templ);
        }
Esempio n. 3
0
        public void LoadSettings(OrderData oInfo)
        {
            var settings     = ProviderUtils.GetProviderSettings("DnnCMolliepayment");
            var appliedtotal = oInfo.PurchaseInfo.GetXmlPropertyDouble("genxml/appliedtotal");
            var alreadypaid  = oInfo.PurchaseInfo.GetXmlPropertyDouble("genxml/alreadypaid");

            var PostUrl = oInfo.PurchaseInfo.GetXmlPropertyDouble("genxml/posturl");

            var orderTotal = (appliedtotal - alreadypaid).ToString("0.00");
        }
        public static String GetBankRemotePost(OrderData orderData)
        {
            var rPost    = new RemotePost();
            var settings = ProviderUtils.GetProviderSettings("DnnCMolliepayment");
            var payData  = new PayData(orderData);

            rPost.Url = orderData.PurchaseInfo.GetXmlProperty("genxml/posturl");

            //Build the re-direct html
            var rtnStr = rPost.GetPostHtml("/DesktopModules/NBright/DnnCMollie/Themes/config/img/cic.jpg");

            if (settings.GetXmlPropertyBool("genxml/checkbox/debugmode"))
            {
                File.WriteAllText(PortalSettings.Current.HomeDirectoryMapPath + "\\debug_DnnCMolliepost.html", rtnStr);
            }
            return(rtnStr);
        }
Esempio n. 5
0
        override protected void OnInit(EventArgs e)
        {
            base.OnInit(e);

            try
            {
                _ctrlkey = "DnnCMolliepayment";
                _info    = ProviderUtils.GetProviderSettings(_ctrlkey);
                var rpDataHTempl = ProviderUtils.GetTemplateData("settings.html", _info);
                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 override string RedirectForPayment(OrderData orderData)
        {
            var appliedtotal = orderData.PurchaseInfo.GetXmlPropertyDouble("genxml/appliedsubtotal");
            var alreadypaid  = orderData.PurchaseInfo.GetXmlPropertyDouble("genxml/alreadypaid");
            var info         = ProviderUtils.GetProviderSettings("DnnCMolliepayment");
            var cartDesc     = info.GetXmlProperty("genxml/textbox/cartdescription");
            var testMode     = info.GetXmlPropertyBool("genxml/checkbox/testmode");
            var testApiKey   = info.GetXmlProperty("genxml/textbox/testapikey");
            var liveApiKey   = info.GetXmlProperty("genxml/textbox/liveapikey");
            var notifyUrl    = Utils.ToAbsoluteUrl("/DesktopModules/NBright/DnnCMollie/notify.ashx");

            var returnUrl = Globals.NavigateURL(StoreSettings.Current.PaymentTabId, "");
            var ItemId    = orderData.PurchaseInfo.ItemID.ToString("");

            var nbi = new NBrightInfo();

            nbi.XMLData = orderData.payselectionXml;
            var paymentMethod = nbi.GetXmlProperty("genxml/textbox/paymentmethod");
            var paymentBank   = nbi.GetXmlProperty("genxml/textbox/paymentbank");
            var apiKey        = testApiKey;

            if (!testMode)
            {
                apiKey = liveApiKey;
            }


            MollieClient mollieClient = new MollieClient();

            mollieClient.setApiKey(apiKey);

            Payment payment = new Payment()
            {
                amount      = decimal.Parse((appliedtotal - alreadypaid).ToString("0.00", CultureInfo.InvariantCulture)), //99.99M,
                description = cartDesc,
                redirectUrl = returnUrl + "/orderid/" + ItemId,
                method      = (Method)Enum.Parse(typeof(Method), paymentMethod, true),
                issuer      = paymentBank,
                metadata    = ItemId,
                webhookUrl  = notifyUrl,
            };

            PaymentStatus paymentStatus = mollieClient.StartPayment(payment);

            orderData.OrderStatus = "020";
            orderData.PurchaseInfo.SetXmlProperty("genxml/paymenterror", "");
            orderData.PurchaseInfo.SetXmlProperty("genxml/posturl", paymentStatus.links.paymentUrl);
            orderData.PurchaseInfo.Lang = Utils.GetCurrentCulture();
            orderData.SavePurchaseData();
            try
            {
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.Write(ProviderUtils.GetBankRemotePost(orderData));
            }
            catch (Exception ex)
            {
                // rollback transaction
                orderData.PurchaseInfo.SetXmlProperty("genxml/paymenterror", "<div>ERROR: Invalid payment data </div><div>" + ex + "</div>");
                orderData.PaymentFail();
                var param = new string[3];
                param[0] = "orderid=" + orderData.PurchaseInfo.ItemID.ToString("");
                param[1] = "status=0";
                return(Globals.NavigateURL(StoreSettings.Current.PaymentTabId, "", param));
            }

            try
            {
                HttpContext.Current.Response.End();
            }
            catch (Exception ex)
            {
                // this try/catch to avoid sending error 'ThreadAbortException'
            }

            return("");
        }
Esempio n. 7
0
        /// <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    = ProviderUtils.GetProviderSettings("DnnCMolliepayment");

            try
            {
                var debugMode = info.GetXmlPropertyBool("genxml/checkbox/debugmode");

                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 = "DnnCMollie DEBUG: " + 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 DnnCMollieStoreOrderID = 0;
                //string DnnCMollieCartID = "";
                //string DnnCMollieClientLang = "";



                var testMode   = info.GetXmlPropertyBool("genxml/checkbox/testmode");
                var testApiKey = info.GetXmlProperty("genxml/textbox/testapikey");
                var liveApiKey = info.GetXmlProperty("genxml/textbox/liveapikey");

                var nbi           = new NBrightInfo();
                var paymentMethod = nbi.GetXmlProperty("genxml/textbox/paymentmethod");
                var paymentBank   = nbi.GetXmlProperty("genxml/textbox/paymentbank");
                var apiKey        = testApiKey;

                if (!testMode)
                {
                    apiKey = liveApiKey;
                }

                string molliePaymentId = context.Request.Form["id"];
                int    oId             = -1;

                int.TryParse(context.Request.Form["orderid"], out oId);
                if (oId <= 0)
                {
                    int.TryParse(context.Request.Form["ordid"], out oId);
                }

                MollieClient mollieClient = new MollieClient();
                mollieClient.setApiKey(apiKey);
                PaymentStatus paymentStatus = mollieClient.GetStatus(molliePaymentId);

                var orderid = paymentStatus.metadata;
                var nbInfo  = modCtrl.Get(Convert.ToInt32(orderid), "ORDER");
                if (nbi != null)
                {
                    var orderData = new OrderData(nbInfo.ItemID);

                    switch (paymentStatus.status.Value)
                    {
                    case Status.paid:
                        orderData.PaymentOk();
                        break;

                    case Status.cancelled:
                        //set order status to Cancelled
                        orderData.PaymentOk("030");
                        break;

                    case Status.failed:
                        //set order status to payment failed
                        orderData.PaymentFail();
                        break;

                    case Status.open:
                        //set order status to Waiting for payment
                        orderData.PaymentOk("060");
                        break;

                    case Status.pending:
                        //set order status to Waiting for payment
                        orderData.PaymentOk("060");
                        break;

                    case Status.expired:
                        //set order status to Incomplete
                        orderData.PaymentOk("010");
                        break;
                    }

                    var rtnStr = paymentStatus.status.Value + "<br/> id = " + molliePaymentId;
                    rtnStr += "<br/> orderId = " + orderid;
                    rtnStr += "<br/> status = " + orderData.OrderStatus;

                    File.WriteAllText(PortalSettings.Current.HomeDirectoryMapPath + "\\debug_DnnC_IPN_return.html", rtnStr.ToString());
                }
            }
            catch { }
        } //end