Beispiel #1
0
    protected void GetPaymentsDoneToday()
    {
        //Log to File
        Logger.Info("PaymentsDoneToday - Start", "GetPaymentsDoneToday", "");

        var paymentsDoneToday = new Models.PaymentsList();
        var paymentsInfoList  = new List <Models.PaymentsInfo>();

        if (HttpRuntime.Cache["PAYTABS_PAYMENTS"] != null)
        {
            paymentsDoneToday = HttpRuntime.Cache["PAYTABS_PAYMENTS"] as Models.PaymentsList;
        }

        if (paymentsDoneToday != null && paymentsDoneToday.PayPageRequests != null)
        {
            paymentsInfoList = paymentsDoneToday.PayPageRequests
                               .Select(x => new Models.PaymentsInfo
            {
                Name            = x.CcFirstNname + ' ' + x.CcLastName,
                Amount          = x.Currency + x.Amount,
                Email           = x.Email,
                AddressShipping = x.AddressShipping + "," + x.StateShipping + "," + x.CountryShipping
            }).ToList();
        }

        lvPaymentsToday.DataSource = paymentsInfoList;
        lvPaymentsToday.DataBind();

        //Log to File
        Logger.Info("PaymentsDoneToday - End", "GetPaymentsDoneToday", paymentsDoneToday);
    }
        protected void btnSave_click(object sender, EventArgs e)
        {
            var objrequest = new Models.PayPageRequest();
            var tmp        = new Models.PayPageResponse();

            try
            {
                var paymentUtility = new Utility();
                objrequest = CreatePayPage();

                //Log to File
                Logger.Info("MakePaymentStep1 - Start", "btnSave_click", objrequest);

                string serviceResponse = paymentUtility.MakeWebServiceCall(Utility.ConstCreatePayPage, paymentUtility.CreatePayPage(objrequest));
                tmp = JsonConvert.DeserializeObject <Models.PayPageResponse>(serviceResponse);

                //Log Response to File
                Logger.Info("MakePaymentStep1 - End", "btnSave_click", tmp);

                if (tmp.response_code != null && tmp.response_code != "4012")
                {
                    lblErrorMessage.Text = paymentUtility.GetPayTabResponseMessage(Utility.PayTabRequestType.CreatePayPage, tmp.response_code, tmp.result);
                }
                else if (tmp.payment_url != "")
                {
                    //Set Payment Active URL to session
//                var activeClient = (Models.Settings)Session["ActiveClient"];
                    Helper.PayTabsSession.CurrentActivePaymentID     = tmp.payment_url;
                    Helper.PayTabsSession.LastPaymentReferenceNumber = tmp.p_id;
                    Helper.PayTabsSession.PageRequestList            = new List <Models.PayPageRequest>();
                    objrequest.PaymentReference = tmp.p_id;

                    var paymentList = new Models.PaymentsList();
                    paymentList.PayPageRequests = new List <Models.PayPageRequest>();
                    if (HttpRuntime.Cache["PAYTABS_PAYMENTS"] != null)
                    {
                        paymentList = HttpRuntime.Cache["PAYTABS_PAYMENTS"] as Models.PaymentsList;

                        //Remove the Old
                        HttpRuntime.Cache.Remove("PAYTABS_PAYMENTS");
                    }

                    paymentList.PayPageRequests.Add(objrequest);

                    HttpRuntime.Cache.Insert("PAYTABS_PAYMENTS", paymentList, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(60));

                    Helper.PayTabsSession.PageRequestList.Add(objrequest);

                    //Redirect to Hosted Page
                    Response.Redirect("~/ClientHost.aspx");
                }
            }
            catch (System.Net.WebException ex)
            {
                //Log Response to File
                Logger.Info("MakePaymentStep1 - Exception", "btnSave_click", ex);

                if (ex.Message.Contains("The remote name could not be resolved"))
                {
                    lblErrorMessage.Text = ex.Message;
                }
            }
            catch (Exception ex)
            {
                //Log Response to File
                Logger.Info("MakePaymentStep1 - Exception", "btnSave_click", ex);
            }
        }