CardEncryption

public struct CardEncryption

Object used to encrypt Visa, MasterCard, and Amex cards for enrollment into the Thanx loyalty platform.

  • Type of card

    Values

    visa Visa.

    mastercard MasterCard.

    amex Amex.

    See more

    Declaration

    Swift

    public enum CardType : String
  • Exception raised when the encryption fails at any point.

    Values

    invalidPublicKey Error during PEM public string parsing.

    invalidRSAEncryption Error when trying to encrypt with the RSA algorithm.

    malformedJson Error when creating JSON strings for the Visa payloads.

    invalidAESEncryption Error when trying to encrypt with the AES algorithm. Only used for Visa.

    requiredUid Error when the user id is required for encryption. Only used for Visa.

    See more

    Declaration

    Swift

    public enum EncryptionError : Error
  • Initializes the encryptor object with the card type and the public key of the specific provider.

    Throws

    Fails with EncryptionError when the public key is invalid or cannot be parsed.

    Declaration

    Swift

    public init(type: CardType, publicKey: String) throws

    Parameters

    type

    The type of card.

    publicKey

    The PEM public key as a string used to encrypt the card numbers.

  • Initializes the encryptor object with the card type and the public key of the specific provider and the user identifier. This constructor is only for Visa.

    Throws

    Fails with EncryptionError when the public key is invalid or cannot be parsed.

    Declaration

    Swift

    public init(type: CardType, publicKey: String, uid: String? = nil) throws

    Parameters

    type

    The type of card.

    publicKey

    The PEM public key as string used to encrypt the card numbers.

    uid

    The UID to link the card to. Only for Visa.

  • Encrypts the card number

    Throws

    Fails with EncryptionError when there is an error during encryption or when uid is required.

    Declaration

    Swift

    public func encrypt(number: String) throws -> String

    Parameters

    number

    The card number.

    Return Value

    The encrypted card number or payload to be used for the Thanx card enrollment.