24min

Truelayer Payments API Plugin

Link to plugin page: https://zeroqode.com/plugin/truelayer--1603890102683x450263958728849300​

Introduction

TrueLayer Platform is integrated with UK and EU banks which offer Payment Initiation APIs and provides a single public API that enables clients to request payment via all integrated banks. With this plugin, users can manage payments through Truelayer directly from the Bubble app.

Prerequisites:

You must have a Truelayer developer account to interact with the plugin, which you can easily create here. After that, you can already fully test the Truelayer Payments plugin in a sandbox environment.

At the launch, the plugin supports UK payments (GBP currency) only.

Note: To use the Truelayer Payments plugin in a production (live) environment, you would also have to be approved for access to the Payments API by the Truelayer team.

How to setup

I. Getting the identifiers for the plugin

  1. Signup or login to the Truelayer developer console
  2. Go to App Settings and copy identifiers (client_id/client_secret) to be used for plugin settings
Document image



II. Setting up the keys in plugin settings

  1. Fill in the plugin settings fields with respective keys from the Truelayer console
Document image

Plugin Actions

PAYMENT: Generate Payments Token - generates the payments api access token for the api calls.

Document image

Action properties:

  • environment: can be either Sandbox or Live. Choose the environment you want from the dropdown.



Plugin Action Calls

For every API Call you have to indicate the following proprieties (environment -sandbox or live), for Create Single Immediate Payment (GBP), Get Single Immediate Payment Statuses, and Get Single Immediate Payment Info API calls you also have to provide the following parameter:

environment: fill it in with ‘-sandbox’ when working in a Sandbox environment, or leave it blank when working in a Live environment

Authorization: string in the following format:

Bearer <access token value>

Use the access token you got from PAYMENT: Generate Payments Token action earlier:

Document image



Besides these, for each API call, you have to fill in other properties. Refer to each call properties documentation for more details

List of API Calls

  • Get providers (for single immediate payment) - Use this call to get information about the active banks and/or to get assets for the bank selection screen
  • Create Single Immediate Payment (GBP) - Use this call to create immediate payment (in GBP)



Properties:

- amount: the amount of money you are requesting in pennies (mandatory)

- currency: the currency code of the payment in three characters (mandatory, currently only GBP is supported)

- remitter_reference: the reference that will appear on the sender’s bank statement. Note: this can only be 18 characters or less (mandatory)

- beneficiary_name: the name on the receiving account (mandatory)

- beneficiary_sort_code: the sort code of the payer, specify this if you want to lock the account from which the payment is being made if the account is a UK account (mandatory)

- beneficiary_account_number: the account number of the receiving account if the account is a UK account (mandatory)

- beneficiary_reference: the reference that will appear on your bank statement. Note: this can only be 18 characters or less (mandatory)

- redirect_uri: the URL the user should be redirected to after authorizing the payment (mandatory)

  • Get Single Immediate Payment Info - Use this call to poll the payment resource to see if the status has been modified. This allows the application to know if the payment was successful or not
  • Get Single Immediate Payment Statuses - Use this call to see all known states of your payment and trace your payment with the timestamps





Plugin States

Returned values:

error: in case of error, will contain the error message

access_token: access token to be used for all your subsequent calls to Truelayer Payments API

expires_in: the number of seconds until the access token expires





Workflow example

I. Authentication flow

  1. Create the login workflow. (You can connect it to a Bubble button or any other element, if applicable. On our demo page we connected it to the ‘Login’ button).
  2. In this workflow, run the plugin action ‘PAYMENT: Generate Payments Token’, setting the right environment for your app:
Document image

3. Save the access token obtained in the previous step, for later use in API calls:

Document image

II. Logout flow

  1. Add to your page a button that will trigger the Logout workflow. (Or set it to be triggered in another way, if applicable. On our demo page it is the ‘Logout’ button).
  2. Add the following workflow triggered by the above button:

- step 1:

Log the user out

- step 2:

Clear all the necessary states. For example, on our demo page, we clear the payment_id and

payment_status states:

Document image

III. Create a Single Immediate Payment flow

The Create Single Immediate Payment workflow should include 2 following steps:

  1. Create a Single Immediate Payment (GBP) API call.

Make sure to set all the required fields. Also, make sure to use for redirect_uri the URL where you want the user to be redirected after the payment has been authorized:

Document image

2. Open an external website. Make sure to use as the destination the result’s auth_uri obtained in the previous step:

Document image

Demo to preview the settings



Updated 10 Jun 2022
Did this page help?
Yes
No