Migrate to the latest iOS SDK version
Update to the current most recent version of the iOS SDK, which is 4.0.1.
We recommend that you update your SDK to the newest version, which is version 4.0.1. This version includes a new, smoother user experience.
This new UI currently works for GBP payments and EUR payments in Ireland. Any payments authorised with the iOS SDK in those countries will automatically use the new UI, while payments elsewhere will fall back to the old UI. You cannot customise the colours of the new UI, but you can still pass customisation values to change the appearance of the old UI when it falls back.

An example of the new Mobile SDK UI on the end user’s side.
The SDK now uses a single-screen, declarative, state-driven navigation system under the hood. If you previously relied on imperative navigation APIs like push
, pop
, and present
to handle navigating to and from the iOS SDK, we strongly recommend that you re-test your implementation to ensure that nothing is broken when you migrate.
The deprecated .redirect
success case has now been completely removed. This is a minor breaking change. Check that there are no compiler errors and update your implementation if needed.
Configure the SDK
Configure the SDK with the following:
await TrueLayer.Payments.manager.configure(environment: .sandbox)
Import the TrueLayer iOS SDK
Import the iOS SDK using import TrueLayerSDK
.
Process a payment
Below is an example of the latest implementation for payment processing.
TrueLayer.Payments.manager.processSinglePayment(
context: TrueLayer.Payments.Models.SinglePayment.Context(
identifier: // Your payment ID,
token: // Your resource token,
redirectURL: // Your redirect URL,
preferences: TrueLayer.Payments.Models.SinglePayment.Preferences(
presentationStyle: .present(on: yourViewController, style: .automatic)
)
)) { result in
switch result {
case .success(let authorizationFlowResult):
// Handle `AuthorizationFlowResult`. See below for the new handling logic.
case .failure(let error):
// Handle error. See below for the new handling logic.
}
}
This is an example of how to process a mandate:
TrueLayer.Payments.manager.processMandate(
context: TrueLayer.Payments.Models.Mandate.Context(
identifier: // Your mandate ID,
token: // Your resource token,
redirectURL: // Your redirect URL
preferences: // Your possible preferences like type of presentation and country code.
)) { processResult in
switch processResult.result {
case .success(let success):
// Handle `TrueLayer.Payments.Models.Mandate.State`.
print(success.state)
case .failure(let failure):
// Handle `TrueLayer.Payments.Models.Mandate.Error`.
print(failure.error)
}
// Handle `resultShown`.
print(processResult.resultShown)
}
We recommend that you re-invoke processSinglePayment
or processMandate
once the user is redirected from their bank back to your application.
Preferences
The implementation of the Preferences
object should look like this:
TrueLayer.Payments.Models.SinglePayment.Preferences(preferredCountryCode: "GB")
Retrieve a payment status
To retrieve a payment status, use the following:
TrueLayer.Payments.manager.singlePaymentStatus(paymentIdentifier: paymentIdentifier, resourceToken: resourceToken)
Some type
s that the SDK exposes have changed their name since version 1.x.x. This means that you may have to rename those types as well to compile the project. The full list of type changes is below.
TrueLayer.Payments.Models.SinglePayment.Context
TrueLayer.Payments.Models.SinglePayment.Preferences
TrueLayer.Payments.Models.SinglePayment.Status
TrueLayer.Payments.Models.SinglePayment.State
TrueLayer.Payments.Models.SinglePayment.Error
Handle the payment result
Result screen
In the Preferences
object, shouldShowResultScreen
is set to true
by default. This tells the SDK to display the result of a payment or mandate at the end of the authorization flow. This screen automatically refreshes until either:
- the payment is creditable
- a maximum wait time is reached.
You can customise what time this is by settingmaximumResultScreenTimeout
.
By default, this timeout happens after 10 seconds. This is also the maximum length of time that you can set in this field (inputting a higher value results in a 10-second wait time).
Some banks require further input from the user, such as one-time passwords and other SCA methods. The SDK displays screens to handle these inputs by default.
Success states
As of version 4.0.1, this is the full list of success states, alongside the events that each of them indicate. They display inside TrueLayer.Payments.Models.SinglePayment.State
.
Note that there is no longer a redirect
success state.
Success state | Description |
---|---|
.authorized | The user authorized the payment with the bank. |
.executed | The bank confirmed the payment. |
.settled | The funds have reached the destination. |
Failure reasons
As of 4.0.1, this is the full list of failure reasons. They display inside TrueLayer.Payments.Models.SinglePayment.Error
.
Failure reason | Description |
---|---|
.authorizationFailed | The authorization process failed when the user tried to connect to their bank. |
.connectionIssues | There was an issue when connecting to the internet. |
.generic | A unexpected error. This error will be passed as a String parameter. |
.invalidToken | The token used to make the payment is not authorised to do so. |
.invalidRedirectURI | The redirect URI passed to the SDK is invalid. |
.paymentExpired | The user took too long to complete the payment, so it expired. |
.paymentNotFound | The requested payment was not found. |
.paymentRejected | The payment was rejected by the bank. |
.providerOffline | The preselected provider was offline. |
.sdkNotConfigured | The SDK configure method has not been called before using it. |
.serverError | The server encountered an error while processing the answer. |
.blocked | The payment has been blocked due to a regulatory requirement. This may happen if your user fails a sanctions check. |
.invalidAccountDetails | The payment failed because either the remitter or beneficiary’s account details were invalid. |
.invalidAccountHolderName | The payment failed because the account holder name was invalid. |
.invalidCredentials | The credentials provided by the end user to log into their bank were incorrect. |
.invalidRemitterAccount | The remitter’s account details were incorrect. |
.invalidRequest | The payment failed due to invalid data in the request. |
.invalidSortCode | The end user provided an invalid sort code. |
.insufficientFunds | The end user did not have the required balance in their account to complete this payment. |
.notAuthorized | The end user cancelled the payment or wasn't able to successfully authenticate on the provider's UI. |
.paymentLimitExceeded | The end user exceeded a payment limit with their bank. |
.providerError | The provider unexpectedly failed when creating the payment. |
.providerExpired | The payment failed because the token or exchange code used to communicate with the bank expired. |
.providerRejected | The provider rejected the payment. |
.unknownError | The payment failed for an unknown reason on the server side. |
.userCanceledAtProvider | The payment failed because the user cancelled the authorisation during the payment flow. |
.unexpectedBehavior | The SDK encountered an unexpected behaviour. |
.userCanceled | The user cancelled the payment. |
Updated about 6 hours ago