Instantly share code, notes, and snippets.

View map_custom_field_to_netsuite_field.js
/*
Author: <mike@suitesync.io>
Description: Maps an ID passed to a custom field on the NetSuite invoice to a
class record reference in Netsuite.
Link: https://gist.github.com/iloveitaly/da9b88e318025ec53f5bc36ff4dafdcf
Installation:
1. https://system.netsuite.com/app/common/scripting/uploadScriptFile.nl
2. User Event
3. Name: Map Custom Field to Class
View close_old_invoices_in_stripe.rb
# Author: <mike@suitesync.io>
# Description: batch close old invoices in Stripe
# Link: https://gist.github.com/iloveitaly/e3c9eb87aa70f350977c22215304079c
require 'stripe'
Stripe.api_key = ENV['STRIPE_KEY']
close_invoices_before_date = Date.new(2016, 05, 15).to_time.to_i
View adjust_inferred_invoice.js
/*
Author: <mike@suitesync.io>
Description: Modifies data on an "inferred" NetSuite invoice created from a standalone Stripe charge
Link: https://gist.github.com/iloveitaly/350363f07b13d7ac81bf81784c1417c9
Installation:
1. https://system.sandbox.netsuite.com/app/common/scripting/uploadScriptFile.nl
2. User Event
3. Name: SuiteSync Inferred Invoice Customization
4. ID: _suitesync_inferred_invoice
View remove_cards_on_stripe_customers.rb
# Michael Bianco <mike@suitesync.io>
# Description: An example script demonstrating how to remove customer cards. This
# is helpful for keeping a card around temporarily for reauthorizing a
# expired card authorization. More information:
# https://dashboard.suitesync.io/docs/auth-fulfill-capture#id-like-to-create-an-authorization-for-more-than-7-
# Link: https://gist.github.com/iloveitaly/683a4664708ea972ca2e081e55b7c547
# Usage:
#
# export STRIPE_KEY=sk_test NETSUITE_EMAIL=user@company.com NETSUITE_PASSWORD=password NETSUITE_ACCOUNT=
View netsuite_generate_stripe_payment_for_estimates.js
/*
Author: <mike@suitesync.io>
Description: Generates the Stripe Payment Link for Estimates, or other records in NetSuite
Link:
Installation:
Create Custom Field:
1. https://dashboard.suitesync.io/docs/netsuite-configuration#creating-the-stripe-quote-payment-link-custom-field
2. Make sure the field has `Store Value` checked and is a free-form text field
View customized_netsuite_stripe_account_mapping.js
/*
Author: <mike@suitesync.io>
Description: Specifies which Stripe account should be used on a transaction based on custom business logic
Link: https://gist.github.com/iloveitaly/aced3081f924651891a44c474625976d
Installation:
Create Custom Field:
1. [Customization > Transaction Body Fields > New](https://system.sandbox.netsuite.com/app/common/custom/bodycustfields.nl)
2. Create a new field to appear on SalesOrders and Invoices.
* Label: "Stripe Account ID"
View stripe_payment_plan_with_subscriptions.rb
# Michael Bianco <mike@suitesync.io>
# Description: Use Stripe Subscriptions to create a payment plan against a single NetSuite Invoice
# Link:
# Usage:
#
# export STRIPE_KEY=sk_test NETSUITE_EMAIL= NETSUITE_PASSWORD= NETSUITE_ACCOUNT=
# gem install stripe netsuite
# ruby stripe_payment_plan_with_subscriptions.rb
View trigger_automatic_stripe_payment.js
function log(msg) {
nlapiLogExecution('DEBUG', msg);
}
function startsWith(str, searchString) {
return str.indexOf(searchString) === 0;
}
function isEmpty(obj) {
return obj === undefined || obj === null || obj === "";
View follow_302_redirects.rb
def get_url_with_redirects(url)
response = nil
loop do
response = HTTPI.get(url)
break if response.code != 302
url = response.headers['location']
end
View simple_usage_billing_with_stripe.rb
# Mike Bianco <mike@suitesync.io>
# Description: Example of using Stripe Subscriptions to manage simplistic usage based billing
# Link: https://gist.github.com/iloveitaly/e56a9487dfa85e08bdf63bfcfcd68dad
require 'stripe'
Stripe.api_key = ENV['STRIPE_KEY']
plan = (Stripe::Plan.retrieve('example-usage-plan') rescue nil)