Octobat
Search
K

GoCardless

GoCardless Integration Guide
GoCardless allows you to collect Direct Debit payments from Eurozone for recurring or one-time payments. Learn more about GoCardless

Integration requirements

The first thing that you have to do is to create an Octobat account. Then, you have to own a GoCardless account either in sandbox mode or in live mode. To ensure that all your invoices are correctly generated, you must follow the way of this guide to make GoCardless API calls.

Connect your Octobat and GoCardless accounts

GoCardless Connect App Screenshot
During your registration, you will be able to connect your GoCardless sandbox account and your GoCardless live account.

Testing

The best way for testing the GoCardless integration with Octobat is to connect a GoCardless sandbox account, test (make API calls or create some objects within your GoCardless dashboard) and look what is happening on Octobat.

GoCardless API calls

This Octobat integration is based on the GoCardless API. Octobat uses some GoCardless basic fields to generate compliant invoices and calculate right taxes. But all these fields are not sufficients, so Octobat uses metadata fields.
Ruby
Second Tab

Reminder

Install the gem 'gocardless_pro'
gem install gocardless_pro

Create a customer

In the case of a B2C customer:
require 'gocardless_pro'
@client = GoCardlessPro::Client.new(
access_token: "your_access_token",
environment: :sandbox
)
@client.customers.create(
params: {
given_name: "John",
family_name: "Doe",
address_line1: "151 rue Montmartre",
city: "Paris",
postal_code: "75002",
region: "",
country_code: "FR",
:metadata => {
:business_type => "B2C"
}
}
)
In the case of a B2B customer:
require 'gocardless_pro'
@client = GoCardlessPro::Client.new(
access_token: "your_access_token",
environment: :sandbox
)
@client.customers.create(
params: {
company_name: "Flatchr",
address_line1: "18 bis rue de Chartres",
city: "Neuilly sur seine",
postal_code: "92200",
region: "",
country_code: "FR",
:metadata => {
:business_type => "B2B",
:tax_number => "FR13803289560"
}
}
)

Create a payment

require 'gocardless_pro'
@client = GoCardlessPro::Client.new(
access_token: "your_access_token",
environment: :sandbox
)
@client.payments.create(
params: {
amount: 1000,
currency: "EUR",
charge_date: "2016-11-28",
description: "One-time charge",
links: {
mandate: "MD123"
},
:metadata => {
:notes => "Notes that will be display on the bottom of the invoice.",
:product_type => "eservice"
}
}
)

Create a refund

require 'gocardless_pro'
@client = GoCardlessPro::Client.new(
access_token: "your_access_token",
environment: :sandbox
)
@client.refunds.create(
params: {
amount: 100,
total_amount_confirmation: 100
links: {
payment: "PM123"
},
:metadata => {
:reason => "Late delivery.",
:notes => "Notes that will be display on the bottom of the invoice.",
:product_type => "eservice"
}
}
)

Create a subscription

require 'gocardless_pro'
@client = GoCardlessPro::Client.new(
access_token: "your_access_token",
environment: :sandbox
)
@client.subscriptions.create(
params: {
amount: 2500,
currency: "EUR",
name: "Monthly streaming videos plan",
interval_unit: "monthly",
day_of_month: 1,
links: {
mandate: "MD123"
},
:metadata => {
:notes => "This is notes which will display on the bottom of the invoice.",
:product_type => "eservice"
}
}
)

Possible metadata fields values

Field Name
Field Values
Default Value
product type
eservice, standard or ebook
optional
take the configuration of your Octobat account
business_type
B2C or B2B
optional
B2C and B2B if vat number is filled