MPQRParser
@interface MPQRParser : NSObject
Primary interface of the framework.
This class provide interface to parse the QRCode string to structured data, i.e. PushPaymentData
.
- It has
+parse:error:
method that do parsing as well as do validation if the string is compliance with EMVCO standard. - It also has
+parseWithoutTagValidation:error:
and+parseWithoutTagValidationAndCRC:error:
to parse the string without validating if the value is compliance with EMVCO standard.
-
Parse QR string to structured data.
It performs validation by calling
PushPaymentData.validate()
after parsingNote
Throws:MPQRError
exceptionsNote
SeeAlso: parseWithoutTagValidation(string:)Declaration
Objective-C
+ (PushPaymentData *_Nullable)parse:(NSString *_Nonnull)string error:(NSError *_Nullable *_Nullable)error;
Swift
class func parse(string: String) throws -> PushPaymentData
Parameters
string
String to parse
Return Value
Parsed
PushPaymentData
-
Parse QR string to structured data without full tag validation. It validates CRC of the provided string.
Note
SeeAlso: parseWithoutTagValidationAndCRC(string:)Declaration
Objective-C
+ (PushPaymentData *_Nullable) parseWithoutTagValidation:(NSString *_Nonnull)string error:(NSError *_Nullable *_Nullable)error;
Swift
class func parseWithoutTagValidation(_ string: String) throws -> PushPaymentData
Parameters
string
String to parse
Return Value
Parsed
PushPaymentData
-
Parse QR string to structured data without full tag and crc validation
Note
Throws:MPQRError
exceptionsDeclaration
Objective-C
+ (PushPaymentData *_Nullable) parseWithoutTagValidationAndCRC:(NSString *_Nonnull)string error:(NSError *_Nullable *_Nullable)error;
Swift
class func parseWithoutTagValidationAndCRC(_ string: String) throws -> PushPaymentData
Parameters
string
String to parse
Return Value
Parsed
PushPaymentData
-
Read next
TLV
from the stringNote
Throws:MPQRError.invalidFormat
exception if length field is not numericDeclaration
Objective-C
+ (TLV *_Nullable)readNextTLV:(NSString *_Nonnull)string start:(NSInteger)start tagType:(Class<Tag> _Nonnull)tagType error:(NSError *_Nullable *_Nullable)error;
Parameters
string
String to read from
start
Index from which to start reading
tagType
Type of the tag to read for
Return Value
Parsed
TLV
-
Parse
AdditionalData
from stringNote
SeeAlso:readNextTLV(string:, start:, tagType:)
Declaration
Objective-C
+ (AdditionalData *_Nullable)parseAdditionalData:(NSString *_Nonnull)string error:(NSError *_Nullable *_Nullable) error;
Swift
class func parseAdditionalData(_ string: String) throws -> AdditionalData
Parameters
string
String to parse
Return Value
Parsed
AdditionalData
-
Read substring
Note
Throws:MPQRError.invalidFormat
if there are not enough characters to be read based on end indexDeclaration
Objective-C
+ (NSString *_Nullable)readSubstring:(NSString *_Nonnull)string start:(NSInteger)start end:(NSInteger)end error:(NSError *_Nullable *_Nullable)error;
Swift
class func readSubstring(_ string: String, start: Int, end: Int) throws -> String
Parameters
string
String to read from
start
Start index of the substring inclusive
end
End index of the substring exclusive
Return Value
Substring