From 375aced80de288b526c6dda25fe7536877830f91 Mon Sep 17 00:00:00 2001 From: TiiFuchs <1958744+TiiFuchs@users.noreply.github.com> Date: Sun, 7 Jul 2024 11:38:11 +0000 Subject: [PATCH] Update code to reflect latest changes to the Bot API documentation --- src/Telegram/Message.php | 6 ++++ src/Telegram/RefundedPayment.php | 50 ++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 src/Telegram/RefundedPayment.php diff --git a/src/Telegram/Message.php b/src/Telegram/Message.php index 817bc54..3e3f1bb 100644 --- a/src/Telegram/Message.php +++ b/src/Telegram/Message.php @@ -206,6 +206,9 @@ class Message extends MaybeInaccessibleMessage /** Optional. Message is a service message about a successful payment, information about the payment. More about payments » */ public ?SuccessfulPayment $successful_payment = null; + /** Optional. Message is a service message about a refunded payment, information about the payment. More about payments » */ + public ?RefundedPayment $refunded_payment = null; + /** Optional. Service message: users were shared with the bot */ public ?UsersShared $users_shared = null; @@ -339,6 +342,7 @@ class Message extends MaybeInaccessibleMessage * @param MaybeInaccessibleMessage $pinned_message Optional. Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply. * @param Invoice $invoice Optional. Message is an invoice for a payment, information about the invoice. More about payments » * @param SuccessfulPayment $successful_payment Optional. Message is a service message about a successful payment, information about the payment. More about payments » + * @param RefundedPayment $refunded_payment Optional. Message is a service message about a refunded payment, information about the payment. More about payments » * @param UsersShared $users_shared Optional. Service message: users were shared with the bot * @param ChatShared $chat_shared Optional. Service message: a chat was shared with the bot * @param string $connected_website Optional. The domain name of the website on which the user has logged in. More about Telegram Login » @@ -425,6 +429,7 @@ public static function make( ?MaybeInaccessibleMessage $pinned_message = null, ?Invoice $invoice = null, ?SuccessfulPayment $successful_payment = null, + ?RefundedPayment $refunded_payment = null, ?UsersShared $users_shared = null, ?ChatShared $chat_shared = null, ?string $connected_website = null, @@ -511,6 +516,7 @@ public static function make( 'pinned_message' => $pinned_message, 'invoice' => $invoice, 'successful_payment' => $successful_payment, + 'refunded_payment' => $refunded_payment, 'users_shared' => $users_shared, 'chat_shared' => $chat_shared, 'connected_website' => $connected_website, diff --git a/src/Telegram/RefundedPayment.php b/src/Telegram/RefundedPayment.php new file mode 100644 index 0000000..921bd75 --- /dev/null +++ b/src/Telegram/RefundedPayment.php @@ -0,0 +1,50 @@ +currency code, or “XTR” for payments in Telegram Stars. Currently, always “XTR” */ + public string $currency = 'XTR'; + + /** Total refunded price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45, total_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). */ + public int $total_amount; + + /** Bot-specified invoice payload */ + public string $invoice_payload; + + /** Telegram payment identifier */ + public string $telegram_payment_charge_id; + + /** Optional. Provider payment identifier */ + public ?string $provider_payment_charge_id = null; + + /** + * @param int $total_amount Total refunded price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45, total_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). + * @param string $invoice_payload Bot-specified invoice payload + * @param string $telegram_payment_charge_id Telegram payment identifier + * @param string $provider_payment_charge_id Optional. Provider payment identifier + */ + public static function make( + int $total_amount, + string $invoice_payload, + string $telegram_payment_charge_id, + ?string $provider_payment_charge_id = null, + ): static { + return new static([ + 'total_amount' => $total_amount, + 'invoice_payload' => $invoice_payload, + 'telegram_payment_charge_id' => $telegram_payment_charge_id, + 'provider_payment_charge_id' => $provider_payment_charge_id, + ]); + } +}