@monkeyplus/payscope 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2800,6 +2800,16 @@ const createPlaceToPay = (options) => {
2800
2800
  ...body
2801
2801
  }
2802
2802
  });
2803
+ },
2804
+ removeToken: (body) => {
2805
+ const { auth } = getSession();
2806
+ return ofetch(`${endpoint}/api/instrument/invalidate`, {
2807
+ method: "POST",
2808
+ body: {
2809
+ auth,
2810
+ ...body
2811
+ }
2812
+ });
2803
2813
  }
2804
2814
  }
2805
2815
  };
@@ -80,7 +80,7 @@ const db = drizzle(process.env.PAYSCOPE_URL, { relations: defineRelations(ecomme
80
80
  to: r.transactions.id
81
81
  }),
82
82
  store: r.one.stores({
83
- from: r.sessions.storeId,
83
+ from: r.orders.storeId,
84
84
  to: r.stores.id
85
85
  })
86
86
  },
@@ -939,6 +939,12 @@ function registerPayment(app, db, { path, storeId, providers, preset, providerOp
939
939
  throw createError({ statusCode: 500 });
940
940
  }
941
941
  }));
942
+ app.post(path("/refund/:provider"), eventHandler(async (event) => {
943
+ const { payment } = instance;
944
+ const { uid, amount } = await readBody(event);
945
+ const provider = safeParams(event.context.params?.provider || "");
946
+ return await payment.refund(provider, uid, { amount: +(amount || 0) });
947
+ }));
942
948
  app.post(path("/verify/:provider"), eventHandler(async (event) => {
943
949
  const { payment } = instance;
944
950
  const { uid } = await readBody(event);
@@ -946,12 +952,22 @@ function registerPayment(app, db, { path, storeId, providers, preset, providerOp
946
952
  const query = getQuery(event);
947
953
  return await payment.verify(provider, uid, !!query.override);
948
954
  }));
949
- app.post(path("/webhook/:provider"), eventHandler(async (event) => {
955
+ const _webhook = eventHandler(async (event) => {
950
956
  const { payment } = instance;
951
957
  const body = await readBody(event);
952
958
  const { reference: uid } = body;
953
959
  const provider = safeParams(event.context.params?.provider || "");
954
960
  return await payment?.webhook?.(provider, uid, body);
961
+ });
962
+ app.post(path("/webhook/:provider"), _webhook);
963
+ app.post(path("/webhook/dev/:provider"), _webhook);
964
+ app.post(path("/methods/:provider/:method"), eventHandler(async (event) => {
965
+ const { _providers } = instance;
966
+ const body = await readBody(event);
967
+ const provider = safeParams(event.context.params?.provider || "");
968
+ const methodName = safeParams(event.context.params?.method || "");
969
+ const method = _providers[provider].methods[methodName];
970
+ return await method(body);
955
971
  }));
956
972
  return { graphql };
957
973
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@monkeyplus/payscope",
3
3
  "type": "module",
4
- "version": "1.0.4",
4
+ "version": "1.0.6",
5
5
  "packageManager": "pnpm@10.8.1",
6
6
  "author": "",
7
7
  "keywords": [],