Skip to content

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

@JacekD98

Description

@JacekD98

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions