Skip to content

Instantly share code, notes, and snippets.

View iloveitaly's full-sized avatar

Michael Bianco iloveitaly

View GitHub Profile
@iloveitaly
iloveitaly / stripe_invoice_with_custom_rev_rec.rb
Last active November 21, 2018 22:41
Create a Stripe invoice with a custom revenue recognition schedule. http://SuiteSync.io/
# 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')
@iloveitaly
iloveitaly / map_custom_field_to_netsuite_field.js
Created November 14, 2018 17:47
Translate one field value on a NetSuite transaction to a value or record reference on another record. http://SuiteSync.io/
/*
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
# 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
/*
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
# 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=
/*
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
/*
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"
@iloveitaly
iloveitaly / stripe_payment_plan_with_subscriptions.rb
Created March 7, 2018 21:52
Use Stripe Subscriptions to create a payment plan for a single NetSuite Invoice
# 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
function log(msg) {
nlapiLogExecution('DEBUG', msg);
}
function startsWith(str, searchString) {
return str.indexOf(searchString) === 0;
}
function isEmpty(obj) {
return obj === undefined || obj === null || obj === "";
@iloveitaly
iloveitaly / follow_302_redirects.rb
Created February 6, 2018 00:31
Follow 302 redirects using ruby's httpi interface
def get_url_with_redirects(url)
response = nil
loop do
response = HTTPI.get(url)
break if response.code != 302
url = response.headers['location']
end