Login to buy

Hi, When a user is not logged in or hasn't yet signup, the pricing page button says "Login to buy". But after the login user is redirected to landing or dashboard pages (which is expected normally). How to redirect the user to payment processor after the login/signup if they had clicked "Login to Buy"?
2 Replies
kapa.ai
kapa.ai2w ago
Hi @Acer. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To address your specific question about redirecting users to a payment processor after login/signup when they click "Login to Buy", Wasp doesn't have a built-in feature for this exact scenario. However, there are a few approaches you could consider: 1. Use the onAuthSucceededRedirectTo option: Wasp provides an onAuthSucceededRedirectTo option that allows you to specify where to redirect after successful login/signup. However, this is a global setting and doesn't account for the specific "Login to Buy" scenario Allow specifying where to redirect after successful login/signup (https://github.com/wasp-lang/wasp/issues/1360). 2. Implement a custom solution: You could create a custom solution by: a. Setting a flag or storing the intended destination (payment processor page) in local storage or a cookie before redirecting to login/signup.
b. After successful login/signup, check for this flag/stored destination in your main app component or a protected route.
c. If the flag/destination exists, redirect to the payment processor; otherwise, proceed to the default dashboard. 3. Use custom server actions: There's an open feature request to add hooks after login/sign-in to execute custom server code Add hooks after login / sign-in, to execute custom server code (https://github.com/wasp-lang/wasp/issues/1556). While this isn't implemented yet, you could potentially use a custom sign-up action to achieve something similar Creating a Custom Sign-up Action (https://wasp-lang.dev/docs/auth/email#creating-a-custom-sign-up-action). Given the current state of Wasp, the second option (implementing a custom solution) would likely be the most feasible approach to achieve your desired behavior. You would need to handle this logic in your client-side code, possibly using React Router for navigation control. Remember to also consider the user experience for already logged-in users, ensuring they can directly access the payment processor when clicking "Buy" without going through the login flow. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Acer, 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?
miho
miho2w ago
Have you tried what the bot suggested?
Want results from more Discord servers?
Add your server