sendInvoice method
Future<Message>
sendInvoice(
- dynamic chatId,
- String title,
- String description,
- String payload,
- String providerToken,
- String currency,
- List<
LabeledPrice> prices, { - int? messageThreadId,
- int? maxTipAmount,
- List<
int> ? suggestedTipAmounts, - String? startParameter,
- String? providerData,
- String? photoUrl,
- int? photoSize,
- int? photoWidth,
- int? photoHeight,
- bool? needName,
- bool? needPhoneNumber,
- bool? needEmail,
- bool? needShippingAddress,
- bool? sendPhoneNumberToProvider,
- bool? sendEmailToProvider,
- bool? isFlexible,
- bool? disableNotification,
- bool? protectContent,
- int? replyToMessageId,
- bool? allowSendingWithoutReply,
- InlineKeyboardMarkup? replyMarkup,
Use this method to send invoices
On success, the sent Message is returned.
Implementation
Future<Message> sendInvoice(
dynamic chatId,
String title,
String description,
String payload,
String providerToken,
String currency,
List<LabeledPrice> prices,
{int? messageThreadId,
int? maxTipAmount,
List<int>? suggestedTipAmounts,
String? startParameter,
String? providerData,
String? photoUrl,
int? photoSize,
int? photoWidth,
int? photoHeight,
bool? needName,
bool? needPhoneNumber,
bool? needEmail,
bool? needShippingAddress,
bool? sendPhoneNumberToProvider,
bool? sendEmailToProvider,
bool? isFlexible,
bool? disableNotification,
bool? protectContent,
int? replyToMessageId,
bool? allowSendingWithoutReply,
InlineKeyboardMarkup? replyMarkup}) async {
if (chatId is! String && chatId is! int) {
return Future.error(TelegramException(
'Attribute \'chatId\' can only be either type of String or int'));
}
var requestUrl = _apiUri('sendInvoice');
var body = <String, dynamic>{
'chat_id': chatId,
'message_thread_id': messageThreadId,
'title': title,
'description': description,
'payload': payload,
'provider_token': providerToken,
'currency': currency,
'prices': jsonEncode(prices),
'max_tip_amount': maxTipAmount,
'suggested_tip_amounts':
suggestedTipAmounts == null ? null : jsonEncode(suggestedTipAmounts),
'start_parameter': startParameter,
'provider_data': providerData,
'photo_url': photoUrl,
'photo_size': photoSize,
'photo_width': photoWidth,
'photo_height': photoHeight,
'need_name': needName,
'need_phone_number': needPhoneNumber,
'need_email': needEmail,
'need_shipping_address': needShippingAddress,
'send_phone_number_to_provider': sendPhoneNumberToProvider,
'send_email_to_provider': sendEmailToProvider,
'is_flexible': isFlexible,
'disable_notification': disableNotification,
'protect_content': protectContent,
'reply_to_message_id': replyToMessageId,
'allow_sending_without_reply': allowSendingWithoutReply,
'reply_markup': replyMarkup == null ? null : jsonEncode(replyMarkup),
};
return Message.fromJson(await HttpClient.httpPost(requestUrl, body: body));
}