Instant Payments

This guide provides step-by-step instructions to integrate Trustly as an instant payment method. Unlike deferred payments, Instant Pay allows for payments to be processed directly through the Trustly UI without requiring an additional backend API call. This creates a streamlined experience for users making payments in real-time, while simplifying the process of managing payment details.

Integration Flow

  1. User Selects Trustly as Payment Method and Completes Authentication

    • The user selects Trustly as their payment method on your website or app.
    • This triggers the Trustly establish method, which opens the Trustly UI for the user to authenticate and authorize payment.
  2. User Authenticates and Completes Payment

    • The Trustly UI guides the user through bank authentication and account selection.
    • The user confirms the payment directly within the Trustly UI, and Trustly processes the transaction instantly.
  3. User is Redirected to Return URL

    • Once authorized, the user is redirected to the returnUrl provided in the establish call. The transactionId is included in the redirect parameters, along with a status indicating whether the payment has been successfully processed.

Steps

Create Authorization and Payment via Trustly UI

Create a Bank Authorization for Instant Payment

  • Start by calling the establish method from the appropriate Trustly SDK for your platform (e.g. JavaScript, iOS, Android).
  • Set the parameter paymentType to the value instant in the establish Data payload along with any other relevant parameters (e.g. amount, description etc.)
  • Generate a requestSignature] to secure the payload and prevent data tampering. See securing requests.
  • The Trustly UI will be rendered, allowing the user to select and authorize their bank account.
Trustly.establish({
  paymentType: 'instant',
  amount: 100.00,
  currency: 'USD',
  returnUrl: 'https://merchant.com/trustly.com/return',
  cancelUrl: 'https://merchant.com/trustly.com/cancel',
  ...otherDetails
});

User Completes Payment via Trustly UI

  • The payment process will continue through the Trustly UI.
  • The user confirms the payment directly, and Trustly processes the transaction.

Handle Redirects

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, you can confirm the successful transaction with the transactionId provided in the redirect parameters. If the status is 7 (Cancelled), you should handle the cancellation appropriately to notify the user and possibly allow them to retry the payment.

Example Return URL

https://merchant.com/trustly.com/return?transactionId=1002633191&status=2

Trustly will append the following parameters to your returnUrl or cancelUrl. These parameters can be used in your backend to verify payment success and update the transaction status.

ParameterDefinition
transactionIdA unique Trustly transaction identifier. (15 characters)
statusInteger value representing the Transaction Status. (2 for Authorized or 7 for Cancelled)

Handle Event Notifications

Trustly sends asynchronous event notifications to your backend to deliver secure data about transactions. These notifications provide real-time updates on transaction statuses, which can be used to verify payments and update user information. Be sure to persist the transactionId securely once the transaction is completed, as it may be needed for future reference. To verify the authenticity of the notifications, use the requestSignature parameter to ensure they originate from Trustly. See the security reference page for more details.

Summary

Trustly's Instant Pay scenario enables a seamless and quick payment experience for first-time users. By integrating the Trustly UI, merchants can ensure that users can make payments efficiently without requiring backend complexity. This reduces friction and helps maintain a fluid payment experience, making it easy for both developers to implement and for users to complete transactions successfully.