Skip to Content
Docs

PayCheckout

Reference for the iOS checkout's methods, and the session, payment method, and saved payment method types they use.

PayCheckout is the headless checkout for one payment or setup session. It runs on the main actor. The module doesn't re-export PayCore. To name PayResult, PayError, or PaymentIDs, also import PayCore.

import PayCheckout

let checkout = try await PayCheckout(clientSecret: clientSecret, configuration: .init(returnURL: returnURL))
let methods = checkout.paymentMethods()
let result = try await checkout.pay(.card(cardFields), presenter: self)

Methods

A PayCheckout has these methods and properties.

MemberWhat it does
PayCheckout(clientSecret:configuration:)Starts a checkout by validating the client_secret and loading the session.
session, configurationThe session the checkout loaded, and the configuration you passed.
paymentMethods(), acceptedCardBrandsThe payment methods and card brands the session accepts.
pay(_:presenter:)Pays with the card fields, an alternative method, a saved method, or an Apple Pay payment.
refreshSession()Reads the amount and currency again, after your server changed them.
PayCheckout.handleReturn(_:)Takes the URLs your app is opened with, so redirects that come back to it finish.
canPayWithApplePay(_:), payWithApplePay(_:presenter:termsAccepted:)Tells whether to offer Apple Pay, and pays with it.
applePayPaymentRequest(_:)Builds the session's Apple Pay request, for your own PassKit code.
savedPaymentMethods()The customer's saved methods in a setup session, or the saved methods a sale or authorization session can pay.
requiresCVC(for:)Whether paying a saved card needs its CVV.
removeSavedPaymentMethod(_:)Deletes one of them.

Single-method types are documented on each method's page (PayCheckout.Configuration on Start a checkout, PayPaymentRequest on Pay, and PayApplePayConfiguration on Pay with Apple Pay).

PaySession

checkout.session describes the session the checkout loaded, with the amount and currency the SDK last read:

PropertyTypeDescription
idStringThe session's ID.
kindPaySession.Kind.sale (charge now), .authorization (authorize now, capture later from your server), .setup (save a payment method without paying), or .unknown, a flow this SDK doesn't recognize. It may charge, so its total is checked as a sale's is.
amountString?The amount as the client API sends it (a decimal string in major units, for example "10.00"). This differs from the minor units you send when you create the session.
currencyString?ISO 4217 alpha-3 currency code.
isLiveBoolWhether the session is live.
expiresAtDate?When the client_secret stops working.
setupFutureUsageString?The session's setup_future_usage (on_session or off_session), when set.
isRecurringBooltrue for a recurring session, whose card is always kept for later charges.
isPayoutBooltrue for a setup session your server created with payout: true, where the customer chooses where payouts go. See Let customers choose a payout method.

PayPaymentMethod

A payment method the session accepts, from paymentMethods(). The drop-in's beforePay receives one too.

PropertyTypeDescription
typeStringThe API's payment method type, such as card, applepay, googlepay, paypal, or ideal.
kindPayPaymentMethod.Kind.card, .wallet (applepay and googlepay), or .alternative (every other type).

PaySavedPaymentMethod

A payment method saved for the customer, from savedPaymentMethods(). It's Identifiable by its id, and Hashable.

PropertyTypeDescription
idStringThe saved method's ID.
typeStringIts type, for example card, us_bank_account, paypal, or cashapp.
isDefaultBooltrue for the customer's default method.
cardPaySavedPaymentMethod.Card?Card details (brand as the API names it, last4, expiryMonth, expiryYear, and issuerName, the issuing bank's name when Pay.com knows it, each a String?). Its cardBrand is the brand as a PayCardBrand, for a PayCVCField's brand.
bankAccountPaySavedPaymentMethod.BankAccount?Bank account details (bankName, last4, country, and currency, each a String?).
emailString?The account's email, for methods that have one, such as PayPal.
details[String: String]The method's other details as the API sends them, with snake_case keys and the values as strings, for example payout: "available" on a card that can receive payouts.
Was this page helpful?