TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Using Cognito with Stripe subscription

1 点作者 ohsik大约 8 年前
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.

1 comment

mattbgates大约 8 年前
Sounds like it will work. Keep it simple.<p>User signs up for your website, becomes a member.<p>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.<p>User unsubscribes, you move them back.<p>I&#x27;m currently using Stripe and PHP.<p>So here are some technicalities that I came across when building my saas:<p>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.<p>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.<p>You should also be checking the actual card to make sure it is valid.<p>You will probably need to build an area for the user to have the ability to update their credit card.<p>There are two ways you can use Stripe and I spoke with a Stripe representative to confirm both were okay.<p>1) Stripe Webhooks will tell you what is going on with a user.<p>Upon receiving these webhooks, you will need make your program do something.<p><a href="https:&#x2F;&#x2F;stripe.com&#x2F;docs&#x2F;webhooks" rel="nofollow">https:&#x2F;&#x2F;stripe.com&#x2F;docs&#x2F;webhooks</a><p><a href="https:&#x2F;&#x2F;www.masteringmodernpayments.com&#x2F;stripe-webhook-event-cheatsheet" rel="nofollow">https:&#x2F;&#x2F;www.masteringmodernpayments.com&#x2F;stripe-webhook-event...</a><p>Those 2 links will pretty much give you everything you need.<p>2) Store all your data in a database and use that information instead of relying completely on Stripe.<p>Before I knew about web hooks.. I actually use(d) #2. And I&#x27;m still using it for my web apps.<p>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.<p>Other than that, I offer a set amount of X a month and I set a monthly renew date.<p>When the user subscribes, this becomes their new renew date. I grab this info:<p>$period_end = $subscription-&gt;current_period_end;<p>I add a day to the period end since the actual renew day is 12:00:00 AM the next day.<p>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 &quot;active&quot; 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 &quot;due to issues&quot;.<p>Implementing these checks and balances will protect you and save you a lot of time and work, especially from fraud.<p>IF you choose #2 route, Stripe support will do very minimal in helping you with anything that goes wrong.
评论 #13997557 未加载