Account Data Retrieval

Trustly provides a solution that allows a user to sign into their Online Banking account and allow the selected ABA Routing and Account Number to be retrieved by the merchant. The merchant can then use this data in their own tokenization and processing platform.

Account ownership verification can be done using Trustly’s [front end establish] launching lightbox function and Get Account Balance . You can also optionally use the Get User to retrieve the users personally identifiable information (PII) and verify account ownership against your own data.

721721
  1. On your site, present the user to sign into Online Banking.
  2. The Trustly Lightbox opens. The user selects their bank from the list, authenticates, and selects their account.
  3. When the user has selected their account, they are returned to your returnUrl.
  4. From your back end, execute the Get Account Balance to retrieve the users bank account and routing information.
  5. Optionally use the Get User to retrieve the users PII (name, address, phone number, email address) to optionally compare the information provided by the users bank account to information previously provided. You can also optionally use this data to pre-fill information required by your user.
  6. Continue processing as needed.

Integration Options and Branding Requirements

Trustly offers two types of Integration Options for its Online Banking solution - Trustly Widget and Trustly Lightbox.

The Trustly Widget is show in-line on your page and shows the most popular bank accounts. Clicking one of the buttons on the Widget opens the Trustly Lightbox, where the User can sign in and authorize their account for use.

930930

Alternately, you can trigger the Trustly Lightbox using your own button. The Trustly Lightbox opens over your existing page.

930930

In addition to determining if the Select Bank Widget or opening the Trustly Lightbox directly is the best option for you, Trustly has a number of Branding Requirements to consider. If you have any questions or specific requirements, please work with your Trustly team or contact [email protected].

Create a Bank Authorization using Online Banking

The Trustly Online Banking Payment service enables end users to pay by signing into their online banking interface within your website. The Trustly User interaction can be completed in 3 simple steps.

502502
  1. The User selects Online Banking as a payment method on your website, which either displays the Trustly Widget (which then launches the Trustly Lightbox) or launches the Trustly Lightbox directly.
  2. From the Trustly Lightbox, the user authenticates with their bank and selects they account they wish to use for the transaction.
  3. The User is returned to you returnUrl, where you can continue processing.

To integrate the Trustly Online Banking Payment service into your website or app, you will need to do the following:

Integrate the Trustly SDK into your flow.

Trustly offers 3 SDK's: JavaScript, iOS, and Android. The SDK has 2 main methods: selectBankWidget and establish. The methods accept 2 parameters, options and establishData. The options parameter is optional and can be used to control pieces of the Lightbox experience. The establishData parameter is used pass transaction parameters to Trustly that are used when establishing the Bank Authorization transaction.

The following examples are using the JavaScript SDK

1. To load the SDK on the page, use the following JavaScript tag (replacing {accessId} with the Access Id provided to you by Trustly):

<script src="https://sandbox.trustly.one/start/scripts/trustly.js?accessId={accessId}"> </script>

2. To provide optional Trustly configuration options, create a TrustlyOptions object:

var TrustlyOptions = {
  closeButton: false,
  dragAndDrop: false,
  widgetContainerId: "widget-container-id" //Page element container for the widget
};

For details on the Trustly configuration options, refer to the SDK Specification.

3. To provide the transaction details to the SDK, create an establishData object:

var establishData = {
  accessId: {accessId},
  requestSignature: {requestSignature},
  merchantId: {merchantId},
  description: 'transaction description',
  merchantReference: 'merchant reference',
  paymentType: 'Retrieval',
  returnUrl: 'https://merchant.com/trustly/return',
  cancelUrl: 'https://merchant.com/trustly/cancel'      
};

🚧

Warning

Do not pass Consumer PII (name, email address, etc) in the description field. You can pass Consumer PII in the customer object.

πŸ“˜

Tip

Ensure you're securing your call by including the requestSignature parameter.

4. Finally, call the Trustly SDK's establish or selectBankWidget function:

Select Bank Widget

Trustly.selectBankWidget(establishData, TrustlyOptions);

Establish

Trustly.establish(establishData, TrustlyOptions);

The following is a full HTML page using the above example.

πŸ“˜

Info

You'll want to replace {accessId} and {merchantId} with the values provided to you by Trustly

