View stripe_close_customer_invoices.rb
# Description: close any open invoices on a customer
require 'stripe'
Stripe.api_key = ENV['STRIPE_KEY']
customer = Stripe::Customer.retrieve('cus_123')
customer.invoices.data.each do |invoice|
if !invoice.closed
# NOTE you can also mark as invoice as forgiven: `invoice.forgiven = true`
View create_standalone_netsuite_invoice_using_stripe.rb
# Michael Bianco <mike@suitesync.io>
# Description: Create a NetSuite Invoice using the Stripe Invoice AP.I
# Simplified version of a similar example: https://gist.github.com/iloveitaly/30e366a516e294b699b6
# Usage:
#
# export STRIPE_KEY=sk_test
# gem install stripe
# ruby create_standalone_netsuite_invoice_using_stripe.rb
View stripe_payment_plan_with_subscriptions.rb
# Michael Bianco <mike@suitesync.io>
# Description: Use Stripe Subscriptions to create a payment plan on a single invoice in NetSuite
# Usage:
#
# export STRIPE_KEY=sk_test NETSUITE_EMAIL= NETSUITE_PASSWORD= NETSUITE_ACCOUNT=
# gem install stripe netsuite
# ruby stripe_payment_plan_with_subscriptions.rb
require 'stripe'
View map_stripe_coupons_to_netsuite.rb
# Mike Bianco <mike@suitesync.io>
# Description: Connect Stripe coupons to existing NetSuite discount items
# Usage: map_stripe_coupons_to_netsuite.rb mapping.csv
require 'stripe'
require 'csv'
Stripe.api_key = ENV['STRIPE_KEY']
View stripe_auto_apply_payments_to_invoices.rb
# Michael Bianco <mike@suitesync.io>
# Description: Example of using SuiteSync's auto-match functionality to apply payments
# https://dashboard.suitesync.io/docs/payment-application
#
# Usage:
#
# export STRIPE_KEY=sk_test NETSUITE_EMAIL=user@company.com NETSUITE_PASSWORD=password NETSUITE_ACCOUNT=
# gem install stripe netsuite
# ruby stripe_auto_match_payment_to_invoice.rb
View close_netsuite_sales_order_with_suitetalk.rb
# Description: Example of closing a SalesOrder with the NetSuite SuiteTalk API
# Author: <mike@suitesync.io>
def close_sales_order(ns_order_id)
# If you want to pull the order associated with an invoice `ns_order_id = ns_invoice.created_from.internal_id`
ns_order = NetSuite::Utilities.get_record(NetSuite::Records::SalesOrder, ns_order_id)
# http://mikebian.co/how-to-close-a-netsuite-salesorder-using-suitetalk/
View map_stripe_plans_to_netsuite.rb
# Mike Bianco <mike@suitesync.io>
# Description: Connect Stripe plans to existing NetSuite items
# Usage: map_stripe_plans_to_netsuite.rb mapping.csv
require 'stripe'
require 'csv'
Stripe.api_key = ENV['STRIPE_KEY']
View netsuite_determine_customer_for_job.rb
# Author <mike@suitesync.io>
# More info: http://mikebian.co/notes-on-working-with-jobs-projects-using-the-suitetalk-netsuite-api/
ns_job_internal_id = 123
mapping_search = NetSuite::Records::Job.search(
criteria: {
basic: [
{
field: 'internalId',
View shopify_auto_paging_each.rb
# NOTE pairs well with API request limit backoff
# https://gist.github.com/iloveitaly/cf0566bd598732c1e81bad0de1be4ff7
# https://github.com/Shopify/shopify_api/pull/339
ShopifyAPI::Base.class_eval do
def self.list(params = {})
find(:all, params: params)
end
View shopify_backoff.rb
ShopifyAPI::Connection.class_eval do
alias_method :shopify_request, :request
def request(*args)
count = 0
limit = 10
begin
count += 1
shopify_request(*args)