#karina_ruby-stripeclient

1 messages ยท Page 1 of 1 (latest)

tiny mangoBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1230640610973716481

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

cerulean streamBOT
#

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

onyx scarab
#

turns out this was not an rspec issue. but rather just a stripe ruby gem issue

granite citrus
#

Oh? Just to be clear, do you still need help?

onyx scarab
#

just informing of a bug, and i was hoping to ask if there is a way to rip the stale client out of given stripe objects so that i can do "existing_client.request" rather than "Stripe::StripeClient.new.request"

#

or if perhaps there would be a more standard way to achieve the above that i'm missing?

granite citrus
#

What are you trying to do exactly? I see the first line is trying to retrieve a Subscription; I take it you're passing a Subscription ID in the request parameters. What are you trying to do with the second line?

onyx scarab
#

those are the reproduction steps. In my case actual case, my code only has a handle on the stripe subscription object. and i need to make a change to it. I am capturing the response because in this case i want to explicitly ignore all incoming stripe events that spawn from that request.

cerulean streamBOT
onyx scarab
#

I would prefer not to do a raw "Stripe::Subscripion.update(id, params, {api_key: ..})" call because my system needs to talk to many stripe instances and knowledge of which particular instance (and therefore which api key) i need to communicate with is harder to get at this point

clear dagger
#

๐Ÿ‘‹ I admit I haven't really done that code with that SDK in a while. Not entirely sure I follow why you expect there to be a return value. Can you maybe give a simple end to end full repro?

#

karina_ruby-stripeclient

onyx scarab
#

stripe_object = Stripe::Subscripion.retrieve(...)
stripe_object, response = Stripe::StripeClient.new.request { stripe_object.save(...) }. # here response is nil

#

stripe_object, response = Stripe::StripeClient.new.request { Stripe::Subscription.update(...) }. # here response is present

clear dagger
#

I'm sorry this is super confusing and not runnable real code ๐Ÿ˜…

#

what does # here response is present mean? That it works? That you expect this to work but it doesn't?

onyx scarab
#

i expect line 2 to return a response, but it doesn't

#

when running it like line 3 it works

#

do you want me to insert ids to make it runnable?

clear dagger
#

I mean ids won't really help since they only work on your account with your key. But yes I was hoping you could write an end to end full script that shows the issue for anyone if possible.
I'm trying to figure out why you're even doing a .save() in that function when this has been deprecated for many years

onyx scarab
#

oh curious, i did not know it was deprecated

#

oh nm i see it now

clear dagger
#

Gotcha, so yeah we added the update() approach years ago and .save() has always had a lot of history/quirks and is highly discouraged

#

so if the issue is specific to .save() I'm not surprised the response isn't stored

#

because that one updates the stripe_object in place, it's a bit of a weird pattern

onyx scarab
#

update on the class?

clear dagger
#

on that local variable, not the class

clear dagger
#

yep that

onyx scarab
#

hm. so is there a way to get the api key out of the object?

clear dagger
#

why do you want the API key? ๐Ÿ˜…

onyx scarab
#

because my app talks to many instances of Stripe, we always have to send the api key when using the class methods

clear dagger
#

Yeah I'm sorry you're losing me a lot not, it feels like trying to do a lot of magic when you should know which client to use for which resource you're accessing/using

onyx scarab
#

i can get it by other means, but i was hoping to avoid it and keep this service class clean

clear dagger
#

I thought it worked fine with .update() though so I don't get the problem. Just never use .save()

onyx scarab
#

yeah, i will look into dropping all instances of .save()

clear dagger
#

yeah I don't think there's a way to get the client logic you're using to work with .save(). But I also don't think you should ever use that approach to re-extract API keys either

onyx scarab
#

k, sounds good, i'll go rearchitect this class in so that we pass the appropriate client in down from the top bits of code that know about which client to talk to

clear dagger
#

๐Ÿ‘