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

Adds option to set publishableKey in on instance creation #5

Closed
wants to merge 1 commit into from

Conversation

lennartzellmer
Copy link

@lennartzellmer lennartzellmer commented Feb 10, 2021

Since this package is running on client side only, rebuilding for every change in the nuxt config or environment variable is not necessary.

Using runtimeconfig would be the better way to provide the publishableKey to the getStripeInstance function
https://nuxtjs.org/docs/2.x/directory-structure/nuxt-config#runtimeconfig

I have the feeling that having a factory function for getStripeInstance would be a bit cleaner, but I am not able to get the type configuration working =/

After my changes, I am using it like this:
const stripe = await $stripe(undefined, $config.stripe.publishableKey)

@lennartzellmer lennartzellmer changed the title Adds option to set publishableKey in on creation Adds option to set publishableKey in on instance creation Feb 10, 2021
@fabiofdsantos
Copy link
Contributor

@lennartzellmer, thanks for your PR!

The plugin.ts already contains the context, which means you can access the "runtime config" via ctx.$config:

const stripePlugin: Plugin = (ctx, inject): void => {

I understand your point but we need to find a clean way to support "runtime config".

@fabiofdsantos
Copy link
Contributor

I've introduced support to runtime configuration 👍🏻

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 this pull request may close these issues.

None yet

2 participants