Create StripeSession type

This commit is contained in:
Forrest Wolf 2022-05-25 11:37:13 -04:00
parent ccf8ffb0b5
commit 9d3c15b115

View File

@ -5,11 +5,13 @@ import Stripe from 'stripe'
import { getPrivateUser, getUser, isProd, payUser } from './utils' import { getPrivateUser, getUser, isProd, payUser } from './utils'
import { sendThankYouEmail } from './emails' import { sendThankYouEmail } from './emails'
export type StripeSession = Stripe.Event.Data.Object & { id: any, metadata: any}
export type StripeTransaction = { export type StripeTransaction = {
userId: string userId: string
manticDollarQuantity: number manticDollarQuantity: number
sessionId: string sessionId: string
session: any session: StripeSession
timestamp: number timestamp: number
} }
@ -96,14 +98,14 @@ export const stripeWebhook = functions
} }
if (event.type === 'checkout.session.completed') { if (event.type === 'checkout.session.completed') {
const session = event.data.object as any const session = event.data.object as StripeSession
await issueMoneys(session) await issueMoneys(session)
} }
res.status(200).send('success') res.status(200).send('success')
}) })
const issueMoneys = async (session: any) => { const issueMoneys = async (session: StripeSession) => {
const { id: sessionId } = session const { id: sessionId } = session
const query = await firestore const query = await firestore