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

  1. Render a standing order button using the SDK.
  2. When clicked, the SDK calls your server to create a standing order.
  3. Your server returns the payLink.
  4. The SDK redirects the payer to the hosted setup flow.
  5. 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 payLink to the SDK.
  • Verify the standing order status using tr-standing-order-id after return.

Next Steps