Пример #1
0
        public override string RedirectForPayment(OrderData orderData)
        {
            orderData.OrderStatus = "020";
            orderData.PurchaseInfo.SetXmlProperty("genxml/paymenterror", "");
            orderData.PurchaseInfo.Lang = Utils.GetCurrentCulture();
            orderData.SavePurchaseData();
            try
            {
                var payPlugData = new PayPlugLimpet(orderData);

                var paymentkey = payPlugData.CreatePayment();
                if (paymentkey != null && paymentkey.ContainsKey("hosted_payment"))
                {
                    var hosted_payment = paymentkey["hosted_payment"];
                    if (hosted_payment != null)
                    {
                        orderData.PurchaseInfo.SetXmlProperty("genxml/posturl", hosted_payment["payment_url"].Value);
                        orderData.PurchaseInfo.SetXmlProperty("genxml/paymentkey", paymentkey["id"]);
                        orderData.Save();

                        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("");
        }
Пример #2
0
        /// <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);
                }
            }
        }