retrieveCheckout method
Used for retrieving a checkout object.
Implementation
Future<PaymentStatus?> retrieveCheckout({required String checkoutId}) async {
PaymentStatus? paymentStatus;
var method = "get";
var checkoutEndpoint = '/v1/checkout/$checkoutId';
final checkoutURL = Uri.parse(baseURL + checkoutEndpoint);
final headers = _generateHeader(
method: method,
endpoint: checkoutEndpoint,
);
try {
var response = await http.get(checkoutURL, headers: headers);
if (response.statusCode == 200) {
dev.log('Checkout retrieved successfully!');
paymentStatus = PaymentStatus.fromJson(jsonDecode(response.body));
} else {
throw ('Failed to retrieve the checkout, status ${response.statusCode}');
}
} catch (_) {
dev.log('Failed to retrieve checkout');
}
return paymentStatus;
}