From b0359c2354451bb9c0e5172965b10e92876a1d7d Mon Sep 17 00:00:00 2001 From: Camilo Sperberg Date: Mon, 19 Jun 2017 19:44:04 +0200 Subject: [PATCH] Fixes invalid LabeledPrice array Tests will follow --- examples/conf.php-sample | 2 ++ src/Telegram/Methods/SendInvoice.php | 15 +++++++++++++++ src/TgLog.php | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/examples/conf.php-sample b/examples/conf.php-sample index 4d36d70..93370da 100644 --- a/examples/conf.php-sample +++ b/examples/conf.php-sample @@ -11,3 +11,5 @@ define('A_GROUP_CHAT_ID', 'XXXXXXXXX'); define('A_FILE_ID', 'XXXXXXXXXXXXXXXXXXXXXXXX'); define('A_USER_ID', 'XXXXXXXX'); + +define('PAYMENT_TOKEN', '123412341234:TEST:XXXXXXXXXXX'); diff --git a/src/Telegram/Methods/SendInvoice.php b/src/Telegram/Methods/SendInvoice.php index cdb77da..9193b84 100644 --- a/src/Telegram/Methods/SendInvoice.php +++ b/src/Telegram/Methods/SendInvoice.php @@ -140,6 +140,21 @@ class SendInvoice extends TelegramMethods */ public $reply_markup; + /** + * Prices must be an array of objects, so json_encode() them + * + * @see https://github.com/unreal4u/telegram-api/issues/32 + * @return TelegramMethods + */ + public function performSpecialConditions(): TelegramMethods + { + if (!empty($this->prices)) { + $this->prices = json_encode($this->prices); + } + + return parent::performSpecialConditions(); + } + public function getMandatoryFields(): array { return [ diff --git a/src/TgLog.php b/src/TgLog.php index 511e6e4..21128bf 100644 --- a/src/TgLog.php +++ b/src/TgLog.php @@ -29,7 +29,7 @@ class TgLog * Stores the token * @var string */ - private $botToken = ''; + private $botToken; /** * Contains an instance to a PSR-3 compatible logger