Skip to content

Instantly share code, notes, and snippets.

@iloveitaly
Last active January 26, 2018 22:21
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/8e6bce2aec361dce38b5c61c48d037ea to your computer and use it in GitHub Desktop.
Save iloveitaly/8e6bce2aec361dce38b5c61c48d037ea to your computer and use it in GitHub Desktop.
Create a standalone Stripe invoice to be paid manually (check, wire, etc) using NetSuite and http://SuiteSync.io/
# 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