Upgrade from Frames for iOS
Last updated: March 12, 2025
Follow this guide to upgrade your Frames for iOS integration to Flow for mobile.
Create a public key and a secret key from the Dashboard, with the following key scopes:
- Public key –
payment-sessions:pay
andvault-tokenization
- Secret key –
payment-sessions
To receive notifications for the payment events that may be triggered throughout the steps, configure your webhook receiver.
To prepare for the upgrade to Flow, remove all Frames code from your client-side and server-side integrations.
Remove the SDK:
Run the following command in the terminal:
1pod deintegrate
Remove any Swift code where you initialize Frames. For example:
1import Frames23let framesViewController = PaymentFormFactory.buildViewController(4configuration: configuration,5style: style,6completionHandler: completion7)89navigationController?.pushViewController(framesViewController, animated: true)
Remove all server-side API calls to the following endpoints:
post
https://api.checkout.com/payments
Update your server to create a PaymentSession
for the Flow integration:
1const createPaymentSession = async (req, res) => {2const response = await fetch("https://api.checkout.com/payment-sessions", {3method: "POST",4headers: {5Authorization: `Bearer ${secretKey}`,6"Content-Type": "application/json",7},8body: JSON.stringify({9amount: 1000,10currency: "GBP",11reference: "ORD-123A",12display_name: "Online Shop",13billing: {14address: { country: "GB" },15},16customer: {17name: "Jia Tsang",18email: "[email protected]",19},20success_url: "https://example.com/payments/success",21failure_url: "https://example.com/payments/failure",22}),23});2425const paymentSession = await response.json();26res.json(paymentSession);27};
In Xcode, go to Project > Package Dependencies and add https://github.com/checkout/checkout-ios-components
.
Configure Flow with your public key and the payment session data returned from the server:
1import CheckoutComponentsSDK23let configuration = try await CheckoutComponents.Configuration(4paymentSession: paymentSession,5publicKey: publicKey,6environment: environment,7callbacks: .init(8onSuccess: { paymentMethod, paymentID in9// Handle success10},11onError: { error in12// Handle error13}14)15)1617// Initialize the Flow for mobile payment component:18try checkoutComponentsSDK.create(.flow())
Check if the Flow component is available and render it:
1// Check if component is available2if component.isAvailable {3return component.render()4} else {5return nil6}
You can use Flow to handle payment methods that require a redirect (asynchronous payments) and those that do not (synchronous payments).
Depending on the payment outcome, customers are redirected to the success_url
or failure_url
you specified when you created the PaymentSession
.
We send a webhook to your server notifying you of changes to the payment's status. Wait for the webhook callback before you trigger your order fulfillment process.
For payments submitted with Flow, the PaymentSession
ID is returned in the webhook payload's data.metadata.cko_payment_session_id
field.
Optionally, you can retrieve the payment result using the callbacks provided by Flow:
onSuccess
for successful paymentsonError
for unsuccessful payments
For payment methods that do not require a redirect, use the onSuccess
callback to handle payments. You can use this to notify the customer of the payment status.
1let callbacks = CheckoutComponents.Callbacks(onSuccess: { paymentMethod, paymentID in2// Payment with ID: paymentID has gone through successfully3}45let configuration = CheckoutComponents.Configuration(callbacks: callbacks)
Use our test cards to simulate different payment flows, to ensure your integration is set up correctly and behaving as expected.
Information
Ensure that you test each payment method that you plan to offer to your customers.
You can check the status of a payment from the Payments > Processing > All payments screen in the Dashboard.
You can use Flow for mobile to natively offer Apple Pay payments.
To upgrade from your Apple Pay Frames integration:
- Remove any
PKPayment
related code from your Frames implementation. For Example:
1func handle(payment: PKPayment) {2// Create a CheckoutAPIClient instance with your public key.3let checkoutAPIClient = CheckoutAPIClient(4publicKey: "PUBLIC_KEY",5environment: .sandbox)67// Get the data containing the encrypted payment information.8let paymentData = payment.token.paymentData910// Request an Apple Pay token.11checkoutAPIClient.createApplePayToken(paymentData: paymentData) { result in12switch result {13case .success(let response):14print(response)15case .failure(let error):16print(error.localizedDescription)17}18}19}
- Follow the Flow for mobile instructions to accept Apple Pay payments.