CardEncryptor

public final class CardEncryptor

An object that provides static methods for encrypting card information and retrieving public keys from the server.

  • Contains the information of a card that is yet to be encrypted.

    See more

    Declaration

    Swift

    public struct Card
  • Contains encrypted card information.

    See more

    Declaration

    Swift

    public struct EncryptedCard
  • Encrypts a card.

    Throws

    CardEncryptor.Error.encryptionFailed if the encryption failed, maybe because the card public key is an invalid one, or for any other reason.

    Throws

    CardEncryptor.Error.invalidEncryptionArguments when trying to encrypt a card with card number, securityCode, expiryMonth, and expiryYear, all of them are nil.

    Declaration

    Swift

    public static func encryptedCard(for card: Card, publicKey: String) throws -> EncryptedCard

    Parameters

    card

    Card containing the data to be encrypted.

    publicKey

    The public key to use for encryption (format “Exponent|Modulus”).

    Return Value

    An encrypted card containing the individually encrypted fields.

  • Encrypts a card.

    Throws

    CardEncryptor.Error.encryptionFailed if the encryption failed, maybe because the card public key is an invalid one, or for any other reason.

    Throws

    CardEncryptor.Error.invalidEncryptionArguments when trying to encrypt a card with card number, securityCode, expiryMonth, expiryYear, and holderName, all of them are nil.

    Throws

    CardEncryptor.Error.unknown if encryption failed for an unknown reason.

    Declaration

    Swift

    public static func encryptedToken(for card: Card, holderName: String?, publicKey: String) throws -> String

    Parameters

    card

    Card containing the data to be encrypted.

    holderName

    The cardholder’s name.

    publicKey

    The public key to use for encryption (format “Exponent|Modulus”).

    Return Value

    A string representing the encrypted card.

  • Requests the public encryption key from Adyen backend.

    Declaration

    Swift

    public static func requestPublicKey(forToken token: String, environment: Environment, completion: @escaping Completion<Result<String, Swift.Error>>)

    Parameters

    token

    Your public key token.

    environment

    The environment to use when requesting the public key.

    completion

    A closure that handles the result of the public key request.

  • Encrypts a card. This methods encapsulates calls to requestPublicKey(forToken:environment:completion:) and encryptedCard(for:publicKey:).

    Declaration

    Swift

    public static func encryptedCard(for card: Card, publicKeyToken: String, environment: Environment, completion: @escaping Completion<Result<EncryptedCard, Swift.Error>>)

    Parameters

    card

    Card containing the data to be encrypted.

    publicKeyToken

    Your public key token.

    environment

    The environment to use when requesting the public key.

    completion

    A closure that provides you with the encrypted card, or an error when the operation fails.

  • Encrypts a card. This methods encapsulates calls to requestPublicKey(forToken:environment:completion:) and encrypt(_:publicKey:).

    Declaration

    Swift

    public static func encryptedToken(for card: Card, holderName: String?, publicKeyToken: String, environment: Environment, completion: @escaping Completion<Result<String, Swift.Error>>)

    Parameters

    card

    Card containing the data to be encrypted.

    holderName

    The cardholder’s name.

    publicKeyToken

    Your public key token.

    environment

    The environment to use when requesting the public key.

    completion

    A closure that provides you with a string representing the encrypted card, or an error when the operation fails.

Error

  • Describes the error that can occur during card encryption and public key fetching.

    See more

    Declaration

    Swift

    public enum Error : Swift.Error, LocalizedError