Create a standalone Stripe invoice to be paid manually (check, wire, etc) using NetSuite and 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 standalone invoice to be paid manually using NetSuite | |
# Link: https://gist.github.com/iloveitaly/8e6bce2aec361dce38b5c61c48d037ea | |
# | |
# Usage: | |
# gem install stripe | |
# export STIRPE_KEY=sk_test_123 | |
# ruby create_standalone_manual_invoice.rb | |
require 'stripe' | |
Stripe.api_key = ENV['STRIPE_KEY'] | |
customer = Stripe::Customer.create({ | |
description: "Sample customer", | |
email: "sample@example.com" | |
}) | |
# NOTE adding a payment source is omitted here since you are creating a invoice for manual payment | |
invoice_item = Stripe::InvoiceItem.create({ | |
customer: customer.id, | |
amount: 50_00, | |
currency: "usd", | |
# this description appears on the line item level in NetSuite | |
description: "A line item", | |
# NOTE you can specify exactly which NetSuite line item you'd like to connect to | |
# using metadata. More info: https://dashboard.suitesync.io/docs/field-customization | |
# metadata: { | |
# netsuite_service_sale_item_id: 123 | |
# } | |
}) | |
# creating this invoice in Stripe will create an open invoice in NetSuite | |
# if you manually pay the invoice in Netsuite, the payment information is pushed | |
# back to Stripe and the invoice is marked as paid. | |
# More information: | |
# https://dashboard.suitesync.io/docs/invoices#manual-invoice-payments | |
# https://stripe.com/docs/subscriptions/ach-credit | |
invoice = Stripe::Invoice.create( | |
customer: customer.id, | |
billing: 'send_invoice', | |
days_until_due: 30 | |
) | |
puts "Stripe Invoice ID #{invoice.id}" | |
# NOTE with SuiteSync enabled, the NetSuite invoice ID is added to the Stripe metadata | |
# shortly after it's created. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment