Create a Stripe invoice with a custom revenue recognition schedule. http://SuiteSync.io/
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
# 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