Last active
October 19, 2018 19:05
-
-
Save iloveitaly/3e4447e6d61cce7b79942296d9400ab0 to your computer and use it in GitHub Desktop.
Close invoices for a specific Stripe customer
This file contains 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
# 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