encryptedToken method

Future<String> encryptedToken ({String publicKeyToken, Environment environment: Environment.TEST, String holderName, CreditCard card, DateTime generationDate })

Encrypts Card information into a single token after requesting a public token from your publicKeyToken. It requires your publicKeyToken, card and a generationDate.

Implementation

static Future<String> encryptedToken(
    {String publicKeyToken,
    Environment environment = Environment.TEST,
    String holderName,
    CreditCard card,
    DateTime generationDate}) async {
  ArgumentError.checkNotNull(publicKeyToken, 'publicKeyToken');
  ArgumentError.checkNotNull(generationDate, 'generationDate');
  ArgumentError.checkNotNull(card, 'card');
  ArgumentError.checkNotNull(card.number, 'card.number');
  ArgumentError.checkNotNull(card.securityCode, 'card.securityCode');
  ArgumentError.checkNotNull(card.expiryMonth, 'card.expiryMonth');
  ArgumentError.checkNotNull(card.expiryYear, 'card.expiryYear');

  try {
    return await _channel.invokeMethod('encryptedToken', <String, dynamic>{
      'publicKeyToken': publicKeyToken,
      'cardNumber': card.number,
      'cardSecurityCode': card.securityCode,
      'cardExpiryMonth': card.expiryMonth,
      'cardExpiryYear': card.expiryYear,
      'environment': environment.toString().split('.')[1],
      'holderName': holderName,
      'generationDate': generationDate.toIso8601String()
    });
  } catch (ex) {
    throw Exception('Could not encrypt the token from the card:$ex');
  }
}