Example #1
0
        private void DisplayDataEntryRepeater(String entryId)
        {
            if (Utils.IsNumeric(entryId) && entryId != "0")
            {
                var orderData = new OrderData(PortalId, Convert.ToInt32(entryId));

                if (orderData.UserId == UserId)
                {
                    // if debug , output the xml used.
                    if (StoreSettings.Current.DebugModeFileOut)
                    {
                        var xmlDoc = new System.Xml.XmlDocument();
                        xmlDoc.LoadXml(orderData.GetInfo().XMLData);
                        xmlDoc.Save(PortalSettings.HomeDirectoryMapPath + "debug_order.xml");
                    }

                    //render the detail page
                    base.DoDetail(rpData, orderData.GetInfo());

                    base.DoDetail(rpItemH, orderData.GetInfo());
                    rpItem.DataSource = orderData.GetCartItemList(StoreSettings.Current.Get("chkgroupresults") == "True");
                    rpItem.DataBind();
                    base.DoDetail(rpItemF, orderData.GetInfo());

                    // display header (Do header after the data return so the productcount works)
                    base.DoDetail(rpDataH, orderData.GetInfo());
                }
            }
        }
Example #2
0
        public static PaymentResponse GetOrderPaymentResponse(OrderData orderData, string origin)
        {
            var info   = ProviderUtils.GetProviderSettings();
            var apiKey = info.GetXmlProperty("genxml/textbox/key");

            IPaymentClient paymentClient = new PaymentClient(apiKey);
            var            task          = Task.Run(async() => await paymentClient.GetPaymentAsync(orderData.PaymentPassKey));

            task.Wait();
            PaymentResponse paymentClientResult = task.Result;

            if (string.IsNullOrEmpty(orderData.GetInfo().GetXmlNode("genxml/paymentreturn")))
            {
                orderData.GetInfo().AddSingleNode("paymentreturn", "", "genxml");
            }

            var xmlDoc  = orderData.GetInfo().XMLDoc;
            var newNode = xmlDoc.CreateNode(XmlNodeType.Element, "data", "");
            var dtAttr  = newNode.Attributes.Append(xmlDoc.CreateAttribute("timestamp"));

            dtAttr.Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            newNode.Attributes.Append(dtAttr);

            var xml = $@"<data timestamp=""{DateTime.Now:yyyy-MM-dd HH:mm:ss}"" origin=""{origin}"">
    <created>{paymentClientResult.CreatedAt:yyyy-MM-dd HH:mm:ss}</created>
    <cancelled>{paymentClientResult.CreatedAt:yyyy-MM-dd HH:mm:ss}</cancelled>
    <expired>{paymentClientResult.CreatedAt:yyyy-MM-dd HH:mm:ss}</expired>
    <failed>{paymentClientResult.CreatedAt:yyyy-MM-dd HH:mm:ss}</failed>
    <paied>{paymentClientResult.CreatedAt:yyyy-MM-dd HH:mm:ss}</paied>
    <description>{paymentClientResult.Description}</description>
    <method>{paymentClientResult.Method}</method>
    <amount>{paymentClientResult.Amount.Value}</amount>
    <currency>{paymentClientResult.Amount.Currency}</currency>
    <status>{paymentClientResult.Status}</status>
</data>";

            orderData.GetInfo().AddXmlNode(xml, "data", "genxml/paymentreturn");
            var modCtrl = new NBrightBuyController();

            modCtrl.Update(orderData.GetInfo());

            return(paymentClientResult);
        }
Example #3
0
        private void DisplayDataEntryRepeater(String entryId)
        {
            if (Utils.IsNumeric(entryId) && entryId != "0")
            {
                var orderData = new OrderData(PortalId, Convert.ToInt32(entryId));

                //render the detail page
                base.DoDetail(rpData, orderData.GetInfo());

                base.DoDetail(rpItemH, orderData.GetInfo());
                rpItem.DataSource = orderData.GetCartItemList(StoreSettings.Current.Get("chkgroupresults") == "True");
                rpItem.DataBind();
                base.DoDetail(rpItemF, orderData.GetInfo());

                // display header (Do header so we pickup the special invoice document field in the header)
                base.DoDetail(rpDataH, orderData.GetInfo());

                // display footer (Do here so we pickup the itemid of the order for the action buttons.)
                base.DoDetail(rpDataF, orderData.GetInfo());
            }
        }
        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);
        }
Example #5
0
        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);
        }