In-app browsers

Present the Trustly Checkout

If you for any reason can not use any of the Trustly SDKs to render the Trustly Checkout in your native application it’s recommended to use a In-App Browser. Specifically, use SFSafariViewController on iOS and Chrome Custom Tabs on Android.

SFSafariViewController

  1. Import SafariServices to your ViewController.
import SafariServices
  1. Create and present an SFSafariViewController and pass your Trustly Checkout URL as parameter.
let safariViewController = SFSafariViewController(url: "<Trustly Checkout URL>", configuration: SFSafariViewController.Configuration())
present(safariViewController, animated: true, completion: nil)

Custom Chrome Tabs

  1. Add the following dependency to your app/build.gradle file:
dependencies {
    ...
    implementation "androidx.browser:browser:1.3.0"
}
  1. Create and launch a Custom Tab and pass in your Trustly Checkout URL as parameter.
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(this, Uri.parse("<Trustly Checkout URL>"));

CUSTOM URL SCHEME

Please note that when rendering the Trustly Checkout from a native app you are required to pass your application's URLScheme as an attribute to the order initiation request. By doing so, Trustly can redirect users back to your app after using external identification apps such as Mobile BankID.

It's a straightforward process; you can follow any Tutorial on iOS/iPhone/Android Custom URL Schemes. The URL scheme can be registered using the following method:

  • Include it in the "URLScheme" attribute when making an API call to Trustly.
  • It's important that the "URLScheme" attribute is only sent if the order is triggered by users from within the app.
  • For any other transaction instances (ex. desktop or interaction via mobile browser directly) the "URLScheme" attribute must not be included.
Attribute nameDescriptionTypeExample
URLSchemeThe URL scheme used to redirect users back to your appTextyourCustomURLScheme://

Example:

{
    "method": "Deposit",
    "params": {
        "Signature": "f4ThjuMqbsdG6u ... S16VbzD4h==",
        "UUID": "258a2184-2842-b485-25ca-293525152425",
        "Data": { 
            "Username": "merchant_username",
            "Password": "merchant_password",
            "Attributes": {
                "Country": "SE",
                "Locale": "sv_SE",
                "URLScheme":"myapp://"
                ...