コード例 #1
0
        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);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            MollieClient mollieClient = new MollieClient();

            mollieClient.setApiKey(ConfigurationManager.AppSettings["mollie_api_key"]);

            Console.WriteLine("Loading iDeal issuers ...");
            Issuers issuers = mollieClient.GetIssuers();

            foreach (Issuer issuer in issuers.data)
            {
                Console.WriteLine(issuer.name);
            }

            Console.WriteLine("Starting payment without method ...");

            Payment payment = new Payment
            {
                amount      = 99.99M,
                description = "Test payment",
                redirectUrl = "http://www.foxip.net/completed/?orderId=1245",
            };

            PaymentStatus status = mollieClient.StartPayment(payment);

            Console.WriteLine("The status is: " + status.status);
            Console.WriteLine("Please follow this link to start the payment:");
            Console.WriteLine(status.links.paymentUrl);

            Console.WriteLine("Press [enter] to continue ...");
            Console.ReadLine();

            Console.WriteLine("Getting status ...");
            status = mollieClient.GetStatus(status.id);
            Console.WriteLine("The status is now: " + status.status);

            //Refunds only for iDEAL, Bancontact/Mister Cash, SOFORT Banking, creditcard and banktransfer
            Console.WriteLine("Refunding ...");
            try
            {
                RefundStatus refundStatus = mollieClient.Refund(status.id);
                Console.WriteLine("The status is now: " + refundStatus.payment.status);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: " + ex.Message);
            }

            Console.WriteLine("Starting payment with a specific method ...");
            status = mollieClient.StartPayment(new Payment
            {
                amount      = 1.99M,
                method      = Method.mistercash,
                description = "Test payment",
                redirectUrl = "http://www.foxip.net/completed/?orderId=12345"
            });
            Console.WriteLine("The status is: " + status.status);
            Console.WriteLine("Please follow this link to start the payment:");
            Console.WriteLine(status.links.paymentUrl);
            Console.WriteLine("Press [enter] to continue ...");
            Console.ReadLine();
        }
コード例 #3
0
        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("");
        }
コード例 #4
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
コード例 #5
0
 public static void InitClass(TestContext conext)
 {
     mollieClient = new MollieClient();
     mollieClient.setApiKey(ConfigurationManager.AppSettings["mollie_api_key"]);
 }