コード例 #1
0
 public IActionResult OnNewTransaction()
 {
     DashboardSocket.OnNewTransaction("providername", "actionid");
     return(this.Content("ok"));
 }
コード例 #2
0
        ///
        /// Main entry point
        ///

        public async Task <IActionResult> Index([FromQuery] T model)
        {
            try
            {
                model.Prepare(this.Request);
                this.TrackingID = model.TrackingID;
                this.Action     = await this.Database.Query <ActionDM>().Where("trackingid={0}", this.TrackingID).LoadSingleAsync();

                await this.PreparePostbackObject();

                if (string.IsNullOrEmpty(this.TrackingID))
                {
                    this.Postback.Log("Could not get trackingGuid.. Flow is interupted");
                    return(this.StatusCode(400));
                }

                if (this.Action == null && this.RequireAction)
                {
                    this.Postback.Log("Could not load Action for trackingId: " + this.TrackingID);
                    return(this.StatusCode(400));
                }

                this.Action = await this.Call(model);

                if (this.Action == null) // abstraction class had some error. we assume that that class will make some log
                {
                    return(this.StatusCode(400));
                }

                bool   isStolen = false, isCharge = false;
                string providerName = (this.Action.providerid.HasValue ? ProvidersCache.Instance.Get(this.Action.providerid.Value).Name : "provider null?");
                if (model.Type == ActionModelEvent.Charge || model.Type == ActionModelEvent.Subscribe)
                {
                    isCharge = true;
                    DashboardSocket.OnNewTransaction(providerName, this.Action.actionid);
                    this.Action.times_charged++;
                    isStolen = this.SystemPostback();
                }

                if (model.Type == ActionModelEvent.Refund)
                {
                    DashboardSocket.OnNewRefund(providerName, this.Action.actionid);
                    this.Action.has_refund = true;
                }

                if (model.Type == ActionModelEvent.Chargeback)
                {
                    DashboardSocket.OnNewChargeback(providerName, this.Action.actionid);
                    this.Action.has_chargeback = true;
                }

                this.Action.UpdateLater();
                await this.Database.TransactionalManager.RunAsync();

                // Redirect to page for facebook pixel
                if (isCharge && !isStolen && this.Action != null && !string.IsNullOrEmpty(this.Action.fbid))
                {
                    return(this.Redirect("/fbid/" + this.Action.fbid));
                }

                return(StatusCode(200));
            }
            catch (Exception e)
            {
                this.Logger.StartLoggin(model != null ? model.TrackingID : "notracking")
                .Add("providername", ProvidersCache.Instance.Get(this.ProviderID).Name)
                .Add("query", HttpContext.Request.QueryString.Value)
                .Add(model != null ? model : null)
                .OnException(e);
                return(StatusCode(200));
            }
        }