makePayment static method
Function to make a new payment. Returns a CyberpayResult class.
Implementation
static Future<CyberpayResult> makePayment({
required String integrationKey,
required double amount,
required String customerEmail,
required bool liveMode,
}) async {
final Map<String, dynamic> params = <String, dynamic>{
"integrationKey": integrationKey,
"amount": amount,
"customerEmail": customerEmail,
"liveMode": liveMode
};
try {
final String? result = await _channel.invokeMethod('checkout', 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);
}
}