fetchSessionDataFromApi method
Implementation
Future<String> fetchSessionDataFromApi(String token) async {
String apienv;
String domain;
if (sandboxEnabled) {
apienv = "sandbox-";
domain = "tech";
} else {
apienv = "";
domain = "in";
}
final apiUrl =
'https://${apienv}apis.boxpay.${domain}/v0/checkout/sessions/$token';
try {
final response = await http.get(Uri.parse(apiUrl));
if (response.statusCode == 200) {
return response.body;
} else {
throw Exception('Failed to load session data');
}
} catch (e) {
throw Exception('Failed to connect to the server');
}
}