Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
# Description: close any open invoices on a customer
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`
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