PayElements
Reference for the iOS SDK's card inputs, and the validation state and card brands they report.
PayElements provides the UIKit inputs that collect a card. The SDK owns what's typed into them. There's no public getter for the card number, expiration date, or CVV, and only PayCheckout reads them when it pays. Your app gets the validation state, the card brand, and the first 8 digits, through onBinChanged.
The inputs also disable copying, cutting, sharing, and dragging their contents.
| Page | What it covers |
|---|---|
| Card fields | PayCardFields, and the field views it groups (PayCardNumberField, PayExpiryField, PayCVCField, and PayNameField). |
| Style the card fields | PayFieldStyle, the look of the field views. |
PayCardFieldsState
The state of a PayCardFields, from its state property and its onChange callback, for your app to drive its own labels and buttons.
| Property | Type | Description |
|---|---|---|
number, expiry, cvc | PayFieldStatus | The status of each field. |
name | PayFieldStatus? | The name field's status, or nil when there's no name field. |
brand | PayCardBrand | The brand detected from the first digits. |
isComplete | Bool | true when every required field is valid. A name field may stay empty unless the name is required. |
PayFieldStatus
The validation status of one field, from its status property and its onChange callback.
| Case | Meaning |
|---|---|
.empty | Nothing is typed. |
.incomplete | What's typed could still become valid, for example a card number that's too short so far. |
.invalid | What's typed can't be valid, for example a card number that fails the Luhn check, an expiration date in the past, or a name without a letter. |
.valid | The field is valid. |
PayCardBrand
The card brand, detected from the number's first digits. It sets the lengths the number and the CVV must have.
| Case | Number length | CVV length |
|---|---|---|
.visa | 13, 16, or 19 | 3 |
.mastercard | 16 | 3 |
.amex | 15 | 4 |
.discover | 16 to 19 | 3 |
.diners | 14 to 19 | 3 |
.jcb | 16 to 19 | 3 |
.unionpay | 16 to 19 | 3 |
.maestro | 12 to 19 | 3 |
.unknown | 12 to 19 | 3 or 4 |
PayCardBrand(apiName:) returns the brand for a name the API sends on a saved card, such as Visa, mastercard, or american_express, and .unknown for any other name. A saved method's card.cardBrand is one already, so you need it only for a brand name from somewhere else, such as your server.