@cimplify/sdk 0.102.0 → 0.103.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.
- package/dist/advanced.d.mts +3 -3
- package/dist/advanced.d.ts +3 -3
- package/dist/advanced.js +23 -22
- package/dist/advanced.mjs +4 -3
- package/dist/{chunk-DCMXUKDQ.mjs → chunk-C2JSNJUC.mjs} +404 -95
- package/dist/chunk-CNN7Z2IP.js +125 -0
- package/dist/{chunk-DKLHCZ5M.mjs → chunk-GERXZQSX.mjs} +487 -11
- package/dist/chunk-GOHSXBKW.mjs +105 -0
- package/dist/{chunk-4KNFBPV2.mjs → chunk-H7ACMHM3.mjs} +32 -14
- package/dist/{chunk-Z3K2D3TE.mjs → chunk-J6PNHDHL.mjs} +453 -483
- package/dist/{chunk-NIOUSKQQ.js → chunk-JG5CQNCB.js} +5 -0
- package/dist/{chunk-YER7DIOM.js → chunk-JSWJ4XDE.js} +471 -519
- package/dist/{chunk-DLW3RWRK.mjs → chunk-M4URVKHE.mjs} +46 -12
- package/dist/{chunk-WMEC5JWN.js → chunk-NNG6IFFX.js} +50 -13
- package/dist/{chunk-LOWSMGRT.js → chunk-QOWPGS7Z.js} +34 -16
- package/dist/{chunk-YDA46OZ6.js → chunk-R6OLQ33I.js} +560 -80
- package/dist/{chunk-EAZGA7LD.js → chunk-VIL6IQCG.js} +406 -97
- package/dist/{chunk-O3YUHLZL.mjs → chunk-VNPEYLB2.mjs} +5 -0
- package/dist/{client-B40KFazg.d.ts → client-BfpNjJ_a.d.mts} +90 -299
- package/dist/{client-BizGfqB7.d.mts → client-DHBwvh7U.d.ts} +90 -299
- package/dist/{client-BdErclfU.d.mts → client-DpqRobY9.d.mts} +2 -2
- package/dist/{client-nsiMwuC1.d.ts → client-Dqg2mc-7.d.ts} +2 -2
- package/dist/{index-DpmnI__D.d.mts → index-C8uDqLwJ.d.ts} +14 -4
- package/dist/{index-nEyXWIyR.d.ts → index-e2y6AK70.d.mts} +14 -4
- package/dist/index.d.mts +81 -8
- package/dist/index.d.ts +81 -8
- package/dist/index.js +202 -169
- package/dist/index.mjs +6 -5
- package/dist/link-cuNVYc2s.d.mts +297 -0
- package/dist/link-cuNVYc2s.d.ts +297 -0
- package/dist/mock/cli.mjs +410 -94
- package/dist/mock/library.js +410 -94
- package/dist/mock/library.mjs +410 -94
- package/dist/mock/msw.js +410 -94
- package/dist/mock/msw.mjs +410 -94
- package/dist/{product-Byf0unSy.d.mts → payment-H5LoIvXU.d.mts} +189 -7
- package/dist/{product-Byf0unSy.d.ts → payment-H5LoIvXU.d.ts} +189 -7
- package/dist/{price-CS4E5zLS.d.mts → price-BvePgDXe.d.mts} +1 -1
- package/dist/{price-BstChV9a.d.ts → price-C2RqscMY.d.ts} +1 -1
- package/dist/react.d.mts +4 -4
- package/dist/react.d.ts +4 -4
- package/dist/react.js +141 -140
- package/dist/react.mjs +5 -4
- package/dist/{server-DqbZh8Bk.d.mts → server-C7FyLdrz.d.mts} +11 -9
- package/dist/{server-Cj40R2ZD.d.ts → server-DoXIpSd7.d.ts} +11 -9
- package/dist/server.d.mts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +11 -10
- package/dist/server.mjs +5 -4
- package/dist/testing/msw.d.mts +2 -2
- package/dist/testing/msw.d.ts +2 -2
- package/dist/testing/msw.js +4 -3
- package/dist/testing/msw.mjs +3 -2
- package/dist/testing/suite.d.mts +6 -6
- package/dist/testing/suite.d.ts +6 -6
- package/dist/testing/suite.js +26 -25
- package/dist/testing/suite.mjs +7 -6
- package/dist/testing.d.mts +154 -55
- package/dist/testing.d.ts +154 -55
- package/dist/testing.js +83 -82
- package/dist/testing.mjs +8 -7
- package/dist/utils.d.mts +4 -4
- package/dist/utils.d.ts +4 -4
- package/dist/utils.js +37 -29
- package/dist/utils.mjs +2 -2
- package/package.json +7 -1
- package/dist/payment-l0rkieEQ.d.mts +0 -113
- package/dist/payment-vzNnIi1n.d.ts +0 -113
package/dist/mock/msw.mjs
CHANGED
|
@@ -2092,6 +2092,8 @@ var ERROR_SUGGESTIONS = {
|
|
|
2092
2092
|
PRICE_CHANGED: "Prices changed since the quote was created. Refresh pricing, show the new total to the shopper, and require explicit confirmation before re-submitting.",
|
|
2093
2093
|
PAYMENT_FAILED: "Payment provider rejected or failed processing. Show retry/change-method options to the shopper.",
|
|
2094
2094
|
PAYMENT_CANCELLED: "Payment was cancelled by the shopper or provider flow. Allow a safe retry path.",
|
|
2095
|
+
PAYMENT_CAPABILITY_MISMATCH: "Refresh collection capabilities for the exact tenant and presentment currency before retrying.",
|
|
2096
|
+
UNSUPPORTED_CURRENCY: "Choose a supported presentment currency before loading payment methods or submitting checkout.",
|
|
2095
2097
|
INSUFFICIENT_FUNDS: "Payment method has insufficient funds. Prompt shopper to use another method.",
|
|
2096
2098
|
CARD_DECLINED: "Card was declined. Ask shopper to retry or switch payment method.",
|
|
2097
2099
|
INVALID_OTP: "Authorization code is invalid. Let shopper re-enter OTP/PIN and retry.",
|
|
@@ -2240,6 +2242,12 @@ function getQueryNum(c, key) {
|
|
|
2240
2242
|
return Number.isFinite(n) ? n : void 0;
|
|
2241
2243
|
}
|
|
2242
2244
|
|
|
2245
|
+
// src/constants.ts
|
|
2246
|
+
var PAYMENT_METHOD = {
|
|
2247
|
+
MOBILE_MONEY: "mobile_money",
|
|
2248
|
+
CARD: "card"
|
|
2249
|
+
};
|
|
2250
|
+
|
|
2243
2251
|
// src/mock/routes/v1.ts
|
|
2244
2252
|
function buildV1(deps) {
|
|
2245
2253
|
const app = new Hono2();
|
|
@@ -2256,10 +2264,22 @@ function buildV1(deps) {
|
|
|
2256
2264
|
}));
|
|
2257
2265
|
});
|
|
2258
2266
|
app.get("/business", (c) => tryRoute(c, () => deps.business.primary()));
|
|
2259
|
-
app.get(
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2267
|
+
app.get(
|
|
2268
|
+
"/business/by-handle/:handle",
|
|
2269
|
+
(c) => tryRoute(c, () => deps.business.byHandle(c.req.param("handle")))
|
|
2270
|
+
);
|
|
2271
|
+
app.get(
|
|
2272
|
+
"/business/by-domain",
|
|
2273
|
+
(c) => tryRoute(c, () => deps.business.byDomain(c.req.query("domain") ?? ""))
|
|
2274
|
+
);
|
|
2275
|
+
app.get(
|
|
2276
|
+
"/business/settings",
|
|
2277
|
+
(c) => tryRoute(c, () => deps.business.settings(deps.defaultBusinessId))
|
|
2278
|
+
);
|
|
2279
|
+
app.get(
|
|
2280
|
+
"/business/locations",
|
|
2281
|
+
(c) => tryRoute(c, () => deps.business.locations(deps.defaultBusinessId))
|
|
2282
|
+
);
|
|
2263
2283
|
app.get("/business/hours", (c) => tryRoute(c, () => deps.business.hours(deps.defaultBusinessId)));
|
|
2264
2284
|
app.get("/catalogue", (c) => tryRoute(c, () => deps.catalogue.snapshot(deps.defaultBusinessId)));
|
|
2265
2285
|
app.get(
|
|
@@ -2274,57 +2294,165 @@ function buildV1(deps) {
|
|
|
2274
2294
|
})
|
|
2275
2295
|
)
|
|
2276
2296
|
);
|
|
2277
|
-
app.get(
|
|
2278
|
-
|
|
2279
|
-
|
|
2297
|
+
app.get(
|
|
2298
|
+
"/catalogue/products/:product_id",
|
|
2299
|
+
(c) => tryRoute(c, () => deps.catalogue.getProduct(c.req.param("product_id")))
|
|
2300
|
+
);
|
|
2301
|
+
app.get(
|
|
2302
|
+
"/catalogue/products/:product_id/variants",
|
|
2303
|
+
(c) => tryRoute(c, () => deps.catalogue.getProductVariants(c.req.param("product_id")))
|
|
2304
|
+
);
|
|
2305
|
+
app.get(
|
|
2306
|
+
"/catalogue/products/:product_id/variant-axes",
|
|
2307
|
+
(c) => tryRoute(c, () => deps.catalogue.getProductVariantAxes(c.req.param("product_id")))
|
|
2308
|
+
);
|
|
2280
2309
|
app.get(
|
|
2281
2310
|
"/catalogue/products/:product_id/variants/:variant_id",
|
|
2282
|
-
(c) => tryRoute(
|
|
2311
|
+
(c) => tryRoute(
|
|
2312
|
+
c,
|
|
2313
|
+
() => deps.catalogue.getProductVariantById(c.req.param("product_id"), c.req.param("variant_id"))
|
|
2314
|
+
)
|
|
2283
2315
|
);
|
|
2284
2316
|
app.post("/catalogue/products/:product_id/variants/find", async (c) => {
|
|
2285
2317
|
const body = await c.req.json().catch(() => ({}));
|
|
2286
2318
|
return tryRoute(
|
|
2287
2319
|
c,
|
|
2288
|
-
() => deps.catalogue.findProductVariant(
|
|
2320
|
+
() => deps.catalogue.findProductVariant(
|
|
2321
|
+
c.req.param("product_id"),
|
|
2322
|
+
body.axis_selections ?? body.properties ?? {}
|
|
2323
|
+
)
|
|
2289
2324
|
);
|
|
2290
2325
|
});
|
|
2291
|
-
app.get(
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
app.get(
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
app.get(
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
app.get(
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2326
|
+
app.get(
|
|
2327
|
+
"/catalogue/products/:product_id/add-ons",
|
|
2328
|
+
(c) => tryRoute(c, () => deps.catalogue.getProductAddOns(c.req.param("product_id")))
|
|
2329
|
+
);
|
|
2330
|
+
app.get(
|
|
2331
|
+
"/catalogue/categories",
|
|
2332
|
+
(c) => tryRoute(c, () => deps.catalogue.listCategories(deps.defaultBusinessId))
|
|
2333
|
+
);
|
|
2334
|
+
app.get(
|
|
2335
|
+
"/catalogue/categories/:category_id",
|
|
2336
|
+
(c) => tryRoute(c, () => deps.catalogue.getCategory(c.req.param("category_id")))
|
|
2337
|
+
);
|
|
2338
|
+
app.get(
|
|
2339
|
+
"/catalogue/categories/:category_id/products",
|
|
2340
|
+
(c) => tryRoute(c, () => deps.catalogue.getCategoryProducts(c.req.param("category_id")))
|
|
2341
|
+
);
|
|
2342
|
+
app.get(
|
|
2343
|
+
"/catalogue/categories/:category_id/attributes",
|
|
2344
|
+
(c) => tryRoute(c, () => deps.catalogue.getCategoryAttributes(c.req.param("category_id")))
|
|
2345
|
+
);
|
|
2346
|
+
app.get(
|
|
2347
|
+
"/catalogue/categories/:category_id/deals",
|
|
2348
|
+
(c) => tryRoute(c, () => deps.catalogue.getCategoryDeals(c.req.param("category_id")))
|
|
2349
|
+
);
|
|
2350
|
+
app.get(
|
|
2351
|
+
"/catalogue/collections",
|
|
2352
|
+
(c) => tryRoute(c, () => deps.catalogue.listCollections(deps.defaultBusinessId))
|
|
2353
|
+
);
|
|
2354
|
+
app.get(
|
|
2355
|
+
"/catalogue/collections/:collection_id",
|
|
2356
|
+
(c) => tryRoute(c, () => deps.catalogue.getCollection(c.req.param("collection_id")))
|
|
2357
|
+
);
|
|
2358
|
+
app.get(
|
|
2359
|
+
"/catalogue/collections/:collection_id/products",
|
|
2360
|
+
(c) => tryRoute(c, () => deps.catalogue.getCollectionProducts(c.req.param("collection_id")))
|
|
2361
|
+
);
|
|
2362
|
+
app.get(
|
|
2363
|
+
"/catalogue/collections/:collection_id/attributes",
|
|
2364
|
+
(c) => tryRoute(c, () => deps.catalogue.getCollectionAttributes(c.req.param("collection_id")))
|
|
2365
|
+
);
|
|
2366
|
+
app.get(
|
|
2367
|
+
"/catalogue/collections/:collection_id/deals",
|
|
2368
|
+
(c) => tryRoute(c, () => deps.catalogue.getCollectionDeals(c.req.param("collection_id")))
|
|
2369
|
+
);
|
|
2370
|
+
app.get(
|
|
2371
|
+
"/catalogue/bundles",
|
|
2372
|
+
(c) => tryRoute(c, () => deps.catalogue.listBundles(deps.defaultBusinessId))
|
|
2373
|
+
);
|
|
2374
|
+
app.get(
|
|
2375
|
+
"/catalogue/bundles/:bundle_id",
|
|
2376
|
+
(c) => tryRoute(c, () => deps.catalogue.getBundle(c.req.param("bundle_id")))
|
|
2377
|
+
);
|
|
2378
|
+
app.get(
|
|
2379
|
+
"/catalogue/composites",
|
|
2380
|
+
(c) => tryRoute(c, () => deps.catalogue.listComposites(deps.defaultBusinessId))
|
|
2381
|
+
);
|
|
2382
|
+
app.get(
|
|
2383
|
+
"/catalogue/composites/by-product/:product_id",
|
|
2384
|
+
(c) => tryRoute(c, () => deps.catalogue.getCompositeByProduct(c.req.param("product_id")))
|
|
2385
|
+
);
|
|
2386
|
+
app.get(
|
|
2387
|
+
"/catalogue/composites/:composite_id",
|
|
2388
|
+
(c) => tryRoute(c, () => deps.catalogue.getComposite(c.req.param("composite_id")))
|
|
2389
|
+
);
|
|
2307
2390
|
app.post("/catalogue/composites/:composite_id/calculate-price", async (c) => {
|
|
2308
2391
|
const body = await c.req.json().catch(() => ({}));
|
|
2309
|
-
return tryRoute(
|
|
2392
|
+
return tryRoute(
|
|
2393
|
+
c,
|
|
2394
|
+
() => deps.catalogue.calculateCompositePrice(c.req.param("composite_id"), body)
|
|
2395
|
+
);
|
|
2310
2396
|
});
|
|
2311
|
-
app.get(
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
app.get(
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2397
|
+
app.get(
|
|
2398
|
+
"/catalogue/taxonomies",
|
|
2399
|
+
(c) => tryRoute(c, () => deps.catalogue.listTaxonomies(deps.defaultBusinessId))
|
|
2400
|
+
);
|
|
2401
|
+
app.get(
|
|
2402
|
+
"/catalogue/taxonomies/search",
|
|
2403
|
+
(c) => tryRoute(
|
|
2404
|
+
c,
|
|
2405
|
+
() => deps.catalogue.searchTaxonomies(deps.defaultBusinessId, c.req.query("q") ?? "")
|
|
2406
|
+
)
|
|
2407
|
+
);
|
|
2408
|
+
app.get(
|
|
2409
|
+
"/catalogue/taxonomies/:taxonomy_id",
|
|
2410
|
+
(c) => tryRoute(c, () => deps.catalogue.getTaxonomy(c.req.param("taxonomy_id")))
|
|
2411
|
+
);
|
|
2412
|
+
app.get(
|
|
2413
|
+
"/catalogue/taxonomies/:taxonomy_id/attributes",
|
|
2414
|
+
(c) => tryRoute(c, () => deps.catalogue.getTaxonomyAttributes(c.req.param("taxonomy_id")))
|
|
2415
|
+
);
|
|
2416
|
+
app.get(
|
|
2417
|
+
"/catalogue/taxonomies/:taxonomy_id/path",
|
|
2418
|
+
(c) => tryRoute(c, () => deps.catalogue.getTaxonomyPath(c.req.param("taxonomy_id")))
|
|
2419
|
+
);
|
|
2420
|
+
app.get(
|
|
2421
|
+
"/catalogue/attributes",
|
|
2422
|
+
(c) => tryRoute(c, () => deps.catalogue.listAttributes(deps.defaultBusinessId))
|
|
2423
|
+
);
|
|
2424
|
+
app.get(
|
|
2425
|
+
"/catalogue/properties/facets",
|
|
2426
|
+
(c) => tryRoute(c, () => deps.catalogue.listPropertyFacets(deps.defaultBusinessId))
|
|
2427
|
+
);
|
|
2428
|
+
app.get(
|
|
2429
|
+
"/catalogue/tags",
|
|
2430
|
+
(c) => tryRoute(c, () => deps.catalogue.listTags(deps.defaultBusinessId))
|
|
2431
|
+
);
|
|
2319
2432
|
app.get("/catalogue/menu", (c) => tryRoute(c, () => deps.lite.getMenu(deps.defaultBusinessId)));
|
|
2320
|
-
app.get(
|
|
2321
|
-
|
|
2322
|
-
|
|
2433
|
+
app.get(
|
|
2434
|
+
"/catalogue/menu/categories/:category_id",
|
|
2435
|
+
(c) => tryRoute(c, () => deps.lite.getMenuCategory(c.req.param("category_id")))
|
|
2436
|
+
);
|
|
2437
|
+
app.get(
|
|
2438
|
+
"/catalogue/menu/items/:item_id",
|
|
2439
|
+
(c) => tryRoute(c, () => deps.catalogue.getProduct(c.req.param("item_id")))
|
|
2440
|
+
);
|
|
2441
|
+
app.get(
|
|
2442
|
+
"/catalogue/knowledge-base/articles",
|
|
2443
|
+
(c) => tryRoute(c, () => ({ articles: deps.catalogue.listKnowledgeArticles(deps.defaultBusinessId) }))
|
|
2444
|
+
);
|
|
2323
2445
|
app.get(
|
|
2324
2446
|
"/catalogue/knowledge-base/search",
|
|
2325
|
-
(c) => tryRoute(c, () => ({
|
|
2447
|
+
(c) => tryRoute(c, () => ({
|
|
2448
|
+
results: deps.catalogue.searchKnowledgeBase(deps.defaultBusinessId, c.req.query("q") ?? ""),
|
|
2449
|
+
query: c.req.query("q") ?? ""
|
|
2450
|
+
}))
|
|
2451
|
+
);
|
|
2452
|
+
app.get(
|
|
2453
|
+
"/catalogue/products/:product_id/attributes",
|
|
2454
|
+
(c) => tryRoute(c, () => deps.catalogue.getProductAttributes(c.req.param("product_id")))
|
|
2326
2455
|
);
|
|
2327
|
-
app.get("/catalogue/products/:product_id/attributes", (c) => tryRoute(c, () => deps.catalogue.getProductAttributes(c.req.param("product_id"))));
|
|
2328
2456
|
app.get(
|
|
2329
2457
|
"/catalogue/products/:product_id/available-now",
|
|
2330
2458
|
(c) => tryRoute(c, () => {
|
|
@@ -2343,22 +2471,45 @@ function buildV1(deps) {
|
|
|
2343
2471
|
"/catalogue/products/:product_id/schedules",
|
|
2344
2472
|
(c) => tryRoute(c, () => {
|
|
2345
2473
|
const p = deps.registry.products.get(c.req.param("product_id"));
|
|
2346
|
-
return {
|
|
2474
|
+
return {
|
|
2475
|
+
schedules: p?.metadata?.["time_profiles"] ?? []
|
|
2476
|
+
};
|
|
2347
2477
|
})
|
|
2348
2478
|
);
|
|
2349
|
-
app.get(
|
|
2350
|
-
|
|
2479
|
+
app.get(
|
|
2480
|
+
"/catalogue/deals",
|
|
2481
|
+
(c) => tryRoute(c, () => deps.catalogue.listDeals(deps.defaultBusinessId))
|
|
2482
|
+
);
|
|
2483
|
+
app.get(
|
|
2484
|
+
"/catalogue/deals/on-sale",
|
|
2485
|
+
(c) => tryRoute(c, () => deps.catalogue.listOnSale(deps.defaultBusinessId))
|
|
2486
|
+
);
|
|
2351
2487
|
app.post("/catalogue/deals/validate", async (c) => {
|
|
2352
2488
|
const body = await c.req.json().catch(() => ({}));
|
|
2353
|
-
return tryRoute(
|
|
2489
|
+
return tryRoute(
|
|
2490
|
+
c,
|
|
2491
|
+
() => deps.catalogue.validateDiscount(
|
|
2492
|
+
body.discount_code ?? body.code ?? "",
|
|
2493
|
+
deps.defaultBusinessId
|
|
2494
|
+
)
|
|
2495
|
+
);
|
|
2354
2496
|
});
|
|
2355
|
-
app.get(
|
|
2497
|
+
app.get(
|
|
2498
|
+
"/catalogue/products/:product_id/deals",
|
|
2499
|
+
(c) => tryRoute(c, () => deps.catalogue.getProductDeals(c.req.param("product_id")))
|
|
2500
|
+
);
|
|
2356
2501
|
app.post("/catalogue/quotes", async (c) => {
|
|
2357
2502
|
const body = await c.req.json().catch(() => ({}));
|
|
2358
2503
|
return tryRoute(c, () => deps.catalogue.createQuote(deps.defaultBusinessId, body));
|
|
2359
2504
|
});
|
|
2360
|
-
app.get(
|
|
2361
|
-
|
|
2505
|
+
app.get(
|
|
2506
|
+
"/catalogue/quotes/:quote_id",
|
|
2507
|
+
(c) => tryRoute(c, () => deps.catalogue.getQuote(c.req.param("quote_id")))
|
|
2508
|
+
);
|
|
2509
|
+
app.post(
|
|
2510
|
+
"/catalogue/quotes/:quote_id/refresh",
|
|
2511
|
+
(c) => tryRoute(c, () => deps.catalogue.refreshQuote(c.req.param("quote_id")))
|
|
2512
|
+
);
|
|
2362
2513
|
app.get("/cart", (c) => tryRoute(c, () => deps.cart.toUICart(deps.cart.get(c.var.session))));
|
|
2363
2514
|
app.delete("/cart", (c) => tryRoute(c, () => deps.cart.clear(c.var.session)));
|
|
2364
2515
|
app.get("/cart/items", (c) => tryRoute(c, () => deps.cart.getItems(c.var.session)));
|
|
@@ -2369,9 +2520,15 @@ function buildV1(deps) {
|
|
|
2369
2520
|
app.patch("/cart/items/:cart_item_id", async (c) => {
|
|
2370
2521
|
const body = await c.req.json().catch(() => ({}));
|
|
2371
2522
|
if (typeof body.quantity !== "number") return fail(c, validation("quantity required"));
|
|
2372
|
-
return tryRoute(
|
|
2523
|
+
return tryRoute(
|
|
2524
|
+
c,
|
|
2525
|
+
() => deps.cart.updateQuantity(c.var.session, c.req.param("cart_item_id"), body.quantity)
|
|
2526
|
+
);
|
|
2373
2527
|
});
|
|
2374
|
-
app.delete(
|
|
2528
|
+
app.delete(
|
|
2529
|
+
"/cart/items/:cart_item_id",
|
|
2530
|
+
(c) => tryRoute(c, () => deps.cart.removeItem(c.var.session, c.req.param("cart_item_id")))
|
|
2531
|
+
);
|
|
2375
2532
|
app.get("/cart/count", (c) => tryRoute(c, () => deps.cart.getCount(c.var.session)));
|
|
2376
2533
|
app.get("/cart/total", (c) => tryRoute(c, () => deps.cart.getTotal(c.var.session)));
|
|
2377
2534
|
app.post("/cart/destination-quote", async (c) => {
|
|
@@ -2382,10 +2539,25 @@ function buildV1(deps) {
|
|
|
2382
2539
|
const body = await c.req.json().catch(() => ({}));
|
|
2383
2540
|
return tryRoute(c, () => deps.cart.applyCoupon(c.var.session, body.coupon_code ?? ""));
|
|
2384
2541
|
});
|
|
2385
|
-
app.delete(
|
|
2386
|
-
|
|
2542
|
+
app.delete(
|
|
2543
|
+
"/cart/coupons/current",
|
|
2544
|
+
(c) => tryRoute(c, () => deps.cart.removeCoupon(c.var.session))
|
|
2545
|
+
);
|
|
2546
|
+
app.get(
|
|
2547
|
+
"/orders",
|
|
2548
|
+
(c) => tryRoute(
|
|
2549
|
+
c,
|
|
2550
|
+
() => deps.orders.list(c.var.session, {
|
|
2551
|
+
limit: getQueryNum(c, "limit"),
|
|
2552
|
+
status: c.req.query("status")
|
|
2553
|
+
})
|
|
2554
|
+
)
|
|
2555
|
+
);
|
|
2387
2556
|
app.get("/orders/:order_id", (c) => tryRoute(c, () => deps.orders.get(c.req.param("order_id"))));
|
|
2388
|
-
app.get(
|
|
2557
|
+
app.get(
|
|
2558
|
+
"/orders/:order_id/payment-status",
|
|
2559
|
+
(c) => tryRoute(c, () => deps.orders.getPaymentStatus(c.req.param("order_id")))
|
|
2560
|
+
);
|
|
2389
2561
|
app.post("/orders/:order_id/cancel", async (c) => {
|
|
2390
2562
|
const body = await c.req.json().catch(() => ({}));
|
|
2391
2563
|
return tryRoute(c, () => deps.orders.cancel(c.req.param("order_id"), body.reason));
|
|
@@ -2394,13 +2566,46 @@ function buildV1(deps) {
|
|
|
2394
2566
|
const body = await c.req.json().catch(() => ({}));
|
|
2395
2567
|
return tryRoute(c, () => deps.orders.updateCustomer(c.req.param("order_id"), body));
|
|
2396
2568
|
});
|
|
2397
|
-
app.post(
|
|
2569
|
+
app.post(
|
|
2570
|
+
"/orders/:order_id/verify-payment",
|
|
2571
|
+
(c) => tryRoute(c, () => deps.orders.verifyPayment(c.req.param("order_id")))
|
|
2572
|
+
);
|
|
2398
2573
|
app.get("/subscriptions", (c) => tryRoute(c, () => deps.subscriptions.list(c.var.session)));
|
|
2399
|
-
app.get(
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
app.post(
|
|
2574
|
+
app.get(
|
|
2575
|
+
"/subscriptions/:subscription_id",
|
|
2576
|
+
(c) => tryRoute(c, () => deps.subscriptions.get(c.req.param("subscription_id")))
|
|
2577
|
+
);
|
|
2578
|
+
app.post(
|
|
2579
|
+
"/subscriptions/:subscription_id/cancel",
|
|
2580
|
+
(c) => tryRoute(c, () => deps.subscriptions.cancel(c.req.param("subscription_id")))
|
|
2581
|
+
);
|
|
2582
|
+
app.post(
|
|
2583
|
+
"/subscriptions/:subscription_id/pause",
|
|
2584
|
+
(c) => tryRoute(c, () => deps.subscriptions.pause(c.req.param("subscription_id")))
|
|
2585
|
+
);
|
|
2586
|
+
app.post(
|
|
2587
|
+
"/subscriptions/:subscription_id/resume",
|
|
2588
|
+
(c) => tryRoute(c, () => deps.subscriptions.resume(c.req.param("subscription_id")))
|
|
2589
|
+
);
|
|
2590
|
+
app.post(
|
|
2591
|
+
"/subscriptions/:subscription_id/skip",
|
|
2592
|
+
(c) => tryRoute(c, () => deps.subscriptions.skipNext(c.req.param("subscription_id")))
|
|
2593
|
+
);
|
|
2594
|
+
app.get("/payments/collection-options", (c) => {
|
|
2595
|
+
const currency = c.req.query("currency")?.trim().toUpperCase();
|
|
2596
|
+
if (!currency || !/^[A-Z]{3}$/.test(currency)) {
|
|
2597
|
+
return fail(c, validation("currency must be a canonical three-letter code"));
|
|
2598
|
+
}
|
|
2599
|
+
return tryRoute(c, () => ({
|
|
2600
|
+
presentment_currency: currency,
|
|
2601
|
+
options: currency === "GHS" ? [
|
|
2602
|
+
{ method: PAYMENT_METHOD.CARD, network: null },
|
|
2603
|
+
{ method: PAYMENT_METHOD.MOBILE_MONEY, network: "mtn" },
|
|
2604
|
+
{ method: PAYMENT_METHOD.MOBILE_MONEY, network: "telecel" },
|
|
2605
|
+
{ method: PAYMENT_METHOD.MOBILE_MONEY, network: "airteltigo" }
|
|
2606
|
+
] : currency === "USD" ? [{ method: PAYMENT_METHOD.CARD, network: null }] : []
|
|
2607
|
+
}));
|
|
2608
|
+
});
|
|
2404
2609
|
app.post("/checkout", async (c) => {
|
|
2405
2610
|
const body = await c.req.json().catch(() => ({}));
|
|
2406
2611
|
return tryRoute(c, () => deps.checkout.process(c.var.session, body));
|
|
@@ -2454,15 +2659,33 @@ function buildV1(deps) {
|
|
|
2454
2659
|
return { success: true, message: "Profile updated successfully" };
|
|
2455
2660
|
});
|
|
2456
2661
|
});
|
|
2457
|
-
app.get(
|
|
2458
|
-
|
|
2662
|
+
app.get(
|
|
2663
|
+
"/inventory/products/:product_id/stock",
|
|
2664
|
+
(c) => tryRoute(c, () => deps.inventory.productStock(c.req.param("product_id")))
|
|
2665
|
+
);
|
|
2666
|
+
app.get(
|
|
2667
|
+
"/inventory/variants/:variant_id/stock",
|
|
2668
|
+
(c) => tryRoute(c, () => deps.inventory.variantStock(c.req.param("variant_id")))
|
|
2669
|
+
);
|
|
2459
2670
|
app.get(
|
|
2460
2671
|
"/inventory/products/:product_id/availability",
|
|
2461
|
-
(c) => tryRoute(
|
|
2672
|
+
(c) => tryRoute(
|
|
2673
|
+
c,
|
|
2674
|
+
() => deps.inventory.productAvailability(
|
|
2675
|
+
c.req.param("product_id"),
|
|
2676
|
+
getQueryNum(c, "quantity") ?? 1
|
|
2677
|
+
)
|
|
2678
|
+
)
|
|
2462
2679
|
);
|
|
2463
2680
|
app.get(
|
|
2464
2681
|
"/inventory/variants/:variant_id/availability",
|
|
2465
|
-
(c) => tryRoute(
|
|
2682
|
+
(c) => tryRoute(
|
|
2683
|
+
c,
|
|
2684
|
+
() => deps.inventory.variantAvailability(
|
|
2685
|
+
c.req.param("variant_id"),
|
|
2686
|
+
getQueryNum(c, "quantity") ?? 1
|
|
2687
|
+
)
|
|
2688
|
+
)
|
|
2466
2689
|
);
|
|
2467
2690
|
app.get(
|
|
2468
2691
|
"/delivery/fee",
|
|
@@ -2489,35 +2712,75 @@ function buildV1(deps) {
|
|
|
2489
2712
|
);
|
|
2490
2713
|
app.post("/places/autocomplete", async (c) => {
|
|
2491
2714
|
const body = await c.req.json().catch(() => ({}));
|
|
2492
|
-
return tryRoute(
|
|
2715
|
+
return tryRoute(
|
|
2716
|
+
c,
|
|
2717
|
+
() => deps.places.autocomplete({ query: body.input ?? body.query ?? "", country: body.country })
|
|
2718
|
+
);
|
|
2493
2719
|
});
|
|
2494
2720
|
app.post("/places/details", async (c) => {
|
|
2495
2721
|
const body = await c.req.json().catch(() => ({}));
|
|
2496
2722
|
return tryRoute(c, () => deps.places.details({ place_id: body.place_id ?? "" }));
|
|
2497
2723
|
});
|
|
2498
|
-
app.get(
|
|
2499
|
-
|
|
2500
|
-
|
|
2724
|
+
app.get(
|
|
2725
|
+
"/scheduling/services",
|
|
2726
|
+
(c) => tryRoute(c, () => deps.scheduling.listServices(deps.defaultBusinessId))
|
|
2727
|
+
);
|
|
2728
|
+
app.get(
|
|
2729
|
+
"/scheduling/services/:service_id",
|
|
2730
|
+
(c) => tryRoute(c, () => deps.scheduling.getService(c.req.param("service_id")))
|
|
2731
|
+
);
|
|
2732
|
+
app.get(
|
|
2733
|
+
"/scheduling/slots",
|
|
2734
|
+
(c) => tryRoute(
|
|
2735
|
+
c,
|
|
2736
|
+
() => deps.scheduling.getSlots(c.req.query("service_id") ?? "", { date: c.req.query("date") })
|
|
2737
|
+
)
|
|
2738
|
+
);
|
|
2501
2739
|
app.get(
|
|
2502
2740
|
"/scheduling/slots/check",
|
|
2503
|
-
(c) => tryRoute(
|
|
2741
|
+
(c) => tryRoute(
|
|
2742
|
+
c,
|
|
2743
|
+
() => deps.scheduling.checkSlot(
|
|
2744
|
+
c.req.query("service_id") ?? "",
|
|
2745
|
+
c.req.query("start") ?? "",
|
|
2746
|
+
c.req.query("end") ?? ""
|
|
2747
|
+
)
|
|
2748
|
+
)
|
|
2749
|
+
);
|
|
2750
|
+
app.get(
|
|
2751
|
+
"/scheduling/availability",
|
|
2752
|
+
(c) => tryRoute(c, () => deps.scheduling.getServiceAvailability(c.req.query("service_id") ?? ""))
|
|
2753
|
+
);
|
|
2754
|
+
app.get(
|
|
2755
|
+
"/scheduling/bookings",
|
|
2756
|
+
(c) => tryRoute(c, () => deps.scheduling.getCustomerBookings(c.var.session))
|
|
2504
2757
|
);
|
|
2505
|
-
app.get("/scheduling/availability", (c) => tryRoute(c, () => deps.scheduling.getServiceAvailability(c.req.query("service_id") ?? "")));
|
|
2506
|
-
app.get("/scheduling/bookings", (c) => tryRoute(c, () => deps.scheduling.getCustomerBookings(c.var.session)));
|
|
2507
2758
|
app.post("/scheduling/bookings/reschedule", async (c) => {
|
|
2508
2759
|
const body = await c.req.json().catch(() => ({}));
|
|
2509
2760
|
return tryRoute(c, () => deps.scheduling.rescheduleBooking(body));
|
|
2510
2761
|
});
|
|
2511
|
-
app.get(
|
|
2762
|
+
app.get(
|
|
2763
|
+
"/scheduling/bookings/:booking_id",
|
|
2764
|
+
(c) => tryRoute(c, () => deps.scheduling.getBooking(c.req.param("booking_id")))
|
|
2765
|
+
);
|
|
2512
2766
|
app.post("/scheduling/bookings/:booking_id/cancel", async (c) => {
|
|
2513
2767
|
const body = await c.req.json().catch(() => ({}));
|
|
2514
2768
|
return tryRoute(c, () => deps.scheduling.cancelBooking(c.req.param("booking_id"), body.reason));
|
|
2515
2769
|
});
|
|
2516
2770
|
app.get("/lite/bootstrap", (c) => tryRoute(c, () => deps.lite.bootstrap(deps.defaultBusinessId)));
|
|
2517
|
-
app.get(
|
|
2771
|
+
app.get(
|
|
2772
|
+
"/lite/resources/:resource_id",
|
|
2773
|
+
(c) => tryRoute(c, () => deps.lite.getResource(c.req.param("resource_id")))
|
|
2774
|
+
);
|
|
2518
2775
|
app.get("/lite/menu", (c) => tryRoute(c, () => deps.lite.getMenu(deps.defaultBusinessId)));
|
|
2519
|
-
app.get(
|
|
2520
|
-
|
|
2776
|
+
app.get(
|
|
2777
|
+
"/lite/menu/categories/:category_id",
|
|
2778
|
+
(c) => tryRoute(c, () => deps.lite.getMenuCategory(c.req.param("category_id")))
|
|
2779
|
+
);
|
|
2780
|
+
app.get(
|
|
2781
|
+
"/fx/rate",
|
|
2782
|
+
(c) => tryRoute(c, () => deps.fx.getRate(c.req.query("from") ?? "USD", c.req.query("to") ?? "GHS"))
|
|
2783
|
+
);
|
|
2521
2784
|
app.post("/fx/quotes", async (c) => {
|
|
2522
2785
|
const body = await c.req.json().catch(() => ({}));
|
|
2523
2786
|
return tryRoute(c, () => deps.fx.lockQuote(body));
|
|
@@ -2530,31 +2793,47 @@ function buildV1(deps) {
|
|
|
2530
2793
|
const body = await c.req.json().catch(() => ({}));
|
|
2531
2794
|
return tryRoute(c, () => deps.uploads.confirm(body));
|
|
2532
2795
|
});
|
|
2533
|
-
app.get(
|
|
2534
|
-
"/store-credit/balance",
|
|
2535
|
-
(c) => c.json({ data: { balance: "0.00", currency: "USD" } })
|
|
2536
|
-
);
|
|
2796
|
+
app.get("/store-credit/balance", (c) => c.json({ data: { balance: "0.00", currency: "USD" } }));
|
|
2537
2797
|
app.post("/activity/session", async (c) => {
|
|
2538
2798
|
await c.req.json().catch(() => ({}));
|
|
2539
2799
|
return c.json({ data: { recorded: true } });
|
|
2540
2800
|
});
|
|
2541
2801
|
app.post("/activity/events", async (c) => {
|
|
2542
2802
|
const body = await c.req.json().catch(() => ({}));
|
|
2543
|
-
return tryRoute(
|
|
2803
|
+
return tryRoute(
|
|
2804
|
+
c,
|
|
2805
|
+
() => deps.activity.recordEvents(
|
|
2806
|
+
deps.defaultBusinessId,
|
|
2807
|
+
body.analytics_session_id ?? c.var.session.id,
|
|
2808
|
+
body.events ?? []
|
|
2809
|
+
)
|
|
2810
|
+
);
|
|
2544
2811
|
});
|
|
2545
|
-
app.get(
|
|
2546
|
-
|
|
2812
|
+
app.get(
|
|
2813
|
+
"/activity/state",
|
|
2814
|
+
(c) => tryRoute(c, () => deps.activity.getState(deps.defaultBusinessId, c.var.session.id))
|
|
2815
|
+
);
|
|
2816
|
+
app.get(
|
|
2817
|
+
"/activity/recommendations",
|
|
2818
|
+
(c) => tryRoute(c, () => deps.activity.getRecommendations(deps.defaultBusinessId))
|
|
2819
|
+
);
|
|
2547
2820
|
app.post("/activity/messages/dismiss", async (c) => {
|
|
2548
2821
|
const body = await c.req.json().catch(() => ({}));
|
|
2549
2822
|
return tryRoute(c, () => deps.activity.dismissMessage(body.code ?? body.message_id ?? ""));
|
|
2550
2823
|
});
|
|
2551
2824
|
app.post(
|
|
2552
2825
|
"/support/conversation",
|
|
2553
|
-
(c) => tryRoute(
|
|
2826
|
+
(c) => tryRoute(
|
|
2827
|
+
c,
|
|
2828
|
+
() => deps.support.openConversation(deps.defaultBusinessId, c.var.session.customer_id)
|
|
2829
|
+
)
|
|
2554
2830
|
);
|
|
2555
2831
|
app.get(
|
|
2556
2832
|
"/support/conversation",
|
|
2557
|
-
(c) => tryRoute(
|
|
2833
|
+
(c) => tryRoute(
|
|
2834
|
+
c,
|
|
2835
|
+
() => deps.support.peekConversation(deps.defaultBusinessId, c.var.session.customer_id)
|
|
2836
|
+
)
|
|
2558
2837
|
);
|
|
2559
2838
|
app.post("/support/conversation/messages", async (c) => {
|
|
2560
2839
|
const body = await c.req.json().catch(() => ({}));
|
|
@@ -2570,7 +2849,12 @@ function buildV1(deps) {
|
|
|
2570
2849
|
});
|
|
2571
2850
|
app.get(
|
|
2572
2851
|
"/support/conversation/messages",
|
|
2573
|
-
(c) => tryRoute(
|
|
2852
|
+
(c) => tryRoute(
|
|
2853
|
+
c,
|
|
2854
|
+
() => deps.support.listMessages(c.req.query("conversation_id") ?? "", {
|
|
2855
|
+
limit: getQueryNum(c, "limit")
|
|
2856
|
+
})
|
|
2857
|
+
)
|
|
2574
2858
|
);
|
|
2575
2859
|
app.post("/support/conversation/messages/:messageId/reactions", async (c) => {
|
|
2576
2860
|
const body = await c.req.json().catch(() => ({}));
|
|
@@ -2591,7 +2875,10 @@ function buildV1(deps) {
|
|
|
2591
2875
|
});
|
|
2592
2876
|
app.get(
|
|
2593
2877
|
"/support/conversation/ws",
|
|
2594
|
-
(c) => c.json(
|
|
2878
|
+
(c) => c.json(
|
|
2879
|
+
{ note: "WebSocket connection \u2014 connect via ws:// at the same path", supported: false },
|
|
2880
|
+
426
|
|
2881
|
+
)
|
|
2595
2882
|
);
|
|
2596
2883
|
return app;
|
|
2597
2884
|
}
|
|
@@ -5043,9 +5330,11 @@ function createCheckoutService(opts) {
|
|
|
5043
5330
|
if (c.items.length === 0) throw validation("Cart is empty", { code: "CART_EMPTY" });
|
|
5044
5331
|
const orderId = ids.order();
|
|
5045
5332
|
const orderNumber = ids.orderNumber();
|
|
5333
|
+
const paymentId = ids.payment();
|
|
5046
5334
|
const reference = ids.payment();
|
|
5047
5335
|
const requiresAuth = body.payment_method === "mobile_money";
|
|
5048
5336
|
const isCard = body.payment_method === "card" || body.payment_method === "stripe";
|
|
5337
|
+
const cardProvider = body.payment_method === "stripe" || body.pay_currency?.toUpperCase() === "USD" ? "stripe" : "paystack";
|
|
5049
5338
|
const order = {
|
|
5050
5339
|
id: orderId,
|
|
5051
5340
|
business_id: c.business_id,
|
|
@@ -5069,6 +5358,7 @@ function createCheckoutService(opts) {
|
|
|
5069
5358
|
items: c.items,
|
|
5070
5359
|
applied_discount_ids: c.applied_discount_ids,
|
|
5071
5360
|
applied_discount_codes: c.applied_discount_codes,
|
|
5361
|
+
payment_id: paymentId,
|
|
5072
5362
|
payment_reference: reference,
|
|
5073
5363
|
metadata: body.metadata,
|
|
5074
5364
|
created_at: clock.iso(),
|
|
@@ -5085,31 +5375,57 @@ function createCheckoutService(opts) {
|
|
|
5085
5375
|
const result = {
|
|
5086
5376
|
order_id: orderId,
|
|
5087
5377
|
order_number: orderNumber,
|
|
5088
|
-
|
|
5378
|
+
payment_id: paymentId,
|
|
5379
|
+
payment_status: requiresAuth || isCard ? "pending" : "succeeded",
|
|
5089
5380
|
payment_reference: reference,
|
|
5090
5381
|
requires_authorization: requiresAuth,
|
|
5091
5382
|
authorization_type: requiresAuth ? "otp" : void 0,
|
|
5092
|
-
next_action: requiresAuth ? {
|
|
5093
|
-
|
|
5383
|
+
next_action: requiresAuth ? {
|
|
5384
|
+
type: "authorization",
|
|
5385
|
+
authorization_type: "otp",
|
|
5386
|
+
display_text: "Approve on your mobile money app"
|
|
5387
|
+
} : { type: "none" },
|
|
5388
|
+
provider: isCard ? cardProvider : body.payment_method,
|
|
5094
5389
|
bill_token: billToken
|
|
5095
5390
|
};
|
|
5096
5391
|
if (isCard) {
|
|
5097
|
-
result.next_action = { type: "redirect", authorization_url: `https://mock.cimplify.io/pay/${reference}` };
|
|
5098
|
-
result.authorization_url = `https://mock.cimplify.io/pay/${reference}`;
|
|
5099
|
-
result.client_secret = `pi_${orderId.slice(-12)}_secret_${Math.random().toString(36).slice(2, 18)}`;
|
|
5100
5392
|
const proc = globalThis.process;
|
|
5101
|
-
result.
|
|
5393
|
+
result.client_secret = cardProvider === "stripe" ? `pi_${orderId.slice(-12)}_secret_${Math.random().toString(36).slice(2, 18)}` : `access_${reference}`;
|
|
5394
|
+
result.public_key = cardProvider === "stripe" ? proc?.env?.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY ?? "pk_test_mock_stripe" : proc?.env?.NEXT_PUBLIC_PAYSTACK_PUBLIC_KEY ?? "pk_test_mock_paystack";
|
|
5395
|
+
result.next_action = {
|
|
5396
|
+
type: "card_popup",
|
|
5397
|
+
provider: cardProvider,
|
|
5398
|
+
client_secret: result.client_secret,
|
|
5399
|
+
public_key: result.public_key
|
|
5400
|
+
};
|
|
5102
5401
|
}
|
|
5103
5402
|
return result;
|
|
5104
5403
|
},
|
|
5105
5404
|
authorize(body) {
|
|
5106
|
-
|
|
5107
|
-
if (!
|
|
5108
|
-
const
|
|
5405
|
+
if (!body.payment_id?.trim()) throw validation("payment_id required");
|
|
5406
|
+
if (!body.authorization) throw validation("authorization required");
|
|
5407
|
+
const order = registry.orders.list(
|
|
5408
|
+
(candidate) => candidate.payment_id === body.payment_id
|
|
5409
|
+
)[0];
|
|
5410
|
+
if (!order) throw notFound(`Payment ${body.payment_id} not found`);
|
|
5411
|
+
const updated = {
|
|
5412
|
+
...order,
|
|
5413
|
+
payment_state: "paid",
|
|
5414
|
+
status: "confirmed",
|
|
5415
|
+
updated_at: clock.iso()
|
|
5416
|
+
};
|
|
5109
5417
|
registry.orders.put(order.id, updated);
|
|
5110
5418
|
bus.emit("order.payment.captured", { order_id: order.id }, order.business_id);
|
|
5111
5419
|
bus.emit("order.confirmed", { order_id: order.id }, order.business_id);
|
|
5112
|
-
return {
|
|
5420
|
+
return {
|
|
5421
|
+
order_id: order.id,
|
|
5422
|
+
order_number: order.user_friendly_id,
|
|
5423
|
+
payment_id: body.payment_id,
|
|
5424
|
+
payment_reference: order.payment_reference,
|
|
5425
|
+
payment_status: "succeeded",
|
|
5426
|
+
requires_authorization: false,
|
|
5427
|
+
next_action: { type: "none" }
|
|
5428
|
+
};
|
|
5113
5429
|
}
|
|
5114
5430
|
};
|
|
5115
5431
|
}
|