Mobile web
The Trustly mobile web integration allows you to securely build a bank authorization workflow in your app when your tech stack (such as Flutter, Xamarin, or MAUI) does not support the Trustly iOS or Android SDKs. Integrate the Select Bank Widget or the Trustly Lightbox using the device’s secure system browser instead of an embedded WebView to handle bank OAuth constraints and retrieve bank authorization data.
If you need help with your integration, contact your Trustly representative or send your request to us.integrations@trustly.com.
Trustly recommends using the Trustly iOS, Android, or React Native SDKs to integrate the Trustly UI within mobile applications. Use the Trustly mobile web integration only if your development framework does not support these SDKs.
Prerequisites
- Trustly merchant credentials: An active merchant account with your assigned
accessIdandmerchantId. - Secure backend infrastructure: A server environment capable of generating HMAC-SHA256 request signatures and handling URL-safe Base64 encoding.
- Mobile deep link configuration: The mobile application launching the in-app browser session must have at least one Universal Link (iOS) or App Link (Android) configured to return customers from the bank’s OAuth login back to the mobile application. To learn more, see Allowing Apps and Websites to Link to Your Content (iOS) and Handling Android App Links (Android).
Integration workflow
The transaction lifecycle uses a secure exchange between your application, your backend server, and the Trustly API.
Build and encode the request payload
Assemble the required transaction parameters on your backend. Serialize the data into a UTF-8 JSON string, and convert it into a URL-safe Base64 security token.
Structure dot-notation properties (such as customer.address.country) as nested JSON objects prior to Base64 encoding.
Required parameters
Required object structures
metadata: Must containdeepLinkUrl,trustlyContext, andintegrationContext.customer: Must containnameand a nestedaddressobject containingcountry.
Xamarin implementation example (C#)
Flutter implementation example (Dart)
Configure the environment URL and presentation options
Route your requests to the appropriate environment by adding the corresponding endpoint to your application configuration:
- Sandbox:
https://sandbox.paywithmybank.com/frontend/mobile/establish - Production:
https://trustly.one/frontend/mobile/establish
Control the presentation of the bank selection screen by appending the widget parameter to your configuration URL:
widget=true: Renders the Bank Selection Widget followed by the Checkout Lightbox.widget=false: Bypasses the widget and renders the Checkout Lightbox directly.
Launch the secure system browser session
Launch the finalized URL combining the base endpoint, the widget parameter, and the token parameter (containing your URL-safe Base64 string) using a secure system browser session based on your development stack.
- Flutter: Use an in-app browser plugin supporting system-level sheets (such as
flutter_custom_tabsorurl_launcherconfigured for an in-app view). - Xamarin / MAUI: Utilize the
WebAuthenticatorAPI fromMicrosoft.Maui.AuthenticationorXamarin.Essentials. - React Native: Use a library that wraps authentication sessions, such as
expo-web-browserorreact-native-inappbrowser-reborn. - iOS: Use
ASWebAuthenticationSession. - Android: Use a
CustomTabsIntentsession (Chrome Custom Tabs).
iOS example
Android example
Process the redirect and verify signatures
When Trustly triggers the deep link back to your app, intercept the incoming URL and extract the query parameters to update your system state.
Example redirect link
Parameters to extract
status: The final checkout status. A value of2indicates success.transactionId: Trustly’s unique tracking identifier for this specific transaction.trustlyContext: The persistent user session token.
Manage user sessions with trustlyContext
The trustlyContext parameter identifies returning users to streamline subsequent checkouts. Determine the appropriate value for your backend payload using this logic:
- First transaction (No prior session):
"new" - Subsequent transactions (Returning user): Pass the last saved
trustlyContextstring
Session lifecycle management
To ensure optimal recognition of returning users, implement this four-step lifecycle process in your application:
- Transmit: Pass the current
trustlyContexttoken in themetadatapayload of every initialization request. - Capture: Extract the
trustlyContextstring from the incoming redirect URL query parameters. - Persist: Save the extracted token locally in secure device storage for future checkouts.
- Fallback: Retain your existing local token if an inbound redirect does not provide a new
trustlyContextparameter. Do not manually modify the token value.