Skip to Content
Docs

Set up recurring payments

Authorize a Trustly Direct Debit mandate and use the stored payment method for recurring charges.

When a customer completes a Trustly payment with recurring enabled, they authorize a Direct Debit Instruction with their bank. This mandate gives you permission to charge their bank account on an ongoing basis without redirecting them again.

Contact your account manager to enable recurring payments with Trustly on your account before starting this integration.

Before you begin

To set up Trustly recurring payments:

  • The mandate must be set up through a payment session.
  • The customer's email address is required in billing_details. Without it, the mandate cannot be created.
  • During the Trustly redirect, the customer authorizes a Direct Debit Instruction. This is a UK-regulated authorization that covers future charges.

Set up the initial payment

The first payment sets up the Direct Debit mandate and gives you a stored payment method for later charges.

  1. 1

    Create a payment session with mandate

    On your server, send a POST request to /v1/sessions/payment with setup_future_usage set to "off_session". Include the customer's email in billing_details. Amounts are in minor units, so 2500 is £25.00.

    {
      "currency": "gbp",
      "amount": 2500,
      "customer_reference_id": "cust-001",
      "payment_method_types": ["trustly"],
      "setup_future_usage": "off_session",
      "return_url": "https://your-site.com/payment/complete",
      "billing_details": {
        "email": "customer@example.com",
        "name": "John Smith",
        "address": {
          "country": "GB"
        }
      }
    }

    Pass the client_secret to your frontend to initialize the SDK.

  2. 2

    Customer authorizes the Direct Debit

    Use the SDK to render the checkout. When the customer selects Trustly, they are redirected to the Trustly payment page where they select their bank and authorize a Direct Debit Instruction. This authorization covers both the initial payment and future charges.

    checkout.universal({
      container: '#pay-com-checkout',
    })

    The customer selects their bank, logs in, and confirms the Direct Debit. After authorization, the customer is returned to your site, and the SDK fires onSuccess (or onPending if Trustly has not confirmed the payment yet, in which case wait for the charge.succeeded webhook event).

  3. 3

    Store the payment method

    onSuccess gives the charge in transaction and the stored method in paymentMethod (pm_trustly_...). Store the payment method ID against the customer in your database. You will need this for future recurring charges.

    Retrieving the charge from your server is optional. Its payment_method is the same ID. Use the charge ID from transaction.

    curl -X GET "https://api.sandbox.pay.com/v1/charges/chrg_771388479263813632" \
      -u ':sk-pay-com-sandbox-…'

Create recurring charges

Once you have the pm_trustly_... ID, you can use it to charge the customer without them being present. Trigger each charge using the stored pm_trustly_... ID with "off_session": true. See the recurring charges guide for the full request format, response handling, and webhook events.

Subscriptions take card payment methods (pm_card_…) only, so you can't attach a pm_trustly_... ID to a subscription.

Requirements

A Trustly mandate needs a payment session with setup_future_usage set to "off_session" and the customer's email.

RequirementDetails
Integration pathPayment session
setup_future_usageMust be "off_session". Set on the payment session, not in source_data.
Customer emailRequired in billing_details.email. The mandate cannot be created without it.
Mandate typeUK Direct Debit Instruction. The customer authorizes this during the Trustly redirect.
Was this page helpful?