@monkeyplus/payscope 1.0.5 → 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.
- package/dist/_chunks/lib.mjs +10 -0
- package/dist/server/router.mjs +17 -1
- package/package.json +1 -1
package/dist/_chunks/lib.mjs
CHANGED
|
@@ -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
|
};
|
package/dist/server/router.mjs
CHANGED
|
@@ -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
|
-
|
|
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
|
}
|