-
Notifications
You must be signed in to change notification settings - Fork 1
/
payments_gen.go
339 lines (260 loc) · 12.1 KB
/
payments_gen.go
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
// Code generated by telegram-apigen. DO NOT EDIT.
package telegram
import "encoding/json"
type SendInvoiceRequest struct {
// Unique identifier for the target chat or username of the target channel (in the
// format @channelusername)
ChatID string `json:"chat_id"`
// Product name, 1-32 characters
Title string `json:"title"`
// Product description, 1-255 characters
Description string `json:"description"`
// Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the
// user, use for your internal processes.
Payload string `json:"payload"`
// Payments provider token, obtained via Botfather
ProviderToken string `json:"provider_token"`
// Three-letter ISO 4217 currency code, see more on currencies
Currency string `json:"currency"`
// Price breakdown, a JSON-serialized list of components (e.g. product price, tax,
// discount, delivery cost, delivery tax, bonus, etc.)
Prices []LabeledPrice `json:"prices"`
// Optional. 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
MaxTipAmount int `json:"max_tip_amount,omitempty"`
// Optional. 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.
SuggestedTipAmounts []int `json:"suggested_tip_amounts,omitempty"`
// Optional. 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
StartParameter string `json:"start_parameter,omitempty"`
// Optional. 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.
ProviderData string `json:"provider_data,omitempty"`
// Optional. 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.
PhotoURL string `json:"photo_url,omitempty"`
// Optional. Photo size
PhotoSize int `json:"photo_size,omitempty"`
// Optional. Photo width
PhotoWidth int `json:"photo_width,omitempty"`
// Optional. Photo height
PhotoHeight int `json:"photo_height,omitempty"`
// Optional. Pass True, if you require the user's full name to complete the order
NeedName bool `json:"need_name,omitempty"`
// Optional. Pass True, if you require the user's phone number to complete the
// order
NeedPhoneNumber bool `json:"need_phone_number,omitempty"`
// Optional. Pass True, if you require the user's email address to complete the
// order
NeedEmail bool `json:"need_email,omitempty"`
// Optional. Pass True, if you require the user's shipping address to complete the
// order
NeedShippingAddress bool `json:"need_shipping_address,omitempty"`
// Optional. Pass True, if user's phone number should be sent to provider
SendPhoneNumberToProvider bool `json:"send_phone_number_to_provider,omitempty"`
// Optional. Pass True, if user's email address should be sent to provider
SendEmailToProvider bool `json:"send_email_to_provider,omitempty"`
// Optional. Pass True, if the final price depends on the shipping method
IsFlexible bool `json:"is_flexible,omitempty"`
// Optional. Sends the message silently. Users will receive a notification with no
// sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// Optional. If the message is a reply, ID of the original message
ReplyToMessageID int `json:"reply_to_message_id,omitempty"`
// Optional. Pass True, if the message should be sent even if the specified
// replied-to message is not found
AllowSendingWithoutReply bool `json:"allow_sending_without_reply,omitempty"`
// Optional. A JSON-serialized object for an inline keyboard. If empty, one 'Pay
// total price' button will be shown. If not empty, the first button must be a Pay
// button.
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}
// Use this method to send invoices. On success, the sent Message is returned.
func (b *Bot) SendInvoice(req *SendInvoiceRequest) (*Message, error) {
j, err := b.makeRequest("sendInvoice", req)
if err != nil {
return nil, err
}
var resp Message
err = json.Unmarshal(j, &resp)
return &resp, err
}
type AnswerShippingQueryRequest struct {
// Unique identifier for the query to be answered
ShippingQueryID string `json:"shipping_query_id"`
// 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)
Ok bool `json:"ok"`
// Optional. Required if ok is True. A JSON-serialized array of available shipping
// options.
ShippingOptions []ShippingOption `json:"shipping_options,omitempty"`
// Optional. 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.
ErrorMessage string `json:"error_message,omitempty"`
}
// 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.
func (b *Bot) AnswerShippingQuery(req *AnswerShippingQueryRequest) (*Update, error) {
j, err := b.makeRequest("answerShippingQuery", req)
if err != nil {
return nil, err
}
var resp Update
err = json.Unmarshal(j, &resp)
return &resp, err
}
type AnswerPreCheckoutQueryRequest struct {
// Unique identifier for the query to be answered
PreCheckoutQueryID string `json:"pre_checkout_query_id"`
// Specify True if everything is alright (goods are available, etc.) and the bot is
// ready to proceed with the order. Use False if there are any problems.
Ok bool `json:"ok"`
// Optional. Required if ok is False. Error message in human readable form that
// explains the reason for failure to proceed with the checkout (e.g. "Sorry,
// somebody just bought the last of our amazing black T-shirts while you were busy
// filling out your payment details. Please choose a different color or garment!").
// Telegram will display this message to the user.
ErrorMessage string `json:"error_message,omitempty"`
}
// Once the user has confirmed their payment and shipping details, the Bot API
// sends the final confirmation in the form of an Update with the field
// pre_checkout_query. Use this method to respond to such pre-checkout queries. On
// success, True is returned. Note: The Bot API must receive an answer within 10
// seconds after the pre-checkout query was sent.
func (b *Bot) AnswerPreCheckoutQuery(req *AnswerPreCheckoutQueryRequest) (*Update, error) {
j, err := b.makeRequest("answerPreCheckoutQuery", req)
if err != nil {
return nil, err
}
var resp Update
err = json.Unmarshal(j, &resp)
return &resp, err
}
// This object represents a portion of the price for goods or services.
type LabeledPrice struct {
// Portion label
Label string `json:"label"`
// 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).
Amount int `json:"amount"`
}
// This object contains basic information about an invoice.
type Invoice struct {
// Product name
Title string `json:"title"`
// Product description
Description string `json:"description"`
// Unique bot deep-linking parameter that can be used to generate this invoice
StartParameter string `json:"start_parameter"`
// Three-letter ISO 4217 currency code
Currency string `json:"currency"`
// Total price 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).
TotalAmount int `json:"total_amount"`
}
// This object represents a shipping address.
type ShippingAddress struct {
// ISO 3166-1 alpha-2 country code
CountryCode string `json:"country_code"`
// State, if applicable
State string `json:"state"`
// City
City string `json:"city"`
// First line for the address
StreetLine1 string `json:"street_line1"`
// Second line for the address
StreetLine2 string `json:"street_line2"`
// Address post code
PostCode string `json:"post_code"`
}
// This object represents information about an order.
type OrderInfo struct {
// Optional. User name
Name string `json:"name,omitempty"`
// Optional. User's phone number
PhoneNumber string `json:"phone_number,omitempty"`
// Optional. User email
Email string `json:"email,omitempty"`
// Optional. User shipping address
ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"`
}
// This object represents one shipping option.
type ShippingOption struct {
// Shipping option identifier
ID string `json:"id"`
// Option title
Title string `json:"title"`
// List of price portions
Prices []LabeledPrice `json:"prices"`
}
// This object contains basic information about a successful payment.
type SuccessfulPayment struct {
// Three-letter ISO 4217 currency code
Currency string `json:"currency"`
// Total price 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).
TotalAmount int `json:"total_amount"`
// Bot specified invoice payload
InvoicePayload string `json:"invoice_payload"`
// Optional. Identifier of the shipping option chosen by the user
ShippingOptionID string `json:"shipping_option_id,omitempty"`
// Optional. Order info provided by the user
OrderInfo *OrderInfo `json:"order_info,omitempty"`
// Telegram payment identifier
TelegramPaymentChargeID string `json:"telegram_payment_charge_id"`
// Provider payment identifier
ProviderPaymentChargeID string `json:"provider_payment_charge_id"`
}
// This object contains information about an incoming shipping query.
type ShippingQuery struct {
// Unique query identifier
ID string `json:"id"`
// User who sent the query
From *User `json:"from"`
// Bot specified invoice payload
InvoicePayload string `json:"invoice_payload"`
// User specified shipping address
ShippingAddress *ShippingAddress `json:"shipping_address"`
}
// This object contains information about an incoming pre-checkout query.
type PreCheckoutQuery struct {
// Unique query identifier
ID string `json:"id"`
// User who sent the query
From *User `json:"from"`
// Three-letter ISO 4217 currency code
Currency string `json:"currency"`
// Total price 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).
TotalAmount int `json:"total_amount"`
// Bot specified invoice payload
InvoicePayload string `json:"invoice_payload"`
// Optional. Identifier of the shipping option chosen by the user
ShippingOptionID string `json:"shipping_option_id,omitempty"`
// Optional. Order info provided by the user
OrderInfo *OrderInfo `json:"order_info,omitempty"`
}