Skip to Content
Docs

iOS SDK

Take card, Apple Pay, and redirect payments in an iOS app, in a ready-made payment sheet or your own screen with SDK-owned card fields.

The Pay.com iOS SDK takes payments in native apps. Your server creates a session, the app starts a checkout with the session's client_secret, and the SDK takes the payment:

  • A ready-made sheet, or your own screen. The drop-in shows the session's payment methods, the card form, and the Pay button in a system sheet. To build your own screen, use the headless checkout and the card fields.
  • Card fields the SDK owns. You place the card number, expiration date, CVV, and name inputs anywhere in your layout. The app never reads the card number. It gets only the validation state, the card brand, and the first 8 digits.
  • 3DS handled for you. When the issuer asks for a challenge, the SDK shows it full screen in a web view over the view controller you pass, then reads the outcome.
  • Apple Pay. The SDK builds the Apple Pay request from the session, shows the sheet, and pays with the token.
  • Redirect payment methods. Alternative payment methods that complete through a redirect or an app switch come back to your app through a return URL.
  • Saved payment methods. At checkout, the customer can pay with one of their saved cards, PayPal accounts, or bank accounts. In a setup session, they pick one of their saved methods or add one, for example to choose where their payouts go.
  • Async/await and typed errors. Calls that reach Pay.com are async, and the checkout's errors are all PayError instances. The card fields are synchronous.

The drop-in for a new customer, and for a returning one:

Illustration of the iOS drop-in for a new customer: Close, Example shop and €24.90, an Apple Pay button, "or", a Pay with list with Card selected, PayPal, and iDEAL, each with its logo, the card fields, and a Pay €24.90 button with the accepted card brands under it.Illustration of the iOS drop-in for a returning customer: Close, Example shop and €24.90, an Apple Pay button, "or", a carousel of saved methods with a Visa card in front, the name Visa ending in 4242, a Change payment method button, and a Pay €24.90 button.

Requirements

The SDK needs these versions:

RequirementVersion
iOS15 or later
Swift6 (strict concurrency), Swift tools 6.0
Package managerSwift Package Manager

The package also lists macOS 12 so its platform-independent code builds and tests on a Mac. The SDK ships for iOS, because the card fields, the drop-in, and the 3DS screens need UIKit.

Install

Add the pay-com-ios package with Swift Package Manager.

Link the products your app uses. Most apps need PayCheckout, PayCore, and PayElements, plus PayDropIn for the drop-in. PayCheckout doesn't re-export PayCore, so an app that names PayResult, PayError, or PaymentIDs must also import PayCore:

ProductWhat it contains
PayCheckoutThe headless checkout (PayCheckout and its Configuration, PaySession, PayPaymentMethod, PaySavedPaymentMethod, PayPaymentRequest, PayApplePayConfiguration, and PayCheckout.handleReturn). Depends on PayCore, PayElements, PayThreeDS, and PayCSE, but doesn't re-export them.
PayCoreShared types (PayResult, PaymentIDs, PayError, PayEnvironment, PayCardFieldKind, ClientSecret, and PaySDK).
PayElementsThe SDK-owned UIKit card inputs (PayCardNumberField, PayExpiryField, PayCVCField, and PayNameField), grouped by PayCardFields, and their style, PayFieldStyle.
PayDropInPayDropIn, a ready-made payment sheet over a PayCheckout with the Apple Pay button, a returning customer's saved methods, the card and redirect methods, the card form, the save-card switch, and the Pay button. PayDropInAppearance and PayDropInStrings change its look and its text. Depends on PayCheckout, PayCore, and PayElements.
PayThreeDSInternal module used by PayCheckout to run the 3DS Method step and 3DS challenge web views.
PayCSEClient-side encryption of card data. PayCheckout uses it when clientSideEncryption is on, and a card form of your own can use it directly. See Client-side encryption on mobile.
PayLinkOutPayLinkOut opens a checkout your server created in the browser app when the App Store's rules allow it and reports how the customer came back. Standalone product with no SDK dependencies.

How a payment works

A payment takes these steps:

  1. Your server creates a payment session with Create a payment session and sends only its client_secret to the app.
  2. The app starts a checkout with that client_secret.
  3. The app presents the drop-in, or builds its own screen from the session's payment methods, the card fields, and an Apple Pay button.
  4. The SDK sends the card or the Apple Pay token to Pay.com, runs 3DS when the session asks for it, and presents any challenge or redirect.
  5. The drop-in or pay returns a PayResult. Treat it as a hint for your UI. Your server confirms the payment with Retrieve a payment session or the payment_session.completed webhook before it fulfills the order. For a setup session, it uses Retrieve a setup session or the setup_session.completed webhook.

A setup session saves a payment method instead of paying. A payout setup session lets the customer choose where their payouts go. See Let customers choose a payout method.

Was this page helpful?