W
Wasp2w ago
Sven

Make a new price in strpie

I made a few prices for my stripe subscriptoin plans but i want to adapt them, however some of them have been used so i have to make a new price. What do i need to change in order to succesfully make a new price and use it on my saas.
11 Replies
kapa.ai
kapa.ai2w ago
Hi @Sven. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the knowledge sources, I can help you with setting up a new price for your Stripe subscription plans in your Wasp SaaS application. When you create a new price in Stripe, you'll need to update your environment variables in your Wasp application to reference the new price ID. Here's what you need to do: 1. First, create your new price in the Stripe dashboard 2. Get the price ID from Stripe (it will look something like price_1OXkv5AHms7vVycMvx4PzB0N) 3. Update your .env file with the new price ID From the knowledge sources, it appears that the OpenSaaS template uses environment variables like SUBSCRIPTION_PRICE_ID, HOBBY_SUBSCRIPTION_PRICE_ID, or PRO_SUBSCRIPTION_PRICE_ID to reference Stripe prices. For example, your .env file might contain something like:
HOBBY_SUBSCRIPTION_PRICE_ID=price_1OXkv5AHms7vVycMvx4PzB0N
PRO_SUBSCRIPTION_PRICE_ID=price_1OXkv5AHms7vVycM4IAAGRcT
HOBBY_SUBSCRIPTION_PRICE_ID=price_1OXkv5AHms7vVycMvx4PzB0N
PRO_SUBSCRIPTION_PRICE_ID=price_1OXkv5AHms7vVycM4IAAGRcT
The code that uses these price IDs is in your server actions, where it creates a checkout session:
const session: Stripe.Checkout.Session = await stripe.checkout.sessions.create({
line_items: [
{
price: process.env.SUBSCRIPTION_PRICE_ID!,
quantity: 1,
},
],
mode: 'subscription',
success_url: `${DOMAIN}/checkout?success=true`,
cancel_url: `${DOMAIN}/checkout?canceled=true`,
automatic_tax: { enabled: true },
customer_update: {
address: 'auto',
},
customer: customer.id,
});
const session: Stripe.Checkout.Session = await stripe.checkout.sessions.create({
line_items: [
{
price: process.env.SUBSCRIPTION_PRICE_ID!,
quantity: 1,
},
],
mode: 'subscription',
success_url: `${DOMAIN}/checkout?success=true`,
cancel_url: `${DOMAIN}/checkout?canceled=true`,
automatic_tax: { enabled: true },
customer_update: {
address: 'auto',
},
customer: customer.id,
});
If you're using multiple subscription tiers, you'll need to make sure your code correctly references the appropriate price ID for each tier. If you're having issues with the implementation, you might want to check out the latest version of the OpenSaaS template, as there might be updates that handle multiple subscription tiers more elegantly. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Sven, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Sven
SvenOP2w ago
And how do i sett he secrets when deploying @kapa.ai
kapa.ai
kapa.ai2w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Based on your previous question about Stripe pricing, I understand you're now asking about setting secrets when deploying your Wasp application. Here's how to set environment variables (including secrets) when deploying: Setting Secrets When Deploying The method depends on your deployment platform: For Fly.io If you're using the Wasp CLI for deployment:
wasp deploy fly cmd secrets set STRIPE_SECRET_KEY=<your-key> --context=server
wasp deploy fly cmd secrets set STRIPE_SECRET_KEY=<your-key> --context=server
Or for multiple secrets at once:
wasp deploy fly cmd secrets set GOOGLE_CLIENT_ID=<...> GOOGLE_CLIENT_SECRET=<...> --context=server
wasp deploy fly cmd secrets set GOOGLE_CLIENT_ID=<...> GOOGLE_CLIENT_SECRET=<...> --context=server
If deploying manually:
flyctl secrets set JWT_SECRET=<random_string_at_least_32_characters_long>
flyctl secrets set STRIPE_SECRET_KEY=<your-key>
flyctl secrets set JWT_SECRET=<random_string_at_least_32_characters_long>
flyctl secrets set STRIPE_SECRET_KEY=<your-key>
Deploying Manually - Fly.io For Heroku
heroku config:set --app <app-name> JWT_SECRET=<random_string_at_least_32_characters_long>
heroku config:set --app <app-name> STRIPE_SECRET_KEY=<your-key>
heroku config:set --app <app-name> JWT_SECRET=<random_string_at_least_32_characters_long>
heroku config:set --app <app-name> STRIPE_SECRET_KEY=<your-key>
Deploying Manually - Heroku For Railway Go to the Railway dashboard, open the Settings and go to the Variables tab to add your secrets. Deploying Manually - Railway Important Notes: 1. For client-side environment variables (prefixed with REACT_APP_), you need to provide them during the build process:
REACT_APP_SOME_VAR_NAME=somevalue npm run build

REACT_APP_SOME_VAR_NAME=somevalue npm run build

