MPQRParser

@interface MPQRParser : NSObject

Primary interface of the framework. This class provide interface to parse the QRCode string to structured data, i.e. PushPaymentData.

  • Parse QR string to structured data.

    It performs validation by calling PushPaymentData.validate() after parsing

    Note

    Throws: MPQRError exceptions

    Note

    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

    Throws: MPQRError.invalidTagValue if the crc tag value is not valid. MPQRError exceptions

    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 exceptions

    Declaration

    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 string

    Note

    Throws: MPQRError.invalidFormat exception if length field is not numeric

    Declaration

    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 string

    Note

    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 index

    Declaration

    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