示例#1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            UpdateDatabase(app);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            //app.UseCors(builder =>
            //    builder.WithOrigins("http://localhost:8080"));

            app.UseCors(MyAllowSpecificOrigins);

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthentication();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            FirstData.Initialize(app);
        }
        public static OperationDataResult UnaryOperationResult()
        {
            var result = new OperationDataResult
            {
                Success = false
            };

            ParseData();
            if (TryExecuteUnary().Success)
            {
                if (float.IsInfinity(FirstData))
                {
                    result.Data = "Ошибка";
                }
                else
                {
                    result.Data = FirstData.ToString();
                }
                result.Success = true;
            }
            return(result);
        }
示例#3
0
        public static void Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;

                try
                {
                    var context = services.GetRequiredService <WarehouseContext>();
                    FirstData.Initialize(context);
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred seeding the DB.");
                }

                host.Run();
            }
        }
        /// <summary>
        /// Executes processing of the deal redemption timeout reversal request.
        /// </summary>
        public ResultCode Execute()
        {
            ResultCode result;

            // Marshal the First Data reverse deal request into a the context.
            FirstData firstData = new FirstData(Context);

            firstData.MarshalRedemptionTimeout();

            // Update the data store to reflect the reversal of the redeemed deal.
            result = ProcessRedemptionTimeout();

            if (result == ResultCode.Success)
            {
                Analytics.Add(AnalyticsAction.ReversedDealNonTimeout, Context.Log.ActivityId);
            }

            // Build the response to send back to First Data based on the result of reversing the deal.
            Context[Key.ResultCode] = result;
            firstData.BuildRedemptionTimeoutResponse();

            return(result);
        }
示例#5
0
        public JsonResult Get_PhysicalDetail([FromBody] FirstData data)
        {
            Main    objmain = new Main();
            DataSet ds      = objmain.getphysical(data.email, data.location);

            try
            {
                if (ds.Tables[1].Rows[0][0].ToString() == "200")
                {
                    return(objmain.DataTableToJsonWithJsonNet(ds.Tables[0]));
                }
                else if (ds.Tables[1].Rows[0][0].ToString() == "500")
                {
                    objmain.deletePhysicalHeader(data.email, data.location);

                    string      apiresult = ds.Tables[2].Rows[0][0].ToString();
                    XmlDocument xmltest   = new XmlDocument();
                    xmltest.LoadXml(apiresult);
                    XmlNodeList error = xmltest.GetElementsByTagName("faultstring");
                    if (error.Count > 0)
                    {
                        string erroroutput = error[0].InnerXml;
                        ds.Tables[2].Columns.Add("condition", typeof(System.String));
                        ds.Tables[2].Columns.Add("Message", typeof(System.String));
                        ds.Tables[2].Rows[0]["condition"] = "False";
                        ds.Tables[2].Rows[0]["Message"]   = erroroutput;
                        return(objmain.DataTableToJsonWithJsonNet(ds.Tables[2]));
                    }
                }
                return(new JsonResult("BAD"));
            }
            catch (Exception)
            {
                return(objmain.DataTableToJsonWithJsonNet(ds.Tables[0]));
            }
        }
        /// <summary>
        /// Executes processing of the deal redemption request.
        /// </summary>
        public ResultCode Execute()
        {
            ResultCode result;

            // Marshal the First Data redeem deal request into a RedeemedDeal object.
            RedeemedDeal redeemedDeal = new RedeemedDeal()
            {
                AnalyticsEventId = Guid.NewGuid()
            };

            Context[Key.RedeemedDeal] = redeemedDeal;
            FirstData firstData = new FirstData(Context);

            firstData.MarshalRedeemDeal();

            // If the purchase date and time was valid, Add the RedeemedDeal to the data store.
            if (redeemedDeal.PurchaseDateTime != DateTime.MinValue)
            {
                string disallowedReason = Context[Key.DisallowedReason] as string;
                if (String.IsNullOrWhiteSpace(disallowedReason) == true)
                {
                    result = AddRedeemedDeal();
                }
                else
                {
                    Context.Log.Warning("Transaction is disallowed because tender type was: {0}.", disallowedReason);
                    Context[Key.RedeemedDealInfo] = new RedeemedDealInfo
                    {
                        PartnerDealId        = (string)Context[Key.PartnerDealId],
                        PartnerClaimedDealId = (string)Context[Key.PartnerClaimedDealId]
                    };
                    result = ResultCode.TransactionDisallowed;
                }
            }
            else
            {
                result = ResultCode.InvalidPurchaseDateTime;
            }

            // Build the response to send back to First Data based on the result of adding the RedeemedDeal.
            Context[Key.ResultCode] = result;
            firstData.BuildRedeemedDealResponse();

            // If the deal was successfully redeemed, send user notification and update analytics.
            if (result == ResultCode.Created)
            {
                RedeemedDealInfo redeemedDealInfo = (RedeemedDealInfo)Context[Key.RedeemedDealInfo];

                // Send notification.
                NotifyAuthorization notifyAuthorization = new NotifyAuthorization(Context);
                Task.Run(new Action(notifyAuthorization.SendNotification));

                // Update analytics.
                SharedUserLogic sharedUserLogic = new SharedUserLogic(Context,
                                                                      CommerceOperationsFactory.UserOperations(Context));
                Context[Key.GlobalUserId] = redeemedDealInfo.GlobalUserId;
                User user = sharedUserLogic.RetrieveUser();
                Analytics.AddRedemptionEvent(redeemedDealInfo.GlobalUserId, redeemedDeal.AnalyticsEventId, user.AnalyticsEventId,
                                             redeemedDealInfo.ParentDealId, redeemedDealInfo.Currency,
                                             redeemedDeal.AuthorizationAmount, redeemedDealInfo.DiscountAmount,
                                             redeemedDealInfo.GlobalId, (string)Context[Key.PartnerMerchantId]);
            }

            return(result);
        }
