Introducing Redwoodjs-Stripe plugin! A super simple way of scaffolding your very own commerce site using Stripe Checkout. By running one command you will get the boilerplate (schemas, services, and React hooks) you need for a simple online store as well as a little example store to show you how to use the plugin AND super simple cart functionality to help you get started. To get started, run the following command and enter your Stripe credentials when prompted:
npx @redwoodjs-stripe/cli@latest setup
This is only the beginning. Take a look at the docs for more information. There is much more to come! Please check it out and let me know what you think and what you would like to see.
A special thanks to RedwoodJS and Stripe teams for all the help
Excited to see the next features ahead as well!
Hi @chrisvdm ,
I’m trying to integrate the redwoodjs-stripe plugin into my web app. I was wondering if there’s any hook for checking whether the logged in user has an active stripe subscription?
Use case: pass the stripeId for the logged in use to a hook that returns true / false if a user has an active subscription or not. If not, redirect user to the “choose subscription” page.
Some help / example would be appreciated, as I’m struggling to figure out how to do this.
Hey Charlie - I am close to the edge of my understanding here… but checking this line
It looks like you may be able to check this field for available subscriptions.
There is also the Subscriptions SDL which presents a lot of fields, but maybe the status field would say active or not?
I’m not sure on the front end, through the hooks, where this property would be accessible. The README states “* Subscription support via
useStripeCustomerPortal() hook” so I guess its available at some point.
Thanks! Also thank you for giving the plugin a go.
There is no hook like that at the moment. Would something that returns a list of a customer’s active subscriptions work? Then you can check for empty list to redirect?
I’m busy working on something to do that. Will update once I’m finished.
That would work great, actually - thank you! Maybe also include all stripe fields for a subscription, so that more logic can be implemented in the future using those fields.
So I have two ways of you getting subscriptions per customer. One is via the useStripeCustomer hook and the other via the useStripeSubscriptions hook…This PR has examples you can follow: https://github.com/chrisvdm/redwoodjs-stripe/pull/121
I’m trying out a new api so there could be bugs if you used the services directly ie made your own custom services using the plugin services. You should able to pass a Fragment to the hook and expand fields. Let me know if you have any issues.
@charliem I forgot to add run
npx @redwoodjs-stripe/cli@latest upgrade to get the latest release. (v1.0.1)
This is fantastic, exactly what I needed. Thank you.
FYI I think a bug was introduced with the prettyList function in stripeCustomerSearch. If the result of the search is null (as there’s no existing customer), prettyList is trying to convert that to an object, and I get a “Cannot convert undefined or null to object.”
I think the line below is causing the bug (whenever there’s no customer returned from the search, as one doesn’t exist yet).
@charliem Thanks for the catch!
You can upgrade now.
prettyList checks for empty objects
@chrisvdm that worked and I have the whole integration working, thank you for your help!
I also have a feature idea: The context should also hold the subscriptions object, so that you can easily create logic in an app based on which subscription someone has.
Use case: activate / deactivate certain features based on whether someone is on a “Basic” or “Premium” subscription. Having that info in the context stack would be very useful.
@charliem I’m glad your integration is working and you are most welcome Thank you for being patient.
Re feature idea: I can see the value in storing a customer’s subscription object in the context. I honestly hadn’t thought of that. Thank you
Please let me know if you have any more issues/ideas
@chrisvdm my pleasure, and thank you for such a great plugin! Will definitely reach out if I have more ideas .