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

Lazy initialize stripe configuration #53

Closed
josemarluedke opened this issue Aug 1, 2019 · 1 comment · Fixed by #59
Closed

Lazy initialize stripe configuration #53

josemarluedke opened this issue Aug 1, 2019 · 1 comment · Fixed by #59

Comments

@josemarluedke
Copy link
Contributor

The lazy option to load Stripe is amazing. Thanks for having that already.

We have a use case where we need to set up the stripe publishable key in runtime instead of having it hardcoded in config/environment.js. (We fetch this information from our API.)

Today I can do that using a hack, but it would be nice to have an official way set stripe configuration at runtime.

Here is the approach I have.

// in beforeModel 
this.stripe.config.publishableKey = 'pk_my-new-key';
return this.stripe.load();

This relies on the fact that the initializer injects the config in the service, so we just override the value.

We also need to set some value in config/environment.js for publishableKey, otherwise, we get an error.

A possible alternative is to have configure method from the service take arguments to be used in the initialization of stripe.

The error from the initializer should be moved to the configure method instead. Currently defined here.

@josemarluedke
Copy link
Contributor Author

I guess #39 is trying to solve the same issue.

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

Successfully merging a pull request may close this issue.

1 participant