You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Title: Stripe Plugin Environment Variable Handling for Non-dotenv Configurations
Description
The current implementation of the Stripe plugin has a rigid dependency on process.env.STRIPE_SECRET_KEY, assuming it's set via dotenv. This causes issues when using alternative deployment configurations like SST, where environment variables are injected differently.
Current Behavior
The plugin currently looks for process.env.STRIPE_SECRET_KEY in three instances, ignoring the Stripe key that's passed into the plugin configuration.
This forces users to implement hacky workarounds, such as manually setting process.env.STRIPE_SECRET_KEY at the top of the payload config, which can lead to errors and is not a robust solution.
Current places Payload does not use the passed in Stripe secret key but only looks for the env var:
Prioritize the Stripe key passed through the plugin configuration
Fall back to or not use process.env.STRIPE_SECRET_KEY
Support different environment variable injection methods beyond dotenv
Proposed Solution
Refactor the plugin to implement a more flexible environment variable handling system:
// Example implementationconstgetStripeKey=(config)=>{if(config.stripeKey){returnconfig.stripeKey;}if(process.env.STRIPE_SECRET_KEY){returnprocess.env.STRIPE_SECRET_KEY;}thrownewError('No Stripe key provided. Please provide it either through plugin configuration or STRIPE_KEY environment variable.');}
Use Case
When using SST (Serverless Stack) for deployment, environment variables are injected at runtime, and we cannot guarantee they'll be available through process.env.STRIPE_KEY. The current implementation makes it difficult to use the plugin in this and similar scenarios.
Impact
This issue affects anyone using the Stripe plugin with:
SST
Other serverless platforms with custom environment variable injection
Custom environment variable management solutions
Container-based deployments with different env variable patterns
Let me know if you need any additional information or clarification.
Describe the Bug
Title: Stripe Plugin Environment Variable Handling for Non-dotenv Configurations
Description
The current implementation of the Stripe plugin has a rigid dependency on
process.env.STRIPE_SECRET_KEY
, assuming it's set via dotenv. This causes issues when using alternative deployment configurations like SST, where environment variables are injected differently.Current Behavior
process.env.STRIPE_SECRET_KEY
in three instances, ignoring the Stripe key that's passed into the plugin configuration.process.env.STRIPE_SECRET_KEY
at the top of the payload config, which can lead to errors and is not a robust solution.Current places Payload does not use the passed in Stripe secret key but only looks for the env var:
https://github.com/payloadcms/payload/blob/main/packages/plugin-stripe/src/hooks/createNewInStripe.ts
https://github.com/payloadcms/payload/blob/main/packages/plugin-stripe/src/hooks/deleteFromStripe.ts
https://github.com/payloadcms/payload/blob/main/packages/plugin-stripe/src/hooks/syncExistingWithStripe.ts
Ideal Behavior
The plugin should:
process.env.STRIPE_SECRET_KEY
Proposed Solution
Refactor the plugin to implement a more flexible environment variable handling system:
Use Case
When using SST (Serverless Stack) for deployment, environment variables are injected at runtime, and we cannot guarantee they'll be available through
process.env.STRIPE_KEY
. The current implementation makes it difficult to use the plugin in this and similar scenarios.Impact
This issue affects anyone using the Stripe plugin with:
Let me know if you need any additional information or clarification.
Link to the code that reproduces this issue
https://github.com/payloadcms/payload
Reproduction Steps
Example stripe plugin set up produces error:
Which area(s) are affected? (Select all that apply)
plugin: stripe
Environment Info
The text was updated successfully, but these errors were encountered: