From fe62cadd6fb4a7e49f7d59401fc74ae0411e32a7 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 26 Aug 2024 21:17:43 -0700 Subject: typescript --- routes/shopify.js | 41 ----------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 routes/shopify.js (limited to 'routes/shopify.js') diff --git a/routes/shopify.js b/routes/shopify.js deleted file mode 100644 index bcb60ea3..00000000 --- a/routes/shopify.js +++ /dev/null @@ -1,41 +0,0 @@ -import got from "got"; -import { g } from "$lib/db"; -import { err } from "$lib/logging"; - -let query = `mutation orderMarkAsPaid($input: OrderMarkAsPaidInput!) { - orderMarkAsPaid(input: $input) { - order { id } - userErrors { - field - message - } - } -}`; - -export default async ({ body: { hash }, params: { id } }, res) => { - let p = await g(`payment:${hash}`); - if (typeof p === "string") p = await g(`payment:${p}`); - let user = await g(`user:${p.uid}`); - - try { - let r = await got - .post( - `https://${user.shopifyStore}.myshopify.com/admin/api/2023-07/graphql.json`, - { - headers: { - "Content-Type": "application/json", - "X-Shopify-Access-Token": user.shopifyToken, - }, - json: { - query, - variables: { input: { id: `gid://shopify/Order/${id}` } }, - }, - }, - ) - .json(); - - res.send(r); - } catch (e) { - err("problem marking shopify order as paid", e.message); - } -}; -- cgit v1.2.3