DSCreditCard
public struct DSCreditCard
A type representation of a credit card that identifies properties of various types and can perform formatting of their numbers.
let creditCard = DSCreditCard(number: "4111111111111111")
print(creditCard.formattedNumber)
-
The type of credit card, identified as best as possible, based on a number.
Declaration
Swift
public private(set) var cardType: DSCreditCardType { get }
-
The raw credit card number.
Declaration
Swift
public private(set) var number: String { get }
-
Returns true if the card number’s brand is identifiable, and valid to those constraints, or if the brand is not identified and has a length greater than 0.
Declaration
Swift
public var isValid: Bool { get }
-
Returns the properly formatted card number if its brand is identified. (.e.g, Visa, Mastercard, etc.)
Declaration
Swift
public var formattedNumber: String { get }
-
Initializes and returns a newly allocated CreditCard based on the number.
Declaration
Swift
public init(number: String)
Parameters
number
A credit card number