#accua
1 messages · Page 1 of 1 (latest)
Hello! What version of the Stripe Ruby library are you using? What version of Ruby are you using?
stripe gem: 8.5.0
ruby: 3.2.0
Hm. Does Stripe::Balance.retrieve() work?
No, this method doesn't take an argument.
It only fetches your balance: https://stripe.com/docs/api/balance/balance_retrieve?lang=ruby
it looks like it returned a json object, but it also gave an error: Read: #<NoMethodError: undefined method `bytesize' for [:object, "balance"]:Array>
and the ui is reporting this
It's reporting that for the balance retrieve or for your original code? Or both?
balance retrieve
Okay, looks like you're trying to use an account ID for your API key.
When initializing the Ruby library you need to specify your API key (starts with sk_ for "secret key"), not your account ID (starts with acct_).
that.. doesn't make sense. 🤔 I've set the Stripe.api_key = "sk_test_XXXXXXXXXXXXXX..."
Can you share all of your Stripe code, but with the API key redacted?
require 'sinatra'
require 'stripe'
require 'pry'
This is your test secret API key.
Stripe.api_key = 'sk_test_XXXX'
set :port, 5000
enable :sessions
set :static, true
set :public_folder, File.join(File.dirname(FILE), "/public")
get '/get_account' do
p Stripe::Balance.retrieve
end
Hm. Maybe there's some obscure Ruby-specific thing happening here. I'm not the best with Ruby; @open widget do you have thoughts on the above?
I'm not overly familiar with Ruby nuances either, but it does seem like something is interfering with your API key there. That error message doesn't really make sense with an account ID as an invalid key
agreed
Can you try running the basic balance retrieve without the sinatra setup involved?
require 'stripe'
Stripe.api_key = 'sk_test_123'
Stripe::Balance.retrieve()
this works, it's gotta be a sinatra issue. Thank you.
NP - hopefully you're able to find out where thats coming from! Let us know if it turns out to be something you think we can improve in the SDK here