createInvoice method
Creates an invoice, associated to your merchant.
Throw UnauthorizedException when the secret key is invalid, otherwise it throws exception TelePayException with any other error.
Implementation
@override
Future<Invoice> createInvoice(CreateInvoice invoice) async {
try {
final response = await _dio.post<Map<String, dynamic>>(
'createInvoice',
data: invoice.toJson(),
options: Options(headers: _headers),
);
if (response.statusCode == 201 && response.data != null) {
return Invoice.fromJson(response.data!);
}
} on DioError catch (e) {
_handlerError(e, 'create invoice');
}
throw const TelePayException('Failed to create invoice.');
}