View create_paid_netsuite_invoice_with_stripe.rb
# Michael Bianco <mike@suitesync.io>
# Description: Example of creating and paying a NetSuite invoice using Stripe
# Usage:
#
# export STRIPE_KEY=sk_test STRIPE_PUBLIC_KEY=pk_test_
# gem install sinatra stripe pry
# ruby create_paid_netsuite_invoice_with_stripe.rb
# open http://localhost:4567
View attach_customer_deposit_to_sales_order.rb
# Michael Bianco <mike@suitesync.io>
# Description: Example of how to attach a Stripe charge as a CustomerDeposit
# against a SalesOrder in NetSuite
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
View suitescript_utilities.js
function isZero(obj) {
return parseFloat(obj) == 0.0
}
function debugObject(obj) {
for (var i in obj.getAllFields()) {
nlapiLogExecution('DEBUG', i)
}
}
View suitesync_wipe_metadata_fields.rb
# Mike Bianco <mike@suitesync.io>
require 'stripe'
Stripe.api_key = 'sk_'
def date_from_stripe_resource(stripe_resource)
if [ Stripe::Invoice, Stripe::Transfer ].include?(stripe_resource.class)
stripe_resource.date
elsif [ Stripe::Charge, Stripe::Refund, Stripe::Dispute ].include?(stripe_resource.class)
View capybara_fill_stripe_elements.rb
def fill_stripe_elements(card)
using_wait_time(15) { within_frame('stripeField_card_element0') do
card.to_s.chars.each do |piece|
find_field('cardnumber').send_keys(piece)
end
find_field('exp-date').send_keys("0122")
find_field('cvc').send_keys '123'
find_field('postal').send_keys '19335'
end }
View capybara_selenium_chrome_with_logging.rb
# https://groups.google.com/forum/#!topic/ruby-capybara/G6d3HHgvWCE
# https://github.com/teamcapybara/capybara/issues/1305
# http://www.assertselenium.com/java/list-of-chrome-driver-command-line-arguments/
Capybara.register_driver :selenium_chrome_driver do |app|
client = Selenium::WebDriver::Remote::Http::Default.new
# recent capybara versions have these two separate properties
client.open_timeout = 60 * 5
client.read_timeout = 60 * 5
View netsuite_pull_inventory_transfer_custom_field_list.rb
# NOTE that although the `customFieldList` exists in the InventoryTransfer search, the customFieldList won't appear in the search results :(
require 'netsuite'
ns_inventory_transfer_id = 123
search = NetSuite::Records::InventoryTransfer.search(
criteria: {
basic: [
{
View monkeypatch_stripe_ruby.rb
Stripe.max_network_retries = 100
# https://github.com/stripe/stripe-ruby/pull/501
Stripe.class_eval do
def self.should_retry?(e, retry_count)
retry_count < self.max_network_retries &&
(
Stripe::RETRY_EXCEPTIONS.any? { |klass| e.is_a?(klass) } ||
(e.is_a?(RestClient::ExceptionWithResponse) && e.response.include?('Error while communicating with one of our backends.'))
)
View stripe_auto_match_payment_to_invoice.rb
# Michael Bianco <mike@suitesync.io>
# Description: Example of using SuiteSync's auto-match functionality to apply payments
# to NetSuite invoices.
# 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 stripe_migrate_customers_by_card_attributes.rb
# Michael Bianco <mike@suitesync.io>
# NOTE tabs are used for easy copy/paste into google sheets
require 'stripe'
require 'csv'
require 'pry'
Stripe.api_key = 'sk_live_'