aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--index.js2
-rw-r--r--routes/shopify.js31
2 files changed, 19 insertions, 14 deletions
diff --git a/index.js b/index.js
index 7c3a134f..673e52b5 100644
--- a/index.js
+++ b/index.js
@@ -95,7 +95,7 @@ app.post("/requests", auth, requests.create);
app.post("/requests/delete", auth, requests.destroy);
app.post("/proxy", payments.proxy);
-app.post("/shopify/:id", auth, shopify);
+app.post("/shopify/:username/:id", shopify);
let host = process.env.HOST || "0.0.0.0";
let port = process.env.PORT || 3119;
diff --git a/routes/shopify.js b/routes/shopify.js
index f15a3468..a0aab057 100644
--- a/routes/shopify.js
+++ b/routes/shopify.js
@@ -1,4 +1,5 @@
import got from "got";
+import { g } from "$lib/db";
let query = `mutation orderMarkAsPaid($input: OrderMarkAsPaidInput!) {
orderMarkAsPaid(input: $input) {
@@ -10,20 +11,24 @@ let query = `mutation orderMarkAsPaid($input: OrderMarkAsPaidInput!) {
}
}`;
-export default async ({ body, params: { id }, user }, res) => {
- 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}` } }
+export default async ({ body, params: { id, username } }, res) => {
+ let user = await g(`user:${await g(`user:${username}`)}`);
+
+ 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();
+ )
+ .json();
res.send(r);
};