Skip to main content
Version: Live

Pay Theory Card UI Fields

This documentation covers all the SwiftUI views provided by the Pay Theory SDK for capturing card information. These views are designed to be used within a PTForm and require a PayTheory object to be provided as an environment object.

Common Requirements​

All of these views:

  • Must be used within a PTForm view hierarchy
  • Require a PayTheory object to be provided as an environment object
  • Automatically handle data binding and validation with the Pay Theory SDK

Required Fields​

The following fields are required to capture card information needed for processing payments:

  • PTCardNumber
  • PTExp
  • PTCvv
  • PTCardPostalCode

PTCardName​

A SwiftUI view that provides a text field for capturing the cardholder's name.

Usage​

PTCardName(placeholder: "Name on Card")

Properties​

PropertyTypeDefaultDescription
placeholderString"Name on Card"The placeholder text displayed when the field is empty

PTCardNumber​

A SwiftUI view that provides a text field for capturing the card number.

Usage​

PTCardNumber(placeholder: "Card Number")

Properties​

PropertyTypeDefaultDescription
placeholderString"Card Number"The placeholder text displayed when the field is empty

PTExp​

A SwiftUI view that provides a text field for capturing the card's expiration date.

Usage​

PTExp(placeholder: "MM/YY")

Properties​

PropertyTypeDefaultDescription
placeholderString"MM/YY"The placeholder text displayed when the field is empty

PTCvv​

A SwiftUI view that provides a text field for capturing the card's CVV (Card Verification Value).

Usage​

PTCvv(placeholder: "CVV")

Properties​

PropertyTypeDefaultDescription
placeholderString"CVV"The placeholder text displayed when the field is empty

PTCardLineOne​

A SwiftUI view that provides a text field for capturing the first line of the billing address.

Usage​

PTCardLineOne(placeholder: "Address Line 1")

Properties​

PropertyTypeDefaultDescription
placeholderString"Address Line 1"The placeholder text displayed when the field is empty

PTCardLineTwo​

A SwiftUI view that provides a text field for capturing the second line of the billing address (if needed).

Usage​

PTCardLineTwo(placeholder: "Address Line 2")

Properties​

PropertyTypeDefaultDescription
placeholderString"Address Line 2"The placeholder text displayed when the field is empty

PTCardCity​

A SwiftUI view that provides a text field for capturing the city of the billing address.

Usage​

PTCardCity(placeholder: "City")

Properties​

PropertyTypeDefaultDescription
placeholderString"City"The placeholder text displayed when the field is empty

PTCardRegion​

A SwiftUI view that provides a text field for capturing the region (state/province) of the billing address.

Usage​

PTCardRegion(placeholder: "State")

Properties​

PropertyTypeDefaultDescription
placeholderString"Region"The placeholder text displayed when the field is empty

PTCardPostalCode​

A SwiftUI view that provides a text field for capturing the postal code of the billing address.

Usage​

PTCardPostalCode(placeholder: "ZIP/Postal Code")

Properties​

PropertyTypeDefaultDescription
placeholderString"Postal Code"The placeholder text displayed when the field is empty

PTCardCountry​

A SwiftUI view that provides a text field for capturing the country of the billing address.

Usage​

PTCardCountry(placeholder: "Country")

Properties​

PropertyTypeDefaultDescription
placeholderString"Country"The placeholder text displayed when the field is empty

Example Usage​

Here's an example of how to use these fields together within a PTForm:

struct CardPaymentView: View {
@EnvironmentObject var payTheory: PayTheory

var body: some View {
PTForm {
VStack(spacing: 20) {
PTCardName()
PTCardNumber()
HStack {
PTExp()
PTCvv()
}
PTCardLineOne()
PTCardLineTwo()
PTCardCity()
HStack {
PTCardRegion()
PTCardPostalCode()
}
PTCardCountry()
}
}
.environmentObject(payTheory)
}
}

This example creates a complete card payment form using all the available card UI fields. Remember to provide the PayTheory object as an environment object to the PTForm for proper functionality.