Standing Orders
Use the JavaScript SDK to create standing orders (direct debit mandates) with a hosted Trustist checkout. The flow is similar to hosted payments but uses a standing order endpoint on your server.
Flow Summary
- Render a standing order button using the SDK.
- When clicked, the SDK calls your server to create a standing order.
- Your server returns the
payLink. - The SDK redirects the payer to the hosted setup flow.
- The payer returns with
tr-standing-order-id.
Client Example
<div id="standing-order-button"></div>
<script src="https://sdk-sandbox.trustistecommerce.com/js/sdk.js?client-id=YOUR_CLIENT_ID" async></script>
<script>
window.trustistReadyCallback = function () {
trustist.ecommerce.StandingOrder({
createStandingOrder: () => {
return fetch("/api/standing-orders", {
method: "post",
headers: {
"Accept": "application/json",
"Content-Type": "application/json"
},
body: JSON.stringify({
amount: 25.00,
reference: "SUBSCRIPTION-123",
returnUrl: window.location.origin + "/standing-orders/complete"
})
})
.then((response) => response.json())
.then((standingOrder) => standingOrder.payLink);
},
paymentComplete: (result) => {
return fetch("/api/standing-orders/" + result["tr-standing-order-id"], {
method: "get"
})
.then((response) => response.json())
.then((standingOrder) => {
if (standingOrder.status === "ACTIVE") {
window.location.href = "/thank-you";
}
});
}
}).render({
path: "#standing-order-button",
buttonText: "Set up standing order",
loadingText: "Redirecting..."
});
};
</script>
Server Responsibilities
- Create the standing order using the Trustist Ecommerce API.
- Return the
payLinkto the SDK. - Verify the standing order status using
tr-standing-order-idafter return.