Stripe direct integration
Stripe allows you to collect credit card payments for recurring or one-time payments.
Learn more about Stripe
In this guide:
Integration requirements
The first thing that you have to do is to create an Octobat account .
Then, you have to own a Stripe account .
To ensure that all your invoices are correctly generated, you must follow the way of this guide to make Stripe API calls.
Connect your Octobat and Stripe accounts

During your registration, you will be able to connect your Stripe account. At this moment, Octobat asks you read and write accesses to your Stripe account.
Testing
The best way for testing the Stripe integration with Octobat is to make API calls or create some objects within your Stripe dashboard and look what is happening on Octobat.
Stripe API calls
This Octobat integration is based on the Stripe API .
Octobat uses some Stripe 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 'stripe'
gem install stripeMore about this gemCreate a customer
In the case of a B2C customer:
require 'stripe'
Stripe.api_key = "sk_test_ocRWOhpjMI3qPvPoYYgbiWHI"
customer = Stripe::Customer.create(
description: 'John Doe',
email: 'john@doe.com',
metadata: {
business_type: 'B2C'
}
)
card = customer.sources.create(:source => "tok_19QGP8JBzWUlTvnEvc9zzn5g") # obtained with Stripe.js
card.name = "John Doe"
card.address_line1 = "801 Via dei Condotti"
card.address_line2 = "Secondo piano"
card.address_city = "Roma"
card.address_zip = "10000"
card.address_state = ""
card.address_country = "Italia"
card.save
In the case of a B2B customer:
require 'stripe'
Stripe.api_key = "sk_test_ocRWOhpjMI3qPvPoYYgbiWHI"
customer = Stripe::Customer.create(
description: 'Nestor',
email: 'contact@nestorparis.com',
metadata: {
business_type: 'B2B',
business_vat_id: 'FR60528551658'
}
)
card = customer.sources.create(:source => "tok_19QGP8JBzWUlTvnEvc9zzn5g") # obtained with Stripe.js
card.name = "Nestor"
card.address_line1 = "17 avenue du Colonel Bonnet"
card.address_line2 = ""
card.address_city = "Paris"
card.address_zip = "76016"
card.address_state = ""
card.address_country = "France"
card.save
Create a payment
require 'stripe'
Stripe.api_key = "sk_test_ocRWOhpjMI3qPvPoYYgbiWHI"
Stripe::Charge.create(
:amount => 2000,
:currency => "eur",
:customer => customer.id,
:description => "One-time charge",
:metadata => {
# Recommended
:ip_address => '192.168.43.152', # It's an evidence to calculate correct tax.
# Optional
:quantity => 5,
:notes => "Notes that will be display on the bottom of the invoice.",
:tax_rate => 10.0, # Force to 10% tax rate. Default is calculated by Octobat.
:product_type => "eservice", # Force to eservice transaction. Default is your account setting.
:sequence => "oc_ns_148141273557ehd884355e" # Octobat sequence id if you have created one into Octobat.
}
)
Create a subscription
require 'stripe'
Stripe.api_key = "sk_test_ocRWOhpjMI3qPvPoYYgbiWHI"
Stripe::Subscription.create(
:customer => customer.id,
:plan => "gold",
:tax_percent => 10.0, # Force to 10% tax rate, default is calculated by Octobat.
:quantity => 5,
:metadata => {
# Recommended
:ip_address => '192.168.43.152', # It's an evidence to calculate correct tax.
# Optional
:notes => "Notes that will be display on the bottom of the invoice.",
:product_type => "eservice", # Force to eservice transaction. Default is your account setting.
:sequence => "oc_ns_148141273557ehd884355e" # Octobat sequence id if you have created one into Octobat.
}
)
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