Closed flozero closed 1 year ago
I'm sorry, I don't fully understand why open up another PR when there is already an existing one with an ongoing discussion with the other maintainers of the project...
This said I do like the approach of exposing other client/server configs directly to the nuxt.config
but relying on the addPlugin it will still make the stripe-js instance load all across the nuxt project instead of where the developers wants it to, degrading the performance of the website/app after the user has visited the stripe-js checkout. I know there isn't proper testing for this, but IMO performance should be taken in consideration.
I'm on mobile rn, so I cannot do some more testings, but why wrap around the useClientStripe in a ClientOnly if it is already something dealt with?
A short list of inconsistencies in this PR I've noticed so far:
stripe-js
load and not truely lazyloading it.stripe-js
(could be an issue on my side tho, I need someone else to confirm this).stripe-js
being loaded server-side (loadStripe
already checks and report this).I would like to hear your opinion @flozero, in particular why open up a new PR that doesn't fully solve the already discussed topics and where did you find the docs for the additional configuration options for both client and server side stripe modules?
I would like to point out another small inconsistency that could degrade the DX for less experienced developers.
Through both stripe
and stripe-js
docs (and in their respective typescript interfaces) it is mentioned multiple times the structure of stripe(apiKey, config)
and stripe(publishableKey, options)
.
IMHO I would keep this structure for a better DX and docs fruition, as I have already done in #19:
export default defineNuxtConfig({
modules: [
'@unlok-co/nuxt-stripe'
],
stripe: {
// Server
apiKey: 'sk_test_123', // required
- apiVersion: '2022-11-15', // optional, default is '2022-11-15'
+ serverConfig: {
+ apiVersion: '2022-11-15', // optional, default is '2022-11-15'
+ },
// Client
publishableKey: 'pk_test_123', // required
+ clientConfig: {
+ apiVersion: '2022-11-15', // optional, default is '2022-11-15'
+ },
}
})
and not to use the proposed change of this PR:
export default defineNuxtConfig({
modules: [
'@unlok-co/nuxt-stripe'
],
stripe: {
// Server
- apiKey: 'sk_test_123', // required
- apiVersion: '2022-11-15', // optional, default is '2022-11-15'
- // Client
- publishableKey: 'pk_test_123', // required
+ server: {
+ key: 'sk_test_123',
+ options: {
+ // your api options override for stripe server side
+ apiVersion: '2022-11-15', // optional, default is '2022-11-15'
+ }
+ // CLIENT
+ },
+ client: {
+ key: 'pk_test_123',
+ // your api options override for stripe client side
+ options: {
+
+ }
+ }
}
})
But, if accepted, this would need to be reflectedon the env variables, that would break the syntax of the official docs:
-NUXT_PUBLIC_STRIPE_PUBLISHABLE_KEY="pk_live_..."
-NUXT_STRIPE_API_KEY="sk_live_..."
+NUXT_PUBLIC_STRIPE_CLIENT_KEY="pk_live_..."
+NUXT_STRIPE_SERVER_KEY="sk_live_..."
not to mention that client-key
could be missleading and associated to something like customer-id
or account-key/id
.
Resolve #19 #20 #18
Types of changes
Description
Checklist: