verifyPayment method

Future<ChargeResponse> verifyPayment(
  1. String flwRef,
  2. Client client
)

Responsible for verifying payments made with bank transfers it returns an instance of ChargeResponse or throws an error

Implementation

Future<ChargeResponse> verifyPayment(final String flwRef, final http.Client client) async {
  final url = FlutterwaveURLS.getBaseUrl(this.isDebugMode) + FlutterwaveURLS.VERIFY_TRANSACTION;
  final uri = Uri.parse(url);
  final VerifyChargeRequest verifyRequest = VerifyChargeRequest(flwRef);
  final payload = verifyRequest.toJson();
  try {
    final http.Response response = await client.post(uri,
        headers: {
          HttpHeaders.authorizationHeader: this.publicKey,
          HttpHeaders.contentTypeHeader: "application/json"
        },
        body: payload);

    final ChargeResponse cardResponse =
    ChargeResponse.fromJson(jsonDecode(response.body));
    return cardResponse;
  } catch (error) {
    throw(FlutterWaveError(error.toString()));
  }
}