How do I add additional products?

I am using the SaaS template and have the 'out of the box' subscription product working. I want to add an additional product option (like the one that exists on the PricingPage.tsx). Here is where my lack of recent dev experience shows. It appears like I would need to pass a var into the stripePayment() call on the PricingPage.tsx noting which button was clicked. And then update Server\Actions.ts to accept that var and update line_items as well as mode in the checkout session based on the details of that var. Is that the best way to approach this? Or is there a simpler path that I am not seeing?
6 Replies
martinsos
martinsos2y ago
@Vinny (@Wasp) is the most experienced with this so I am mentioning him :)!
Vinny (@Wasp)
Vinny (@Wasp)2y ago
Not quite. I think you’d want to go first to the main.wasp file and create a new action for that specific product Then you’d call that function you created rather than stripePayment. Then uncomment out the other product check in the webhook and fill in that products details
hometechdad
hometechdad2y ago
Ok, that makes sense. Would there also need to be changes in Server\Actions.ts? It appears that SUBSCRIPTION_PRICE_ID is coded in that file and we would need to send a different product ID. Correct?
hometechdad
hometechdad2y ago
Yep, referred back to the great wasp documentation (https://wasp-lang.dev/docs/tutorials/todo-app/04-creating-tasks#action). Then duplicated the export const stripePayment function, renamed it and updated line_items to the 2nd product price id env variable as well as mode to 'payment'. It seems to be working now.
Creating tasks | Wasp
To enable the creation of new tasks, we will need two things:
Vinny (@Wasp)
Vinny (@Wasp)2y ago
You got it! If you do payment mode and not subscription, then you’ll only be making a one-time sale. I’m assuming that’s what you want though
hometechdad
hometechdad2y ago
Yep, I wanted to give them the option of 1 time or subscription.
Want results from more Discord servers?
Add your server