Created
October 19, 2018 19:26
-
-
Save iloveitaly/e3c9eb87aa70f350977c22215304079c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: <[email protected]> | |
# 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