Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
TelegramBot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
TelegramBot
Commits
33432947
Unverified
Commit
33432947
authored
May 21, 2017
by
Armando Lüscher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new payment entities and update types.
parent
79444db3
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
323 additions
and
0 deletions
+323
-0
CHANGELOG.md
CHANGELOG.md
+1
-0
Invoice.php
src/Entities/Payments/Invoice.php
+31
-0
LabeledPrice.php
src/Entities/Payments/LabeledPrice.php
+28
-0
OrderInfo.php
src/Entities/Payments/OrderInfo.php
+38
-0
PreCheckoutQuery.php
src/Entities/Payments/PreCheckoutQuery.php
+43
-0
ShippingAddress.php
src/Entities/Payments/ShippingAddress.php
+32
-0
ShippingOption.php
src/Entities/Payments/ShippingOption.php
+60
-0
ShippingQuery.php
src/Entities/Payments/ShippingQuery.php
+40
-0
SuccessfulPayment.php
src/Entities/Payments/SuccessfulPayment.php
+41
-0
Update.php
src/Entities/Update.php
+9
-0
No files found.
CHANGELOG.md
View file @
33432947
...
...
@@ -8,6 +8,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
-
Documents can be sent by providing its contents via Psr7 stream (as opposed to passing a file path).
-
Allow setting a custom Guzzle HTTP Client for requests (#511).
-
First implementations towards Bots API 3.0.
-
New entities and update types for Payments.
### Changed
-
[
:exclamation:
][
unreleased-bc-chats-params-array
]
`Request::sendToActiveChats`
and
`DB::selectChats`
now accept parameters as an options array.
### Deprecated
...
...
src/Entities/Payments/Invoice.php
0 → 100644
View file @
33432947
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Longman\TelegramBot\Entities\Payments
;
use
Longman\TelegramBot\Entities\Entity
;
/**
* Class Invoice
*
* This object contains basic information about an invoice.
*
* @link https://core.telegram.org/bots/api#invoice
*
* @method string getTitle() Product name
* @method string getDescription() Product description
* @method string getStartParameter() Unique bot deep-linking parameter that can be used to generate this invoice
* @method string getCurrency() Three-letter ISO 4217 currency code
* @method int getTotalAmount() Total price in the smallest units of the currency (integer, not float/double).
**/
class
Invoice
extends
Entity
{
}
src/Entities/Payments/LabeledPrice.php
0 → 100644
View file @
33432947
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Longman\TelegramBot\Entities\Payments
;
use
Longman\TelegramBot\Entities\Entity
;
/**
* Class LabeledPrice
*
* This object represents a portion of the price for goods or services.
*
* @link https://core.telegram.org/bots/api#labeledprice
*
* @method string getLabel() Portion label
* @method int getAmount() Price of the product in the smallest units of the currency (integer, not float/double).
**/
class
LabeledPrice
extends
Entity
{
}
src/Entities/Payments/OrderInfo.php
0 → 100644
View file @
33432947
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Longman\TelegramBot\Entities\Payments
;
use
Longman\TelegramBot\Entities\Entity
;
/**
* Class OrderInfo
*
* This object represents information about an order.
*
* @link https://core.telegram.org/bots/api#orderinfo
*
* @method string getName() Optional. User name
* @method string getPhoneNumber() Optional. User's phone number
* @method string getEmail() Optional. User email
* @method ShippingAddress getShippingAddress() Optional. User shipping address
**/
class
OrderInfo
extends
Entity
{
/**
* {@inheritdoc}
*/
public
function
subEntities
()
{
return
[
'shipping_address'
=>
ShippingAddress
::
class
,
];
}
}
src/Entities/Payments/PreCheckoutQuery.php
0 → 100644
View file @
33432947
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Longman\TelegramBot\Entities\Payments
;
use
Longman\TelegramBot\Entities\Entity
;
use
Longman\TelegramBot\Entities\User
;
/**
* Class PreCheckoutQuery
*
* This object contains information about an incoming pre-checkout query.
*
* @link https://core.telegram.org/bots/api#precheckoutquery
*
* @method string getId() Unique query identifier
* @method User getFrom() User who sent the query
* @method string getCurrency() Three-letter ISO 4217 currency code
* @method int getTotalAmount() Total price in the smallest units of the currency (integer, not float/double).
* @method string getInvoicePayload() Bot specified invoice payload
* @method string getShippingOptionId() Optional. Identifier of the shipping option chosen by the user
* @method OrderInfo getOrderInfo() Optional. Order info provided by the user
**/
class
PreCheckoutQuery
extends
Entity
{
/**
* {@inheritdoc}
*/
public
function
subEntities
()
{
return
[
'user'
=>
User
::
class
,
'order_info'
=>
OrderInfo
::
class
,
];
}
}
src/Entities/Payments/ShippingAddress.php
0 → 100644
View file @
33432947
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Longman\TelegramBot\Entities\Payments
;
use
Longman\TelegramBot\Entities\Entity
;
/**
* Class ShippingAddress
*
* This object represents a shipping address.
*
* @link https://core.telegram.org/bots/api#shippingaddress
*
* @method string getCountryCode() ISO 3166-1 alpha-2 country code
* @method string getState() State, if applicable
* @method string getCity() City
* @method string getStreetLine1() First line for the address
* @method string getStreetLine2() Second line for the address
* @method string getPostCode() Address post code
**/
class
ShippingAddress
extends
Entity
{
}
src/Entities/Payments/ShippingOption.php
0 → 100644
View file @
33432947
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Longman\TelegramBot\Entities\Payments
;
use
Longman\TelegramBot\Entities\Entity
;
/**
* Class ShippingOption
*
* This object represents one shipping option.
*
* @link https://core.telegram.org/bots/api#shippingoption
*
* @method string getId() Shipping option identifier
* @method string getTitle() Option title
**/
class
ShippingOption
extends
Entity
{
/**
* {@inheritdoc}
*/
protected
function
subEntities
()
{
return
[
'prices'
=>
LabeledPrice
::
class
,
];
}
/**
* List of price portions
*
* This method overrides the default getPrices method and returns a nice array
*
* @return LabeledPrice[]
*/
public
function
getPrices
()
{
$all_prices
=
[];
if
(
$these_prices
=
$this
->
getProperty
(
'prices'
))
{
foreach
(
$these_prices
as
$prices
)
{
$new_prices
=
[];
foreach
(
$prices
as
$price
)
{
$new_prices
[]
=
new
LabeledPrice
(
$price
);
}
$all_prices
[]
=
$new_prices
;
}
}
return
$all_prices
;
}
}
src/Entities/Payments/ShippingQuery.php
0 → 100644
View file @
33432947
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Longman\TelegramBot\Entities\Payments
;
use
Longman\TelegramBot\Entities\Entity
;
use
Longman\TelegramBot\Entities\User
;
/**
* Class ShippingQuery
*
* This object contains information about an incoming shipping query.
*
* @link https://core.telegram.org/bots/api#shippingquery
*
* @method string getId() Unique query identifier
* @method User getFrom() User who sent the query
* @method string getInvoicePayload() Bot specified invoice payload
* @method ShippingAddress getShippingAddress() User specified shipping address
**/
class
ShippingQuery
extends
Entity
{
/**
* {@inheritdoc}
*/
public
function
subEntities
()
{
return
[
'user'
=>
User
::
class
,
'shipping_address'
=>
ShippingAddress
::
class
,
];
}
}
src/Entities/Payments/SuccessfulPayment.php
0 → 100644
View file @
33432947
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Longman\TelegramBot\Entities\Payments
;
use
Longman\TelegramBot\Entities\Entity
;
/**
* Class SuccessfulPayment
*
* This object contains basic information about a successful payment.
*
* @link https://core.telegram.org/bots/api#successfulpayment
*
* @method string getCurrency() Three-letter ISO 4217 currency code
* @method int getTotalAmount() Total price in the smallest units of the currency (integer, not float/double).
* @method string getInvoicePayload() Bot specified invoice payload
* @method string getShippingOptionId() Optional. Identifier of the shipping option chosen by the user
* @method OrderInfo getOrderInfo() Optional. Order info provided by the user
* @method string getTelegramPaymentChargeId() Telegram payment identifier
* @method string getProviderPaymentChargeId() Provider payment identifier
**/
class
SuccessfulPayment
extends
Entity
{
/**
* {@inheritdoc}
*/
public
function
subEntities
()
{
return
[
'order_info'
=>
OrderInfo
::
class
,
];
}
}
src/Entities/Update.php
View file @
33432947
...
...
@@ -10,6 +10,9 @@
namespace
Longman\TelegramBot\Entities
;
use
Longman\TelegramBot\Entities\Payments\PreCheckoutQuery
;
use
Longman\TelegramBot\Entities\Payments\ShippingQuery
;
/**
* Class Update
*
...
...
@@ -23,6 +26,8 @@ namespace Longman\TelegramBot\Entities;
* @method InlineQuery getInlineQuery() Optional. New incoming inline query
* @method ChosenInlineResult getChosenInlineResult() Optional. The result of an inline query that was chosen by a user and sent to their chat partner.
* @method CallbackQuery getCallbackQuery() Optional. New incoming callback query
* @method ShippingQuery getShippingQuery() Optional. New incoming shipping query. Only for invoices with flexible price
* @method PreCheckoutQuery getPreCheckoutQuery() Optional. New incoming pre-checkout query. Contains full information about checkout
*/
class
Update
extends
Entity
{
...
...
@@ -39,6 +44,8 @@ class Update extends Entity
'inline_query'
=>
InlineQuery
::
class
,
'chosen_inline_result'
=>
ChosenInlineResult
::
class
,
'callback_query'
=>
CallbackQuery
::
class
,
'shipping_query'
=>
ShippingQuery
::
class
,
'pre_checkout_query'
=>
PreCheckoutQuery
::
class
,
];
}
...
...
@@ -57,6 +64,8 @@ class Update extends Entity
'inline_query'
,
'chosen_inline_result'
,
'callback_query'
,
'shipping_query'
,
'pre_checkout_query'
,
];
foreach
(
$types
as
$type
)
{
if
(
$this
->
getProperty
(
$type
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment