CardEncryption
public struct CardEncryption
Object used to encrypt Visa, MasterCard, and Amex cards for enrollment into the Thanx loyalty platform.
-
Declaration
Swift
public enum CardType : String -
Exception raised when the encryption fails at any point.
Values
invalidPublicKeyError during PEM public string parsing.invalidRSAEncryptionError when trying to encrypt with the RSA algorithm.malformedJsonError when creating JSON strings for the Visa payloads.invalidAESEncryptionError when trying to encrypt with the AES algorithm. Only used for Visa.
See morerequiredUidError when the user id is required for encryption. Only used for Visa.Declaration
Swift
public enum EncryptionError : Error -
Initializes the encryptor object with the card type and the public key of the specific provider.
Throws
Fails withEncryptionErrorwhen the public key is invalid or cannot be parsed.Declaration
Swift
public init(type: CardType, publicKey: String) throwsParameters
typeThe type of card.
publicKeyThe 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 withEncryptionErrorwhen the public key is invalid or cannot be parsed.Declaration
Swift
public init(type: CardType, publicKey: String, uid: String? = nil) throwsParameters
typeThe type of card.
publicKeyThe PEM public key as string used to encrypt the card numbers.
uidThe UID to link the card to. Only for Visa.
-
Encrypts the card number
Declaration
Swift
public func encrypt(number: String) throws -> StringParameters
numberThe card number.
Return Value
The encrypted card number or payload to be used for the Thanx card enrollment.
CardEncryption Structure Reference