- iOS
- Android
- Flutter
Version:
0.2.0 (lite-ios)The Checkout SDK takes a payment in your iOS app. It collects the card or Apple Pay, encrypts card details on the device, and submits the payment to lite. Raw card details never reach your code or your server.Choose an integration
- iOS
- Android
- Flutter
The SDK offers three ways to collect a payment method. All three use the same checkout session and return the same result.
How it works
- iOS
- Android
- Flutter
- Your server creates a checkout session with the lite API and gets back its
client_secret. - Your app passes the
client_secretto the SDK. - The SDK loads the session and shows the payment methods enabled for it.
- The customer pays with a new card, a saved card or Apple Pay.
- The SDK submits the payment and returns a result to your app.
- Your server confirms the payment before you fulfil the order.
Before you begin
- iOS
- Android
- Flutter
You need:
- A lite account with a terminal. Enable the payment methods you want to offer there: cards, and Apple Pay if you’ll offer it. A checkout session offers only the methods enabled on its terminal.
- lite API keys, kept on your server.
- A backend endpoint that creates checkout sessions.
- Xcode 15 or later, and an app targeting iOS 15 or later.
1. Create a checkout session
Your server creates a checkout session with your API key for each payment attempt. The session fixes the amount, currency, customer, and the payment methods and card networks on offer.client_secret to the app exactly as you received it. It’s a signed token (a JWT), not an ID: the SDK reads from it which session to load and which lite server to call, so any other value fails when the SDK starts. The app doesn’t use hosted_url, which is for the hosted checkout page.
amount is in minor units: 4999 is SAR 49.99. terminal_id is optional: without it, the session uses your default online terminal. To use another, send its ID: open the terminal under Acceptance → Online in the dashboard, and the ID is the last part of the page address. Include the customer’s id to offer the cards they saved before. If you send customer at all, its id is required, at least 3 characters: a customer with only an email or a name is refused with a 400. redirect_urls is required, with https URLs, even though the app never redirects to them. See Create a checkout session for every field.
Only one unexpired session can exist per order.reference, whatever its status. Creating another for the same reference returns 409 DUPLICATE_REQUEST, with or without an idempotency key. So give each new session its own order.reference, for example ORD-123456-2, and check first that the earlier attempt didn’t succeed.
MOTO sessions (processing_type: "MOTO") are not supported in the app. Create them for the web SDK only.
2. Install the SDK
- iOS
- Android
- Flutter
In Xcode, select File → Add Package Dependencies, enter the package URL, and add the If you manage dependencies in Then import it where you take payments:App privacy. With each payment, the SDK sends lite details of the device: its identifier for vendor, model, iOS version, screen size, preferred language, and time zone. The package has no privacy manifest, so include this data in your app’s privacy details in App Store Connect.
LiteSDK product to your app target:Package.swift:3. Pass the client secret to the SDK
- iOS
- Android
- Flutter
The
client_secret is a short-lived credential for this one checkout session. It lets the SDK read the session and pay it, and nothing else: it can’t read other sessions or move money elsewhere. Return it from your server to the app, and keep the session id on your server to confirm the payment later.Do not log the client_secret, and create a new session for each checkout attempt.The payment sheet and the embeddable form take the secret directly. With the Apple Pay button or the secure fields, start a Lite with it yourself. Lite runs on the main actor, so start it from your view, for example in .task:lite.phase becomes .ready once the session is loaded. It becomes .failed(message) if the secret is expired or rejected, the session is MOTO, or lite can’t be reached. With the Apple Pay button or the secure fields, show that message to the customer. The payment sheet and the embeddable form show it themselves, and don’t report it as a result: the form never calls onPayResult, so watch lite.phase for .failed, and the sheet completes with .cancelled when the customer closes it.A session that already ended still loads. phase becomes .ready, and lite.lastPayResult holds the outcome: .alreadyCompleted if the session was paid, .failure if it failed. The payment sheet and the embeddable form pass it to your callback. With the Apple Pay button or the secure fields nothing calls you, so check lite.lastPayResult once phase is .ready, and don’t show the pay controls if it’s set.4. Payment sheet and elements
- iOS
- Android
- Flutter
Payment sheet (drop-in)
LitePaymentSheet presents lite’s complete checkout over a visible UIViewController, and calls you back when it closes. A SwiftUI view has no view controller of its own: present the sheet from your window’s top view controller.Only one sheet can be on screen at a time. A second
present completes with a failure whose error code is already_presenting.Cards: the embeddable payment form
LitePaymentForm is lite’s card and saved-card checkout, placed inside your SwiftUI screen. It draws its own pay button.onPayResult:. Written as a trailing closure, the closure goes to onPrivacyClick instead, and Swift 6 refuses to compile it.Passing clientSecret starts the SDK for you. Keep one Lite for the checkout, owned by @StateObject or something with the same lifetime: don’t create one during a view update. LitePaymentForm and LiteApplePayButton are SwiftUI views: in a UIKit screen, host them in a UIHostingController.Apple Pay
LiteApplePayButton is Apple Pay as a standalone button, for a checkout you lay out yourself:lite.pay(). If the customer closes the Apple Pay sheet without paying, the button calls nothing, and your screen stays as it was.Apple Pay needs your app to carry the Apple Pay entitlement:- Create your own Apple Pay Merchant ID in your Apple Developer account: an iOS app can’t use lite’s. Then contact lite to set it on your online terminal and to exchange the payment processing certificate, so lite can decrypt your Apple Pay payments. The dashboard can’t do this for business accounts yet.
- In Apple Developer, enable Apple Pay for your app’s identifier.
- In Xcode, open your target’s Signing & Capabilities, add Apple Pay, and select that Merchant ID.
- Refresh the provisioning profile so it carries the entitlement.
merchant_identifier, and the session must return Apple Pay as ACTIVE. The SDK reads both from the session. Test Apple Pay on a physical device with a card in Wallet.Appearance and language
The payment sheet and the embeddable form are in English only and always light, whatever the device’s language or dark mode setting, and you can’t change their colours or fonts. The secure fields’ placeholders and messages are in English too, and the card number, expiry, and CVV always run left to right. To match your app’s look, use the secure fields and style them withLiteFieldStyle: see step 5.5. Secure fields (cards)
- iOS
- Android
- Flutter
Place the secure fields, add your own pay button, and call
lite.pay(). Start the session first, as in step 3.lite.isReadyToPayistruewhen the card is complete, or an enabled saved card is selected.- Place at most one field of each type for a
Lite. Keep the fields in aVStackorScrollView, not aListorLazyVStack, which clear the typed card when it scrolls away. In UIKit, useLiteCardNumberFieldView,LiteExpiryFieldView,LiteCvvFieldViewandLiteCardholderNameFieldView. onChangereportsvalid,focused,brandanderror(invalidNumber,invalidExpiry,invalidCvv), withmessageas text to show. It never includes the card data. Cardholder name is optional.- A card whose scheme the session doesn’t take is not a field error. The payment fails with
PAYMENT_METHOD_NOT_SUPPORTED, andlite.isPayLockedstaystrue, withlite.payLockMessageto show, until the card number changes. lite.pay(storeForFuture: true)also saves the new card for later payments. Pass it only with the customer’s consent.- Every field takes a
style.LiteFieldStylesets the font, the colours (text, placeholder, background, border, error, and focused border), the border width, the corner radius, the padding, and the minimum height. A field is at least 48 points high.
6. Stored instruments
- iOS
- Android
- Flutter
Cards the customer saved before are stored instruments. The payment sheet and the embeddable form list them automatically, and offer a Save card for future purchase control for a new card.With the secure fields, list them yourself after Then call
start:lite.pay() as usual, or pay one directly with lite.pay(instrumentId:). lite.selectNewCard() returns to the fields. enabledOnly: true drops cards whose scheme this session doesn’t take.Stored instruments appear when your server creates the session with the customer’s id and that customer has cards saved for later payments. A card shows only if its payment method is enabled on the session’s terminal.7. Handle the result
- iOS
- Android
- Flutter
Each payment attempt ends with a
Lite.PayResult:A second
pay() while one is running returns the same result, so a double tap pays once. Keep the checkout screen alive until the result arrives.3D Secure
3D Secure is the card issuer’s extra check, usually a one-time code. When the issuer asks for it, the SDK opens the issuer’s page itself, full screen over your app’s top view controller: you add nothing for it, but don’t present anything over it. After 10 minutes the SDK closes the page and reports.failure.If the customer closes that page, a payment already exists and waits for 3D Secure. lite fails it 15 minutes after the challenge started, and until then refuses another payment on this session. Before you offer a new attempt, look the payment up from your server with GET /payments?order_id=<order.reference>. The payment sheet and the embeddable form stay open and don’t call you back. If the customer then closes the sheet, it completes with a plain .cancelled, with no paymentId. lite.pay() returns .cancelled with paymentId.8. Clean up
- iOS
- Android
- Flutter
The payment sheet clears the card when it closes. For the embeddable form, the Apple Pay button or the secure fields, reset the SDK when the customer leaves checkout or you start again with a new session:
reset() cancels a payment in progress and clears the session, the typed card, the selected saved card and the last result.What’s new in 0.2.0
- iOS
- Android
- Flutter
- Apple Pay retries report once. If the customer tries again in the Apple Pay sheet after a failed attempt,
onResultgets only the last attempt’s result. - Instruments SDK: saving a card with Apple Pay, and renamed instrument fields. See the Instruments SDK guide.