GoCardlessDeveloper Docs
Create a sandbox account

Setting up mandates#

View as Markdown

Setting up Direct Debit mandates#

You'll need to provide a way for your users to set up Direct Debit mandates with their customers (whom we'll refer to from now on as "end customers") so they can start collecting payments from them.

A mandate allows you to pull money from an end customer's bank account with a simple API call.

Sending merchants to your app#

Firstly - once a merchant completes verification, there are two ways they might make their way to your platform to start setting up payments:

  1. Via the post-onboarding redirect - if you've configured a post onboarding URL in your App settings, GoCardless redirects the merchant there automatically after they finish verification. In this case they land directly on your platform can finish setting up their account with you and start setting up payments.
  2. Via the GoCardless dashboard - some merchants will land on the GoCardless dashboard, either by navigating there directly or returning after verification. To handle this, you can set a payment setup URL in your App settings. This controls where the "Get started with payments" prompt in the dashboard takes them - it should link to the page on your platform where they can begin creating mandates and payments.

If no payment_setup_url is set, the prompt falls back to your post_onboarding_url, or your website_url if neither is configured.

Partner - dashboard setup payments

Partners - payment setup URL

Making API Calls on behalf of your merchant#

Prerequisite: We must have gotten and saved merchants' access tokens after following the steps here.

To make an API call against a merchant's account, we will have to use the saved access token. See an example below:

<?php
require 'vendor/autoload.php';

$client = new \GoCardlessPro\Client([
// You'll need to identify the user that the customer is paying
// and fetch their access token
'access_token' => $user->gocardlessAccessToken,
// Change me to LIVE when you're ready to go live
'environment' => \GoCardlessPro\Environment::SANDBOX
]);
import os
import gocardless_pro

client = gocardless_pro.Client( # You'll need to identify the user that the customer is paying # and fetch their access token
access_token=user.gocardless_access_token, # Change this to 'live' when you are ready to go live.
environment='sandbox'
)
require 'gocardless_pro'

client = GoCardlessPro::Client.new(

# You'll need to identify the user that the customer is paying

# and fetch their access token

access_token: user.gocardless_access_token,

# Remove the following line when you're ready to go live

environment: :sandbox
)
package com.gcintegration;

import com.gocardless.GoCardlessClient;
import com.gocardless.resources.RedirectFlow;

GoCardlessClient client = GoCardlessClient
// You'll need to identify the user that the customer is paying
// and fetch their access token
.newBuilder(CurrentUser.gocardlessAccessToken)
// Change me to LIVE when you're ready to go live
.withEnvironment(GoCardlessClient.Environment.SANDBOX)
.build();
const constants = require("gocardless-nodejs/constants");

const client = gocardless(
// We recommend storing your access token in an environment
// variable for security
user.GoCardlessAccessToken,
// Change this to constants.Environments.Live when you're ready to go live
constants.Environments.Sandbox,
);
using GoCardless;

GoCardlessClient client = GoCardlessClient.Create(
// We recommend storing your access token in an
// configuration setting for security
User["GoCardlessAccessToken"],
// Change me to LIVE when you're ready to go live
GoCardlessClient.Environment.SANDBOX
);
package main

import (
"fmt"

  gocardless "github.com/gocardless/gocardless-pro-go/v6"

)

func main() {
accessToken := user.accessToken
config, err := gocardless.NewConfig(accessToken, gocardless.WithEndpoint(gocardless.SandboxEndpoint))
if err != nil {
fmt.Printf("got err in initialising config: %s", err.Error())
return
}
client, err := gocardless.New(config)
if err != nil {
fmt.Println("error in initialisating client: %s", err.Error())
return
}
}

Collecting Payments#

Once you have the client set up with your merchant's access token, use a Billing Request Flow to set up Direct Debit mandates or Pay By Banks on their behalf. This handles the full payer experience — collecting bank details, authorisation, and confirmation.

For a full walkthrough of Billing Request Flows and the payer journey, see collecting payments.

What's Next?#