generateCardValidationData method

Future<GenerateCardValidationDataOutput> generateCardValidationData({
  1. required CardGenerationAttributes generationAttributes,
  2. required String keyIdentifier,
  3. required String primaryAccountNumber,
  4. int? validationDataLength,
})

Generates card-related validation data using algorithms such as Card Verification Values (CVV/CVV2), Dynamic Card Verification Values (dCVV/dCVV2), or Card Security Codes (CSC). For more information, see Generate card data in the Amazon Web Services Payment Cryptography User Guide.

This operation generates a CVV or CSC value that is printed on a payment credit or debit card during card production. The CVV or CSC, PAN (Primary Account Number) and expiration date of the card are required to check its validity during transaction processing. To begin this operation, a CVK (Card Verification Key) encryption key is required. You can use CreateKey or ImportKey to establish a CVK within Amazon Web Services Payment Cryptography. The KeyModesOfUse should be set to Generate and Verify for a CVK encryption key.

For information about valid keys for this operation, see Understanding key attributes and Key types for specific data operations in the Amazon Web Services Payment Cryptography User Guide.

Cross-account use: This operation supports cross-account use when the key has a resource-based policy that grants access. For more information, see Resource-based policies.

Related operations:

May throw AccessDeniedException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ThrottlingException. May throw ValidationException.

Parameter generationAttributes : The algorithm for generating CVV or CSC values for the card within Amazon Web Services Payment Cryptography.

Parameter keyIdentifier : The keyARN of the CVK encryption key that Amazon Web Services Payment Cryptography uses to generate card data.

Parameter primaryAccountNumber : The Primary Account Number (PAN), a unique identifier for a payment credit or debit card that associates the card with a specific account holder.

Parameter validationDataLength : The length of the CVV or CSC to be generated. The default value is 3.

Implementation

Future<GenerateCardValidationDataOutput> generateCardValidationData({
  required CardGenerationAttributes generationAttributes,
  required String keyIdentifier,
  required String primaryAccountNumber,
  int? validationDataLength,
}) async {
  _s.validateNumRange(
    'validationDataLength',
    validationDataLength,
    3,
    5,
  );
  final $payload = <String, dynamic>{
    'GenerationAttributes': generationAttributes,
    'KeyIdentifier': keyIdentifier,
    'PrimaryAccountNumber': primaryAccountNumber,
    if (validationDataLength != null)
      'ValidationDataLength': validationDataLength,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/cardvalidationdata/generate',
    exceptionFnMap: _exceptionFns,
  );
  return GenerateCardValidationDataOutput.fromJson(response);
}