Customising your Stripe integration

If you'd like to customise your Stripe integration, to provide yourself and Quaderno with more information about your customers, we've made it easy to do!

Customising the customer billing info

You might want to customise the billing info on your Stripe-generated invoices. You can do this in two main ways (with a bonus third way just for Quaderno customers!).

You can add extra info when you tokenise the card in the custom form on your front-end, like so:

stripe = Stripe(stripePublishableKey);
stripeCardElement = elements.create('card')
stripeCardElement.mount('#card-container')

stripe.createToken(stripeCardElement, {
  name: $('#customer-name').val(),
  address_line1: $('#address').val(),
  address_city: $('#city').val(),
  address_zip: $('#postal-code').val(),
  address_country: $('#country').val(),
}).then(stripeResponseHandler);

Here we have added the customer's name and address information while creating the token, so that in Stripe's backend the auto-created customer will have all the right information.

You can also use the metadata fields available when you create the Stripe Customer on your back end. We're a Ruby shop, so here's an example of us doing this in a Rails back-end:

customer = Stripe::Customer.create(
  :name => 'Reynholm Industries',
  :email => 'billing@reynholm.co.uk',
  :address => {
    :line1 => '123 Carenden Road',
    :line2 => 'Suite 201',
    :city => 'London',
    :state => 'London',
    :postal_code => 'EC5M 8AJ',
    :country => 'GB', # 2-letter ISO code
  },
  :tax_info => { # opcional
    :tax_id => 'GB123456789',
    :type => 'eu_vat'
  },
  :metadata => { # optional
    :contact_person => 'Maurice Moss' # billing contact person (only for businesses)
  },
  :source => 'tok_103NCO2eZvKYlo2Cc4lerc1E' # obtained with Stripe.js
)

We recommend that you at least send the country and postal code of your customer to calculate the right tax rates.

And there's a third way to create customer on Stripe: you can use Quaderno Checkout, our checkout form that calculates taxes in real time.

Customising the transaction info

You might also want to customise both your charges and your subscriptions on Stripe. We are all for it, allowing you to set the tax rates you want to apply and to send us the IP address of the customer, as another piece of location confirmation evidence.

Here's a Rails example of us adding some relevant metadata to a couple of charges while creating them in Stripe:

Stripe::Charge.create(
  :amount => 2420, # total amount (taxes included)
  :currency => 'usd',
  :customer => customer.id,
  :description => 'The Neverending Story, Michael Ende (EPUB)',
  :metadata => {
    :ip_address => request.ip
  }
)

customer.subscriptions.create(
  :plan => 'awesome',
  :tax_percent => 20,
  :metadata => {
    :ip_address => request.ip
  }
)

In this case, you can even calculate the taxes with our Tax API.

All the metadata for charges and subscriptions is optional. Quaderno can make sense of the following fields:

Metadata Description
transaction_type Type of transaction: eservice, ebook or standard.
The default is the type of transaction you've selected on Settings > Preferences.
sku Unique code of the product or service sold.
tax_name Name of the tax, e.g Sales Tax, VAT, GST, etc.
tax_rate Value of the tax rate, e.g. 20 for a tax rate of 20%.
extra_tax_name Name of a secondary tax for the same charge, e.g. PST
extra_tax_rate Value of a secondary rate for the same charge.
ip_address IP address of the customer
po_number PO number
notes Any note you want to add to the final invoice
tags Tag invoices when they are created e.g. tag1,tag2,tag3
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us