<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <script>
      var TrustlyOptions = {
        closeButton: false,
        dragAndDrop: true,
        widgetContainerId: 'widget',
      };
    </script>
    <script src="https://sandbox.trustly.one/start/scripts/trustly.js?accessId={accessId}"></script>
  </head>
  <body style="margin: 0;">
    <div id="widget"></div>
  </body>
   <script>
    var establishData = {
      accessId: {accessId},
      requestSignature: {requestSignature},
      merchantId: {merchantId},
      description: 'transaction description',
      merchantReference: 'merchant reference',
      paymentType: 'Retrieval',
      returnUrl: 'https://merchant.com/trustly/return',
      cancelUrl: 'https://merchant.com/trustly/cancel'      
    };
    Trustly.selectBankWidget(establishData, TrustlyOptions);
  </script>
</html>

Handle the redirect

If the User cancels the request, Trustly will direct the User to your provided cancelUrl. If the User successfully authorizes the request, Trustly will direct the User to your provided returnUrl.

Once you get a successful redirect to your returnUrl, check to ensure you've received the Split Token and added the account on file. If you have not, add the account on file with the provided transactionId and a blank or null splitToken.

Example Cancel URL

https://merchant.com/trustly/cancel?transactionId=1002810573&transactionType=1&merchantReference=123123123456789&status=7&payment.paymentType=6&panel=1&payment.paymentProviderTransaction.status=UC01&requestSignature=W33v56Z3csgmcKIV5cbPYOB7CSw%3D

Example Return URL

https://merchant.com/trustly/return?transactionId=1002810549&transactionType=1&merchantReference=123123123456789&status=2&payment.paymentType=6&payment.paymentProvider.type=1&payment.account.verified=true&panel=1&requestSignature=68UoOfuVyEBHQB4PPdL4vtAPDoc%3D

Redirect URL Parameters

Trustly will append the following parameters to your returnUrl or cancelUrl:

ParameterDefinition
transactionIdA unique Trustly transaction identifier. (15 characters)
transactionTypeWill always be 1 in this use case.
merchantReferenceA specific merchant reference for this cancelation. For example, this could be your order number or session id.
statusInteger value representing the Transaction Status. This will either be 2 (Authorized) or 7 (Cancelled). Refer to Transaction Status Values in the SDK Specification for a complete list of values and their definitions.
payment.paymentTypeWill always be 2 (Deferred) in this use case.
payment.paymentProvider.typeWill always be 1 (Online Banking) in this use case.
payment.account.verified...
panelInteger value representing the Trustly screen the user exited the flow on.
payment.paymentProviderTransaction.statusInteger value representing the Payment Provider Transaction Status of the transaction. Refer to Payment Provider Transaction Status for a complete list of values and their definitions.
requestSignatureThis is a signature that you can calculate to ensure the request you receive is coming from Trustly. See Validate the Redirect Signature for more information.

Retrieve Bank Details or User PII from Trustly

With a valid Bank Authorization, you can use the Trustly Get Transaction API to retrieve information about the Users bank account that can be displayed in their account on your system. You can also use the Trustly Get User API to retrieve personal information (name, address, email, etc) that can be used to pre-fill fields on your flow or verify information you have already collected from the User.

Use Get Account Balance to retrieve Bank information

Calling the Get User API allows you to get the banking information selected for a given transaction. You call the Get User API by executing a GET request to the Get Transaction endpoint Get Transaction endpoint, where {transactionId} is the Bank Account Authorization transaction id. Please refer to the Get Account Balance definition in the API Reference for more information.

Example Get Account Balance API request

https://sandbox.trustly.com/api/v1/transactions/1002810549/payment/paymentProvider/account/balance

The Get Account Balance call returns a JSON response with Bank Account data that you can use in your application. Relevant fields from the response include:

  • accountBalance.account.providerId: Trustly Identifier for the Bank selected. You can use this identifier to display the Bank logo to the User.
  • accountBalance.account.nameOnAccount: Users name that is provided by the selected account.
  • accountBalance.account.name: Name (friendly identifier) of the Users Bank Account.
  • accountBalance.account.type: Type of Account selected (Checking or Savings).
  • accountBalance.account.accountNumber: Bank Account Number provided by the selected account.
  • accountBalance.account.iban: IBAN provided by the selected account.
  • accountBalance.account.routingNumber: Bank Routing Number provided by the selected account. RTN on U.S and Sort Code on Europe.

