Handle webhooks
Trustly uses asynchronous event notifications (webhooks) to communicate transaction status. Because transfers on the Automated Clearing House (ACH) network are not instant, you cannot rely on the immediate API response to determine the final state. You must implement a notification handler to receive and process these updates.
Prerequisites
Before you can handle event notifications, ensure you have completed the following:
- Publicly Accessible Endpoint: You must have a publicly accessible HTTPS endpoint on your server to receive POST requests from Trustly.
- Security Configuration: You should be prepared to validate the cryptographic signature included in the request headers to ensure the notification is authentic. See Validate the notification signature.
Configure your listener
To receive notifications, you must configure a webhook listener URL. You can establish this URL in two ways:
- Default configuration: Contact your Trustly Integration team or Support representative to configure a default
notificationUrlin the Trustly administrative interface. - Per-Transaction: Override the default by passing a specific
notificationUrlin theestablishDataobject when you initiate a transaction.
Event types
The following table lists the primary event types you will encounter.
| Event Type | Description |
|---|---|
Establish | The transaction originated in the Trustly system. |
Authorize | The customer successfully authorized the transaction with their bank. |
Process | Trustly submitted the transaction to the banking network. |
Completed | Trustly successfully moved the funds (captured or deposited). |
Failed | The transaction failed (for example, NSF, Risk, or Customer Cancel). |
Deny | The bank or Trustly denied the transaction. |
Cancel / Cancelled | The customer or merchant canceled the transaction. |
Refund | Trustly refunded the transaction. |
Reverse | The bank reversed the transaction. |
Dispute | A user initiated a dispute for the transaction. |
Reconcile | Trustly reconciled the transaction. |
Expire | The transaction expired before completion. |
Update | Trustly updated the transaction details. |
Refresh | The account balance or data refreshed. |
DataReady | Trustly retrieved all bank-qualified data (balance, account details) and it is ready for access. |
CONSENT_REVOKED | The customer revoked their data sharing consent. |
Event payload
Trustly sends event data as a URL-encoded string (application/x-www-form-urlencoded). You must parse these name-value pairs to update your internal order status.
Example Payload (Parsed)
merchantReference=order-123&transactionId=1002636615&eventId=1002636616&eventType=Authorize&status=2&statusMessage=Authorized&paymentType=2×tamp=1632268808515Verify the signature
To ensure the notification originated from Trustly and has not been tampered with, you must validate the cryptographic signature included in the Authorization header of the request.
See Validate the notification signature for implementation details and code samples.
Available Funds Guidance
If your merchant account is enabled for Available Funds Guidance, you can use webhook data to recover transactions that fail due to insufficient funds.
When a transaction fails, the notification payload may contain a suggestedRetryAmount. This value represents a safe upper limit for a new transaction attempt based on the customer's available balance at the time of the failure.
Prerequisites
- Feature enablement: Contact your Trustly Customer Success Manager or Implementation Team to enable Available Funds Guidance for your merchant account.
Handle the event
To implement this recovery logic in your application:
- Listen for
DenyorFailedevents wherepaymentProviderTransaction.statusequalsSW021(Insufficient Funds) orSW054(Security Controls), ANDsuggestedRetryAmountis greater than0. - Check the payload for the
suggestedRetryAmountfield. - Prompt the customer to retry the payment using the suggested value.
Example event payload (parsed)
merchantReference=order-123&transactionId=1002636615&eventType=Deny&status=8&paymentProviderTransaction.status=SW021&message=Not+enough+balance&suggestedRetryAmount=500.00Updated 6 days ago