Overview
The lite iOS SDK lets customers pay without leaving your app. It provides two integration options:- Payment Sheet: a complete checkout presented over your existing interface.
- Embeddable payment form: the same lite-managed checkout UI placed inside your SwiftUI layout.
How it works
- Your server creates a checkout session with the lite API and receives a session secret.
- Your app gives the session secret to the SDK.
- The SDK loads the session and displays the payment methods enabled for it.
- The customer enters or selects a payment method.
- The SDK encrypts new card data, tokenizes the payment method, and submits the payment.
- If required, the SDK presents and completes 3D Secure automatically.
- Your server confirms the final payment result before fulfilling the order.
Before you begin
You need:- A lite account with a configured channel.
- Valid lite API keys on your server.
- A backend endpoint that creates lite checkout sessions.
- Xcode and an app targeting iOS 15 or later.
Integrate the SDK
1. Install the SDK
The SDK is distributed through Swift Package Manager. CocoaPods is not supported. In Xcode, select File → Add Package Dependencies, then enter:0.0.2 and add the LiteSDK product to your application target.
If you manage dependencies in Package.swift, add:
LiteSDK to your application target:
2. Create a checkout session
Your server must create a checkout session using your lite API credentials and return its session secret to the app. Do not generate the session secret in the app and do not include your lite API keys in the application bundle.client_secret to your app, where the SDK takes it as clientSecret. Keep the session id on your server so you can confirm the payment afterwards.
The session determines the amount, currency, enabled payment methods, available card networks, and eligible saved cards. Create a new session for each checkout attempt.
3. Present the Payment Sheet
The Payment Sheet is the recommended integration. Present it from a visibleUIViewController:
already_presenting.
The available card layouts are:
4. Embed the payment form
UseLitePaymentForm when checkout must appear inside your own SwiftUI screen. Keep one Lite instance alive for the checkout:
clientSecret starts the SDK automatically. Alternatively, start it yourself and observe its state:
Lite instance during SwiftUI view updates. Use @StateObject or another owner with an equivalent lifetime.
5. Save and reuse cards
When the session contains eligible saved cards, the Payment Sheet and embeddable form display them automatically. The customer can select a saved card or enter a new one. For a new card, the form includes a Save card for future purchase control. To select it by default in the Payment Sheet:6. Handle 3D Secure
No separate 3D Secure integration is required. If authentication is needed, the SDK presents the issuer challenge in a secured in-app view and resumes payment processing when it finishes. Keep the presenting view controller and checkout screen alive until the result callback runs. Do not fulfill the order from the 3D Secure callback or redirect alone; wait for the lite payment result and verify it from your server.7. Handle the result
The completion receives aLite.PayResult:
Concurrent payment calls are coalesced into the same in-flight operation, preventing double taps from creating duplicate SDK payment attempts.
8. Confirm the payment on your server
A client-side success result is not sufficient for order fulfillment. The app can close, lose connectivity, or be modified. Always retrieve the checkout session or payment from your server and verify its final state before fulfilling the order.Enable Apple Pay
Apple Pay is not completely plug-and-play because Apple requires the host app to carry a signed Apple Pay entitlement. Before enabling Apple Pay:- Complete Apple Pay merchant onboarding with lite.
- In Apple Developer, enable Apple Pay for your app’s identifier.
- In Xcode, open your app target’s Signing & Capabilities settings.
- Add the Apple Pay capability.
- Select the Merchant ID provided during onboarding.
- Regenerate or refresh the provisioning profile so it contains the Apple Pay entitlement.
merchant_identifier returned in the lite checkout session. The SDK reads this value from the session; you do not pass it in application code.
The session must also return Apple Pay with an ACTIVE status. When applePayEnabled is true, the SDK displays Apple Pay only if the session enables it and the device can make payments using the configured card networks.
Test Apple Pay end to end on a physical device with a supported card in Wallet. Missing capabilities, a mismatched Merchant ID, or an incorrectly signed provisioning profile can prevent the Apple Pay sheet from opening.
Clean up
The Payment Sheet clears card fields when it closes. For an embeddable integration, reset the SDK when the customer abandons the checkout or when you intentionally restart with a new flow:reset() cancels the active SDK payment task and removes the loaded session, collected card fields, selected saved card, and previous result.
Test your integration
Use lite test API keys and test cards to verify:- Successful card payments.
- Declined and unsupported cards.
- 3D Secure success, failure, and cancellation.
- Processing payments.
- Saved-card display and payment.
- Saving a new card for future use.
- Payment Sheet dismissal.
- Reopening a completed session.
- Apple Pay on a correctly provisioned physical device.