mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 20:26:49 +00:00
24 lines
560 B
TypeScript
24 lines
560 B
TypeScript
import type { CheckoutEndpoint } from '.'
|
|
|
|
const submitCheckout: CheckoutEndpoint['handlers']['submitCheckout'] = async ({
|
|
res,
|
|
body: { cartId },
|
|
config: { restBuyerFetch },
|
|
}) => {
|
|
// Return an error if no item is present
|
|
if (!cartId) {
|
|
return res.status(400).json({
|
|
data: null,
|
|
errors: [{ message: 'Missing item' }],
|
|
})
|
|
}
|
|
|
|
// Submit order
|
|
await restBuyerFetch('POST', `/orders/Outgoing/${cartId}/submit`, {})
|
|
|
|
// Return cart and errors
|
|
res.status(200).json({ data: null, errors: [] })
|
|
}
|
|
|
|
export default submitCheckout
|