panMerchantMethod property

PANMerchantMethod get panMerchantMethod

Determines the Merchant Payment Method based on the 9th character of the PAN.

The 9th character (index 8) of the PAN is used to determine the Merchant's payment method, which could represent Debit, Credit, Electronic Money, or a reserved method for future use.

Returns:

Implementation

PANMerchantMethod get panMerchantMethod {
  final panCode = pan;
  if (panCode.isNotEmpty && panCode.length >= 9) {
    final code = int.tryParse(panCode[8]);
    switch (code) {
      case 0:
        return PANMerchantMethod.unspecified;
      case 1:
        return PANMerchantMethod.debit;
      case 2:
        return PANMerchantMethod.credit;
      case 3:
        return PANMerchantMethod.electronicMoney;
      default:
        return (code != null && code >= 4 && code <= 9)
            ? PANMerchantMethod.rfu
            : PANMerchantMethod.unspecified;
    }
  }
  return PANMerchantMethod.unspecified;
}