sendInvoice method

Future<Message> sendInvoice(
  1. dynamic chat_id,
  2. String title,
  3. String description,
  4. String payload,
  5. String provider_token,
  6. String currency,
  7. List<LabeledPrice> prices, {
  8. int? max_tip_amount,
  9. List<int>? suggested_tip_amounts,
  10. String? start_parameter,
  11. String? provider_data,
  12. String? photo_url,
  13. int? photo_size,
  14. int? photo_width,
  15. int? photo_height,
  16. bool? need_name,
  17. bool? need_phone_number,
  18. bool? need_email,
  19. bool? need_shipping_address,
  20. bool? send_phone_number_to_provider,
  21. bool? send_email_to_provider,
  22. bool? is_flexible,
  23. bool? disable_notification,
  24. int? reply_to_message_id,
  25. bool? allow_sending_without_reply,
  26. InlineKeyboardMarkup? reply_markup,
})
inherited

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