Skip to main content
Version: Lab (preview)

Apple Pay Models

The Pay Theory SDK includes several models for configuring and handling Apple Pay payments.

Configuration Models​

PTApplePaySheetConfig​

Main configuration object for the Apple Pay payment sheet.

public struct PTApplePaySheetConfig {
public var requestConfiguration: PTApplePayRequestConfig
public var transactionDetails: ApplePayTransactionDetails
public var onPaymentCompletion: ((ApplePayResponse) -> Void)?
public var onPaymentTokenizationCompletion: ((String) -> Bool)?
public var onPaymentMethodUpdate: ((PKPaymentMethod) -> PKPaymentRequestPaymentMethodUpdate)?
public var onShippingContactUpdate: ((PKContact) -> PKPaymentRequestShippingContactUpdate)?
public var onShippingMethodUpdate: ((PKShippingMethod) -> PKPaymentRequestShippingMethodUpdate)?
public var onCouponCodeUpdate: ((String) -> PKPaymentRequestCouponCodeUpdate)?
}
PropertyTypeDescription
requestConfigurationPTApplePayRequestConfigConfiguration for the Apple Pay payment request
transactionDetailsApplePayTransactionDetailsDetails for the transaction being processed
onPaymentCompletion((ApplePayResponse) -> Void)?Optional callback for handling payment completion
onPaymentTokenizationCompletion((String) -> Bool)?Optional callback for handling payment tokenization. This allows you to take this string and process the payment through your server.
onPaymentMethodUpdate((PKPaymentMethod) -> PKPaymentRequestPaymentMethodUpdate)?Optional callback for handling payment method changes
onShippingContactUpdate((PKContact) -> PKPaymentRequestShippingContactUpdate)?Optional callback for handling shipping contact changes
onShippingMethodUpdate((PKShippingMethod) -> PKPaymentRequestShippingMethodUpdate)?Optional callback for handling shipping method changes
onCouponCodeUpdate((String) -> PKPaymentRequestCouponCodeUpdate)?Optional callback for handling coupon code entry
note

The onPaymentTokenizationCompletion callback should return a boolean value. If the value is true, the payment was successful and the sheet will dismiss with a success response. If the value is false, the payment failed and the sheet will dismiss with a failure response.

note

You need to implement either the onPaymentTokenizationCompletion or the onPaymentCompletion callback, but not both.

PTApplePayRequestConfig​

Configuration for the Apple Pay payment request.

public struct PTApplePayRequestConfig {
let merchantIdentifier: String
var paymentSummaryItems: Array<PKPaymentSummaryItem>
public var supportedNetworks: Array<PKPaymentNetwork>
public var merchantCapabilities: PKMerchantCapability
public var requiredBillingContactFields: Array<PKContactField>
public var requiredShippingContactFields: Array<PKContactField>
public var billingContact: PKContact?
public var shippingContact: PKContact?
public var shippingMethods: Array<PKShippingMethod>?
public var shippingType: PKShippingType?
public var supportsCouponCode: Bool
public var applicationData: Data?
public var serviceFeeSummaryItemLabels: serviceFeeSummaryItemLabels
}
PropertyTypeDescription
merchantIdentifierStringYour Apple Pay merchant identifier
paymentSummaryItemsArray of PKPaymentSummaryItemArray of items showing payment breakdown
supportedNetworksArray of PKPaymentNetworkSupported payment networks (e.g., Visa, Mastercard)
merchantCapabilitiesPKMerchantCapabilityPayment capabilities supported by the merchant
requiredBillingContactFieldsArray of PKContactFieldRequired billing contact information fields
requiredShippingContactFieldsArray of PKContactFieldRequired shipping contact information fields
billingContactPKContact?Optional pre-filled billing contact
shippingContactPKContact?Optional pre-filled shipping contact
shippingMethodsArray of PKShippingMethod?Available shipping methods
shippingTypePKShippingType?Type of shipping (e.g., shipping, delivery)
supportsCouponCodeBoolWhether coupon codes are supported
applicationDataData?Optional additional data to pass with the payment
serviceFeeSummaryItemLabelsServiceFeeSummaryItemLabelsCustom labels for service fee display

ServiceFeeSummaryItemLabels​

Customizable labels for service fee display.

public struct serviceFeeSummaryItemLabels {
public var serviceFee: String
public var total: String
public var subtotal: String

public init(
serviceFee: String = "Service Fee",
total: String = "Total",
subtotal: String = "Subtotal"
)
}
PropertyTypeDefaultDescription
serviceFeeString"Service Fee"Label for the service fee line item
totalString"Total"Label for the total amount
subtotalString"Subtotal"Label for the subtotal amount

Transaction Models​

ApplePayTransactionDetails​

Details for the Apple Pay transaction.

public struct ApplePayTransactionDetails: Encodable {
public var accountCode: String?
public var feeMode: FeeMode
public var healthExpenseType: HealthExpenseType?
public var invoiceId: String?
public var level3DataSummary: Level3DataSummary?
public var metadata: Record<String, String>?
public var payor: Payor?
public var payorId: String?
public var receiptDescription: String?
public var recurringId: String?
public var reference: String?
public var sendReceipt: Bool
}
PropertyTypeRequiredDescription
accountCodeString?NoAccount code for the transaction
feeModeFeeModeYesFee handling mode for the transaction
healthExpenseTypeHealthExpenseType?NoType of health expense if applicable
invoiceIdString?NoAssociated invoice ID
level3DataSummaryLevel3DataSummary?NoLevel 3 processing data
metadataRecord<String, String>?NoAdditional transaction metadata
payorPayor?NoPayor information
payorIdString?NoUnique identifier for the payor
receiptDescriptionString?NoDescription for the receipt
recurringIdString?NoID for recurring payments
referenceString?NoReference identifier
sendReceiptBoolYesWhether to send a receipt

ApplePayResponse​

Enum representing possible responses from a transaction.

public enum ApplePayResponse {
case error(PTError)
case failure(FailedTransaction)
case success(SuccessfulTransaction)
}

ApplePayTokenDetails​

Details of the tokenized payment method.

public struct ApplePayTokenDetails: Encodable {
let paymentData: String
let paymentNetwork: String
let cardDisplayName: String
let cardType: String
let billingDetails: Payor
let shippingDetails: Payor
}
PropertyTypeRequiredDescription
paymentDataStringYesEncrypted payment data
paymentNetworkStringYesPayment network identifier
cardDisplayNameStringYesDisplay name for the card
cardTypeStringYesType of card used
billingDetailsPayorYesBilling contact information
shippingDetailsPayorYesShipping contact information