encryptedCard method

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

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

Implementation

static Future<CreditCard> encryptedCard(
    {String publicKeyToken,
    Environment environment = Environment.TEST,
    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 {
    final Map<dynamic, dynamic> results =
        await _channel.invokeMethod('encryptedCard', <String, dynamic>{
      'publicKeyToken': publicKeyToken,
      'cardNumber': card.number,
      'cardSecurityCode': card.securityCode,
      'cardExpiryMonth': card.expiryMonth,
      'cardExpiryYear': card.expiryYear,
      'environment': environment.toString().split('.')[1],
      'generationDate': generationDate.toIso8601String()
    });
    var encryptedNumber = results['encryptedNumber'];
    var encryptedSecurityCode = results['encryptedSecurityCode'];
    var encryptedExpiryMonth = results['encryptedExpiryMonth'];
    var encryptedExpiryYear = results['encryptedExpiryYear'];
    return CreditCard(
        number: encryptedNumber,
        securityCode: encryptedSecurityCode,
        expiryMonth: encryptedExpiryMonth,
        expiryYear: encryptedExpiryYear);
  } catch (ex) {
    throw new Exception("Could not encrypt the card from the input card:$ex");
  }
}