VGSPaymentCards

@MainActor
final public class VGSPaymentCards

Class responsible for storing and managing Payment Card definitions used by the SDK.

  • Provides predefined payment card models (Visa, Mastercard, Amex, etc.).
  • Supports adding custom payment card models (regex & format pattern based).
  • Allows configuring behaviour and validation for unknown brands through VGSPaymentCards.unknown.

CardBrand Enum Cases

  • Supported card brands handled by the SDK.

    Note

    .custom(brandName:) can be used to add developer-defined brands; ensure brandName uniqueness.
    See more

    Declaration

    Swift

    public enum CardBrand : Equatable, Sendable

Payment Card Models

Unknown Payment Card Model

Custom Payment Card Models

  • Array of custom payment card models.

    Important

    Order impacts brand detection priority. Earlier entries are matched first.

    Declaration

    Swift

    @MainActor
    public static var cutomPaymentCardModels: [VGSCustomPaymentCardModel]
  • Explicit list of valid brands (predefined + custom) to be used for detection. If nil, availableCardBrands is used.

    Important

    Order impacts brand detection priority.

    Declaration

    Swift

    @MainActor
    public static var validCardBrands: [VGSPaymentCardModelProtocol]?

Attributes

  • Returns the payment card model for a specific brand from currently available models.
    

    Declaration

    Swift

    @MainActor
    static func getCardModelFromAvailableModels(brand: VGSPaymentCards.CardBrand) -> VGSPaymentCardModelProtocol?

    Parameters

    brand

    Brand to look up.

    Return Value

    VGSPaymentCardModelProtocol? matching model or nil if not available.

  • Detects card brand from raw PAN input by evaluating regex of available models in priority order.
    

    Declaration

    Swift

    @MainActor
    static func detectCardBrandFromAvailableCards(input: String) -> VGSPaymentCards.CardBrand

    Parameters

    input

    Raw card number string (digits only or may include spacing which should be sanitized before detection).

    Return Value

    Resolved CardBrand or .unknown if no regex matches.