You can then use this information to display the selected Payment Method to your user and use the provided Account and Routing number in your application.

906906

Example Get Transaction response (abbreviated)

{
    "accountBalance": {
        "account": {
            "providerId": "200005501",
            "paymentProvider": {
                "paymentProviderId": "200005501"
            },
            "nameOnAccount": "John Smith",
            "name": "Demo Checking Account",
            "type": 1,
            "profile": 1,
            "accountNumber": "123456576",
            "routingNumber": "124003116",
            "verified": true,
            "verification": {
                "verified": true,
                "type": 2,
                "hasEnoughFunds": true,
                "verificationDate": 1561162678111
            }
        }
    }
}

Please refer to the Get Account Balance definition in the API Reference for more information.

Use Get User Information to retrieve, validate, and display User information

Calling the Get User API allows you to get the personal information (Account Owner name, address, phone, and email) of the User from their selected Bank Account. You call the Get User API by executing a GET request to the Get Transaction endpoint, where {transactionId} is the Bank Account Authorization transaction id.

Example Get User request

https://sandbox.trustly.com/api/v1/transactions/1002548448/payment/paymentProvider/user

The Get User call returns a JSON response with User data that you can use in your application. Relevant fields from the response include:

  • name: Name(s) associated with the Users Bank Account.
  • address: Address(es) associated with the Users Bank Account.
  • phone: Phone Number(s) associated with the Users Bank Account.
  • email: Email Address(es) associated with the Users Bank Account.

You can then use this information to pre-fill or display the Users information in your flow. You can also use this information to validate the personal information the User may have previously provided in your flow.

906906

Example Get User response (abbreviated)

{
  "user": {
    "name": [
      "John Smith",
      "Mary Smith"
    ],
    "address": [
      {
      "address1": "2000 Broadway Street",
      "address2": "",
      "city": "Redwood City",
      "state": "CA",
      "zip": "94063",
      "country": "US"
      },
      {
      "address1": "105 Alternate1 Street",
      "address2": "#401",
      "city": "Redmond",
      "state": "WA",
      "zip": "98052",
      "country": "US"
      },
    ],
    "phone": [
      "2145553434"
    ],
    "email": [
      "[email protected]"
    ],
  }
}

Please refer to the Get User definition in the API Reference for more information.

Adding support for Micro Challenge Deposits (MCD)

If your account has been enabled to process Micro Challenge Deposit (MCD) verification requests, there is an additional step you must take to finish the verification process.

Create the initial bank authorization

The initial bank authorization does not change. You pass in the same establishData object as usual.

var establishData = {
  accessId: {accessId},
  requestSignature: {requestSignature},
  merchantId: {merchantId},
  transactionId: {transactionId},
  merchantReference: 'merchant reference',
  paymentType: 'Retrieval',
  returnUrl: 'https://merchant.com/trustly/return',
  cancelUrl: 'https://merchant.com/trustly/cancel'        
};

🚧

Warning

Do not pass Consumer PII (name, email address, etc) in the description field. You can pass Consumer PII in the customer object.

πŸ“˜

Note

Ensure you're securing your call by including the requestSignature parameter.

439439 439439

Handle the redirect

Once you get a successful redirect to your returnUrl, confirm if the user needs to continue the verification process. Ensure the payment.paymentProvider.type value is 2 (Manual Entry), the status is 2 (Authorized), and the payment.account.verified is false. Because the payment.paymentProvider.type is 2 (Manual Entry) and the payment.account.verified value is false, message to the user to return to your site when they are ready to verify their account.

Retrieving the test verification code

You can use our Sandbox Merchant Portal to view the test account verification deposit code that was generated for the Bank Authorization.

1. After signing into the Sandbox Merchant Portal, find the Bank Authorization transaction your created earlier.

11731173

2. Click on the Transaction ID to bring up the details. Scroll down to the 'Account Verification Deposits' section. Copy the 'Reference Code' value.

11771177

Initiate the verification flow

The following examples are using the JavaScript SDK

