Created
October 31, 2017 15:43
-
-
Save iloveitaly/69f179af5ad7a15e69310891b9309273 to your computer and use it in GitHub Desktop.
Classify NetSuite income and revenue using http://SuiteSync.io/ by passing a department or location into Stripe
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: Classify NetSuite income and revenue by passing a department or location | |
# into Stripe using metadata. | |
# Usage: | |
# | |
# export STRIPE_KEY=sk_test | |
# gem install stripe | |
# ruby classify_netsuite_revenue_using_stripe.rb | |
# | |
# NOTE an alternative way of doing this by using a SuiteScript | |
# https://gist.github.com/iloveitaly/c4e330f9e1a839b266c5b1aaca5a6836 | |
require 'stripe' | |
Stripe.api_key = ENV['STRIPE_KEY'] | |
# 1. Create a standalone Stripe charge and specify a department and class | |
# | |
# This is done by passing the internal ID of the department, class, or any other fields | |
# into the Stripe charge via a Stripe metadata field. Note that it is important | |
# to use the internal ID of the departnment, class, etc NOT the name or other ID of the record | |
# Learn more here: https://dashboard.suitesync.io/docs/field-customization | |
class_mapping = { | |
'Shirt' => 2 | |
} | |
department_mapping = { | |
'Retail' => 1 | |
} | |
Stripe::Charge.create( | |
description: "eCommerce Order", | |
amount: 100_00, | |
currency: 'usd', | |
source: 'tok_visa', | |
metadata: { | |
netsuite_department_id: department_mapping['Retail'], | |
netsuite_class_id: class_mapping['Shirt'] | |
} | |
) | |
# 2. Create a recurring subscription in Stripe and associate it with a specific class or department | |
# NOTE contact support for this use case! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment