Exemplo n.º 1
0
 protected virtual void OnPaymentSaveAndClose(PaymentEventArgs e)
 {
     if (PaymentSaveAndClose != null)
     {
         PaymentSaveAndClose(this, e);
     }
 }
 public void Register(object sender, PaymentEventArgs args)
 {
     if (OnRegister != null)
     {
         OnRegister(sender, args);
     }
 }
Exemplo n.º 3
0
 //Cleanup static variables
 static void salesDoc_PaymentMade(object sender, PaymentEventArgs args)
 {
     input.Clear();
     if (paymentInfo != null)
     {
         paymentInfo.Amount = 0;
     }
 }
Exemplo n.º 4
0
        protected virtual void OnNewPayment(Payment payment)
        {
            var e = new PaymentEventArgs(payment);

            OnPayment?.Invoke(this, e);

            switch (payment.Type)
            {
            case PaymentType.In:
                OnIncomingPayment?.Invoke(this, e);
                break;

            case PaymentType.Out:
                OnOutgoingPayment?.Invoke(this, e);
                break;
            }
        }
Exemplo n.º 5
0
 internal void StartPayment(object s, PaymentEventArgs pe)
 {
     if (decimal.TryParse(pe.CashGivenStr, out decimal cashGiven))
     {
         decimal cartVal = GetTransactionValue();
         if (cashGiven == cartVal)
         {
             RaiseCartPayedFor();
         }
         else if (cashGiven > cartVal)
         {
             RaiseProvideChange(cashGiven, cartVal);
         }
         else
         {
             Console.WriteLine("Not enough money handed over");
         }
     }
     else
     {
         Console.WriteLine("Invalid cash format");
     }
 }
Exemplo n.º 6
0
        private static async Task TelegramMessage(TelegramFSMBot bot, Message message)
        {
            if (message.Type == MessageType.Text)
            {
                if (Regex.IsMatch(message.Text, PARAMETRIC_COMMAND_PALETTE))
                {
                    string ParametricCommand = Regex.Match(message.Text, PARAMETRIC_COMMAND_PALETTE).Groups[1].Value;
                    bot.ReceiveParametricStart(new ParametricStartEventArgs()
                    {
                        ParametricCommand = ParametricCommand, UserId = message.From.Id
                    });
                    return;
                }
                TelegramTextCommand command = new TelegramTextCommand(message.From.Id, message.Text);
                bot.Dispatch(command);
            }
            if (message.Type == MessageType.Photo || message.Type == MessageType.Document)
            {
                MemoryStream    ms       = new MemoryStream();
                string          FileName = null;
                TelegramCommand command  = null;
                switch (message.Type)
                {
                case MessageType.Photo:
                    bot.GetInfoAndDownloadFileAsync(message.Photo.Last().FileId, ms).Wait();
                    ms.Seek(0, SeekOrigin.Begin);
                    command = new TelegramPhotoCommand(message.From.Id, ms.ToArray());
                    break;

                case MessageType.Document:
                    if (message.Document.FileSize < 19922944)
                    {
                        if (bot.AnswerToFilesWithType)
                        {
                            bot.Sender.Enqueue(new TelegramTypingMessage(message.From.Id));
                        }
                        bot.GetInfoAndDownloadFileAsync(message.Document.FileId, ms).Wait();
                        ms.Seek(0, SeekOrigin.Begin);
                        FileName = message.Document.FileName;
                        command  = new TelegramFileCommand(message.From.Id, ms.ToArray(), FileName);
                    }
                    else
                    {
                        FileTooBigEventArgs ftbea = new FileTooBigEventArgs(message.Chat.Id, message.From.Id, message.MessageId, message.Document.FileName, message.Document.FileId, message.Document.FileSize);
                        EventHandler <FileTooBigEventArgs> handler = bot.FileTooBig;
                        handler.Invoke(bot, ftbea);
                        command = new TelegramEmptyCommand(message.From.Id);
                    }
                    break;
                }
                bot.Dispatch(command);
            }
            if (message.Type == MessageType.SuccessfulPayment)
            {
                string           InvoiceId = message.SuccessfulPayment.InvoicePayload;
                PaymentEventArgs pea       = new PaymentEventArgs(InvoiceId);
                EventHandler <PaymentEventArgs> handler = bot.PaymentReceived;
                handler.Invoke(bot, pea);
            }
            if (message.Type == MessageType.ChatMembersAdded)
            {
                Console.WriteLine(message.NewChatMembers);
            }
            if (message.Type == MessageType.Location || (message.Type == MessageType.Venue && message.Location != null))
            {
                double[] coords = new double[2];
                coords[0] = message.Location.Latitude;
                coords[1] = message.Location.Longitude;
                TelegramGeoCommand command = new TelegramGeoCommand(message.From.Id, coords);
                bot.Dispatch(command);
            }
        }
 private void StellarService_PaymentReceived(object sender, PaymentEventArgs e)
 {
     Payments.Add(e.Payment);
 }