This repository has been archived by the owner on Feb 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
TelegramBotApi.Types.Payments.pas
350 lines (338 loc) · 13.6 KB
/
TelegramBotApi.Types.Payments.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
{***************************************************************************}
{ }
{ TelegaPi }
{ }
{ Copyright (C) 2021 Maxim Sysoev }
{ }
{ https://t.me/CloudAPI }
{ }
{ }
{***************************************************************************}
{ }
{ Licensed under the Apache License, Version 2.0 (the "License"); }
{ you may not use this file except in compliance with the License. }
{ You may obtain a copy of the License at }
{ }
{ http://www.apache.org/licenses/LICENSE-2.0 }
{ }
{ Unless required by applicable law or agreed to in writing, software }
{ distributed under the License is distributed on an "AS IS" BASIS, }
{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }
{ See the License for the specific language governing permissions and }
{ limitations under the License. }
{ }
{***************************************************************************}
unit TelegramBotApi.Types.Payments;
interface
uses
CloudApi.Attributes,
CloudApi.Types,
System.JSON.Serializers,
TelegramBotApi.Types.Abstract;
type
/// <summary>
/// This object represents a portion of the price for goods or services.
/// </summary>
TtgLabeledPrice = record
private
[JsonName('label')]
FLabel: string;
[JsonName('amount')]
FAmount: Integer;
public
/// <summary>
/// Portion label
/// </summary>
property &Label: string read FLabel write FLabel;
/// <summary>
/// Price of the product in the smallest units of the currency (integer, not
/// float/double). For example, for a price of US$ 1.45 pass 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).
/// </summary>
property Amount: Integer read FAmount write FAmount;
class function Create(const ALabel: string; const AAmount: Integer): TtgLabeledPrice; static;
end;
/// <summary>
/// This object represents one shipping option.
/// </summary>
TtgShippingOption = class
private
[JsonName('title')]
FId: string;
[JsonName('title')]
FTitle: string;
[JsonName('prices')]
FPrices: TArray<TtgLabeledPrice>;
public
/// <summary>
/// Shipping option identifier
/// </summary>
property Id: string read FId write FId;
/// <summary>
/// Option title
/// </summary>
property Title: string read FTitle write FTitle;
/// <summary>
/// List of price portions
/// </summary>
property Prices: TArray<TtgLabeledPrice> read FPrices write FPrices;
end;
/// <summary>
/// Use this method to send invoices. On success, the sent Message is returned.
/// </summary>
[caName('sendInvoice')]
[caMethod(TcaMethod.POST)]
[caParameterType(TcaParameterType.GetOrPost)]
TtgSendInvoiceArgument = class(TtgSendMessageBase)
private
[caName('title')]
[caIsRequaired]
[caDefaultValueString('')]
FTitle: string;
[caName('description')]
[caIsRequaired]
[caDefaultValueString('')]
FDescription: string;
[caName('payload')]
[caIsRequaired]
[caDefaultValueString('')]
FPayload: string;
[caName('provider_token')]
[caIsRequaired]
[caDefaultValueString('')]
FProviderToken: string;
[caName('currency')]
[caIsRequaired]
[caDefaultValueString('')]
FCurrency: string;
[caName('prices')]
[caIsRequaired]
[caDefaultValueString('[]')]
FPrices: TArray<TtgLabeledPrice>;
[caName('max_tip_amount')]
[caDefaultValueInt(0)]
FMaxTipAmount: Integer;
[caName('suggested_tip_amounts')]
[caDefaultValueString('[]')]
FSuggestedTipAmounts: TArray<Integer>;
[caName('start_parameter')]
[caDefaultValueString('')]
FStartParameter: string;
[caName('provider_data')]
[caDefaultValueString('')]
FProviderData: string;
[caName('photo_url')]
[caDefaultValueString('')]
FPhotoUrl: string;
[caName('photo_size')]
[caDefaultValueInt(0)]
FPhotoSize: Integer;
[caName('photo_width')]
[caDefaultValueInt(0)]
FPhotoWidth: Integer;
[caName('photo_height')]
[caDefaultValueInt(0)]
FPhotoHeight: Integer;
[caName('need_name')]
[caDefaultValueBoolean(False)]
FNeedName: Boolean;
[caName('need_phone_number')]
[caDefaultValueBoolean(False)]
FNeedPhoneNumber: Boolean;
[caName('need_email')]
[caDefaultValueBoolean(False)]
FNeedEmail: Boolean;
[caName('need_shipping_address')]
[caDefaultValueBoolean(False)]
FNeedShippingAddress: Boolean;
[caName('send_phone_number_to_provider')]
[caDefaultValueBoolean(False)]
FSendPhoneNumberToProvider: Boolean;
[caName('send_email_to_provider')]
[caDefaultValueBoolean(False)]
FSendEmailToProvider: Boolean;
[caName('is_flexible')]
[caDefaultValueBoolean(False)]
FIsFlexible: Boolean;
[caName('protect_content')]
FProtectContent: Boolean;
public
/// <summary>Unique identifier for the target chat or username of the target
/// channel (in the format @channelusername)</summary>
property ChatId;
/// <summary>
/// Product name, 1-32 characters
/// </summary>
property Title: string read FTitle write FTitle;
/// <summary>
/// Product description, 1-255 characters
/// </summary>
property Description: string read FDescription write FDescription;
/// <summary>
/// Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the
/// user, use for your internal processes.
/// </summary>
property Payload: string read FPayload write FPayload;
/// <summary>
/// Payments provider token, obtained via Botfather
/// </summary>
property ProviderToken: string read FProviderToken write FProviderToken;
/// <summary>
/// Three-letter ISO 4217 currency code, see more on currencies
/// </summary>
property Currency: string read FCurrency write FCurrency;
/// <summary>
/// Price breakdown, a JSON-serialized list of components (e.g. product price, tax,
/// discount, delivery cost, delivery tax, bonus, etc.)
/// </summary>
property Prices: TArray<TtgLabeledPrice> read FPrices write FPrices;
/// <summary>
/// The maximum accepted amount for tips in the smallest units of the currency (
/// integer, not float/double). For example, for a maximum tip of US$ 1.45 pass
/// max_tip_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). Defaults to 0
/// </summary>
property MaxTipAmount: Integer read FMaxTipAmount write FMaxTipAmount;
/// <summary>
/// A JSON-serialized array of suggested amounts of tips in the smallest units of
/// the currency (integer, not float/double). At most 4 suggested tip amounts can
/// be specified. The suggested tip amounts must be positive, passed in a strictly
/// increased order and must not exceed max_tip_amount.
/// </summary>
property SuggestedTipAmounts: TArray<Integer> read FSuggestedTipAmounts write FSuggestedTipAmounts;
/// <summary>
/// Unique deep-linking parameter. If left empty, forwarded copies of the sent
/// message will have a Pay button, allowing multiple users to pay directly from
/// the forwarded message, using the same invoice. If non-empty, forwarded copies
/// of the sent message will have a URL button with a deep link to the bot (instead
/// of a Pay button), with the value used as the start parameter
/// </summary>
property StartParameter: string read FStartParameter write FStartParameter;
/// <summary>
/// A JSON-serialized data about the invoice, which will be shared with the payment
/// provider. A detailed description of required fields should be provided by the
/// payment provider.
/// </summary>
property ProviderData: string read FProviderData write FProviderData;
/// <summary>
/// URL of the product photo for the invoice. Can be a photo of the goods or a
/// marketing image for a service. People like it better when they see what they
/// are paying for.
/// </summary>
property PhotoUrl: string read FPhotoUrl write FPhotoUrl;
/// <summary>
/// Photo size
/// </summary>
property PhotoSize: Integer read FPhotoSize write FPhotoSize;
/// <summary>
/// Photo width
/// </summary>
property PhotoWidth: Integer read FPhotoWidth write FPhotoWidth;
/// <summary>
/// Photo height
/// </summary>
property PhotoHeight: Integer read FPhotoHeight write FPhotoHeight;
/// <summary>
/// Pass True, if you require the user's full name to complete the order
/// </summary>
property NeedName: Boolean read FNeedName write FNeedName;
/// <summary>
/// Pass True, if you require the user's phone number to complete the order
/// </summary>
property NeedPhoneNumber: Boolean read FNeedPhoneNumber write FNeedPhoneNumber;
/// <summary>
/// Pass True, if you require the user's email address to complete the order
/// </summary>
property NeedEmail: Boolean read FNeedEmail write FNeedEmail;
/// <summary>
/// Pass True, if you require the user's shipping address to complete the order
/// </summary>
property NeedShippingAddress: Boolean read FNeedShippingAddress write FNeedShippingAddress;
/// <summary>
/// Pass True, if user's phone number should be sent to provider
/// </summary>
property SendPhoneNumberToProvider: Boolean read FSendPhoneNumberToProvider write FSendPhoneNumberToProvider;
/// <summary>
/// Pass True, if user's email address should be sent to provider
/// </summary>
property SendEmailToProvider: Boolean read FSendEmailToProvider write FSendEmailToProvider;
/// <summary>
/// Pass True, if the final price depends on the shipping method
/// </summary>
property IsFlexible: Boolean read FIsFlexible write FIsFlexible;
/// <summary>Sends the message silently. Users will receive a notification with no
/// sound.</summary>
property DisableNotification;
/// <summary>
/// If the message is a reply, ID of the original message
/// </summary>
property ReplyToMessageId;
/// <summary>
/// Pass True, if the message should be sent even if the specified replied-to
/// message is not found
/// </summary>
property AllowSendingWithoutReply;
/// <summary>
/// A JSON-serialized object for an keyboard
/// </summary>
property ReplyMarkup;
/// <summary>
/// Protects the contents of the sent message from forwarding and saving
/// </summary>
property ProtectContent: Boolean read FProtectContent write FProtectContent;
end;
/// <summary> If you sent an invoice requesting a shipping address and the
/// parameter is_flexible was specified, the Bot API will send an Update with a
/// shipping_query field to the bot. Use this method to reply to shipping queries.
/// On success, True is returned.
/// </summary>
[caName('answerShippingQuery')]
[caMethod(TcaMethod.POST)]
[caParameterType(TcaParameterType.GetOrPost)]
TtgAnswerShippingQuery = class
private
[caName('shipping_query_id')]
[caIsRequaired]
[caDefaultValueString('')]
FShippingQueryId: string;
[caName('ok')]
[caIsRequaired]
[caDefaultValueBoolean(False)]
FOk: Boolean;
[caName('shipping_options')]
[caDefaultValueString('[]')]
FShippingOptions: TArray<TtgShippingOption>;
[caName('error_message')]
[caDefaultValueString('')]
FErrorMessage: string;
public
/// <summary>
/// Unique identifier for the query to be answered
/// </summary>
property ShippingQueryId: string read FShippingQueryId write FShippingQueryId;
/// <summary>
/// Specify True if delivery to the specified address is possible and False if
/// there are any problems (for example, if delivery to the specified address is
/// not possible)
/// </summary>
property Ok: Boolean read FOk write FOk;
/// <summary>
/// Required if ok is True. A JSON-serialized array of available shipping options.
/// </summary>
property ShippingOptions: TArray<TtgShippingOption> read FShippingOptions write FShippingOptions;
/// <summary>
/// Required if ok is False. Error message in human readable form that explains why
/// it is impossible to complete the order (e.g. "Sorry, delivery to your desired
/// address is unavailable'). Telegram will display this message to the user.
/// </summary>
property ErrorMessage: string read FErrorMessage write FErrorMessage;
end;
implementation
class function TtgLabeledPrice.Create(const ALabel: string; const AAmount: Integer): TtgLabeledPrice;
begin
Result.&Label := ALabel;
Result.Amount := AAmount;
end;
end.