
Ask HN: Using Cognito with Stripe subscription - ohsik
Hi, I&#x27;m new to AWS + Stripe and trying to figure out how I&#x27;m going to make this work for the monthly subscription system with using AWS Cognito and Stripe on a serverless web app.<p>I set up Cognito User Pools for my app to have users sign up. My thoughts on the monthly subscription system.<p>1. Create User Pools groups ( paid_member and member )
2. Assign user to member User Pools group on signup
3. Move user to paid_member group when user enter credit card information
4. Implement Strip subscription to paid_member Cognito User Pools
5. Cancel subscription, move the user back to member User Pools group<p>Does it make sense and will actually work?
I would love to hear other solutions on this too.
======
mattbgates
Sounds like it will work. Keep it simple.

User signs up for your website, becomes a member.

User likes your app and pays a monthly subscription: they click on button, pay
with their credit card, and you change them to a paid user.

User unsubscribes, you move them back.

I'm currently using Stripe and PHP.

So here are some technicalities that I came across when building my saas:

Credit cards have an expiration date so you need to either capture this and
store it into the database and do a check for it.

Upon credit card expiration -- like 5 days before, email the user, or pop up a
form alerting the user their credit card is about to expire.

You should also be checking the actual card to make sure it is valid.

You will probably need to build an area for the user to have the ability to
update their credit card.

There are two ways you can use Stripe and I spoke with a Stripe representative
to confirm both were okay.

1) Stripe Webhooks will tell you what is going on with a user.

Upon receiving these webhooks, you will need make your program do something.

[https://stripe.com/docs/webhooks](https://stripe.com/docs/webhooks)

[https://www.masteringmodernpayments.com/stripe-webhook-
event...](https://www.masteringmodernpayments.com/stripe-webhook-event-
cheatsheet)

Those 2 links will pretty much give you everything you need.

2) Store all your data in a database and use that information instead of
relying completely on Stripe.

Before I knew about web hooks.. I actually use(d) #2. And I'm still using it
for my web apps.

I use webhooks to capture the moment the third attempt of a credit card charge
fails just so I know this user is not actively engaged anymore.

Other than that, I offer a set amount of X a month and I set a monthly renew
date.

When the user subscribes, this becomes their new renew date. I grab this info:

$period_end = $subscription->current_period_end;

I add a day to the period end since the actual renew day is 12:00:00 AM the
next day.

So on the day of their renew day, you need to check for that credit card
expiration and to see if they are still active (Stripe will do all the work of
making sure it is an active valid credit card and let you know if the user
status is "active" or not. If the checks fail, you have it switch the user
back to an unpaid account and you should probably have it send an email that
their account has been reverted back to free "due to issues".

Implementing these checks and balances will protect you and save you a lot of
time and work, especially from fraud.

IF you choose #2 route, Stripe support will do very minimal in helping you
with anything that goes wrong.

~~~
ohsik
Thank you so much for the reply. This will help me a lot to work on Stripe!

