merchantId property

String get merchantId

Retrieves the Merchant ID (MID) from the QR code data.

The Merchant ID (MID) is located in sub-tag 02 within the merchant information tags. The tags to be checked are 26, 27, 50, and 51. The MID is retrieved from the tag where it is found.

The MID will be returned as a string:

  • If the MID is found and is less than 15 characters, it will be right-padded with spaces to ensure it is exactly 15 characters long.
  • If the MID is 15 characters or longer, it will be returned as-is (without truncation).
  • If the MID is not found in any of the tags, an empty string is returned.

Returns:

  • A string containing the Merchant ID (MID), with any leading or trailing spaces removed. If the MID is not found, an empty string is returned.

Example:

String mid = QRISMPM(qrData).merchant.merchantId;
print(mid); // "133211213"

Implementation

String get merchantId {
  for (var tagId in _baseTagIds) {
    var merchantData = _raw['merchant_information_$tagId'];
    if (merchantData != null && merchantData['merchant_id'] != null) {
      String merchantId = merchantData['merchant_id'];
      return merchantId;
    }
  }

  return '';
}