@cimplify/sdk 0.102.0 → 0.104.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-2WPVUIHX.mjs} +455 -105
- package/dist/{chunk-NIOUSKQQ.js → chunk-4BKOKHE3.js} +9 -0
- package/dist/{chunk-YDA46OZ6.js → chunk-5BDYDZ4U.js} +722 -90
- package/dist/{chunk-4KNFBPV2.mjs → chunk-5RT4HYMP.mjs} +61 -15
- package/dist/{chunk-WMEC5JWN.js → chunk-7PDEX54K.js} +50 -13
- package/dist/chunk-CNN7Z2IP.js +125 -0
- package/dist/{chunk-DLW3RWRK.mjs → chunk-DYIAX3WI.mjs} +46 -12
- package/dist/{chunk-LOWSMGRT.js → chunk-E4K2VQDD.js} +64 -16
- package/dist/chunk-GOHSXBKW.mjs +105 -0
- package/dist/{chunk-O3YUHLZL.mjs → chunk-H3RATH4B.mjs} +9 -0
- package/dist/{chunk-YER7DIOM.js → chunk-IQFFSKE2.js} +753 -594
- package/dist/{chunk-Z3K2D3TE.mjs → chunk-OCCNG6MO.mjs} +735 -558
- package/dist/{chunk-DKLHCZ5M.mjs → chunk-OKADBZAI.mjs} +652 -25
- package/dist/{chunk-EAZGA7LD.js → chunk-YVAEY3VC.js} +457 -107
- package/dist/{client-nsiMwuC1.d.ts → client-BVNWjk6W.d.ts} +2 -2
- package/dist/{client-B40KFazg.d.ts → client-BuLcOWLv.d.ts} +202 -319
- package/dist/{client-BizGfqB7.d.mts → client-D5AoobFc.d.mts} +202 -319
- package/dist/{client-BdErclfU.d.mts → client-fM716k7G.d.mts} +2 -2
- package/dist/{index-DpmnI__D.d.mts → index-BtcoqrY1.d.ts} +14 -4
- package/dist/{index-nEyXWIyR.d.ts → index-D7Tf3v7c.d.mts} +14 -4
- package/dist/index.d.mts +83 -8
- package/dist/index.d.ts +83 -8
- package/dist/index.js +203 -169
- package/dist/index.mjs +7 -5
- package/dist/link-D9iSVxt5.d.mts +308 -0
- package/dist/link-D9iSVxt5.d.ts +308 -0
- package/dist/mock/cli.mjs +463 -104
- package/dist/mock/library.js +463 -104
- package/dist/mock/library.mjs +463 -104
- package/dist/mock/msw.js +463 -104
- package/dist/mock/msw.mjs +463 -104
- package/dist/{product-Byf0unSy.d.mts → payment-g0HFkEDU.d.mts} +708 -61
- package/dist/{product-Byf0unSy.d.ts → payment-g0HFkEDU.d.ts} +708 -61
- package/dist/{price-BstChV9a.d.ts → price-BLIeAb8K.d.ts} +1 -1
- package/dist/{price-CS4E5zLS.d.mts → price-Czq_cTC_.d.mts} +1 -1
- package/dist/react.d.mts +4 -4
- package/dist/react.d.ts +4 -4
- package/dist/react.js +194 -169
- package/dist/react.mjs +55 -30
- package/dist/{server-DqbZh8Bk.d.mts → server-BkVhOIwn.d.mts} +14 -10
- package/dist/{server-Cj40R2ZD.d.ts → server-DKK_D-PP.d.ts} +14 -10
- package/dist/server.d.mts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +12 -10
- package/dist/server.mjs +6 -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 +195 -56
- package/dist/testing.d.ts +195 -56
- package/dist/testing.js +95 -82
- package/dist/testing.mjs +14 -9
- 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/registry/chat-widget.json +1 -1
- package/dist/payment-l0rkieEQ.d.mts +0 -113
- package/dist/payment-vzNnIi1n.d.ts +0 -113
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkXREIZ56K_js = require('./chunk-XREIZ56K.js');
|
|
4
|
-
var
|
|
4
|
+
var chunkCNN7Z2IP_js = require('./chunk-CNN7Z2IP.js');
|
|
5
|
+
var chunk4BKOKHE3_js = require('./chunk-4BKOKHE3.js');
|
|
5
6
|
var chunkOWW5GUSB_js = require('./chunk-OWW5GUSB.js');
|
|
6
7
|
|
|
7
8
|
// ../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/compose.js
|
|
@@ -2077,8 +2078,8 @@ var MockError = class extends Error {
|
|
|
2077
2078
|
};
|
|
2078
2079
|
}
|
|
2079
2080
|
};
|
|
2080
|
-
var notFound = (msg) => new MockError(
|
|
2081
|
-
var validation = (msg, ctx) => new MockError(
|
|
2081
|
+
var notFound = (msg) => new MockError(chunk4BKOKHE3_js.ErrorCode.NOT_FOUND, msg, 404);
|
|
2082
|
+
var validation = (msg, ctx) => new MockError(chunk4BKOKHE3_js.ErrorCode.VALIDATION_ERROR, msg, 400, ctx);
|
|
2082
2083
|
|
|
2083
2084
|
// src/mock/routes/_helpers.ts
|
|
2084
2085
|
function authMiddleware(deps) {
|
|
@@ -2190,10 +2191,22 @@ function buildV1(deps) {
|
|
|
2190
2191
|
}));
|
|
2191
2192
|
});
|
|
2192
2193
|
app.get("/business", (c) => tryRoute(c, () => deps.business.primary()));
|
|
2193
|
-
app.get(
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2194
|
+
app.get(
|
|
2195
|
+
"/business/by-handle/:handle",
|
|
2196
|
+
(c) => tryRoute(c, () => deps.business.byHandle(c.req.param("handle")))
|
|
2197
|
+
);
|
|
2198
|
+
app.get(
|
|
2199
|
+
"/business/by-domain",
|
|
2200
|
+
(c) => tryRoute(c, () => deps.business.byDomain(c.req.query("domain") ?? ""))
|
|
2201
|
+
);
|
|
2202
|
+
app.get(
|
|
2203
|
+
"/business/settings",
|
|
2204
|
+
(c) => tryRoute(c, () => deps.business.settings(deps.defaultBusinessId))
|
|
2205
|
+
);
|
|
2206
|
+
app.get(
|
|
2207
|
+
"/business/locations",
|
|
2208
|
+
(c) => tryRoute(c, () => deps.business.locations(deps.defaultBusinessId))
|
|
2209
|
+
);
|
|
2197
2210
|
app.get("/business/hours", (c) => tryRoute(c, () => deps.business.hours(deps.defaultBusinessId)));
|
|
2198
2211
|
app.get("/catalogue", (c) => tryRoute(c, () => deps.catalogue.snapshot(deps.defaultBusinessId)));
|
|
2199
2212
|
app.get(
|
|
@@ -2208,57 +2221,165 @@ function buildV1(deps) {
|
|
|
2208
2221
|
})
|
|
2209
2222
|
)
|
|
2210
2223
|
);
|
|
2211
|
-
app.get(
|
|
2212
|
-
|
|
2213
|
-
|
|
2224
|
+
app.get(
|
|
2225
|
+
"/catalogue/products/:product_id",
|
|
2226
|
+
(c) => tryRoute(c, () => deps.catalogue.getProduct(c.req.param("product_id")))
|
|
2227
|
+
);
|
|
2228
|
+
app.get(
|
|
2229
|
+
"/catalogue/products/:product_id/variants",
|
|
2230
|
+
(c) => tryRoute(c, () => deps.catalogue.getProductVariants(c.req.param("product_id")))
|
|
2231
|
+
);
|
|
2232
|
+
app.get(
|
|
2233
|
+
"/catalogue/products/:product_id/variant-axes",
|
|
2234
|
+
(c) => tryRoute(c, () => deps.catalogue.getProductVariantAxes(c.req.param("product_id")))
|
|
2235
|
+
);
|
|
2214
2236
|
app.get(
|
|
2215
2237
|
"/catalogue/products/:product_id/variants/:variant_id",
|
|
2216
|
-
(c) => tryRoute(
|
|
2238
|
+
(c) => tryRoute(
|
|
2239
|
+
c,
|
|
2240
|
+
() => deps.catalogue.getProductVariantById(c.req.param("product_id"), c.req.param("variant_id"))
|
|
2241
|
+
)
|
|
2217
2242
|
);
|
|
2218
2243
|
app.post("/catalogue/products/:product_id/variants/find", async (c) => {
|
|
2219
2244
|
const body = await c.req.json().catch(() => ({}));
|
|
2220
2245
|
return tryRoute(
|
|
2221
2246
|
c,
|
|
2222
|
-
() => deps.catalogue.findProductVariant(
|
|
2247
|
+
() => deps.catalogue.findProductVariant(
|
|
2248
|
+
c.req.param("product_id"),
|
|
2249
|
+
body.axis_selections ?? body.properties ?? {}
|
|
2250
|
+
)
|
|
2223
2251
|
);
|
|
2224
2252
|
});
|
|
2225
|
-
app.get(
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
app.get(
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
app.get(
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
app.get(
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2253
|
+
app.get(
|
|
2254
|
+
"/catalogue/products/:product_id/add-ons",
|
|
2255
|
+
(c) => tryRoute(c, () => deps.catalogue.getProductAddOns(c.req.param("product_id")))
|
|
2256
|
+
);
|
|
2257
|
+
app.get(
|
|
2258
|
+
"/catalogue/categories",
|
|
2259
|
+
(c) => tryRoute(c, () => deps.catalogue.listCategories(deps.defaultBusinessId))
|
|
2260
|
+
);
|
|
2261
|
+
app.get(
|
|
2262
|
+
"/catalogue/categories/:category_id",
|
|
2263
|
+
(c) => tryRoute(c, () => deps.catalogue.getCategory(c.req.param("category_id")))
|
|
2264
|
+
);
|
|
2265
|
+
app.get(
|
|
2266
|
+
"/catalogue/categories/:category_id/products",
|
|
2267
|
+
(c) => tryRoute(c, () => deps.catalogue.getCategoryProducts(c.req.param("category_id")))
|
|
2268
|
+
);
|
|
2269
|
+
app.get(
|
|
2270
|
+
"/catalogue/categories/:category_id/attributes",
|
|
2271
|
+
(c) => tryRoute(c, () => deps.catalogue.getCategoryAttributes(c.req.param("category_id")))
|
|
2272
|
+
);
|
|
2273
|
+
app.get(
|
|
2274
|
+
"/catalogue/categories/:category_id/deals",
|
|
2275
|
+
(c) => tryRoute(c, () => deps.catalogue.getCategoryDeals(c.req.param("category_id")))
|
|
2276
|
+
);
|
|
2277
|
+
app.get(
|
|
2278
|
+
"/catalogue/collections",
|
|
2279
|
+
(c) => tryRoute(c, () => deps.catalogue.listCollections(deps.defaultBusinessId))
|
|
2280
|
+
);
|
|
2281
|
+
app.get(
|
|
2282
|
+
"/catalogue/collections/:collection_id",
|
|
2283
|
+
(c) => tryRoute(c, () => deps.catalogue.getCollection(c.req.param("collection_id")))
|
|
2284
|
+
);
|
|
2285
|
+
app.get(
|
|
2286
|
+
"/catalogue/collections/:collection_id/products",
|
|
2287
|
+
(c) => tryRoute(c, () => deps.catalogue.getCollectionProducts(c.req.param("collection_id")))
|
|
2288
|
+
);
|
|
2289
|
+
app.get(
|
|
2290
|
+
"/catalogue/collections/:collection_id/attributes",
|
|
2291
|
+
(c) => tryRoute(c, () => deps.catalogue.getCollectionAttributes(c.req.param("collection_id")))
|
|
2292
|
+
);
|
|
2293
|
+
app.get(
|
|
2294
|
+
"/catalogue/collections/:collection_id/deals",
|
|
2295
|
+
(c) => tryRoute(c, () => deps.catalogue.getCollectionDeals(c.req.param("collection_id")))
|
|
2296
|
+
);
|
|
2297
|
+
app.get(
|
|
2298
|
+
"/catalogue/bundles",
|
|
2299
|
+
(c) => tryRoute(c, () => deps.catalogue.listBundles(deps.defaultBusinessId))
|
|
2300
|
+
);
|
|
2301
|
+
app.get(
|
|
2302
|
+
"/catalogue/bundles/:bundle_id",
|
|
2303
|
+
(c) => tryRoute(c, () => deps.catalogue.getBundle(c.req.param("bundle_id")))
|
|
2304
|
+
);
|
|
2305
|
+
app.get(
|
|
2306
|
+
"/catalogue/composites",
|
|
2307
|
+
(c) => tryRoute(c, () => deps.catalogue.listComposites(deps.defaultBusinessId))
|
|
2308
|
+
);
|
|
2309
|
+
app.get(
|
|
2310
|
+
"/catalogue/composites/by-product/:product_id",
|
|
2311
|
+
(c) => tryRoute(c, () => deps.catalogue.getCompositeByProduct(c.req.param("product_id")))
|
|
2312
|
+
);
|
|
2313
|
+
app.get(
|
|
2314
|
+
"/catalogue/composites/:composite_id",
|
|
2315
|
+
(c) => tryRoute(c, () => deps.catalogue.getComposite(c.req.param("composite_id")))
|
|
2316
|
+
);
|
|
2241
2317
|
app.post("/catalogue/composites/:composite_id/calculate-price", async (c) => {
|
|
2242
2318
|
const body = await c.req.json().catch(() => ({}));
|
|
2243
|
-
return tryRoute(
|
|
2319
|
+
return tryRoute(
|
|
2320
|
+
c,
|
|
2321
|
+
() => deps.catalogue.calculateCompositePrice(c.req.param("composite_id"), body)
|
|
2322
|
+
);
|
|
2244
2323
|
});
|
|
2245
|
-
app.get(
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
app.get(
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2324
|
+
app.get(
|
|
2325
|
+
"/catalogue/taxonomies",
|
|
2326
|
+
(c) => tryRoute(c, () => deps.catalogue.listTaxonomies(deps.defaultBusinessId))
|
|
2327
|
+
);
|
|
2328
|
+
app.get(
|
|
2329
|
+
"/catalogue/taxonomies/search",
|
|
2330
|
+
(c) => tryRoute(
|
|
2331
|
+
c,
|
|
2332
|
+
() => deps.catalogue.searchTaxonomies(deps.defaultBusinessId, c.req.query("q") ?? "")
|
|
2333
|
+
)
|
|
2334
|
+
);
|
|
2335
|
+
app.get(
|
|
2336
|
+
"/catalogue/taxonomies/:taxonomy_id",
|
|
2337
|
+
(c) => tryRoute(c, () => deps.catalogue.getTaxonomy(c.req.param("taxonomy_id")))
|
|
2338
|
+
);
|
|
2339
|
+
app.get(
|
|
2340
|
+
"/catalogue/taxonomies/:taxonomy_id/attributes",
|
|
2341
|
+
(c) => tryRoute(c, () => deps.catalogue.getTaxonomyAttributes(c.req.param("taxonomy_id")))
|
|
2342
|
+
);
|
|
2343
|
+
app.get(
|
|
2344
|
+
"/catalogue/taxonomies/:taxonomy_id/path",
|
|
2345
|
+
(c) => tryRoute(c, () => deps.catalogue.getTaxonomyPath(c.req.param("taxonomy_id")))
|
|
2346
|
+
);
|
|
2347
|
+
app.get(
|
|
2348
|
+
"/catalogue/attributes",
|
|
2349
|
+
(c) => tryRoute(c, () => deps.catalogue.listAttributes(deps.defaultBusinessId))
|
|
2350
|
+
);
|
|
2351
|
+
app.get(
|
|
2352
|
+
"/catalogue/properties/facets",
|
|
2353
|
+
(c) => tryRoute(c, () => deps.catalogue.listPropertyFacets(deps.defaultBusinessId))
|
|
2354
|
+
);
|
|
2355
|
+
app.get(
|
|
2356
|
+
"/catalogue/tags",
|
|
2357
|
+
(c) => tryRoute(c, () => deps.catalogue.listTags(deps.defaultBusinessId))
|
|
2358
|
+
);
|
|
2253
2359
|
app.get("/catalogue/menu", (c) => tryRoute(c, () => deps.lite.getMenu(deps.defaultBusinessId)));
|
|
2254
|
-
app.get(
|
|
2255
|
-
|
|
2256
|
-
|
|
2360
|
+
app.get(
|
|
2361
|
+
"/catalogue/menu/categories/:category_id",
|
|
2362
|
+
(c) => tryRoute(c, () => deps.lite.getMenuCategory(c.req.param("category_id")))
|
|
2363
|
+
);
|
|
2364
|
+
app.get(
|
|
2365
|
+
"/catalogue/menu/items/:item_id",
|
|
2366
|
+
(c) => tryRoute(c, () => deps.catalogue.getProduct(c.req.param("item_id")))
|
|
2367
|
+
);
|
|
2368
|
+
app.get(
|
|
2369
|
+
"/catalogue/knowledge-base/articles",
|
|
2370
|
+
(c) => tryRoute(c, () => ({ articles: deps.catalogue.listKnowledgeArticles(deps.defaultBusinessId) }))
|
|
2371
|
+
);
|
|
2257
2372
|
app.get(
|
|
2258
2373
|
"/catalogue/knowledge-base/search",
|
|
2259
|
-
(c) => tryRoute(c, () => ({
|
|
2374
|
+
(c) => tryRoute(c, () => ({
|
|
2375
|
+
results: deps.catalogue.searchKnowledgeBase(deps.defaultBusinessId, c.req.query("q") ?? ""),
|
|
2376
|
+
query: c.req.query("q") ?? ""
|
|
2377
|
+
}))
|
|
2378
|
+
);
|
|
2379
|
+
app.get(
|
|
2380
|
+
"/catalogue/products/:product_id/attributes",
|
|
2381
|
+
(c) => tryRoute(c, () => deps.catalogue.getProductAttributes(c.req.param("product_id")))
|
|
2260
2382
|
);
|
|
2261
|
-
app.get("/catalogue/products/:product_id/attributes", (c) => tryRoute(c, () => deps.catalogue.getProductAttributes(c.req.param("product_id"))));
|
|
2262
2383
|
app.get(
|
|
2263
2384
|
"/catalogue/products/:product_id/available-now",
|
|
2264
2385
|
(c) => tryRoute(c, () => {
|
|
@@ -2277,22 +2398,75 @@ function buildV1(deps) {
|
|
|
2277
2398
|
"/catalogue/products/:product_id/schedules",
|
|
2278
2399
|
(c) => tryRoute(c, () => {
|
|
2279
2400
|
const p = deps.registry.products.get(c.req.param("product_id"));
|
|
2280
|
-
return {
|
|
2401
|
+
return {
|
|
2402
|
+
schedules: p?.metadata?.["time_profiles"] ?? []
|
|
2403
|
+
};
|
|
2281
2404
|
})
|
|
2282
2405
|
);
|
|
2283
|
-
app.get(
|
|
2284
|
-
|
|
2406
|
+
app.get(
|
|
2407
|
+
"/catalogue/deals",
|
|
2408
|
+
(c) => tryRoute(c, () => deps.catalogue.listDeals(deps.defaultBusinessId))
|
|
2409
|
+
);
|
|
2410
|
+
app.get(
|
|
2411
|
+
"/catalogue/deals/on-sale",
|
|
2412
|
+
(c) => tryRoute(c, () => deps.catalogue.listOnSale(deps.defaultBusinessId))
|
|
2413
|
+
);
|
|
2285
2414
|
app.post("/catalogue/deals/validate", async (c) => {
|
|
2286
2415
|
const body = await c.req.json().catch(() => ({}));
|
|
2287
|
-
return tryRoute(
|
|
2416
|
+
return tryRoute(
|
|
2417
|
+
c,
|
|
2418
|
+
() => deps.catalogue.validateDiscount(
|
|
2419
|
+
body.discount_code ?? body.code ?? "",
|
|
2420
|
+
deps.defaultBusinessId
|
|
2421
|
+
)
|
|
2422
|
+
);
|
|
2288
2423
|
});
|
|
2289
|
-
app.get(
|
|
2424
|
+
app.get(
|
|
2425
|
+
"/catalogue/products/:product_id/deals",
|
|
2426
|
+
(c) => tryRoute(c, () => deps.catalogue.getProductDeals(c.req.param("product_id")))
|
|
2427
|
+
);
|
|
2290
2428
|
app.post("/catalogue/quotes", async (c) => {
|
|
2291
2429
|
const body = await c.req.json().catch(() => ({}));
|
|
2292
2430
|
return tryRoute(c, () => deps.catalogue.createQuote(deps.defaultBusinessId, body));
|
|
2293
2431
|
});
|
|
2294
|
-
app.get(
|
|
2295
|
-
|
|
2432
|
+
app.get(
|
|
2433
|
+
"/catalogue/quotes/:quote_id",
|
|
2434
|
+
(c) => tryRoute(c, () => deps.catalogue.getQuote(c.req.param("quote_id")))
|
|
2435
|
+
);
|
|
2436
|
+
app.post(
|
|
2437
|
+
"/catalogue/quotes/:quote_id/refresh",
|
|
2438
|
+
(c) => tryRoute(c, () => deps.catalogue.refreshQuote(c.req.param("quote_id")))
|
|
2439
|
+
);
|
|
2440
|
+
app.get("/reviews/summary", (c) => {
|
|
2441
|
+
const productId = c.req.query("product_id");
|
|
2442
|
+
if (productId !== void 0 && (productId.length === 0 || productId.trim() !== productId)) {
|
|
2443
|
+
return fail(c, validation("product_id must be a non-empty canonical identifier"));
|
|
2444
|
+
}
|
|
2445
|
+
const response = {
|
|
2446
|
+
data: {
|
|
2447
|
+
ratings: {
|
|
2448
|
+
product_id: productId ?? null,
|
|
2449
|
+
review_count: 0,
|
|
2450
|
+
rating_sum: 0,
|
|
2451
|
+
average_rating: null,
|
|
2452
|
+
distribution: { one: 0, two: 0, three: 0, four: 0, five: 0 }
|
|
2453
|
+
},
|
|
2454
|
+
trust_chips: {
|
|
2455
|
+
on_time_delivery_percent: null,
|
|
2456
|
+
delivery_sample_size: 0,
|
|
2457
|
+
average_first_response_seconds: null,
|
|
2458
|
+
support_sample_size: 0
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
};
|
|
2462
|
+
return c.json(response);
|
|
2463
|
+
});
|
|
2464
|
+
app.get("/reviews", (c) => {
|
|
2465
|
+
const response = {
|
|
2466
|
+
data: { items: [], next_cursor: null }
|
|
2467
|
+
};
|
|
2468
|
+
return c.json(response);
|
|
2469
|
+
});
|
|
2296
2470
|
app.get("/cart", (c) => tryRoute(c, () => deps.cart.toUICart(deps.cart.get(c.var.session))));
|
|
2297
2471
|
app.delete("/cart", (c) => tryRoute(c, () => deps.cart.clear(c.var.session)));
|
|
2298
2472
|
app.get("/cart/items", (c) => tryRoute(c, () => deps.cart.getItems(c.var.session)));
|
|
@@ -2303,9 +2477,15 @@ function buildV1(deps) {
|
|
|
2303
2477
|
app.patch("/cart/items/:cart_item_id", async (c) => {
|
|
2304
2478
|
const body = await c.req.json().catch(() => ({}));
|
|
2305
2479
|
if (typeof body.quantity !== "number") return fail(c, validation("quantity required"));
|
|
2306
|
-
return tryRoute(
|
|
2480
|
+
return tryRoute(
|
|
2481
|
+
c,
|
|
2482
|
+
() => deps.cart.updateQuantity(c.var.session, c.req.param("cart_item_id"), body.quantity)
|
|
2483
|
+
);
|
|
2307
2484
|
});
|
|
2308
|
-
app.delete(
|
|
2485
|
+
app.delete(
|
|
2486
|
+
"/cart/items/:cart_item_id",
|
|
2487
|
+
(c) => tryRoute(c, () => deps.cart.removeItem(c.var.session, c.req.param("cart_item_id")))
|
|
2488
|
+
);
|
|
2309
2489
|
app.get("/cart/count", (c) => tryRoute(c, () => deps.cart.getCount(c.var.session)));
|
|
2310
2490
|
app.get("/cart/total", (c) => tryRoute(c, () => deps.cart.getTotal(c.var.session)));
|
|
2311
2491
|
app.post("/cart/destination-quote", async (c) => {
|
|
@@ -2316,10 +2496,25 @@ function buildV1(deps) {
|
|
|
2316
2496
|
const body = await c.req.json().catch(() => ({}));
|
|
2317
2497
|
return tryRoute(c, () => deps.cart.applyCoupon(c.var.session, body.coupon_code ?? ""));
|
|
2318
2498
|
});
|
|
2319
|
-
app.delete(
|
|
2320
|
-
|
|
2499
|
+
app.delete(
|
|
2500
|
+
"/cart/coupons/current",
|
|
2501
|
+
(c) => tryRoute(c, () => deps.cart.removeCoupon(c.var.session))
|
|
2502
|
+
);
|
|
2503
|
+
app.get(
|
|
2504
|
+
"/orders",
|
|
2505
|
+
(c) => tryRoute(
|
|
2506
|
+
c,
|
|
2507
|
+
() => deps.orders.list(c.var.session, {
|
|
2508
|
+
limit: getQueryNum(c, "limit"),
|
|
2509
|
+
status: c.req.query("status")
|
|
2510
|
+
})
|
|
2511
|
+
)
|
|
2512
|
+
);
|
|
2321
2513
|
app.get("/orders/:order_id", (c) => tryRoute(c, () => deps.orders.get(c.req.param("order_id"))));
|
|
2322
|
-
app.get(
|
|
2514
|
+
app.get(
|
|
2515
|
+
"/orders/:order_id/payment-status",
|
|
2516
|
+
(c) => tryRoute(c, () => deps.orders.getPaymentStatus(c.req.param("order_id")))
|
|
2517
|
+
);
|
|
2323
2518
|
app.post("/orders/:order_id/cancel", async (c) => {
|
|
2324
2519
|
const body = await c.req.json().catch(() => ({}));
|
|
2325
2520
|
return tryRoute(c, () => deps.orders.cancel(c.req.param("order_id"), body.reason));
|
|
@@ -2328,13 +2523,46 @@ function buildV1(deps) {
|
|
|
2328
2523
|
const body = await c.req.json().catch(() => ({}));
|
|
2329
2524
|
return tryRoute(c, () => deps.orders.updateCustomer(c.req.param("order_id"), body));
|
|
2330
2525
|
});
|
|
2331
|
-
app.post(
|
|
2526
|
+
app.post(
|
|
2527
|
+
"/orders/:order_id/verify-payment",
|
|
2528
|
+
(c) => tryRoute(c, () => deps.orders.verifyPayment(c.req.param("order_id")))
|
|
2529
|
+
);
|
|
2332
2530
|
app.get("/subscriptions", (c) => tryRoute(c, () => deps.subscriptions.list(c.var.session)));
|
|
2333
|
-
app.get(
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
app.post(
|
|
2531
|
+
app.get(
|
|
2532
|
+
"/subscriptions/:subscription_id",
|
|
2533
|
+
(c) => tryRoute(c, () => deps.subscriptions.get(c.req.param("subscription_id")))
|
|
2534
|
+
);
|
|
2535
|
+
app.post(
|
|
2536
|
+
"/subscriptions/:subscription_id/cancel",
|
|
2537
|
+
(c) => tryRoute(c, () => deps.subscriptions.cancel(c.req.param("subscription_id")))
|
|
2538
|
+
);
|
|
2539
|
+
app.post(
|
|
2540
|
+
"/subscriptions/:subscription_id/pause",
|
|
2541
|
+
(c) => tryRoute(c, () => deps.subscriptions.pause(c.req.param("subscription_id")))
|
|
2542
|
+
);
|
|
2543
|
+
app.post(
|
|
2544
|
+
"/subscriptions/:subscription_id/resume",
|
|
2545
|
+
(c) => tryRoute(c, () => deps.subscriptions.resume(c.req.param("subscription_id")))
|
|
2546
|
+
);
|
|
2547
|
+
app.post(
|
|
2548
|
+
"/subscriptions/:subscription_id/skip",
|
|
2549
|
+
(c) => tryRoute(c, () => deps.subscriptions.skipNext(c.req.param("subscription_id")))
|
|
2550
|
+
);
|
|
2551
|
+
app.get("/payments/collection-options", (c) => {
|
|
2552
|
+
const currency = c.req.query("currency")?.trim().toUpperCase();
|
|
2553
|
+
if (!currency || !/^[A-Z]{3}$/.test(currency)) {
|
|
2554
|
+
return fail(c, validation("currency must be a canonical three-letter code"));
|
|
2555
|
+
}
|
|
2556
|
+
return tryRoute(c, () => ({
|
|
2557
|
+
presentment_currency: currency,
|
|
2558
|
+
options: currency === "GHS" ? [
|
|
2559
|
+
{ method: chunkCNN7Z2IP_js.PAYMENT_METHOD.CARD, network: null },
|
|
2560
|
+
{ method: chunkCNN7Z2IP_js.PAYMENT_METHOD.MOBILE_MONEY, network: "mtn" },
|
|
2561
|
+
{ method: chunkCNN7Z2IP_js.PAYMENT_METHOD.MOBILE_MONEY, network: "telecel" },
|
|
2562
|
+
{ method: chunkCNN7Z2IP_js.PAYMENT_METHOD.MOBILE_MONEY, network: "airteltigo" }
|
|
2563
|
+
] : currency === "USD" ? [{ method: chunkCNN7Z2IP_js.PAYMENT_METHOD.CARD, network: null }] : []
|
|
2564
|
+
}));
|
|
2565
|
+
});
|
|
2338
2566
|
app.post("/checkout", async (c) => {
|
|
2339
2567
|
const body = await c.req.json().catch(() => ({}));
|
|
2340
2568
|
return tryRoute(c, () => deps.checkout.process(c.var.session, body));
|
|
@@ -2388,15 +2616,33 @@ function buildV1(deps) {
|
|
|
2388
2616
|
return { success: true, message: "Profile updated successfully" };
|
|
2389
2617
|
});
|
|
2390
2618
|
});
|
|
2391
|
-
app.get(
|
|
2392
|
-
|
|
2619
|
+
app.get(
|
|
2620
|
+
"/inventory/products/:product_id/stock",
|
|
2621
|
+
(c) => tryRoute(c, () => deps.inventory.productStock(c.req.param("product_id")))
|
|
2622
|
+
);
|
|
2623
|
+
app.get(
|
|
2624
|
+
"/inventory/variants/:variant_id/stock",
|
|
2625
|
+
(c) => tryRoute(c, () => deps.inventory.variantStock(c.req.param("variant_id")))
|
|
2626
|
+
);
|
|
2393
2627
|
app.get(
|
|
2394
2628
|
"/inventory/products/:product_id/availability",
|
|
2395
|
-
(c) => tryRoute(
|
|
2629
|
+
(c) => tryRoute(
|
|
2630
|
+
c,
|
|
2631
|
+
() => deps.inventory.productAvailability(
|
|
2632
|
+
c.req.param("product_id"),
|
|
2633
|
+
getQueryNum(c, "quantity") ?? 1
|
|
2634
|
+
)
|
|
2635
|
+
)
|
|
2396
2636
|
);
|
|
2397
2637
|
app.get(
|
|
2398
2638
|
"/inventory/variants/:variant_id/availability",
|
|
2399
|
-
(c) => tryRoute(
|
|
2639
|
+
(c) => tryRoute(
|
|
2640
|
+
c,
|
|
2641
|
+
() => deps.inventory.variantAvailability(
|
|
2642
|
+
c.req.param("variant_id"),
|
|
2643
|
+
getQueryNum(c, "quantity") ?? 1
|
|
2644
|
+
)
|
|
2645
|
+
)
|
|
2400
2646
|
);
|
|
2401
2647
|
app.get(
|
|
2402
2648
|
"/delivery/fee",
|
|
@@ -2423,35 +2669,75 @@ function buildV1(deps) {
|
|
|
2423
2669
|
);
|
|
2424
2670
|
app.post("/places/autocomplete", async (c) => {
|
|
2425
2671
|
const body = await c.req.json().catch(() => ({}));
|
|
2426
|
-
return tryRoute(
|
|
2672
|
+
return tryRoute(
|
|
2673
|
+
c,
|
|
2674
|
+
() => deps.places.autocomplete({ query: body.input ?? body.query ?? "", country: body.country })
|
|
2675
|
+
);
|
|
2427
2676
|
});
|
|
2428
2677
|
app.post("/places/details", async (c) => {
|
|
2429
2678
|
const body = await c.req.json().catch(() => ({}));
|
|
2430
2679
|
return tryRoute(c, () => deps.places.details({ place_id: body.place_id ?? "" }));
|
|
2431
2680
|
});
|
|
2432
|
-
app.get(
|
|
2433
|
-
|
|
2434
|
-
|
|
2681
|
+
app.get(
|
|
2682
|
+
"/scheduling/services",
|
|
2683
|
+
(c) => tryRoute(c, () => deps.scheduling.listServices(deps.defaultBusinessId))
|
|
2684
|
+
);
|
|
2685
|
+
app.get(
|
|
2686
|
+
"/scheduling/services/:service_id",
|
|
2687
|
+
(c) => tryRoute(c, () => deps.scheduling.getService(c.req.param("service_id")))
|
|
2688
|
+
);
|
|
2689
|
+
app.get(
|
|
2690
|
+
"/scheduling/slots",
|
|
2691
|
+
(c) => tryRoute(
|
|
2692
|
+
c,
|
|
2693
|
+
() => deps.scheduling.getSlots(c.req.query("service_id") ?? "", { date: c.req.query("date") })
|
|
2694
|
+
)
|
|
2695
|
+
);
|
|
2435
2696
|
app.get(
|
|
2436
2697
|
"/scheduling/slots/check",
|
|
2437
|
-
(c) => tryRoute(
|
|
2698
|
+
(c) => tryRoute(
|
|
2699
|
+
c,
|
|
2700
|
+
() => deps.scheduling.checkSlot(
|
|
2701
|
+
c.req.query("service_id") ?? "",
|
|
2702
|
+
c.req.query("start") ?? "",
|
|
2703
|
+
c.req.query("end") ?? ""
|
|
2704
|
+
)
|
|
2705
|
+
)
|
|
2706
|
+
);
|
|
2707
|
+
app.get(
|
|
2708
|
+
"/scheduling/availability",
|
|
2709
|
+
(c) => tryRoute(c, () => deps.scheduling.getServiceAvailability(c.req.query("service_id") ?? ""))
|
|
2710
|
+
);
|
|
2711
|
+
app.get(
|
|
2712
|
+
"/scheduling/bookings",
|
|
2713
|
+
(c) => tryRoute(c, () => deps.scheduling.getCustomerBookings(c.var.session))
|
|
2438
2714
|
);
|
|
2439
|
-
app.get("/scheduling/availability", (c) => tryRoute(c, () => deps.scheduling.getServiceAvailability(c.req.query("service_id") ?? "")));
|
|
2440
|
-
app.get("/scheduling/bookings", (c) => tryRoute(c, () => deps.scheduling.getCustomerBookings(c.var.session)));
|
|
2441
2715
|
app.post("/scheduling/bookings/reschedule", async (c) => {
|
|
2442
2716
|
const body = await c.req.json().catch(() => ({}));
|
|
2443
2717
|
return tryRoute(c, () => deps.scheduling.rescheduleBooking(body));
|
|
2444
2718
|
});
|
|
2445
|
-
app.get(
|
|
2719
|
+
app.get(
|
|
2720
|
+
"/scheduling/bookings/:booking_id",
|
|
2721
|
+
(c) => tryRoute(c, () => deps.scheduling.getBooking(c.req.param("booking_id")))
|
|
2722
|
+
);
|
|
2446
2723
|
app.post("/scheduling/bookings/:booking_id/cancel", async (c) => {
|
|
2447
2724
|
const body = await c.req.json().catch(() => ({}));
|
|
2448
2725
|
return tryRoute(c, () => deps.scheduling.cancelBooking(c.req.param("booking_id"), body.reason));
|
|
2449
2726
|
});
|
|
2450
2727
|
app.get("/lite/bootstrap", (c) => tryRoute(c, () => deps.lite.bootstrap(deps.defaultBusinessId)));
|
|
2451
|
-
app.get(
|
|
2728
|
+
app.get(
|
|
2729
|
+
"/lite/resources/:resource_id",
|
|
2730
|
+
(c) => tryRoute(c, () => deps.lite.getResource(c.req.param("resource_id")))
|
|
2731
|
+
);
|
|
2452
2732
|
app.get("/lite/menu", (c) => tryRoute(c, () => deps.lite.getMenu(deps.defaultBusinessId)));
|
|
2453
|
-
app.get(
|
|
2454
|
-
|
|
2733
|
+
app.get(
|
|
2734
|
+
"/lite/menu/categories/:category_id",
|
|
2735
|
+
(c) => tryRoute(c, () => deps.lite.getMenuCategory(c.req.param("category_id")))
|
|
2736
|
+
);
|
|
2737
|
+
app.get(
|
|
2738
|
+
"/fx/rate",
|
|
2739
|
+
(c) => tryRoute(c, () => deps.fx.getRate(c.req.query("from") ?? "USD", c.req.query("to") ?? "GHS"))
|
|
2740
|
+
);
|
|
2455
2741
|
app.post("/fx/quotes", async (c) => {
|
|
2456
2742
|
const body = await c.req.json().catch(() => ({}));
|
|
2457
2743
|
return tryRoute(c, () => deps.fx.lockQuote(body));
|
|
@@ -2464,31 +2750,47 @@ function buildV1(deps) {
|
|
|
2464
2750
|
const body = await c.req.json().catch(() => ({}));
|
|
2465
2751
|
return tryRoute(c, () => deps.uploads.confirm(body));
|
|
2466
2752
|
});
|
|
2467
|
-
app.get(
|
|
2468
|
-
"/store-credit/balance",
|
|
2469
|
-
(c) => c.json({ data: { balance: "0.00", currency: "USD" } })
|
|
2470
|
-
);
|
|
2753
|
+
app.get("/store-credit/balance", (c) => c.json({ data: { balance: "0.00", currency: "USD" } }));
|
|
2471
2754
|
app.post("/activity/session", async (c) => {
|
|
2472
2755
|
await c.req.json().catch(() => ({}));
|
|
2473
2756
|
return c.json({ data: { recorded: true } });
|
|
2474
2757
|
});
|
|
2475
2758
|
app.post("/activity/events", async (c) => {
|
|
2476
2759
|
const body = await c.req.json().catch(() => ({}));
|
|
2477
|
-
return tryRoute(
|
|
2760
|
+
return tryRoute(
|
|
2761
|
+
c,
|
|
2762
|
+
() => deps.activity.recordEvents(
|
|
2763
|
+
deps.defaultBusinessId,
|
|
2764
|
+
body.analytics_session_id ?? c.var.session.id,
|
|
2765
|
+
body.events ?? []
|
|
2766
|
+
)
|
|
2767
|
+
);
|
|
2478
2768
|
});
|
|
2479
|
-
app.get(
|
|
2480
|
-
|
|
2769
|
+
app.get(
|
|
2770
|
+
"/activity/state",
|
|
2771
|
+
(c) => tryRoute(c, () => deps.activity.getState(deps.defaultBusinessId, c.var.session.id))
|
|
2772
|
+
);
|
|
2773
|
+
app.get(
|
|
2774
|
+
"/activity/recommendations",
|
|
2775
|
+
(c) => tryRoute(c, () => deps.activity.getRecommendations(deps.defaultBusinessId))
|
|
2776
|
+
);
|
|
2481
2777
|
app.post("/activity/messages/dismiss", async (c) => {
|
|
2482
2778
|
const body = await c.req.json().catch(() => ({}));
|
|
2483
2779
|
return tryRoute(c, () => deps.activity.dismissMessage(body.code ?? body.message_id ?? ""));
|
|
2484
2780
|
});
|
|
2485
2781
|
app.post(
|
|
2486
2782
|
"/support/conversation",
|
|
2487
|
-
(c) => tryRoute(
|
|
2783
|
+
(c) => tryRoute(
|
|
2784
|
+
c,
|
|
2785
|
+
() => deps.support.openConversation(deps.defaultBusinessId, c.var.session.customer_id)
|
|
2786
|
+
)
|
|
2488
2787
|
);
|
|
2489
2788
|
app.get(
|
|
2490
2789
|
"/support/conversation",
|
|
2491
|
-
(c) => tryRoute(
|
|
2790
|
+
(c) => tryRoute(
|
|
2791
|
+
c,
|
|
2792
|
+
() => deps.support.peekConversation(deps.defaultBusinessId, c.var.session.customer_id)
|
|
2793
|
+
)
|
|
2492
2794
|
);
|
|
2493
2795
|
app.post("/support/conversation/messages", async (c) => {
|
|
2494
2796
|
const body = await c.req.json().catch(() => ({}));
|
|
@@ -2504,7 +2806,12 @@ function buildV1(deps) {
|
|
|
2504
2806
|
});
|
|
2505
2807
|
app.get(
|
|
2506
2808
|
"/support/conversation/messages",
|
|
2507
|
-
(c) => tryRoute(
|
|
2809
|
+
(c) => tryRoute(
|
|
2810
|
+
c,
|
|
2811
|
+
() => deps.support.listMessages(c.req.query("conversation_id") ?? "", {
|
|
2812
|
+
limit: getQueryNum(c, "limit")
|
|
2813
|
+
})
|
|
2814
|
+
)
|
|
2508
2815
|
);
|
|
2509
2816
|
app.post("/support/conversation/messages/:messageId/reactions", async (c) => {
|
|
2510
2817
|
const body = await c.req.json().catch(() => ({}));
|
|
@@ -2525,7 +2832,10 @@ function buildV1(deps) {
|
|
|
2525
2832
|
});
|
|
2526
2833
|
app.get(
|
|
2527
2834
|
"/support/conversation/ws",
|
|
2528
|
-
(c) => c.json(
|
|
2835
|
+
(c) => c.json(
|
|
2836
|
+
{ note: "WebSocket connection \u2014 connect via ws:// at the same path", supported: false },
|
|
2837
|
+
426
|
|
2838
|
+
)
|
|
2529
2839
|
);
|
|
2530
2840
|
return app;
|
|
2531
2841
|
}
|
|
@@ -3052,9 +3362,10 @@ function buildLink(deps) {
|
|
|
3052
3362
|
app.post("/auth/request-otp", async (c) => {
|
|
3053
3363
|
const body = await c.req.json().catch(() => ({}));
|
|
3054
3364
|
return tryRoute(c, () => {
|
|
3055
|
-
deps.auth.requestOtp(body.contact ?? "");
|
|
3365
|
+
const challenge = deps.auth.requestOtp(body.contact ?? "");
|
|
3056
3366
|
return {
|
|
3057
3367
|
success: true,
|
|
3368
|
+
challenge_id: challenge.otp_id,
|
|
3058
3369
|
message: `OTP sent to ${body.contact ?? "contact"}`,
|
|
3059
3370
|
expires_in: 300,
|
|
3060
3371
|
is_new_account: false
|
|
@@ -3064,7 +3375,11 @@ function buildLink(deps) {
|
|
|
3064
3375
|
app.post("/auth/verify-otp", async (c) => {
|
|
3065
3376
|
const body = await c.req.json().catch(() => ({}));
|
|
3066
3377
|
return tryRoute(c, () => {
|
|
3067
|
-
const session = deps.auth.verifyOtp(
|
|
3378
|
+
const session = deps.auth.verifyOtp(
|
|
3379
|
+
body.contact ?? "",
|
|
3380
|
+
body.otp_code ?? "",
|
|
3381
|
+
body.challenge_id
|
|
3382
|
+
);
|
|
3068
3383
|
c.header("x-session-token", session.token);
|
|
3069
3384
|
const customer = deps.link.ensureCustomer(session.customer_id ?? session.id, {
|
|
3070
3385
|
email: body.contact?.includes("@") ? body.contact : void 0,
|
|
@@ -3158,10 +3473,7 @@ function buildLink(deps) {
|
|
|
3158
3473
|
};
|
|
3159
3474
|
});
|
|
3160
3475
|
});
|
|
3161
|
-
app.get(
|
|
3162
|
-
"/preferences",
|
|
3163
|
-
(c) => tryRoute(c, () => deps.link.getPreferences(customerId(c)))
|
|
3164
|
-
);
|
|
3476
|
+
app.get("/preferences", (c) => tryRoute(c, () => deps.link.getPreferences(customerId(c))));
|
|
3165
3477
|
app.post("/preferences", async (c) => {
|
|
3166
3478
|
const body = await c.req.json().catch(() => ({}));
|
|
3167
3479
|
return tryRoute(c, () => {
|
|
@@ -3638,9 +3950,16 @@ function createAuthService(opts) {
|
|
|
3638
3950
|
code_hint: options.mode === "permissive" ? code : void 0
|
|
3639
3951
|
};
|
|
3640
3952
|
},
|
|
3641
|
-
verifyOtp(contact, code) {
|
|
3642
|
-
|
|
3643
|
-
|
|
3953
|
+
verifyOtp(contact, code, challengeId) {
|
|
3954
|
+
let otp = challengeId ? registry.otps.get(challengeId) : void 0;
|
|
3955
|
+
if (!challengeId) {
|
|
3956
|
+
const matching = registry.otps.list((o) => o.contact === contact);
|
|
3957
|
+
otp = matching[matching.length - 1];
|
|
3958
|
+
}
|
|
3959
|
+
if (challengeId) {
|
|
3960
|
+
if (!otp) throw new Error("No OTP challenge found");
|
|
3961
|
+
if (otp.contact !== contact) throw new Error("OTP challenge does not match contact");
|
|
3962
|
+
}
|
|
3644
3963
|
if (options.mode === "strict") {
|
|
3645
3964
|
if (!otp) throw new Error("No OTP requested");
|
|
3646
3965
|
if (otp.code !== code && code !== options.defaultOtp) throw new Error("Invalid OTP");
|
|
@@ -4968,7 +5287,7 @@ function createCartService(opts) {
|
|
|
4968
5287
|
|
|
4969
5288
|
// src/mock/domain/checkout.ts
|
|
4970
5289
|
function createCheckoutService(opts) {
|
|
4971
|
-
const { registry, clock, ids, bus} = opts;
|
|
5290
|
+
const { registry, clock, ids, bus } = opts;
|
|
4972
5291
|
return {
|
|
4973
5292
|
process(session, body) {
|
|
4974
5293
|
if (!body.cart_id) throw validation("cart_id required");
|
|
@@ -4977,9 +5296,11 @@ function createCheckoutService(opts) {
|
|
|
4977
5296
|
if (c.items.length === 0) throw validation("Cart is empty", { code: "CART_EMPTY" });
|
|
4978
5297
|
const orderId = ids.order();
|
|
4979
5298
|
const orderNumber = ids.orderNumber();
|
|
5299
|
+
const paymentId = ids.payment();
|
|
4980
5300
|
const reference = ids.payment();
|
|
4981
5301
|
const requiresAuth = body.payment_method === "mobile_money";
|
|
4982
5302
|
const isCard = body.payment_method === "card" || body.payment_method === "stripe";
|
|
5303
|
+
const cardProvider = body.payment_method === "stripe" || body.pay_currency?.toUpperCase() === "USD" ? "stripe" : "paystack";
|
|
4983
5304
|
const order = {
|
|
4984
5305
|
id: orderId,
|
|
4985
5306
|
business_id: c.business_id,
|
|
@@ -5003,6 +5324,7 @@ function createCheckoutService(opts) {
|
|
|
5003
5324
|
items: c.items,
|
|
5004
5325
|
applied_discount_ids: c.applied_discount_ids,
|
|
5005
5326
|
applied_discount_codes: c.applied_discount_codes,
|
|
5327
|
+
payment_id: paymentId,
|
|
5006
5328
|
payment_reference: reference,
|
|
5007
5329
|
metadata: body.metadata,
|
|
5008
5330
|
created_at: clock.iso(),
|
|
@@ -5019,31 +5341,57 @@ function createCheckoutService(opts) {
|
|
|
5019
5341
|
const result = {
|
|
5020
5342
|
order_id: orderId,
|
|
5021
5343
|
order_number: orderNumber,
|
|
5022
|
-
|
|
5344
|
+
payment_id: paymentId,
|
|
5345
|
+
payment_status: requiresAuth || isCard ? "pending" : "succeeded",
|
|
5023
5346
|
payment_reference: reference,
|
|
5024
5347
|
requires_authorization: requiresAuth,
|
|
5025
5348
|
authorization_type: requiresAuth ? "otp" : void 0,
|
|
5026
|
-
next_action: requiresAuth ? {
|
|
5027
|
-
|
|
5349
|
+
next_action: requiresAuth ? {
|
|
5350
|
+
type: "authorization",
|
|
5351
|
+
authorization_type: "otp",
|
|
5352
|
+
display_text: "Approve on your mobile money app"
|
|
5353
|
+
} : { type: "none" },
|
|
5354
|
+
provider: isCard ? cardProvider : body.payment_method,
|
|
5028
5355
|
bill_token: billToken
|
|
5029
5356
|
};
|
|
5030
5357
|
if (isCard) {
|
|
5031
|
-
result.next_action = { type: "redirect", authorization_url: `https://mock.cimplify.io/pay/${reference}` };
|
|
5032
|
-
result.authorization_url = `https://mock.cimplify.io/pay/${reference}`;
|
|
5033
|
-
result.client_secret = `pi_${orderId.slice(-12)}_secret_${Math.random().toString(36).slice(2, 18)}`;
|
|
5034
5358
|
const proc = globalThis.process;
|
|
5035
|
-
result.
|
|
5359
|
+
result.client_secret = cardProvider === "stripe" ? `pi_${orderId.slice(-12)}_secret_${Math.random().toString(36).slice(2, 18)}` : `access_${reference}`;
|
|
5360
|
+
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";
|
|
5361
|
+
result.next_action = {
|
|
5362
|
+
type: "card_popup",
|
|
5363
|
+
provider: cardProvider,
|
|
5364
|
+
client_secret: result.client_secret,
|
|
5365
|
+
public_key: result.public_key
|
|
5366
|
+
};
|
|
5036
5367
|
}
|
|
5037
5368
|
return result;
|
|
5038
5369
|
},
|
|
5039
5370
|
authorize(body) {
|
|
5040
|
-
|
|
5041
|
-
if (!
|
|
5042
|
-
const
|
|
5371
|
+
if (!body.payment_id?.trim()) throw validation("payment_id required");
|
|
5372
|
+
if (!body.authorization) throw validation("authorization required");
|
|
5373
|
+
const order = registry.orders.list(
|
|
5374
|
+
(candidate) => candidate.payment_id === body.payment_id
|
|
5375
|
+
)[0];
|
|
5376
|
+
if (!order) throw notFound(`Payment ${body.payment_id} not found`);
|
|
5377
|
+
const updated = {
|
|
5378
|
+
...order,
|
|
5379
|
+
payment_state: "paid",
|
|
5380
|
+
status: "confirmed",
|
|
5381
|
+
updated_at: clock.iso()
|
|
5382
|
+
};
|
|
5043
5383
|
registry.orders.put(order.id, updated);
|
|
5044
5384
|
bus.emit("order.payment.captured", { order_id: order.id }, order.business_id);
|
|
5045
5385
|
bus.emit("order.confirmed", { order_id: order.id }, order.business_id);
|
|
5046
|
-
return {
|
|
5386
|
+
return {
|
|
5387
|
+
order_id: order.id,
|
|
5388
|
+
order_number: order.user_friendly_id,
|
|
5389
|
+
payment_id: body.payment_id,
|
|
5390
|
+
payment_reference: order.payment_reference,
|
|
5391
|
+
payment_status: "succeeded",
|
|
5392
|
+
requires_authorization: false,
|
|
5393
|
+
next_action: { type: "none" }
|
|
5394
|
+
};
|
|
5047
5395
|
}
|
|
5048
5396
|
};
|
|
5049
5397
|
}
|
|
@@ -5426,6 +5774,7 @@ function createDeliveryService() {
|
|
|
5426
5774
|
rate_id: "dlvrt_mock_standard",
|
|
5427
5775
|
name: "Standard",
|
|
5428
5776
|
fee: standardFree ? money(0) : money(15),
|
|
5777
|
+
fee_status: "priced",
|
|
5429
5778
|
currency: "GHS",
|
|
5430
5779
|
free_delivery_applied: standardFree,
|
|
5431
5780
|
free_over_amount: money(200),
|
|
@@ -5439,6 +5788,7 @@ function createDeliveryService() {
|
|
|
5439
5788
|
name: "Express",
|
|
5440
5789
|
description: "Delivered within the hour",
|
|
5441
5790
|
fee: money(25),
|
|
5791
|
+
fee_status: "priced",
|
|
5442
5792
|
currency: "GHS",
|
|
5443
5793
|
free_delivery_applied: false,
|
|
5444
5794
|
eta_min_minutes: 30,
|