(req: NextApiRequest, res: NextApiResponse)
| 7 | }); |
| 8 | |
| 9 | export default async function handler(req: NextApiRequest, res: NextApiResponse) { |
| 10 | const id: string = req.query.id as string; |
| 11 | try { |
| 12 | if (!id.startsWith("cs_")) { |
| 13 | throw Error("Incorrect CheckoutSession ID."); |
| 14 | } |
| 15 | const checkout_session: Stripe.Checkout.Session = await stripe.checkout.sessions.retrieve(id, { |
| 16 | expand: ["payment_intent"], |
| 17 | }); |
| 18 | |
| 19 | res.status(200).json(checkout_session); |
| 20 | } catch (err) { |
| 21 | const errorMessage = err instanceof Error ? err.message : "Internal server error"; |
| 22 | res.status(500).json({ statusCode: 500, message: errorMessage }); |
| 23 | } |
| 24 | } |
nothing calls this directly
no outgoing calls
no test coverage detected