sendInvoice method

Future<Message> sendInvoice(
  1. dynamic chatId,
  2. String title,
  3. String description,
  4. String payload,
  5. String providerToken,
  6. String currency,
  7. List<LabeledPrice> prices, {
  8. int? messageThreadId,
  9. int? maxTipAmount,
  10. List<int>? suggestedTipAmounts,
  11. String? startParameter,
  12. String? providerData,
  13. String? photoUrl,
  14. int? photoSize,
  15. int? photoWidth,
  16. int? photoHeight,
  17. bool? needName,
  18. bool? needPhoneNumber,
  19. bool? needEmail,
  20. bool? needShippingAddress,
  21. bool? sendPhoneNumberToProvider,
  22. bool? sendEmailToProvider,
  23. bool? isFlexible,
  24. bool? disableNotification,
  25. bool? protectContent,
  26. int? replyToMessageId,
  27. bool? allowSendingWithoutReply,
  28. InlineKeyboardMarkup? replyMarkup,
})

Use this method to send invoices

On success, the sent Message is returned.

https://core.telegram.org/bots/api#sendinvoice

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));
}