cancelInvoice method
Cancel invoice, by its number.
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> cancelInvoice(String invoiceNumber) async {
try {
final response = await _dio.post<Map<String, dynamic>>(
'cancelInvoice/$invoiceNumber',
options: Options(headers: _headers),
);
if (response.statusCode == 200 && response.data != null) {
return Invoice.fromJson(response.data!);
}
} on DioError catch (e) {
_handlerError(e, 'cancel invoice');
}
throw const TelePayException('Failed to cancel invoice.');
}