JudoKit

public struct JudoKit

Entry point for interacting with judoKit

  • JudoKit local judo session

    Declaration

    Swift

    public var apiSession = Session()
  • the theme of the current judoKitSession

    Declaration

    Swift

    public var theme: Theme = Theme()
  • currently active JudoPayViewController if available

    Declaration

    Swift

    public weak var activeViewController: JudoPayViewController?
  • designated initializer of JudoKit

    Parameter

    Parameter token: a string object representing the token

    Parameter

    Parameter secret: a string object representing the secret

    Throws

    Throws JailbrokenDeviceDisallowedError: In case jailbroken devices are not allowed, this method will throw an exception if it is run on a jailbroken device

    Declaration

    Swift

    public init(token: String, secret: String, allowJailbrokenDevices: Bool) throws

    Parameters

    token

    a string object representing the token

    secret

    a string object representing the secret

    allowJailbrokenDevices

    boolean that indicates whether jailbroken devices are restricted

    Return Value

    a new instance of JudoKit

  • convenience initializer of JudoKit

    Parameter

    Parameter token: a string object representing the token

    Parameter

    Parameter secret: a string object representing the secret

    Declaration

    Swift

    public init(token: String, secret: String)

    Parameters

    token

    a string object representing the token

    secret

    a string object representing the secret

    Return Value

    a new instance of JudoKit

  • Set the app to sandboxed mode

    Declaration

    Swift

    public mutating func sandboxed(enabled: Bool)

    Parameters

    enabled

    true to set the SDK to sandboxed mode

  • A mandatory function that sets the token and secret for making payments with judo

    Parameter

    Parameter token: a string object representing the token

    Parameter

    Parameter secret: a string object representing the secret

    Declaration

    Swift

    public mutating func setToken(token: String, secret: String)

    Parameters

    token

    a string object representing the token

    secret

    a string object representing the secret

  • A function to check whether a token and secret has been set

    Returns

    a Boolean indicating whether the parameters have been set

    Declaration

    Swift

    public func didSetTokenAndSecret() -> Bool

    Return Value

    a Boolean indicating whether the parameters have been set

  • Main payment method

    Declaration

    Swift

    public mutating func invokePayment(judoId: String, amount: Amount, reference: Reference, cardDetails: CardDetails? = nil, completion: (Response?, JudoError?) -> ()) throws

    Parameters

    judoId

    The judoId of the merchant to receive the payment

    amount

    The amount and currency of the payment (default is GBP)

    reference

    Reference object that holds consumer and payment reference and a meta data dictionary which can hold any kind of JSON formatted information

    completion

    The completion handler which will respond with a Response Object or an NSError

  • Make a pre-auth using this method

    Declaration

    Swift

    public mutating func invokePreAuth(judoId: String, amount: Amount, reference: Reference, cardDetails: CardDetails? = nil, completion: (Response?, JudoError?) -> ()) throws

    Parameters

    judoId

    The judoId of the merchant to receive the pre-auth

    amount

    The amount and currency of the payment (default is GBP)

    reference

    Reference object that holds consumer and payment reference and a meta data dictionary which can hold any kind of JSON formatted information

    completion

    The completion handler which will respond with a Response Object or an NSError

  • Initiates a card registration

    Declaration

    Swift

    public mutating func invokeRegisterCard(judoId: String, amount: Amount, reference: Reference, cardDetails: CardDetails? = nil, completion: (Response?, JudoError?) -> ()) throws

    Parameters

    judoId

    The judoId of the merchant to receive the pre-auth

    amount

    The amount and currency of the payment (default is GBP)

    reference

    Reference object that holds consumer and payment reference and a meta data dictionary which can hold any kind of JSON formatted information

    completion

    The completion handler which will respond with a Response Object or an NSError

  • Initiates the token payment process

    Declaration

    Swift

    public mutating func invokeTokenPayment(judoId: String, amount: Amount, reference: Reference, cardDetails: CardDetails, paymentToken: PaymentToken, completion: (Response?, JudoError?) -> ()) throws

    Parameters

    judoId

    The judoId of the merchant to receive the payment

    amount

    The amount and currency of the payment (default is GBP)

    reference

    Reference object that holds consumer and payment reference and a meta data dictionary which can hold any kind of JSON formatted information

    cardDetails

    The card details to present in the input fields

    paymentToken

    The consumer and card token to make a token payment with

    completion

    The completion handler which will respond with a Response Object or an NSError

  • Initiates the token pre-auth process

    Declaration

    Swift

    public mutating func invokeTokenPreAuth(judoId: String, amount: Amount, reference: Reference, cardDetails: CardDetails, paymentToken: PaymentToken, completion: (Response?, JudoError?) -> ()) throws

    Parameters

    judoId

    The judoId of the merchant to receive the pre-auth

    amount

    The amount and currency of the payment (default is GBP)

    reference

    Reference object that holds consumer and payment reference and a meta data dictionary which can hold any kind of JSON formatted information

    cardDetails

    The card details to present in the input fields

    paymentToken

    The consumer and card token to make a token payment with

    completion

    The completion handler which will respond with a Response Object or an NSError

  • Starting point and a reactive method to create a transaction that is sent to a certain judo ID

    Parameter

    Parameter transactionType: The type of the transaction (payment, pre-auth or registercard)

    Parameter

    Parameter judoId: The recipient - has to be between 6 and 10 characters and luhn-valid

    Parameter

    Parameter amount: The amount of the Payment

    Parameter

    Parameter reference: The reference

    Throws

    JudoIDInvalidError judoId does not match the given length or is not luhn valid

    Throws

    InvalidOperationError if you call this method with .Refund as a transactionType

    Returns

    a Payment Object

    Declaration

    Swift

    public func transaction(transactionType: TransactionType, judoId: String, amount: Amount, reference: Reference) throws -> Transaction

    Parameters

    transactionType

    The type of the transaction (payment, pre-auth or registercard)

    judoId

    The recipient - has to be between 6 and 10 characters and luhn-valid

    amount

    The amount of the Payment

    reference

    The reference

    Return Value

    a Payment Object

  • Starting point and a reactive method to create a payment that is sent to a certain judo ID

    Parameter

    Parameter judoId: The recipient - has to be between 6 and 10 characters and luhn-valid

    Parameter

    Parameter amount: The amount of the Payment

    Parameter

    Parameter reference: The reference

    Throws

    JudoIDInvalidError judoId does not match the given length or is not luhn valid

    Returns

    a Payment Object

    Declaration

    Swift

    public func payment(judoId: String, amount: Amount, reference: Reference) throws -> Payment

    Parameters

    judoId

    The recipient - has to be between 6 and 10 characters and luhn-valid

    amount

    The amount of the Payment

    reference

    The reference

    Return Value

    a Payment Object

  • Starting point and a reactive method to create a pre-auth that is sent to a certain judo ID

    Parameter

    Parameter judoId: The recipient - has to be between 6 and 10 characters and LUHN valid

    Parameter

    Parameter amount: The amount of the pre-auth

    Parameter

    Parameter reference: The reference

    Throws

    JudoIDInvalidError judoId does not match the given length or is not LUHN valid

    Returns

    pre-auth Object

    Declaration

    Swift

    public func preAuth(judoId: String, amount: Amount, reference: Reference) throws -> PreAuth

    Parameters

    judoId

    The recipient - has to be between 6 and 10 characters and LUHN valid

    amount

    The amount of the pre-auth

    reference

    The reference

    Return Value

    pre-auth Object

  • Starting point and a reactive method to create a RegisterCard that is sent to a certain judo ID

    Parameter

    Parameter judoId: The recipient - has to be between 6 and 10 characters and LUHN valid

    Parameter

    Parameter amount: The amount of the RegisterCard

    Parameter

    Parameter reference: The reference

    Throws

    JudoIDInvalidError judoId does not match the given length or is not LUHN valid

    Returns

    a RegisterCard Object

    Declaration

    Swift

    public func registerCard(judoId: String, reference: Reference) throws -> RegisterCard

    Parameters

    judoId

    The recipient - has to be between 6 and 10 characters and LUHN valid

    amount

    The amount of the RegisterCard

    reference

    The reference

    Return Value

    a RegisterCard Object

  • Creates a Receipt object which can be used to query for the receipt of a given ID.

    The receipt ID has to be LUHN valid, an error will be thrown if the receipt ID does not pass the LUHN check.

    If you want to use the receipt function - you need to enable that in the judo Dashboard - Your Apps - Permissions for the given App

    Parameter

    Parameter receiptId: The receipt ID as a String

    Throws

    LuhnValidationError if the receiptId does not match

    Returns

    a Receipt Object for reactive usage

    Declaration

    Swift

    public func receipt(receiptId: String? = nil) throws -> Receipt

    Parameters

    receiptId

    The receipt ID as a String

    Return Value

    a Receipt Object for reactive usage

  • Creates a Collection object which can be used to collect a previously pre-authorized transaction

    Parameter

    Parameter receiptId: The receipt of the previously authorized transaction

    Parameter

    Parameter amount: The amount to be transacted

    Parameter

    Parameter paymentReference: The payment reference string

    Throws

    LuhnValidationError judoId does not match the given length or is not LUHN valid

    Returns

    a Collection object for reactive usage

    Declaration

    Swift

    public func collection(receiptId: String, amount: Amount) throws -> Collection

    Parameters

    receiptId

    The receipt of the previously authorized transaction

    amount

    The amount to be transacted

    paymentReference

    The payment reference string

    Return Value

    a Collection object for reactive usage

  • Creates a Refund object which can be used to refund a previous transaction

    Parameter

    Parameter receiptId: The receipt of the previous transaction

    Parameter

    Parameter amount: The amount to be refunded (will check if funds are available in your account)

    Parameter

    Parameter paymentReference: The payment reference string

    Throws

    LuhnValidationError judoId does not match the given length or is not LUHN valid

    Returns

    a Refund object for reactive usage

    Declaration

    Swift

    public func refund(receiptId: String, amount: Amount) throws -> Refund

    Parameters

    receiptId

    The receipt of the previous transaction

    amount

    The amount to be refunded (will check if funds are available in your account)

    paymentReference

    The payment reference string

    Return Value

    a Refund object for reactive usage

  • Creates a VoidTransaction object which can be used to void a previous preAuth

    Parameter

    Parameter receiptId: The receipt of the previous transaction

    Parameter

    Parameter amount: The amount to be refunded (will check if funds are available in your account)

    Parameter

    Parameter paymentReference: The payment reference string

    Throws

    LuhnValidationError judoId does not match the given length or is not LUHN valid

    Returns

    a Void object for reactive usage

    Declaration

    Swift

    public func voidTransaction(receiptId: String, amount: Amount) throws -> VoidTransaction

    Parameters

    receiptId

    The receipt of the previous transaction

    amount

    The amount to be refunded (will check if funds are available in your account)

    paymentReference

    The payment reference string

    Return Value

    a Void object for reactive usage

  • Creates an instance of a class that conforms to SessionProtocol. This means that anything related to Payments or PreAuths can be queried for a list

    Declaration

    Swift

    public func list<T:SessionProtocol>(type: T.Type) -> T

    Parameters

    type

    the type

    Return Value

    a new instance that can be used to fetch information