BTPaymentMethodNonceParser

@objcMembers
public class BTPaymentMethodNonceParser : NSObject

A JSON parser that parses BTJSON into concrete BTPaymentMethodNonce objects. It supports registration of parsers at runtime.

BTPaymentMethodNonceParser provides access to JSON parsing for different payment options without introducing compile-time dependencies on payment option frameworks and their symbols.

  • The singleton instance

    Declaration

    Swift

    @objc(sharedParser)
    public static let shared: BTPaymentMethodNonceParser
  • An array of the tokenization types currently registered

    Declaration

    Swift

    public var allTypes: [String] { get }
  • Indicates whether a tokenization type is currently registered

    Declaration

    Swift

    public func isTypeAvailable(_ type: String) -> Bool

    Parameters

    type

    The tokenization type string

    Return Value

    A bool indicating if the payment method type is available.

  • Registers a parsing block for a tokenization type.

    Declaration

    Swift

    public func registerType(_ type: String?, withParsingBlock: @escaping (_ json: BTJSON?) -> BTPaymentMethodNonce?)

    Parameters

    type

    The tokenization type string

    withParsingBlock

    jsonParsingBlock The block to execute when parseJSON:type: is called for the tokenization type. This block should return a BTPaymentMethodNonce object, or nil if the JSON cannot be parsed.

  • Parses tokenized payment information that has been serialized to JSON, and returns a BTPaymentMethodNonce object.

    The BTPaymentMethodNonce object is created by the JSON parsing block that has been registered for the tokenization type.

    If the type has not been registered, this method will attempt to read the nonce from the JSON and return a basic object; if it fails, it will return nil.

    Declaration

    Swift

    public func parseJSON(_ json: BTJSON?, withParsingBlockForType type: String?) -> BTPaymentMethodNonce?

    Return Value

    A BTPaymentMethodNonce object, or nil if the tokenized payment info JSON does not contain a nonce