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