makePaymentWithReference static method

Future<CyberpayResult> makePaymentWithReference({
  1. required String integrationKey,
  2. required String reference,
  3. required bool liveMode,
})

Function to make a new payment, when transaction has already been initated from the server. Returns a CyberpayResult class.

Implementation

static Future<CyberpayResult> makePaymentWithReference({
  required String integrationKey,
  required String reference,
  required bool liveMode,
}) async {
  final Map<String, dynamic> params = <String, dynamic>{
    "integrationKey": integrationKey,
    "reference": reference,
    "liveMode": liveMode,
  };
  try {
    final String result = await _channel.invokeMethod('checkoutRef', params);
    var _paymentReference = '$result';
    return CyberpayResult(
        isPaymentSuccessFul: true, paymentReference: _paymentReference);
  } on PlatformException catch (e) {
    var _errorMessage = "Error: '${e.message}'.";
    return CyberpayResult(
        isPaymentSuccessFul: false, errorMessage: _errorMessage);
  }
}