panWithCheckDigit property

String get panWithCheckDigit

Retrieves the Merchant PAN (Primary Account Number) with the check digit appended.

The Merchant PAN is first extracted using the pan getter, and if available, the check digit is calculated and appended to the PAN. This provides the full PAN, including the Luhn check digit.

PAN Validation:

  • The base PAN (retrieved from the pan getter)
  • If the base PAN is valid, the check digit is appended to the PAN.
  • If the base PAN is invalid, the base PAN is returned without appending the check digit.
  • If the base PAN is not available, an empty string ('') is returned.

Check Digit Calculation:

  • The check digit is computed using the Luhn algorithm and ensures the validity of the full PAN when used for processing.

Returns:

  • The full Merchant PAN as a string (18 digits + 1 check digit = 19 digits total), or an empty string ('') if the base PAN is not found or invalid.

Example:

String fullPan = QRISMPM(qrData).merchant.panWithCheckDigit;
print(fullPan); // "9360088600000000423" if valid, or an empty string if not found or invalid.

Implementation

String get panWithCheckDigit {
  if (pan.isNotEmpty) {
    final digit = pan.calculateCheckDigit();
    final valid = isPanValid();
    if (!valid) {
      return pan;
    } else {
      return pan + digit.toString();
    }
  }
  return '';
}