Accept payments in your iOS app
This guide covers the whole integration: installing the SDK and showing the Cashier (this page), the payment methods and flows your customers go through (Payment methods and flows), and testing and going live (Testing and going live). For a minimal working example to copy, start with the Quick Start.
The Praxis iOS SDK lets you accept deposits and withdrawals in your iOS app with the native Praxis Cashier. This guide takes you from installation to your first payment with the predefined Cashier template.
How it works
From an implementation perspective, the integration has these parts:
- Server-side: create a cashier session for the iOS SDK with the Cashier Payment Request and send its token to your app.
- Client-side: choose the environment and show the Cashier with the token.
- Client-side: handle the result when the Cashier closes.
- Webhooks: receive the Payment Notification with the final status of each payment.
The full payment flow, with a diagram, is in the iOS SDK overview.
Implementation overview
- Install the SDK
- Choose the environment
- Create a cashier session
- Show the Cashier
- Register the return URL
- Handle the result
- Handle the webhook
Before you begin
Make sure you have:
- your Praxis merchant credentials (
merchant_id,application_keyand merchant secret) for the sandbox, from your CSM; - the iOS SDK enabled for your sandbox application (ask your CSM);
- request signing in place on your server (see Authentication);
- an iOS 17 project built with Xcode 27.2 or later.
Implement the iOS SDK
Install the SDK
Client-side
The SDK is distributed with Swift Package Manager as one product, PraxisCashier, from the public repository bitbucket.org/praxis-tech/ios-sdk.
Xcode: choose File → Add Package Dependencies…, enter the package URL below, set Dependency Rule to Exact Version with the version your CSM gives you (for example 2.0.0-beta.6), and add the PraxisCashier library to your app target.
https://bitbucket.org/praxis-tech/ios-sdk.gitPackage.swift:
dependencies: [
.package(url: "https://bitbucket.org/praxis-tech/ios-sdk.git", exact: "2.0.0-beta.6")
],
targets: [
.target(
name: "YourApp",
dependencies: [
.product(name: "PraxisCashier", package: "ios-sdk")
]
)
]Versions. The SDK is in beta: its versions are 2.0.0-beta.N. Swift Package Manager does not select a beta version through a version range, so use exact: and change the version when you update. The changelog lists every version and what changed. From 2.0.0 on, use from: "2.0.0" (Up to Next Major Version in Xcode): it takes every 2.x release, which adds features and fixes without breaking your code.
Versions before2.0.0-beta.6are withdrawnThe package no longer offers them. Use
2.0.0-beta.6or newer.
Import it where you show the Cashier:
import PraxisCashierThe SDK has no third-party dependencies.
What the package holds
The SDK ships as a compiled binary, not as source code.
Package.swiftdeclaresPraxisCashieras a binary target. When Xcode resolves the package, it downloadsPraxisCashier.xcframework.zipfromhttps://sdk.praxis.techand checks it against the SHA-256 checksum inPackage.swift. If your network or CI limits outbound traffic, allowsdk.praxis.techandbitbucket.org.- The XCFramework holds the SDK for iOS devices (
arm64) and the iOS Simulator (arm64,x86_64), its public interface and its documentation comments: Option-click anyPraxisCashiersymbol for Quick Help. - Xcode must be the version that built the release or newer: an older Xcode cannot read the interface of a newer one. Today that is Xcode 27.2.
- The framework holds its privacy manifest (
PrivacyInfo.xcprivacy). Xcode adds it to the privacy report of your app archive. Use the report for your App Store privacy details. - The package has no source code, so you cannot step into the SDK in the debugger. If your app crashes inside the SDK, send the crash report to your CSM: Praxis keeps the debug symbols (dSYMs) of each release and symbolicates SDK frames.
- The package holds
LICENSEandCHANGELOG.md.
Choose the environment
Client-side
CashierEnvironment selects the Praxis environment the Cashier talks to. The SDK has the service addresses of each environment built in; you do not configure any address, key or secret in the app.
| Value | Description |
|---|---|
| .sandbox | The Praxis sandbox, for development and testing. |
| .live | The Praxis live environment. |
#if DEBUG
let environment: CashierEnvironment = .sandbox
#else
let environment: CashierEnvironment = .live
#endifThe examples in this guide pass this environment to the Cashier.
Match the environmentUse the environment your server creates sessions in: a session created in the Praxis sandbox works only with
.sandbox, a live session only with.live.
Create a cashier session
Server-side
When the customer starts a deposit or withdrawal, your server creates a session with the Cashier Payment Request (POST /cashier/cashier), as for the Hosted Payment Page, with two extra parameters:
| Parameter | Description | Format | Required |
|---|---|---|---|
| channel | Where the session runs. Set ios_sdk. Without it, or with web, the session is a web session and the SDK ends at once with the configuration_error code. | String | Yes, for the iOS SDK |
| app_return_url | Where the customer returns to your app after a provider, APM or 3-D Secure page, for example from a bank app. A custom-scheme link (merchantapp://praxis/return) or an https Universal Link, up to 512 characters. | String | Yes, with channel: ios_sdk |
channel and app_return_url are not signed. The gt-authentication signature stays merchant_id, application_key, timestamp, intent, cid and order_id, so your signing code does not change.
{
"merchant_id": "Test-Integration-Merchant",
"application_key": "Sandbox",
"version": "1.3",
"timestamp": 1762855200,
"intent": "payment",
"currency": "EUR",
"amount": 1500,
"cid": "user-1001",
"order_id": "order-55120",
"locale": "en-GB",
"customer_data": { "country": "GB", "first_name": "John", "last_name": "Johnson", "email": "[email protected]" },
"notification_url": "https://merchant.example/praxis/notify",
"return_url": "https://merchant.example/return",
"channel": "ios_sdk",
"app_return_url": "merchantapp://praxis/return"
}The response has no redirect_url (an iOS SDK session cannot open in a browser) and returns session.channel = ios_sdk:
{
"status": 0,
"description": "Ok",
"session": {
"auth_token": "8a7sd87a8sd778ac961062c6bedddb8",
"intent": "payment",
"session_status": "created",
"order_id": "order-55120",
"currency": "EUR",
"amount": 1500,
"channel": "ios_sdk"
},
"timestamp": 1762855201,
"version": "1.3"
}Return only session.auth_token to your app:
{ "token": "8a7sd87a8sd778ac961062c6bedddb8" }Intents. payment, authorization and withdrawal are supported, and so are sessions with more than one intent (secondary_intents), which show Deposit and Withdraw tabs. Only regular cashier sessions can use the iOS SDK channel; virtual terminal, manual and payment link sessions are rejected.
Errors. Validation errors come back together: status 400, messages in description, separated by commas.
| Message | Cause |
|---|---|
| Incorrect channel | channel is not web or ios_sdk. |
| The iOS SDK is not available for your application | The iOS SDK is not enabled for the application. Contact your CSM. |
| Incorrect app return url | app_return_url is missing, or is not a custom-scheme link or an https URL with a host. |
| The iOS SDK channel is not available for this session type | The session is a virtual terminal, manual or payment link session. |
Session lifetime. A session expires 15 minutes after the Cashier first opens it. Within that time the same token can open the Cashier again, for example after your app restarts. After it, create a new session. Use a new session for each new payment.
Protect your session endpointAuthenticate your app user before you create a session, and take
cid, amount, currency and intent from your own records, not from the app. Keep your Praxis credentials on the server only.
Show the Cashier
Client-side
Show CashierView with the token. It starts the session when it appears and closes it when it disappears. onResult is called once, on the main actor, when the Cashier closes.
struct DepositButton: View {
@State private var launch: Launch?
let environment: CashierEnvironment
var body: some View {
Button("Deposit") {
Task {
do {
launch = Launch(token: try await myServer.createCashierSession())
} catch {
showSessionError(error) // your server could not create the session
}
}
}
.fullScreenCover(item: $launch) { launch in
CashierView(token: launch.token, environment: environment) { result in
handle(result)
self.launch = nil
}
}
}
}
struct Launch: Identifiable {
let id = UUID()
let token: String
}Button("Deposit") { showsCashier = true }
.cashierSheet(isPresented: $showsCashier, token: token, environment: environment) { result in
handle(result)
}let cashier = CashierViewController(token: token, environment: environment) { [weak self] result in
self?.dismiss(animated: true)
self?.handle(result)
}
present(cashier, animated: true).cashierSheet draws its own sheet chrome and turns the binding to false when the customer closes the Cashier from inside. While a payment runs, the Cashier hides its close button and refuses a swipe down.
Stored properties
CashierViewis generic over its layout. To keep one in a stored property, write the full type, for exampleCashierView<Cashier.AmountFirstLayout>.
To change features, the theme or the texts, pass a CashierConfiguration (see Configuration and Customization).
Register the return URL
Client-side
3-D Secure and provider pages open inside the Cashier, and your app needs no URL-handling code for them. When a provider page hands the customer to a bank app, the app_return_url from step 3 brings the customer back to your app, if your app registers it:
- Custom scheme (
merchantapp://praxis/return): add the scheme under Target → Info → URL Types. - Universal Link (
https://…): add the Associated Domains capability and host theapple-app-site-associationfile.
If your app does not register it, the customer switches back by hand. Either way, the Cashier reads the payment status when your app is active again. When iOS opens your app with the app_return_url, your app's URL handler (onOpenURL, application(_:open:options:) or your Universal Link handler) also receives it: ignore that URL rather than treating it as an unknown deep link. How these pages open, end and return is described in 3-D Secure and provider pages.
Handle the result
func handle(_ result: CashierResult) {
switch result.status {
case .completed, .authorized: showThankYou()
case .pending: showProcessing()
case .failed: showError(message(for: result.errorCode))
default: break // .canceled, or a status added later
}
}The statuses are .completed, .authorized, .pending, .failed and .canceled; result.errorCode says why a payment failed. The SDK returns codes, not text: map each CashierErrorCode to your own message. What each status and code means is in Results & Error Codes.
Handle the webhook
Server-side
Praxis sends the Payment Notification to your notification_url for every status change. Your handler must:
- Verify the
gt-authenticationsignature. - Be idempotent: the same notification can arrive more than once.
- Update the customer's balance only from the webhook, never from the result in the app.
Implementation checklist
Before you go live, test your integration in the sandbox with the scenarios and the implementation checklist in Testing and going live. When everything works, switch your server to live and your CashierEnvironment to .live, and repeat a payment in live.
Updated 8 days ago