Skip to main content
Version: Lab (preview)

Payor Class

The Payor structure in the Pay Theory SDK represents an individual who is making a payment. It encapsulates personal details and address information of the payor.

Overview​

Payor is a Swift structure that conforms to the Codable protocol. It provides a standardized way to handle payor information across the Pay Theory SDK.

Properties​

PropertyTypeDescription
phoneString?The phone number of the payor.
firstNameString?The first name of the payor.
lastNameString?The last name of the payor.
emailString?The email address of the payor.
personalAddressAddressThe personal address of the payor.

Initializer​

public init(firstName: String? = nil,
lastName: String? = nil,
email: String? = nil,
phone: String? = nil,
personalAddress: Address = Address())

Creates a new Payor instance.

Parameters​

ParameterTypeDefaultDescription
firstNameString?nilThe first name of the payor.
lastNameString?nilThe last name of the payor.
emailString?nilThe email address of the payor.
phoneString?nilThe phone number of the payor.
personalAddressAddressAddress()The personal address of the payor.

Usage Example​

let payorAddress = Address(line1: "123 Main St", city: "Anytown", region: "CA", postalCode: "12345", country: "USA")
let payor = Payor(
firstName: "John",
lastName: "Doe",
email: "john.doe@example.com",
phone: "1234567890",
personalAddress: payorAddress
)

// Accessing properties
print(payor.firstName ?? "") // Outputs: John
print(payor.personalAddress.city ?? "") // Outputs: Anytown

// Updating properties
var mutablePayor = payor
mutablePayor.email = "newemail@example.com"

Methods​

clear()​

public mutating func clear()

Clears all information in the Payor instance, resetting all properties to their default values.

Usage​

var payor = Payor(firstName: "John", lastName: "Doe")
payor.clear()
print(payor.firstName ?? "No name") // Outputs: No name