Skip to content

Instantly share code, notes, and snippets.

@iloveitaly
Last active November 21, 2018 22:41
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/5f31a6cf826dcbe72ef4a229afa52d67 to your computer and use it in GitHub Desktop.
Save iloveitaly/5f31a6cf826dcbe72ef4a229afa52d67 to your computer and use it in GitHub Desktop.
Create a Stripe invoice with a custom revenue recognition schedule. http://SuiteSync.io/
# Michael Bianco <mike@suitesync.io>
# Description: Create a Stripe invoice with a custom rev rec schedule
require 'stripe'
Stripe.api_key = ENV['STRIPE_KEY']
customer = Stripe::Customer.create
customer.sources.create(card: 'tok_visa')
invoice_item = Stripe::InvoiceItem.create({
customer: customer.id,
amount: 10_00,
currency: "usd",
description: "123 units of component at 0.25",
metadata: {
# https://dashboard.suitesync.io/docs/field-customization
netsuite_product_name: "component",
# if the line item represents tax on the order, this flag must be specified
netsuite_tax: true,
# if the items have a revenue schedule it needs to be specified via two fields
# dates needs to be formatted in UTC0 as a unix timestamp
# https://dashboard.suitesync.io/docs/field-customization#field-types
netsuite_rev_rec_start_date: Time.now.utc.to_i - (60 * 60 * 24 * 30),
netsuite_rev_rec_start_date: Time.now.utc.to_i,
}
})
invoice = Stripe::Invoice.create({
customer: customer.id
})
invoice.pay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment