GoCardless integration guide

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

In this guide:

Integration requirements

The first thing that you have to do is to.
Then, you have to own a GoCardless account either insandbox mode or inlive 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


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 theGoCardless 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.

Reminder

Install the gem 'gocardless_pro'

gem install gocardless_pro
More about this gem

Create a customer

In the case of aB2Ccustomer:

require 'gocardless_pro'

@client = GoCardlessPro::Client.new(
  access_token: "your_access_token",
  environment: :sandbox
)

@client.customers.create(
  params: {
    email: "john@doe.com",
    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 aB2Bcustomer:

require 'gocardless_pro'

@client = GoCardlessPro::Client.new(
  access_token: "your_access_token",
  environment: :sandbox
)

@client.customers.create(
  params: {
    email: "contact@flatchr.io",
    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

  • product_type:eservice, standard or ebook
    optional
    default: take the configuration of your Octobat account (link)
  • business_type:B2C or B2B
    optional
    default: B2C and B2B if vat number is filled