Defining Env Vars in Production 2. Never store secrets in client-side environment variables as they'll be publicly readable. 3. For Stripe webhook secrets in production, you'll need to create a webhook in the Stripe dashboard pointing to your server URL and then add the webhook secret to your server environment variables. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Sven, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Sven
SvenOP2w ago
"deploy": "REACT_APP_EXTENSION_ID=XX REACT_APP_GOOGLE_ANALYTICS_ID=XXX REACT_APP_API_URL=XXX wasp deploy fly deploy" This is my command in package.json how do i adap to also update secrets @kapa.ai
kapa.ai
kapa.ai2w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- I see you're trying to update server-side secrets while deploying your Wasp app to Fly.io. Your current command correctly sets client-side environment variables (prefixed with REACT_APP_), but server-side secrets need to be handled differently. For server-side secrets, you have two options: Option 1: Set secrets before deployment
wasp deploy fly cmd secrets set SECRET_NAME=secret_value --context=server
wasp deploy fly cmd secrets set SECRET_NAME=secret_value --context=server
Then run your deployment command:
"deploy": "REACT_APP_EXTENSION_ID=XX REACT_APP_GOOGLE_ANALYTICS_ID=XXX REACT_APP_API_URL=XXX wasp deploy fly deploy"
"deploy": "REACT_APP_EXTENSION_ID=XX REACT_APP_GOOGLE_ANALYTICS_ID=XXX REACT_APP_API_URL=XXX wasp deploy fly deploy"
Option 2: Set secrets during initial deployment If you're doing the initial deployment with launch, you can use the --server-secret flag:
"deploy": "REACT_APP_EXTENSION_ID=XX REACT_APP_GOOGLE_ANALYTICS_ID=XXX REACT_APP_API_URL=XXX wasp deploy fly launch my-app-name region-code --server-secret SECRET_NAME=secret_value"
"deploy": "REACT_APP_EXTENSION_ID=XX REACT_APP_GOOGLE_ANALYTICS_ID=XXX REACT_APP_API_URL=XXX wasp deploy fly launch my-app-name region-code --server-secret SECRET_NAME=secret_value"
Deploying with the Wasp CLI Important notes: 1. Your current approach for client-side variables is correct. The REACT_APP_ prefixed variables are embedded into the client code during build time. Defining Env Vars in Production 2. Server-side secrets should never be included directly in your package.json as they would be visible in your code repository. 3. You can verify your server secrets were set correctly with:
wasp deploy fly cmd secrets list --context=server

wasp deploy fly cmd secrets list --context=server

Deploying with the Wasp CLI ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Sven, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Sven
SvenOP2w ago
@kapa.ai how do i integrate a free trial in my pricing options
kapa.ai
kapa.ai2w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Based on the knowledge sources, I can help you integrate a free trial into your Wasp application's pricing options. According to a Discord support thread, you can add a trial period to your Stripe subscriptions by using the trial_period_days parameter when creating a subscription. This is documented in the Stripe API. One community member shared their solution:
I found a way around this: I just add trial_period_days when creating a subscription, here's the doc: https://docs.stripe.com/api/subscriptions/create#create_subscription-trial_period_days
To implement this in your Wasp application, you would need to modify your server-side code where you create the Stripe checkout session. Specifically, you would add the subscription_data parameter with the trial_period_days field when creating the checkout session. Here's how you might modify your code:
const session: Stripe.Checkout.Session = await stripe.checkout.sessions.create({
line_items: [
{
price: process.env.SUBSCRIPTION_PRICE_ID!,
quantity: 1,
},
],
mode: 'subscription',
subscription_data: {
trial_period_days: 14, // Set your desired trial period length in days
},
success_url: `${DOMAIN}/checkout?success=true`,
cancel_url: `${DOMAIN}/checkout?canceled=true`,
automatic_tax: { enabled: true },
customer_update: {
address: 'auto',
},
customer: customer.id,
});
const session: Stripe.Checkout.Session = await stripe.checkout.sessions.create({
line_items: [
{
price: process.env.SUBSCRIPTION_PRICE_ID!,
quantity: 1,
},
],
mode: 'subscription',
subscription_data: {
trial_period_days: 14, // Set your desired trial period length in days
},
success_url: `${DOMAIN}/checkout?success=true`,
cancel_url: `${DOMAIN}/checkout?canceled=true`,
automatic_tax: { enabled: true },
customer_update: {
address: 'auto',
},
customer: customer.id,
});
You'll also want to make sure your application correctly handles the trial status in your UI. You can check the subscription status in your webhook handler to determine if a user is in a trial period. Remember to test this thoroughly using Stripe's test mode before deploying to production. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Sven, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Sven
SvenOP7d ago
@Wasp Team anyone that can help me witht his problem on how to setup a 7day free trial? And how to notify customer that trial is ending? take ur time tho Please @ me
martinsos
martinsos7d ago
Hey @Sven this is quite non-Wasp/OpenSaaS specific -> it is more about Stripe and how stuff work there, and just general React / node. @Vinny (@Wasp) might be able to help, but he is traveling at the moment, and the rest of the team doesn't know Stripe well enough. I actually suggest you would get a better answer by asking GPT probably than us! But if you have something more Wasp or Open-Saas specific, let us know.
Vinny (@Wasp)
Vinny (@Wasp)7d ago
I’ve never done this before. I’d also refer to stripe docs here @Sven
Sven
SvenOP6d ago
Ah okay thanks

Did you find this page helpful?