GoCardless Redirect Flows API (Legacy).
This is a legacy API. New integrations should use
GoCardlessClient.Resources.BillingRequestFlows instead, which supports
Open Banking, fallback flows, and more flexible customisation.
Redirect Flows create a GoCardless-hosted page where a customer sets up a
Direct Debit mandate. After the customer completes the flow, you must call
complete/3 with the original session token to create the mandate.
Example
{:ok, flow} = GoCardlessClient.Resources.RedirectFlows.create(client, %{
description: "Set up your Direct Debit",
session_token: "unique-session-token",
success_redirect_url: "https://myapp.com/mandate-complete"
})
# Redirect customer to flow["redirect_url"]
# After redirect back:
{:ok, completed} = GoCardlessClient.Resources.RedirectFlows.complete(
client,
flow["id"],
%{session_token: "unique-session-token"}
)
mandate_id = completed["links"]["mandate"]
Summary
Functions
Eagerly collects all redirect flows into a list.
Completes a Redirect Flow after the customer has returned from GoCardless.
Creates a Redirect Flow and returns a hosted redirect_url.
Retrieves a single Redirect Flow by ID.
Lists redirect flows. Filter by :created_at[gte], :created_at[lte].
Returns a lazy Stream over all pages of redirect flows.
Functions
@spec collect_all(GoCardlessClient.Client.t(), map(), keyword()) :: {:ok, [map()]} | {:error, GoCardlessClient.APIError.t() | GoCardlessClient.Error.t()}
Eagerly collects all redirect flows into a list.
@spec complete(GoCardlessClient.Client.t(), String.t(), map(), keyword()) :: {:ok, map()} | {:error, GoCardlessClient.APIError.t() | GoCardlessClient.Error.t()}
Completes a Redirect Flow after the customer has returned from GoCardless.
Must be called with the same :session_token used at creation.
Returns the created mandate and customer IDs in links.
@spec create(GoCardlessClient.Client.t(), map(), keyword()) :: {:ok, map()} | {:error, GoCardlessClient.APIError.t() | GoCardlessClient.Error.t()}
Creates a Redirect Flow and returns a hosted redirect_url.
Params
:description— shown on the GoCardless-hosted page (required):session_token— unique token tying this session to your user (required):success_redirect_url— where to redirect after completion (required):prefilled_customer— map of customer details to pre-populate:scheme— Direct Debit scheme (optional)links.creditor— Creditor ID if managing multiple creditors (optional)
@spec get(GoCardlessClient.Client.t(), String.t(), keyword()) :: {:ok, map()} | {:error, GoCardlessClient.APIError.t() | GoCardlessClient.Error.t()}
Retrieves a single Redirect Flow by ID.
@spec list(GoCardlessClient.Client.t(), map(), keyword()) :: {:ok, %{items: [map()], meta: map()}} | {:error, GoCardlessClient.APIError.t() | GoCardlessClient.Error.t()}
Lists redirect flows. Filter by :created_at[gte], :created_at[lte].
@spec stream(GoCardlessClient.Client.t(), map(), keyword()) :: Enumerable.t()
Returns a lazy Stream over all pages of redirect flows.