sendInvoice method
Future<Message>
sendInvoice(
- dynamic chat_id,
- String title,
- String description,
- String payload,
- String provider_token,
- String currency,
- List<
LabeledPrice> prices, { - int? max_tip_amount,
- List<
int> ? suggested_tip_amounts, - String? start_parameter,
- String? provider_data,
- String? photo_url,
- int? photo_size,
- int? photo_width,
- int? photo_height,
- bool? need_name,
- bool? need_phone_number,
- bool? need_email,
- bool? need_shipping_address,
- bool? send_phone_number_to_provider,
- bool? send_email_to_provider,
- bool? is_flexible,
- bool? disable_notification,
- int? reply_to_message_id,
- bool? allow_sending_without_reply,
- InlineKeyboardMarkup? reply_markup,
inherited
Use this method to send invoices
On success, the sent Message
is returned.
Implementation
Future<Message> sendInvoice(
dynamic chat_id,
String title,
String description,
String payload,
String provider_token,
String currency,
List<LabeledPrice> prices,
{int? max_tip_amount,
List<int>? suggested_tip_amounts,
String? start_parameter,
String? provider_data,
String? photo_url,
int? photo_size,
int? photo_width,
int? photo_height,
bool? need_name,
bool? need_phone_number,
bool? need_email,
bool? need_shipping_address,
bool? send_phone_number_to_provider,
bool? send_email_to_provider,
bool? is_flexible,
bool? disable_notification,
int? reply_to_message_id,
bool? allow_sending_without_reply,
InlineKeyboardMarkup? reply_markup}) async {
if (chat_id is! String && chat_id is! int) {
return Future.error(TelegramException(
'Attribute \'chat_id\' can only be either type of String or int'));
}
var requestUrl = _apiUri('sendInvoice');
var body = <String, dynamic>{
'chat_id': chat_id,
'title': title,
'description': description,
'payload': payload,
'provider_token': provider_token,
'currency': currency,
'prices': jsonEncode(prices),
'max_tip_amount': max_tip_amount,
'suggested_tip_amounts': suggested_tip_amounts == null
? null
: jsonEncode(suggested_tip_amounts),
'start_parameter': start_parameter,
'provider_data': provider_data,
'photo_url': photo_url,
'photo_size': photo_size,
'photo_width': photo_width,
'photo_height': photo_height,
'need_name': need_name,
'need_phone_number': need_phone_number,
'need_email': need_email,
'need_shipping_address': need_shipping_address,
'send_phone_number_to_provider': send_phone_number_to_provider,
'send_email_to_provider': send_email_to_provider,
'is_flexible': is_flexible,
'disable_notification': disable_notification,
'reply_to_message_id': reply_to_message_id,
'allow_sending_without_reply': allow_sending_without_reply,
'reply_markup': reply_markup == null ? null : jsonEncode(reply_markup),
};
return Message.fromJson(await HttpClient.httpPost(requestUrl, body: body));
}