1. To load the SDK on the page, use the following JavaScript tag (replacing {accessId} with the Access Id provided to you by Trustly):

<script src="https://sandbox.trustly.com/start/scripts/trustly.js?accessId={accessId}"> </script>

2. To provide optional Trustly configuration options, create a TrustlyOptions object:

var TrustlyOptions = {
  closeButton: false,
  dragAndDrop: false,
  widgetContainerId: "widget-container-id" //Page element container for the widget
};

For details on the Trustly configuration options, refer to the SDK Specification.

3. To provide the transaction details to the SDK, create an establishData object:

var establishData = {
  accessId: {accessId},
  requestSignature: {requestSignature},
  merchantId: {merchantId},
  transactionId: {transactionId},
  merchantReference: 'merchant reference',
  paymentType: 'Retrieval',
  returnUrl: 'https://merchant.com/trustly/return',
  cancelUrl: 'https://merchant.com/trustly/cancel'      
};

🚧

Warning

Do not pass Consumer PII (name, email address, etc) in the description field. You can pass Consumer PII in the customer object.

πŸ“˜

Tip

Ensure you're securing your call by including the requestSignature parameter.

4. Finally, call the Trustly SDK's establish function:

Trustly.establish(establishData, TrustlyOptions);

The following is a full HTML page using the above example.

πŸ“˜

Info

You'll want to replace {accessId} and {merchantId} with the values provided to you by Trustly

<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <script>
      var TrustlyOptions = {
        closeButton: false,
        dragAndDrop: true,
        widgetContainerId: 'widget',
      };
    </script>
    <script src="https://sandbox.trustly.com/start/scripts/trustly.js?accessId={accessId}"></script>
  </head>
  <body style="margin: 0;">
    <div id="widget"></div>
  </body>
   <script>
    var establishData = {
      accessId: {accessId},
      requestSignature: {requestSignature},
      merchantId: {merchantId},
      transactionId: {transactionId},
      merchantReference: 'merchant reference',
      paymentType: 'Retrieval',
      returnUrl: 'https://merchant.com/trustly/return',
      cancelUrl: 'https://merchant.com/trustly/cancel'      
    };
    Trustly.establish(establishData, TrustlyOptions);
  </script>
</html>

Enter the test verification code

Using the verification HTML you created above, launch the Trustly Lightbox.

439439

After entering the code retrieved from the Sandbox Merchant Portal and clicking OK, the user is directed back to your site.

Handle the redirect

Once you get a successful redirect to your returnUrl, confirm if the user is indeed verified. Ensure the payment.paymentProvider.type value is 2 (Manual Entry), the status is 2 (Authorized), and the payment.account.verified is true. If payment.account.verified is true, the account is verified.

Testing

Trustly offers a Demo Bank in the Sandbox environment that can be used to trigger a number of testing scenarios. Read more in Testing.

Error Handling

Trustly uses conventional HTTP response codes to indicate success or failure of an API request.

HTTP Status CodeDescription
200 OKEverything worked as expected.
400 Bad RequestOften due to a missing, required parameter.
401 UnauthorizedInvalid accessId or accessKey.
500 Server errorSomething went wrong on Trustly's end.
503 Service UnavailableThe server is currently unable to handle the request due to a temporary overloading or server maintenance.

Not all errors map cleanly onto HTTP response codes, however. In addition to the HTTP response code, Trustly returns an array of error objects that describes the errors as a JSON string such as the example below.

{
  "errors": [
    {
      "domain" : "com.trustly.merchantgateway.v1.exception.InvalidParameterException",
      "code" : 200,
      "message" : "Could not find a transaction using Id 10000021"
    }
  ]
}
Error CodeDescription
100Internal error. An internal error (an internal database exception for example) occurred when trying to process the request.
150Remote error. A remote error (the consumer's bank interface is down) occurred when trying to process the request. This is an internal error.
200Invalid parameter error. One of the request parameters is invalid (sending an invalid amount format string for example).
300Security error. These are generic security errors that can happen when trying to process the request.
326Expired split token.
330Invalid account.
331Not enough balance.
375Access control error. These occurs when some security parameter (accessId, accessKey or requestSignature) is invalid and the request cannot be processed.
390Fraud analysis. Suspicious transaction or negative data.

Further Reading


Did this page help you?