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 { sendThankYouEmail } from './emails'
export type StripeSession = Stripe.Event.Data.Object & { id: any, metadata: any}
export type StripeTransaction = {
userId: string
manticDollarQuantity: number
sessionId: string
session: any
session: StripeSession
timestamp: number
}
@ -96,14 +98,14 @@ export const stripeWebhook = functions
}
if (event.type === 'checkout.session.completed') {
const session = event.data.object as any
const session = event.data.object as StripeSession
await issueMoneys(session)
}
res.status(200).send('success')
})
const issueMoneys = async (session: any) => {
const issueMoneys = async (session: StripeSession) => {
const { id: sessionId } = session
const query = await firestore