Redirect URLs
Redirect URLs return users back to your application after they interact with the Trustly UI. When a user completes or cancels a workflow, the SDK redirects them to your specified returnUrl or cancelUrl respectively. These URLs capture critical transaction data through query parameters, which you can use to verify status, call Trustly APIs, or guide the user to the next step.
Receive the redirect
Trustly returns the user to your application using a GET request, appending several fields to the URL. You can parse this data in your backend to handle the transition.
Preventing Tampered Redirects
To ensure the redirect is secure and authentic:
-
Verify that the
merchantReferenceon the return URL matches the unique value you sent in the Establish Data Object for this session.-
Validate the request by verifying the Redirect Signature in your backend before processing any data.
-
Alternatively, call the Get Transaction API to confirm that the API response values match the parameters received in the redirect URL.
-
Example cancel URL
Example return URL
Process the return URL
Upon receiving a successful redirect to your returnUrl, you should associate the account on file with the provided transactionId.
If you are using the Split Token flow, you must also verify the corresponding incoming Authorize webhook event associated with this transactionId and store the splitToken provided in that event alongside the account details.
Parameters
The following table outlines the parameters appended to the redirect URL and provides their definitions.