getInvoice method
Retrieves invoice details from the Paylink API.
transactionNo - The transaction number for which to retrieve invoice details.
Returns a map containing invoice details.
Implementation
Future<Map<String, dynamic>> getInvoice({String? transactionNo}) async {
try {
if (transactionNo == null) {
throw ArgumentError('Transaction number cannot be null.');
}
if (paymentToken == null) await _authenticate();
final response = await http.get(
Uri.parse('$apiLink/api/getInvoice/$transactionNo'),
headers: {
'accept': '*/*',
'content-type': 'application/json',
'Authorization': 'Bearer $paymentToken',
},
);
if (response.statusCode != 200) {
throw Exception('Failed to load order details: ${response.body}');
}
/// Decode the order details
Map<String, dynamic> orderDetails = json.decode(response.body);
return orderDetails;
} catch (e) {
rethrow;
}
}