logo
Trustly Docs
BETA
Integration guide for E-commerce

How to get started with Trustly Payments for E-commerce

Provide Trustly as a payment method to customers in your checkout process.

Common scenarios

Trustly's payment integrations cover the following scenarios:

  • Accept one-time payments

  • Accept recurring payments (only available in Sweden at the moment)

  • Let customers Pay by invoice.

  • Let customers Pay by link.

  • Provide a Refund.

Common functions

API methods and notifications to implement in your e-commerce system are shown in the following table:

API method/notificationFunctionPurpose
DepositPaymentLets a customer make a one-time payment from their bank account.
RefundRefundRefunds a previous Deposit.
SelectAccountRecurring paymentLets a customer register a direct debit mandate.
ChargeRecurring paymentTo charge a customer’s bank account that has an active direct debit mandate.
CancelChargeRecurring paymentCancels a Charge transaction with a future payment date.
Pending notificationNotificationTo notify you when the user has completed all the steps in the Trustly checkout (Deposit and SelectAccount) or when a Charge request has been received.
Cancel notificationNotificationTo notify you when a Deposit, SelectAccount or Charge order has been canceled.
Credit notificationNotificationTo notify you when a Deposit or Charge has been confirmed.
Debit notificationNotificationTo notify you that a Deposit has failed, even though a credit notification has already been sent.
Account notificationNotification (Optional)To let you know the status of a direct debit mandate (active or inactive). Can also be sent for Deposits to provide additional information about the bank account that was used by the customer.

Accept a payment

Build integration for customers to make one-time payments with Trustly

Before you start

  • Make sure that you have completed Sign up and received a Trustly test account.

  • If you have a native app implementation, integrate Trustly SDKs.

Deposit flow

In a typical Deposit flow:

  1. Your customer enters the amount for payment in your checkout.

  2. Your system sends an API call to Deposit .

  3. Trustly responds with a checkout URL and OrderID.

  4. Your system redirects the customer to the Trustly checkout where they log in to their bank and authorise the payment.

  5. The customer will be redirected from the Trustly checkout to SuccessURL specified in the deposit API call.

  6. Depending on the outcome, Trustly may send these notifications:

Note: Account, Pending, Credit notifications can arrive in any order. The Account notification is not enabled by default. Contact Trustly Integration Support, if you need it.

7. Your system responds to the received notifications.

Step 1: Integrate your system with Trustly

Develop business logic according to the deposit flow.

  1. Make sure that your integration follows security requirements. See Security.

  2. When a customer chooses Trustly in your checkout, your system calls Deposit.

  3. Integrate Trustly Express. See Trustly Express API.

  4. When Trustly responds with a Trustly URL, your system presents the URL to the customer to select a bank for making the deposit.

  5. Make sure that your integration logs and handles error codes that are returned from API calls. See Error handling.

  6. Make sure that your integration responds correctly to notifications that Trustly may send out.

Step 2: Design service presentation

When your integration presents a Trustly URL to customers, the presentation must follow Trustly checkout guidelines.

Step 3: Do acceptance testing

Prior to going live, the Trustly Integration Specialist will perform Acceptance testing. Make sure your integration has passed all test cases, including:

  • Deposit API calls

  • Built-in test cases of acceptance testing: D1 to D5, and G1 to G3.

  • Verify that your app has correct responses to notifications. See Notification tool.

Step 4: Verify and go live

Follow the instructions to go live.

Refund

Build integration to refund customers with Trustly

Before you start

  • Make sure that you have completed Sign up and received a Trustly test account.

  • If you have a native app implementation, integrate Trustly SDKs.

Refund flow

In a typical Refund flow:

  1. Your system sends an API call to Refund.

  2. Trustly responds with "result" : "1" to acknowledge the call is received.

  3. Trustly checks whether the funds have been settled.

    • If the funds are not settled, Trustly will process the refund request when the funds are settled.

    • If the funds are settled, Trustly will process the refund request.

  4. Trustly sends a Payout confirmation when the funds are successfully sent from Trustly.

    Note: The Payout confirmation is not enabled by default. Contact Trustly Integration Support, if you need it.

  5. If the refund fails, Trustly will send a Credit notification.

  6. Your system responds to the received notifications.

Step 1: Integrate your system with Trustly

Develop business logic according to the charge flow.

  1. Make sure that your integration follows security requirements. See Security.

  2. Make sure that you have sufficient funds in your Trustly account. You can schedule API call to Balance to ensure that your balance is sufficient.

  3. When a customer requests a refund, you system sends a call to Refund.

  4. Make sure that your integration logs and handles error codes that are returned from API calls. See Error handling.

  5. Make sure that your integration responds correctly to Trustly notifications.

Step 2: Do acceptance testing

Prior to going live, the Trustly Integration Specialist will perform Acceptance testing. Make sure your integration has passed all test cases, including:

  • Refund API calls, both full and partial

  • Verify that your integration has the correct responses to notifications. See Notification tool.

Step 3: Verify and go live

Follow the instructions to go live.

Pay by invoice

Build integration to let customers pay by invoice

You can integrate pay by invoice as follows:

  • Build an integration to Accept one-time payments.

  • In the Deposit API calls, include an invoice ID in attribute ExternalReference.

Pay by link

Build integration to let customers pay with payment links

You can integrate pay by invoice as follows:

  • You can integrate pay by link as follows:

    • Build an integration to Accept one-time payments.

    • Your system sends payment links to customers through SMS or email.

      The link must point to a page that is hosted by you. You cannot pre-fetch the Trustly URL.

    • When the customer clicks the payment link, your system sends the Deposit API call which returns the Trustly URL where they enter bank details and pay.

    Note: Trustly URL will only be valid up to a maximum of 30 minutes before a timeout is reached.