1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
4
|
|
|
|
5
|
|
|
namespace unreal4u\TelegramAPI\Telegram\Methods; |
6
|
|
|
|
7
|
|
|
use unreal4u\TelegramAPI\Abstracts\TelegramMethods; |
8
|
|
|
use unreal4u\TelegramAPI\Telegram\Types\Inline\Keyboard\Markup; |
9
|
|
|
use unreal4u\TelegramAPI\Telegram\Types\LabeledPrice; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Use this method to send invoices. On success, the sent Message is returned. |
13
|
|
|
* |
14
|
|
|
* Objects defined as-is May 2017 |
15
|
|
|
* |
16
|
|
|
* @see https://core.telegram.org/bots/api#sendinvoice |
17
|
|
|
*/ |
18
|
|
|
class SendInvoice extends TelegramMethods |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* Unique identifier for the target private chat |
22
|
|
|
* @var int |
23
|
|
|
*/ |
24
|
|
|
public $chat_id = 0; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Product name |
28
|
|
|
* @var string |
29
|
|
|
*/ |
30
|
|
|
public $title = ''; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Product description |
34
|
|
|
* @var string |
35
|
|
|
*/ |
36
|
|
|
public $description = ''; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
public $payload = ''; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Payments provider token, obtained via Botfather |
46
|
|
|
* @var string |
47
|
|
|
*/ |
48
|
|
|
public $provider_token = ''; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter |
52
|
|
|
* @var string |
53
|
|
|
*/ |
54
|
|
|
public $start_parameter = ''; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Three-letter ISO 4217 currency code, see more on currencies |
58
|
|
|
* @see https://core.telegram.org/bots/payments#supported-currencies |
59
|
|
|
* @var string |
60
|
|
|
*/ |
61
|
|
|
public $currency = ''; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, |
65
|
|
|
* etc.) |
66
|
|
|
* @var LabeledPrice[] |
67
|
|
|
*/ |
68
|
|
|
public $prices = []; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Optional. URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a |
72
|
|
|
* service. People like it better when they see what they are paying for |
73
|
|
|
* @var string |
74
|
|
|
*/ |
75
|
|
|
public $photo_url = ''; |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Optional. Photo size |
79
|
|
|
* @var int |
80
|
|
|
*/ |
81
|
|
|
public $photo_size = 0; |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Optional. Photo width |
85
|
|
|
* @var int |
86
|
|
|
*/ |
87
|
|
|
public $photo_width = 0; |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Optional. Photo height |
91
|
|
|
* @var int |
92
|
|
|
*/ |
93
|
|
|
public $photo_height = 0; |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Optional. Pass True, if you require the user's full name to complete the order |
97
|
|
|
* @var bool |
98
|
|
|
*/ |
99
|
|
|
public $need_name = false; |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Optional. Pass True, if you require the user's phone number to complete the order |
103
|
|
|
* @var bool |
104
|
|
|
*/ |
105
|
|
|
public $need_phone_number = false; |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Optional. Pass True, if you require the user's email to complete the order |
109
|
|
|
* @var bool |
110
|
|
|
*/ |
111
|
|
|
public $need_email = false; |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Optional. Pass True, if you require the user's shipping address to complete the order |
115
|
|
|
* @var bool |
116
|
|
|
*/ |
117
|
|
|
public $need_shipping_address = false; |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Optional. Pass True, if the final price depends on the shipping method |
121
|
|
|
* @var bool |
122
|
|
|
*/ |
123
|
|
|
public $is_flexible = false; |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Optional. Sends the message silently. Users will receive a notification with no sound. |
127
|
|
|
* @var bool |
128
|
|
|
*/ |
129
|
|
|
public $disable_notification = false; |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Optional. If the message is a reply, ID of the original message |
133
|
|
|
* @var int |
134
|
|
|
*/ |
135
|
|
|
public $reply_to_message_id = 0; |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Optional. A JSON-serialized object for an inline keyboard. If empty, one 'Pay total price' button will be shown. |
139
|
|
|
* If not empty, the first button must be a Pay button |
140
|
|
|
* @var Markup |
141
|
|
|
*/ |
142
|
|
|
public $reply_markup; |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* Prices must be an array of objects, so json_encode() them |
146
|
|
|
* |
147
|
|
|
* @see https://github.com/unreal4u/telegram-api/issues/32 |
148
|
|
|
* @return TelegramMethods |
149
|
|
|
*/ |
150
|
1 |
|
public function performSpecialConditions(): TelegramMethods |
151
|
|
|
{ |
152
|
1 |
|
if (!empty($this->prices)) { |
153
|
1 |
|
$this->prices = json_encode($this->prices); |
154
|
|
|
} |
155
|
|
|
|
156
|
1 |
|
return parent::performSpecialConditions(); |
157
|
|
|
} |
158
|
|
|
|
159
|
1 |
|
public function getMandatoryFields(): array |
160
|
|
|
{ |
161
|
|
|
return [ |
162
|
1 |
|
'chat_id', |
163
|
|
|
'title', |
164
|
|
|
'description', |
165
|
|
|
'payload', |
166
|
|
|
'provider_token', |
167
|
|
|
'start_parameter', |
168
|
|
|
'currency', |
169
|
|
|
'prices', |
170
|
|
|
]; |
171
|
|
|
} |
172
|
|
|
} |
173
|
|
|
|