TelegramBots / Telegram.Bot

.NET Client for Telegram Bot API
https://telegrambots.github.io/book
MIT License
3.17k stars 686 forks source link

Message with type SuccessfulPayment never catched #592

Closed a-a-k closed 6 years ago

a-a-k commented 6 years ago

I don't sure is it a library bug or API directly so take a look.

Steps to reproduce

Run your bot and make any successful payment without shipment_option. Then try to catch info about this payment.

switch (update.Message.Type) // Breakpoint is here
{
   case MessageType.TextMessage:
   {
      await ParseTextMessageAsync(update);
      break;
    }
// ... 
    case MessageType.SuccessfulPayment: // Another breakpoint here too
    {
       await ParseSuccessfulPaymentAsync(update);
       break;
     }
}

Expected behavior

Message with type SuccessfulPayment must be catched.

Actual behavior

Running flow doesn't enter even into the switch clause.

Environment data

NuGet Package Version: 13.4.0

.NET Version: Core 2.0

IDE: VS2017, Rider 2017.3

App: Android UPD 01.02.2018

poulad commented 6 years ago

@a-a-k I cannot reproduce this. Our tests already check that option and it looks fine.

You can debug this test to learn more.

https://github.com/TelegramBots/Telegram.Bot/blob/master/test/Telegram.Bot.Tests.Integ/Payments/PaymentTests.cs#L166

a-a-k commented 6 years ago

@pouladpld there I see the Should_Receive_Successful_Payment_With_Shipment_Option test. Its name tells that shipment_option should be switched on. Isn't it? I have orders with shipment_option switched off.

Also you directly set MessageType.SuccessfulPayment value to sending update object in test so there can't be something wrong. But try to check that manually on your phone. I think this is cause of not-reproducibility.

poulad commented 6 years ago

It's not about shipment info or anything else. When any payment is done, I can see type has proper value.

a-a-k commented 6 years ago

@pouladpld I don't know what it's about but when I've added needShippingAddress = true into sendInvoice the successfulPayment were catched on my breakpoints.

Have you tried to do payments out of tests?