Create StripeSession type
This commit is contained in:
parent
ccf8ffb0b5
commit
9d3c15b115
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user