@easy-cms/plugin-ecommerce 0.62.0 → 0.63.0
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.
|
@@ -776,7 +776,7 @@ var INFO = {
|
|
|
776
776
|
name: "@easy-cms/plugin-ecommerce",
|
|
777
777
|
// The plugin API it is written for (`PLUGIN_API_VERSION` of @easy-cms/core).
|
|
778
778
|
apiVersion: 1,
|
|
779
|
-
...true ? { version: "0.
|
|
779
|
+
...true ? { version: "0.63.0" } : {}
|
|
780
780
|
};
|
|
781
781
|
|
|
782
782
|
// src/shop.ts
|
|
@@ -1229,10 +1229,12 @@ var Orders = class {
|
|
|
1229
1229
|
}
|
|
1230
1230
|
/**
|
|
1231
1231
|
* After the page says the payment went through: asks the payment method, and makes the order
|
|
1232
|
-
* when it did. Safe to call again: the order is made once.
|
|
1232
|
+
* when it did. Safe to call again: the order is made once. Only for whoever started the
|
|
1233
|
+
* payment (its customer, or the guest with its cart's secret) and staff; others get 404.
|
|
1233
1234
|
*/
|
|
1234
|
-
async confirm(id, input) {
|
|
1235
|
+
async confirm(who, ref, id, input) {
|
|
1235
1236
|
const tx = await this.transaction(id);
|
|
1237
|
+
if (!await this.startedBy(who, ref, tx)) throw new NotFoundError(TRANSACTIONS, String(id));
|
|
1236
1238
|
if (tx.order)
|
|
1237
1239
|
return { status: tx.status, order: orderRef(await this.order(tx.order)) };
|
|
1238
1240
|
const adapter = this.adapter(tx.method);
|
|
@@ -1254,6 +1256,18 @@ var Orders = class {
|
|
|
1254
1256
|
);
|
|
1255
1257
|
return { status: outcome === "failed" ? "failed" : "processing", order: null };
|
|
1256
1258
|
}
|
|
1259
|
+
/** The caller started this payment: its customer, the guest holding its cart, or staff. */
|
|
1260
|
+
async startedBy(who, ref, tx) {
|
|
1261
|
+
const user = who.user;
|
|
1262
|
+
if (user && user.member !== true) return true;
|
|
1263
|
+
if (tx.customer) return !!user && same(tx.customer, user.id);
|
|
1264
|
+
const cart = idOf2(tx.cart);
|
|
1265
|
+
if (cart === null) return false;
|
|
1266
|
+
const raw = await this.cms.db.findById({ collection: CARTS, id: cart });
|
|
1267
|
+
if (!raw) return false;
|
|
1268
|
+
if (user && same(raw.customer, user.id)) return true;
|
|
1269
|
+
return !!ref && same(ref.id, cart) && sameSecret(ref.secret, raw.secret);
|
|
1270
|
+
}
|
|
1257
1271
|
/** A payment the provider reports as failed (e.g. from its webhook). */
|
|
1258
1272
|
async fail(id, error) {
|
|
1259
1273
|
await this.cms.update(
|
|
@@ -1751,8 +1765,8 @@ function ecommercePlugin(options) {
|
|
|
1751
1765
|
method: "post",
|
|
1752
1766
|
handler: async (req) => {
|
|
1753
1767
|
const body = await req.json();
|
|
1754
|
-
const { transaction, ...input } = body;
|
|
1755
|
-
return runtime(req.cms).orders.confirm(transaction, input);
|
|
1768
|
+
const { transaction, cart: _cart, ...input } = body;
|
|
1769
|
+
return runtime(req.cms).orders.confirm(who(req), cartRef(body), transaction, input);
|
|
1756
1770
|
}
|
|
1757
1771
|
},
|
|
1758
1772
|
{
|
|
@@ -258,7 +258,11 @@ function createShopClient(options = {}) {
|
|
|
258
258
|
},
|
|
259
259
|
async confirm(transaction, input = {}) {
|
|
260
260
|
return busy(async () => {
|
|
261
|
-
const result = await call(
|
|
261
|
+
const result = await call(
|
|
262
|
+
"POST",
|
|
263
|
+
"/shop/confirm",
|
|
264
|
+
withCart({ ...input, transaction })
|
|
265
|
+
);
|
|
262
266
|
if (result.order) {
|
|
263
267
|
remember(null);
|
|
264
268
|
set({ cart: null });
|
package/dist/client.js
CHANGED
package/dist/index.js
CHANGED
package/dist/react.js
CHANGED
package/dist/stripe.js
CHANGED
package/dist/vue.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easy-cms/plugin-ecommerce",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.63.0",
|
|
4
4
|
"description": "A shop for Easy CMS: products and variants, prices in several currencies, carts (guests too), checkout with Stripe or bank transfer, orders, stock, customer accounts, and React and Vue hooks (experimental)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"react": ">=18.0.0",
|
|
37
37
|
"stripe": ">=17.0.0",
|
|
38
38
|
"vue": "^3.4.0",
|
|
39
|
-
"@easy-cms/core": "^0.
|
|
39
|
+
"@easy-cms/core": "^0.63.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependenciesMeta": {
|
|
42
42
|
"react": {
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"happy-dom": "^20.14.5",
|
|
55
55
|
"react": "^19.2.0",
|
|
56
56
|
"vue": "^3.5.43",
|
|
57
|
-
"@easy-cms/core": "^0.
|
|
58
|
-
"@easy-cms/db-sqlite": "^0.
|
|
59
|
-
"@easy-cms/plugin-multi-tenant": "^0.
|
|
57
|
+
"@easy-cms/core": "^0.63.0",
|
|
58
|
+
"@easy-cms/db-sqlite": "^0.63.0",
|
|
59
|
+
"@easy-cms/plugin-multi-tenant": "^0.63.0"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|
|
62
62
|
"node": ">=22.12"
|