示例#7
0
        /// <summary>
        /// Selects the partner through whom to claim the deal.
        /// </summary>
        /// <returns>
        /// The partner through whom the deal will be claimed.
        /// </returns>
        /// <remarks>
        /// * If the card is an Amex and the deal contains Amex info, claim the deal with Amex.
        /// * If the card is a Visa
        ///     * If the deal contains First Data info, claim the deal with First Data.
        ///     * Else if the deal contains Visa info and Visa is enabled, claim the deal with Visa.
        /// * If the card is a MasterCard
        ///     * If the deal contains First Data info, claim the deal with First Data.
        ///     * Else if the deal contains MasterCard info and MasterCard is enabled, claim the deal with MasterCard.
        /// </remarks>
        private ICommercePartner SelectPartner()
        {
            ICommercePartner result = null;

            // Find partner information within the deal.
            Card            card                     = (Card)Context[Key.Card];
            Deal            deal                     = (Deal)Context[Key.Deal];
            PartnerDealInfo amexDealInfo             = null;
            PartnerDealInfo firstDataPartnerDealInfo = null;
            PartnerDealInfo visaDealInfo             = null;
            PartnerDealInfo masterCardDealInfo       = null;

            foreach (PartnerDealInfo partnerDealInfo in deal.PartnerDealInfoList)
            {
                switch (partnerDealInfo.PartnerId)
                {
                case Partner.Amex:
                    amexDealInfo = partnerDealInfo;
                    break;

                case Partner.FirstData:
                    firstDataPartnerDealInfo = partnerDealInfo;
                    break;

                case Partner.Visa:
                    visaDealInfo = partnerDealInfo;
                    break;

                case Partner.MasterCard:
                    masterCardDealInfo = partnerDealInfo;
                    break;
                }
            }

            // Determine the partner with whom to claim the deal.
            switch (card.CardBrand)
            {
            case CardBrand.AmericanExpress:
                if (amexDealInfo != null)
                {
                    result = new Amex(Context);
                }
                break;

            case CardBrand.Visa:
                if (firstDataPartnerDealInfo != null)
                {
                    result = new FirstData(Context);
                }
                else if (visaDealInfo != null)
                {
                    result = new Visa(Context);
                }
                break;

            case CardBrand.MasterCard:
                if (firstDataPartnerDealInfo != null)
                {
                    result = new FirstData(Context);
                }
                else if (masterCardDealInfo != null)
                {
                    result = new MasterCard(Context);
                }
                break;
            }

            return(result);
        }
        /// <summary>
        /// Executes processing of the redemption event info.
        /// </summary>
        public void Execute()
        {
            FirstData firstData = new FirstData(Context);

            firstData.BuildPingResponse();
        }
示例#9
0
        static void Main(string[] args)
        {
            ILogger       logger       = new ConsoleLogger();
            IAddUserMoney addUserMoney = new AddUserMoneyService();
            var           shop         = new Shop(logger)
            {
                Name = "Maxima"
            };
            var user = new User(addUserMoney);

            FirstData.FirstDataCreation(shop, user);
            bool commandExit = true;

            while (commandExit)
            {
                logger.Write($"This is shop {shop.Name}.\nBalance - Displays user balance\nTopup - Increase balance by .. EUR\nList - Displays available items\nBuy - Buy wanted amount of the item\nAdd - Increases amount of items\nExit - Exits the program.\n");

                try
                {
                    string command = logger.Read();

                    switch (command)
                    {
                    case "add":
                        logger.Write("Please, enter what type of item you want to add : cup, candy or book and amount.e g 'cup 10' ");
                        string[] addItemType = logger.Read().Split(' ');
                        var      addItem     = addItemType[0];
                        var      addAmount   = int.Parse(addItemType[1]);
                        shop.AddItems(addItem, addAmount);
                        break;

                    case "buy":
                        logger.Write("Please, enter what type of item you want to buy : cup, candy or book and amount.e g 'cup 10' ");
                        string[] addItemTypeAndAmount = logger.Read().Split(' ');
                        var      buyItem   = addItemTypeAndAmount[0];
                        var      buyAmount = int.Parse(addItemTypeAndAmount[1]);
                        shop.Buy(user, buyItem, buyAmount);
                        break;

                    case "list":
                        shop.ListItems();
                        break;

                    case "balance":
                        logger.Write($"User balance: { user.Balance}");
                        break;

                    case "topup":
                        logger.Write("Please, enter amount");
                        var amount = decimal.Parse(logger.Read());
                        user.AddMoney(user, amount);
                        logger.Write($"New balance {user.Balance}");
                        break;

                    case "exit":
                        commandExit = false;
                        break;

                    default:
                        throw new InvalidOperationException();
                    }
                }
                catch (InvalidOperationException)
                {
                    logger.Write("error");
                }
                catch (Exception e)
                {
                    logger.Write(e.Message);
                }
            }
        }