payWithVoucher method
Initiates voucher payments Returns an inatance of ChargeResponse or throws an error
Implementation
Future<ChargeResponse> payWithVoucher(
VoucherPaymentRequest payload, http.Client client) async {
final url = FlutterwaveURLS.getBaseUrl(this.isDebugMode) +
FlutterwaveURLS.VOUCHER_PAYMENT;
final uri = Uri.parse(url);
try {
final http.Response response = await client.post(uri,
headers: {HttpHeaders.authorizationHeader: this.publicKey},
body: payload.toJson());
ChargeResponse chargeResponse =
ChargeResponse.fromJson(json.decode(response.body));
return chargeResponse;
} catch (error) {
throw (FlutterError(error.toString()));
}
}