#connectplatform-ruby-requestid
1 messages · Page 1 of 1 (latest)
Hey @fluid nest. Let me show you a few things
https://github.com/stripe/stripe-ruby#accessing-a-response-object that's how you can access a request id yourself but it's a bit annoying
We put the request id in the exception too but I need to remember where, let me check
We just want to log it
sure but to log it you need to access it :p
yeah okay if you log the whole exception it has the request id!
I just tried and I got Error is: (Status 402) (Request req_123) Your card was declined. for puts "Error is: #{e}" so what you have should work
koopajah, is StandardError sufficient to cover all cases or do we need other things in the rescue block. For me in the CLI, I get this for e in the rescue block and there is no request id.
e:
irb(main):023:0> e
=> #<Stripe::PermissionError: (Status 403) The provided key 'sk_live_**************' does not have access to account 'acct_xxxxxxxxxx' (or that account does not exist). Application access may have been revoked.>
e.message is the same as e and
e.request_id is nil
irb(main):025:0> e.request_id
=> nil
yeah you're misunderstanding most of what I said I think
there's no request_id property on that exception, it appears when you log the exception itself, and you want to catch a Stripe exception
I'd recommend reading https://stripe.com/docs/error-handling?lang=ruby and catching rescue Stripe::StripeError => e
begin
pi = Stripe::PaymentIntent.create({
amount: 2000,
currency: 'usd',
payment_method_types: ['card'],
payment_method: 'pm_card_chargeDeclined',
confirm: true
})
rescue Stripe::StripeError => e
puts "Error is: #{e.error.message}"
puts "Error is: #{e}"
end``` try that code for example
Sorry, man, I don't see a request id.
begin
customer = Stripe::Customer.retrieve(stripe_connect_customer_id, :stripe_account => @site.stripe_user_id)
rescue Stripe::StripeError => e
Rails.logger.warn "StandardError => e: #{e}"
Rails.logger.warn "StandardError => e.error: #{e.error}"
Rails.logger.warn "StandardError => e.error.message: #{e.error.message}"
end
That is a failing API call
I see now the e.error has some good data....but I do not see the request id even when we use Stripe::StripeError => e
I would love a key that is request_id but do not see it
=> #Stripe::ErrorObject:0x3fa0d08ed8c4 JSON: {
"code": "account_invalid",
"doc_url": "https://stripe.com/docs/error-codes/account-invalid",
"message": "The provided key 'sk_live_' does not have access to account 'acct_xxxxxx' (or that account does not exist). Application access may have been revoked.",
"type": "invalid_request_error"
}
i see code, doc_url, message, and type but no request_id?
hum
old API?
how do you trigger that error exactly?
also why not test in test mode like all devs 😅
i could. this was an actual strange error in production i'm debugging. My developer has a test account set up in production and connected to Stripe and was on a fake active site but I guess we deauthroized him so we are making an API call to a connected account that has deauthorized. I was just in the midst of figuring out why the job was throwing an error and had it up in my CLI so was using that as the example. I just want to return from that error since it may happen again and muddies the waters so I want to log the request ID and return.
API call fails since the connect account has deauthorized but we still have in our db that he is active.
customer = Stripe::Customer.retrieve(stripe_connect_customer_id, :stripe_account => @site.stripe_user_id)
We try to get a customer on the connected account.
And get a
Stripe::PermissionError: (Status 403)
Okay so I think those requests do not create a request id
because it is connnect?
because they can't succeed at all as you have no permissions on the account
It's like passing the wrong API key. We don't know which account you are since your key is wrong, so we can error but there's no req_123
aha!
same for "Rate limits" we just error way before we start logging the requests
does that make sense?
totally! got it.
I'd say try a card error and a 404 (like retrieve cus_fakefakefake) and those should have the req_123