Instant Payments

Use the information provided here to implement Trustly as a payment method. Unlike deferred payments, Instant Pay allows payments to be processed directly through the Trustly user interface (UI) without requiring a subsequent backend Application Programming Interface (API) call. This provides a streamlined, real-time payment experience for users while simplifying the payment management process.

Integration workflow

The following table outlines the sequential stages of the Instant Pay workflow.

StageUser actionSystem or API actionOutcome
ASelects Trustly as the payment method.Merchant calls the establish method.The Trustly UI (Lightbox) opens for bank authentication.
BAuthenticates with the bank, selects an account, and confirms the payment.Trustly processes the payment instantly in the background.The payment is instantly authorized and processed.
CRedirects back to the merchant's site.Trustly redirects the user to the returnUrl with the transactionId and final status appended to the Uniform Resource Locator (URL).The transaction is complete; the merchant can fulfill the order.

Create a bank authorization for instant payment

Call the establish method from the appropriate Trustly Software Development Kit (SDK) for your platform (for example, JavaScript, iOS, Android).

  • Set the parameter paymentType to the value instant in the establish Data payload along with any other relevant parameters (for example, amount, description).
  • Generate a requestSignature to secure the payload and prevent data tampering. See Securing requests.
  • The Trustly UI renders, allowing the user to select and authorize their bank account.
  • The payment process will continue through the Trustly UI.
  • The user confirms the payment directly, and Trustly processes the transaction.

The following is an example of the establish method call.

Trustly.establish({
  paymentType: 'instant',
  amount: 100.00,
  currency: 'USD',
  returnUrl: '[https://merchant.com/trustly.com/return](https://merchant.com/trustly.com/return)',
  cancelUrl: '[https://merchant.com/trustly.com/cancel](https://merchant.com/trustly.com/cancel)',
  ...otherDetails
});

Handle redirects

If the user cancels the request, Trustly directs 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 (Canceled), 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 Canceled)

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 you can use to verify payments and update user information. Be sure to persist the transactionId securely once the transaction completes, as you may need it 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.