GoCardlessDeveloper Docs
Create a sandbox account

Set up#

View as Markdown

This guide covers all the essential steps to prepare for your integration with the GoCardless API. You'll learn the basics of the API, create a sandbox account, and configure your client to make requests.

Overview#

The GoCardless API makes it easy to collect bank payments from your customers' bank accounts. With one integration, you can collect payments from the UK, Eurozone, Sweden, Denmark, Australia, New Zealand, Canada, and the United States.

Our API has two main functions:

We also have a range of developer tools to help you with your integration. The rest of this guide will focus on using one of our client libraries to make requests.

Step-by-step guide#

1. Get your sandbox access token#

GoCardless has two environments: a free Sandbox for testing and Live for processing real payments. Each environment is completely separate, with its own account, dashboard, access tokens, and API URLs.

For this guide, we will only use the Sandbox environment.

A dedicated testing environment to build your integration without moving real money.

SettingValue
Dashboardmanage-sandbox.gocardless.com
API Base URLhttps://api-sandbox.gocardless.com/

The production environment for taking real payments from customers after your integration is complete.

SettingValue
Dashboardmanage.gocardless.com
API Base URLhttps://api.gocardless.com/

To start, you will need a read-write access token from your Sandbox account.

  • Sign up for a Sandbox account: Create one in Sandbox if you haven't already.
  • Create an access token: In your Sandbox dashboard, go to the Developers tab and select Create access token. Give your token a name and choose Read-Write access.
  • Copy your token: Click the Copy button and save the token somewhere safe. For security, you will not be able to view it again.

2. Set up your client#

Now it's time to set up your application to communicate with the GoCardless API. You have two options:

Our client libraries handle boilerplate code, authentication, and request signing for you. We recommend using a library if one is available for your language.

Official libraries

If you prefer, you can interact with our REST API directly. Include your access token in the Authorization header with the Bearer scheme.

Export your token as an environment variable to use with the cURL examples throughout this guide:

export GC_ACCESS_TOKEN="your_access_token_here"

Install and initialise#

Install the library using your package manager, then initialise the client with your sandbox access token.

pip install gocardless_pro
<!-- Maven -->
<dependency>
<groupId>com.gocardless</groupId>
<artifactId>gocardless-pro</artifactId>
<version>LATEST</version>
</dependency>
go get github.com/gocardless/gocardless-pro-go/v6
gem install gocardless_pro
npm install gocardless-nodejs
composer require gocardless/gocardless-pro
dotnet add package GoCardless
import os
import gocardless_pro

client = gocardless_pro.Client(
access_token=os.environ["GC_ACCESS_TOKEN"],
environment="sandbox"
)
import com.gocardless.GoCardlessClient;

GoCardlessClient client = GoCardlessClient
.newBuilder(System.getenv("GC_ACCESS_TOKEN"))
.withEnvironment(GoCardlessClient.Environment.SANDBOX)
.build();
import gocardless "github.com/gocardless/gocardless-pro-go/v6"

accessToken := os.Getenv("GC_ACCESS_TOKEN")
client, err := gocardless.New(accessToken, gocardless.WithEndpoint(gocardless.SandboxEndpoint))
require "gocardless_pro"

client = GoCardlessPro::Client.new(
access_token: ENV["GC_ACCESS_TOKEN"],
environment: :sandbox
)
const gocardless = require("gocardless-nodejs");
const constants = require("gocardless-nodejs/constants");

const client = gocardless(
process.env.GC_ACCESS_TOKEN,
constants.Environments.Sandbox
);
<?php
require "vendor/autoload.php";

$client = new \GoCardlessPro\Client([
"access_token" => getenv("GC_ACCESS_TOKEN"),
"environment" => \GoCardlessPro\Environment::SANDBOX,
]);
using GoCardless;

var client = GoCardlessClient.Create(
Environment.GetEnvironmentVariable("GC_ACCESS_TOKEN"),
GoCardlessClient.Environment.SANDBOX
);
export GC_ACCESS_TOKEN="your_access_token_here"

# Example: list customers

curl -H "Authorization: Bearer $GC_ACCESS_TOKEN" \
-H "GoCardless-Version: 2015-07-06" \
https://api-sandbox.gocardless.com/customers

3. You're ready to go!#

You have now configured your client and are ready to make your first API request.

Next steps#