getPaymentStatus method
Get payment status
Implementation
@override
Future<PaymentResponse> getPaymentStatus(String reference) async {
try {
final result = await methodChannel.invokeMethod<Map<dynamic, dynamic>>(
'getPaymentStatus',
{'reference': reference},
);
if (result == null) {
throw PaystackError(message: 'No response from payment status check');
}
final castedResult = result.cast<String, dynamic>();
if (castedResult['status'] != 'success') {
throw PaystackError.fromApiResponse(castedResult);
}
return PaymentResponse.fromApiResponse(castedResult);
} on PlatformException catch (e) {
throw PaystackError(
message: e.message ?? 'Failed to get payment status',
code: e.code,
);
}
}