Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let StripeClient be built with an app_info that overrides the global Stripe.app_info #1525

Open
JacekD98 opened this issue Jan 23, 2025 · 1 comment

Comments

@JacekD98
Copy link

JacekD98 commented Jan 23, 2025

Is your feature request related to a problem? Please describe.

It can be annoying to be dynamically setting the app info based on the execution context for every http request, as you need to take care to reset it to what it was before. Before, you need to do something along the lines of:

def xyz
  previous_app_info = Stripe.app_info
  some_condition = Foo.condition?
  
  Stripe.set_app_info("bar") if some_condition
  
  stripe_client.request do
    return block.call
  end
ensure
 Stripe.app_info = previous_app_info if some_condition
end

and then wrap your requests, in the case of an app info changing dynamically.

Describe the solution you'd like

Allow a StripeClient initializer to take in an optional app_info param, that will override the global app_info for that instance of the client. This allows you to decide the app info in a certain execution context in a way that is isolated from any other contexts and doesn't have to take care to reset the app info to what it may have been before.

Describe alternatives you've considered

No response

Additional context

No response

@JacekD98
Copy link
Author

#1524

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

No branches or pull requests

1 participant