getInvoice method

  1. @override
Future<Invoice> getInvoice(
  1. String invoiceNumber
)
override

Get invoice details, by ID.

Throw UnauthorizedException when the secret key is invalid. Throw NotFoundException when no match was found with the invoiceNumber. It throws exception TelePayException with any other error.

Implementation

@override
Future<Invoice> getInvoice(String invoiceNumber) async {
  try {
    final response = await _dio.get<Map<String, dynamic>>(
      'getInvoice/$invoiceNumber',
      options: Options(headers: _headers),
    );
    if (response.statusCode == 200 && response.data != null) {
      return Invoice.fromJson(response.data!);
    }
  } on DioError catch (e) {
    _handlerError(e, 'get invoice');
  }
  throw const TelePayException('Failed to get invoice info');
}