예제 #1
0
 public BuyGiftCardResponse Buy([FromBody] BuyGiftCardRequest request)
 {
     ActorSystem.RootActor.Tell(request);
     //todo figure out response
     return(new BuyGiftCardResponse
     {
         CardCode = Guid.NewGuid().ToString()
     });
 }
예제 #2
0
        public IPortal SetCardPrice(BuyGiftCardRequest request)
        {
            driver.FindElement(By.Name("giftGoal")).Clear();
            driver.FindElement(By.Name("giftGoal")).SendKeys(request.GiftCard.Price.ToString());

            Thread.Sleep(1000);
            driver.FindElement(By.Id("btnSelf")).Click();
            return(this);
        }
예제 #3
0
        void BuyGiftCardHandler(BuyGiftCardRequest request)
        {
            _log.Info($"0. Handling request. Id: {request.Id}. Price: {request.GiftCard.Price}. Description: {request.GiftCard.Description}");

            if (!_portal.IsAuthenticated)
            {
                _log.Warning("Auth required");

                _telegramActor.Tell(new RequestCookie());

                Become(UnAuthenticated);
            }
            else
            {
                _log.Warning("1. Launching portal API");
                var cardCode = _portal
                               .GoToGiftCards()
                               .ChooseCard(request)
                               .SetCardPrice(request)
                               .Checkout()
                               .PayWithBitcoin(invoice =>
                {
                    _log.Info($"2. payment callback. wallet: {invoice.BitcoinAddress}, btc : {invoice.BtcPrice}, fiat: {invoice.FiatPrice} ");

                    var walletService = new FakeWalletService();

                    var waletResponse = walletService.CreateWallet(new WalletRequest {
                        customer = new WalletRequest.Customer {
                            id = request.Customer.Id
                        }
                    });
                    var paymentResult = walletService.MakePayment(new PaymentRequest {
                        customer = new PaymentRequest.Customer {
                            id = request.Customer.Id
                        }, transfer = new PaymentRequest.Transfer {
                            amount = invoice.SatoshiPrice, to = invoice.BitcoinAddress
                        }
                    });
                })
                               .GetCardCode();

                _log.Info($"3. BuyCardHandler finished. Card code: {cardCode}");
            }
            _log.Info($"BuyCardHandler finished.");
        }
예제 #4
0
 public IPortal SetCardPrice(BuyGiftCardRequest request)
 {
     Thread.Sleep(_sleepInterval);
     Console.WriteLine($"set card price {request.GiftCard.Price}");
     return(this);
 }
예제 #5
0
 public IPortal ChooseCard(BuyGiftCardRequest request)
 {
     Thread.Sleep(_sleepInterval);
     Console.WriteLine($"choose card {request.GiftCard.Description}");
     return(this);
 }
 void ScrapEntityHandler(BuyGiftCardRequest entity)
 {
     PortalActor.Forward(entity);
 }
예제 #7
0
 public IPortal ChooseCard(BuyGiftCardRequest request)
 {
     driver.FindElement(By.XPath($"//img[@alt='{request.GiftCard.Description}']")).Click();
     return(this);
 }