Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of creating a BitCoin charge in Stripe and inspecting the resulting NetSuite CustomerPayment using http://SuiteSync.io
# Michael Bianco <mike@suitesync.io>
require 'stripe'
Stripe.api_key = 'sk_test_xxx'
customer = Stripe::Customer.create(
:description => "Sample customer for bitcoin test",
:email => "bitcoin-#{Time.now.to_i}@example.com",
)
bitcoin_receiver = Stripe::BitcoinReceiver.create(
:amount => 10_00,
:currency => "usd",
:email => customer.email
)
# NOTE bitcoin receivers are 'filled' async
# TODO check to see if this is resolved in future Stripe API updates
while !bitcoin_receiver.filled do
puts "waiting for bitcoin payment to fill"
sleep(1)
bitcoin_receiver.refresh
end
customer.sources.create(source: bitcoin_receiver.id)
charge = Stripe::Charge.create(
:amount => bitcoin_receiver.amount,
:currency => bitcoin_receiver.currency,
:customer => customer.id,
:description => bitcoin_receiver.email,
)
# retrieve the internalId of the created CustomerPayment in NetSuite
# NOTE this will only work if your integration account is processing live translations
loop do
charge.refresh
if internal_id = charge.metadata['netsuite_customer_payment_id']
puts "CustomerPayment Internal ID: #{internal_id}"
exit(0)
end
puts "Waiting for BitCoin charge to translate to NetSuite..."
sleep(1)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.