Instantly share code, notes, and snippets.

Embed
What would you like to do?
Close invoices for a specific Stripe customer
# Description: close open invoices on a Stripe customer
# Link: https://gist.github.com/iloveitaly/3e4447e6d61cce7b79942296d9400ab0
require 'stripe'
Stripe.api_key = ENV['STRIPE_KEY']
customer = Stripe::Customer.retrieve('cus_123')
customer.invoices.data.each do |invoice|
if !invoice.closed
# NOTE you can also mark as invoice as forgiven: `invoice.forgiven = true`
# this has the same effect in NetSuite of creating a credit memo
invoice.closed = true
invoice.save
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment