View find_closed_stripe_invoices.rb
# Mike Bianco <mike@suitesync.io>
require 'stripe'
Stripe.api_key = 'sk_live_123'
def find_closed_invoices
limit = 2000
invoices = []
created_after = Date.new(2016,05,15)
View mandrill_mailer.rb
require 'mandrill'
class MandrillMailer
include SimpleStructuredLogger
def self.mail(*args)
self.new.mail(*args)
end
def mail(email:, template:, vars:)
View stripe_custom_transaction_report.rb
require 'stripe'
# replace this with your Stripe API key
Stripe.api_key = 'sk_live_'
start_date = DateTime.new(2016,5,1)
end_date = DateTime.new(2016,5,30)
# refund list API guarantees refunds are returned in date order
# this is important because the refund endpoint does not have any date filters
View stripe_test_edge_cases_for_netsuite.rb
# Michael Bianco <mike@suitesync.io>
# This script tests the following edge cases:
#
# - Disputes on a invoice-created charge
# - Invoice with prorations
# - Partial refund on a invoice
require 'stripe'
require 'faker'
View create_stripe_subscription_with_existing_netsuite_items.rb
# Michael Bianco <mike@suitesync.io>
require 'stripe'
Stripe.api_key = 'sk_test'
customer = Stripe::Customer.create({
:description => "Sample Customer"
})
View rails_class_configuration.rb
module ClassConfiguration
extend ActiveSupport::Concern
module ClassMethods
def class_configuration(key, default = nil)
class_attribute :"_#{key}"
define_singleton_method(key) do |*args|
if args.empty?
View pay_netsuite_invoice_with_stripe.rb
# Michael Bianco <mike@suitesync.io>
require 'stripe'
# Replace this test mode key and run this example on your account
Stripe.api_key = 'sk_test_123'
# Create a card token to be associated with a customer. This is normally done
# on your payment frontend using Stripe.js https://stripe.com/docs/custom-form
card_token = Stripe::Token.create(
View target_blank_external_links_filter.rb
View image_asset_path_filter.rb
module HTML
class Pipeline
class ImageAssetPathFilter < HTML::Pipeline::Filter
def call
doc.search("img").each do |img|
next if img['src'].nil?
src = img['src'].strip
View stripe_transfer_containing_charge.rb
# NOTE `auto_paging_each` requires a recent stripe ruby gem version
def stripe_transfer_containing_charge(stripe_charge, limit: 100)
txn = stripe_charge.balance_transaction
Stripe::Transfer.list({ limit: 100, created: { gt: stripe_charge.created }}).auto_paging_each do |transfer|
Stripe::BalanceTransaction.list({ limit: 100, transfer: transfer.id }).auto_paging_each do |bt|
if bt.id == stripe_charge.balance_transaction
return transfer
end