Skip to content

Instantly share code, notes, and snippets.

@iloveitaly
Created October 19, 2018 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iloveitaly/e3c9eb87aa70f350977c22215304079c to your computer and use it in GitHub Desktop.
Save iloveitaly/e3c9eb87aa70f350977c22215304079c to your computer and use it in GitHub Desktop.
# Author: <mike@suitesync.io>
# Description: batch close old invoices in Stripe
# Link: https://gist.github.com/iloveitaly/e3c9eb87aa70f350977c22215304079c
require 'stripe'
Stripe.api_key = ENV['STRIPE_KEY']
close_invoices_before_date = Date.new(2016, 05, 15).to_time.to_i
Stripe::Invoice.list(paid: false, limit: 100, date: { lte: close_invoices_before_date }).auto_paging_each do |invoice|
if !invoice.closed
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