initializeCardTokenizer method

Future<bool> initializeCardTokenizer (
  1. {@required String merchantID,
  2. @required String customerMobile,
  3. @required String customerEmail,
  4. String merchantRefNumber,
  5. Language language: Language.EN,
  6. Environment environment: Environment.TEST,
  7. Map<String, dynamic> customParam}
)

Initialize Card Tokenizer.

Initialize the adding new card. Returns true if it initialized fine. Throws exception if not.

merchantID sets the merchantID that you have received from Fawry. customerMobile sets the user phone number. customerEmail sets the user email. merchantRefNumber sets an optional number consists of 16 random characters and numbers. language sets the language of payment, whether English or Arabic, default English. environment sets the environment of payment, whether Test or Live, default Test. customParam sets a map of custom data you want to receive back with result data after payment.

Implementation

Future<bool> initializeCardTokenizer({
  @required String merchantID,
  @required String customerMobile,
  @required String customerEmail,
  String merchantRefNumber,
  Language language = Language.EN,
  Environment environment = Environment.TEST,
  Map<String, dynamic> customParam,
}) async {
  // Check customerMobile and customerEmail not equals null.
  assert(customerMobile != null && customerEmail != null, "You should set customerMobile and customerEmail.");

  try {
    return await _channel.invokeMethod(_METHOD_INITIALIZE_CARD_TOKENIZER, <String, dynamic>{
      'merchantID': merchantID,
      'customerMobile': customerMobile,
      'customerEmail': customerEmail,
      'merchantRefNumber': merchantRefNumber,
      'language': language.toString(),
      'environment': environment.toString(),
      'customParam': customParam,
    });
  } on PlatformException catch (e) {
    if (e.code == _ERROR_INITIALIZE_CARD_TOKENIZER)
      throw "Error Occurred: Code: $_ERROR_INITIALIZE_CARD_TOKENIZER. Message: ${e.message}. Details: SDK Initialize Card Tokenizer Error";
    throw "Error Occurred: Code: ${e.code}. Message: ${e.message}. Details: ${e.details}";
  } catch (e) {
    throw "Error Occurred: $e";
  }
}