Stripe integration flow

This commit is contained in:
metacryst
2026-03-05 00:29:34 -06:00
parent bdd260c2b5
commit 661bf86a1a
17 changed files with 303 additions and 117 deletions

View File

@@ -28,6 +28,7 @@ class Server {
/* Stripe */
router.post("/create-checkout-session", PaymentsHandler.newSubscription)
router.post("/webhook", express.raw({ type: "application/json" }), PaymentsHandler.webhook)
router.post('/api/stripe/onboarded', PaymentsHandler.finishConnectSetup)
/* Auth */
router.post('/login', this.auth.login)
@@ -39,32 +40,10 @@ class Server {
router.get('/db/images/*', this.getUserImage)
router.get('/api/orgdata/*', this.getOrgData)
router.get('/api/mydata/*', this.getPersonalData)
router.get('/api/stripe/onboarded', this.stripeOnboarded)
router.get('/*', this.get)
return router
}
async stripeOnboarded() {
const { code } = req.body;
const response = await stripe.oauth.token({
grant_type: "authorization_code",
code,
});
const { stripe_user_id, access_token } = response;
await db.users.update({
where: { id: req.user.id },
data: {
stripeAccountId: stripe_user_id,
stripeAccessToken: access_token,
}
});
res.json({ success: true });
}
getPersonalData = async (req, res, next) => {
try {
const memberId = req.params[0]
@@ -243,8 +222,10 @@ class Server {
constructor() {
this.db = new Database()
global.db = this.db
this.auth = new AuthHandler()
global.db = this.db
global.auth = this.auth
global.payments = PaymentsHandler
const app = express();
app.post("/webhook", express.raw({ type: "application/json" }), PaymentsHandler.webhook)
const allowedOrigins = new Set([