From c3950f3de28e7ac1e677f4006521ffbed5db4ee0 Mon Sep 17 00:00:00 2001 From: Joe Carstairs <65492573+Sycamost@users.noreply.github.com> Date: Tue, 8 Aug 2023 08:14:29 +0100 Subject: Renames createPaypalOrder -> create-paypal-order --- api-src/createPaypalOrder.ts | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 api-src/createPaypalOrder.ts (limited to 'api-src/createPaypalOrder.ts') diff --git a/api-src/createPaypalOrder.ts b/api-src/createPaypalOrder.ts deleted file mode 100644 index 676d788..0000000 --- a/api-src/createPaypalOrder.ts +++ /dev/null @@ -1,30 +0,0 @@ -import type { VercelRequest, VercelResponse } from '@vercel/node'; -import type Order from './Order'; -import { paypalCreateOrder } from './_paypal'; - -export default async function handler(request: VercelRequest, response: VercelResponse) { - const { productDescription, shortDescription, totalPrice }: Partial = request.body; - - if (request.method !== 'POST') { - console.warn('Method was not POST. Method was ' + request.method); - response.status(404); - return; - } - - if (!productDescription) { - response.status(400).send('Expected body to contain productDescription, but none provided.'); - } else if (!shortDescription) { - response.status(400).send('Expected body to contain shortDescription, but none provided.'); - } else if (!totalPrice) { - response.status(400).send('Expected body to contain totalPrice, but none provided.'); - } else { - try { - const paypalResponse = await paypalCreateOrder({ productDescription, shortDescription, totalPrice }); - response.status(201).json({ - orderId: paypalResponse.id, - }); - } catch (err) { - response.status(500).send(`Internal server error. ${err}`); - } - } -} -- cgit v1.2.3