verifyPayment method
Verify a payment transaction
Implementation
@override
Future<PaymentResponse> verifyPayment(String reference) async {
try {
final result = await methodChannel.invokeMethod<Map<dynamic, dynamic>>(
'verifyPayment',
{'reference': reference},
);
if (result == null) {
throw PaystackError(message: 'No response from payment verification');
}
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 verify payment',
code: e.code,
);
}
}