From 0442831ecc3e0e73b77d2391dae9507fe7c3e8e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D0=B5=D0=B3=D1=81=D0=B5=D0=B9?= <63949026+Apolisk@users.noreply.github.com> Date: Sat, 10 Aug 2024 17:51:27 +0300 Subject: [PATCH] implement bot api 7.7 (#728) --- bot_test.go | 5 +++++ message.go | 3 +++ payments.go | 8 ++++++++ telebot.go | 1 + update.go | 5 ++++- 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/bot_test.go b/bot_test.go index 8f1c3225..74e10620 100644 --- a/bot_test.go +++ b/bot_test.go @@ -234,6 +234,10 @@ func TestBotProcessUpdate(t *testing.T) { assert.NotNil(t, c.Message().Payment) return nil }) + b.Handle(OnRefund, func(c Context) error { + assert.NotNil(t, c.Message().RefundedPayment) + return nil + }) b.Handle(OnAddedToGroup, func(c Context) error { assert.NotNil(t, c.Message().GroupCreated) return nil @@ -334,6 +338,7 @@ func TestBotProcessUpdate(t *testing.T) { b.ProcessUpdate(Update{Message: &Message{Venue: &Venue{}}}) b.ProcessUpdate(Update{Message: &Message{Invoice: &Invoice{}}}) b.ProcessUpdate(Update{Message: &Message{Payment: &Payment{}}}) + b.ProcessUpdate(Update{Message: &Message{RefundedPayment: &RefundedPayment{}}}) b.ProcessUpdate(Update{Message: &Message{Dice: &Dice{}}}) b.ProcessUpdate(Update{Message: &Message{GroupCreated: true}}) b.ProcessUpdate(Update{Message: &Message{UserJoined: &User{ID: 1}}}) diff --git a/message.go b/message.go index 46f83d14..1b959ad5 100644 --- a/message.go +++ b/message.go @@ -282,6 +282,9 @@ type Message struct { // Message is a service message about a successful payment. Payment *Payment `json:"successful_payment"` + // Message is a service message about a refunded payment, information about the payment. + RefundedPayment *RefundedPayment `json:"refunded_payment"` + // For a service message, a user was shared with the bot. UserShared *RecipientShared `json:"users_shared,omitempty"` diff --git a/payments.go b/payments.go index 1546dcd5..16fa23ed 100644 --- a/payments.go +++ b/payments.go @@ -45,6 +45,14 @@ type Payment struct { ProviderChargeID string `json:"provider_payment_charge_id"` } +type RefundedPayment struct { + Currency string `json:"currency"` + TotalAmount int `json:"total_amount"` + InvoicePayload string `json:"invoice_payload"` + TelegramChargeID string `json:"telegram_payment_charge_id"` + ProviderChargeID string `json:"provider_payment_charge_id"` +} + // PreCheckoutQuery contains information about an incoming pre-checkout query. type PreCheckoutQuery struct { Sender *User `json:"from"` diff --git a/telebot.go b/telebot.go index 5530d1fc..ef11bccf 100644 --- a/telebot.go +++ b/telebot.go @@ -60,6 +60,7 @@ const ( OnDice = "\adice" OnInvoice = "\ainvoice" OnPayment = "\apayment" + OnRefund = "\arefund" OnGame = "\agame" OnPoll = "\apoll" OnPollAnswer = "\apoll_answer" diff --git a/update.go b/update.go index ea6d9b35..ef63bc05 100644 --- a/update.go +++ b/update.go @@ -106,7 +106,10 @@ func (b *Bot) ProcessUpdate(u Update) { b.handle(OnPayment, c) return } - + if m.RefundedPayment != nil { + b.handle(OnRefund, c) + return + } if m.TopicCreated != nil { b.handle(OnTopicCreated, c) return