Get started with Rowy in minutes
If you have a business, you need to handle invoices. And if you have an online business, you probably use Stripe for your payment infrastructure. By using Stripe in combination with Rowy, companies can use invoice automation to take control of their financial data to save time and costs.
Invoice automation uses software to streamline the invoicing process to fit your business needs. It includes tasks like creating invoices, sending payment requests, and generating reports. In this article, we will walk through the process of using Stripe and Rowy to automate various invoice-related tasks.
A study by Online Invoices declares that 54% of small and medium businesses expect late payments: by automating your invoice management system, you can reduce the risk of payment errors and late invoices―which in turn will result in reduced costs. This is particularly true for businesses that process a large number of invoices each month, but you'll also benefit from the added peace of mind if you're a freelancer with few clients: manual processes are more likely to create mistakes, so automation will help with accurate reporting and data handling.
First, you will need a secret authentication key to use Stripe's API:
You can now use your Stripe API keys to interact with Stripe from Rowy:
Having a CRM system in place to keep track of your customer information is an essential first step to automating your invoicing process. Stripe is great for that, but if you're using a spreadsheet or other manual system, you'll need to manually enter customer details into Stripe. Combining Stripe with Rowy to get the best of both worlds is a great alternative: you can use Stripe to process payments, and Rowy to manage customer data in a spreadsheet UI.
First, let's create a few columns in Rowy to store customer information:
email
column to store the customer's email address.address
column to store the customer's address as a subtable with the fields city
, country
, line1
, postal_code
, and state
.name
column to store the company name.stripe_customer_id
column to store the customer's ID created by Stripe.All these columns are optional for Stripe's API, but they'll be necessary to create correct invoices.
Next, we create a new Action column to create a new customer in Stripe using an API call, with the following code in the Action settings:
const action:Action = async ({row,ref,db,storage,auth,actionParams,user,logging}) => {
const res = await fetch('https://api.stripe.com/v1/customers', {
method: 'POST',
headers: {
'Authorization': `Bearer ${rowy.secrets.stripe_secret_key}`
},
body: JSON.stringify({
email: row.email,
address: row.address,
name: row.name
})
}).then(res => res.json())
row.stripe_customer_id = res.id
}
You'll obtain the following table:
Every time you add a new row and click the Action button, the script will run to create a new customer object in Stripe and return the customer's ID:
We can then use this customer ID to create new payments and invoices. You could for example create a new Stripe customer every time someone fills up your contact form on your website.
We can now use Stripe to automatically generate invoices. This can be done via API by specifying the customer id and individual invoice items with a specific amount. Stripe considers an invoice to be a collection of invoice items, and each invoice item has a price, quantity, and description.
First, we create a new sub-table to store our invoices:
Then, we add another sub-table inside the invoice sub-table to store each individual invoice items:
We can now update the runInvoiceCustomer
Action column in the invoices
sub-table to create the Stripe invoice we can use to request payments from customers:
const invoice = await fetch('https://api.stripe.com/v1/invoices', {
method: 'POST',
headers: {
'Authorization': `Bearer ${rowy.secrets.stripe_secret_key}`
},
body: JSON.stringify({
customer: row.stripe_customer_id,
description: row.description
})
}).then(res => res.json())
row.stripe_invoice_id = invoice.id
const invoiceItems = row.invoice_items
const size = invoiceItems.length
for(let i = 0 ; i < size ; i++){
const item = await fetch('https://api.stripe.com/v1/invoiceitems', {
method: 'POST',
headers: {
'Authorization': `Bearer ${rowy.secrets.stripe_secret_key}`
},
body: JSON.stringify({
customer: row.stripe_customer_id,
amount: item.amount,
description: item.description,
currency: 'usd',
invoice: invoice.id
})
}).then(item => item.json())
row.invoiceitems[i].stripe_invoiceitem_id = item.id
}
This will create a new invoice object for the customer specified by the "customer" parameter and returns the invoice's ID:
Once the invoice object is created, you can retrieve the invoice PDF, send a payment link, and more. Here is an example of an invoice as a PDF generated automatically by Stripe:
It's also worth noting that you can use additional API methods to retrieve all the invoices of a customer or update them.
We can use a Rowy Action column to automate accounting tasks using our invoice data like calculating totals or estimate taxes. For example, an action column to calculate the total amount of all invoices for a given customer:
const customer = row.stripe_customer_id
const invoices = row.invoices
const invoice_size = invoices.length
let total = 0
for(let i = 0 ; i < invoice_size ; i++){
const invoice = invoices[i]
const invoice_items = invoice.invoice_items
const invoice_item_size = invoice_items.length
for(let j = 0 ; j < invoice_item_size ; j++){
const item = invoice_items[j]
total += item.amount
}
}
return total
This will retrieve all invoices and compute the total amount.
Of course, you can use custom logic to calculate the total amount of all invoices for a given month, or per quarter, for example―whatever you want to create your own custom invoice reports.
Last but not least, you can send payment requests from generated invoices with the click of a button using another Rowy action:
const isSent = await fetch(`https://api.stripe.com/v1/invoices/${row.stripe_invoice_id}/send`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${rowy.secrets.stripe_secret_key}`
}
}).then(item => item.json())
if(isSent){
row.is_sent = true
}
This Stripe API endpoint will send an email to the customer with a payment link:
The payment link redirects the customer to Stripe's payment portal where they can pay the invoice in a secure user interface:
In conclusion, Stripe and Rowy offer together a simple way to automate invoice processing, to save online businesses a significant amount of time and resources. After obtaining Stripe API keys, you can connect your Stripe account to Rowy via API and automate various invoice-related tasks like creating new customers, generating invoices, automating accounting tasks, and sending payment requests: a great way to streamline your business processes and focus on growth!
For more useful demos or to ask questions, join our Discord community. It's free, and we'll be happy to help you with your specific use cases.