Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iloveitaly/b9f3bcb4be5924c6935f0cc0b9533513 to your computer and use it in GitHub Desktop.
Save iloveitaly/b9f3bcb4be5924c6935f0cc0b9533513 to your computer and use it in GitHub Desktop.
Example of how to create a NetSuite SalesOrder (or Invoice) with an associated payment using the Stripe Relay API with http://SuiteSync.io/
# Michael Bianco <mike@suitesync.io>
# Description: Example of how to create a NetSuite SalesOrder (or Invoice) with an
# associated payment using the Stripe Relay API
# Usage:
# gem install stripe
# export STRIPE_KEY=sk_test_
# ruby stripe_simple_netsuite_ecommerce_with_relay.rb
require 'stripe'
Stripe.api_key = ENV['STRIPE_KEY']
customer = Stripe::Customer.create(
description: "Sample customer for NetSuite",
email: "sample@example.com",
)
customer.sources.create(card: 'tok_visa')
# ensures that a new product and sku is created
randomization_token = Time.now.to_i
product = Stripe::Product.create(
:name => 'Your Product',
:description => 'A description',
:id => "your_product_id_#{randomization_token}",
# `shippable = true` creates a InventoryItem instead of a NonInventoryItem
:shippable => false
)
sku = Stripe::SKU.create(
:id => "your_product_sku_#{randomization_token}",
:product => product.id,
:price => 15_00,
:currency => 'usd',
:inventory => {
'type' => 'infinite'
}
)
order = Stripe::Order.create(
:currency => 'usd',
:items => [
{
:type => 'sku',
:parent => sku.id
}
],
:shipping => {
:name => 'John Doe',
:address => {
:line1 => '1234 Main street',
:line2 => 'Top Floor',
:city => 'Anytown',
:country => 'US',
:postal_code => '123456'
}
},
:customer => customer.id
)
order.pay(customer: customer)
@philipdenys
Copy link

got this in JS?

@iloveitaly
Copy link
Author

@philipdenys I don't, unfortunately!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment