@cimplify/sdk 0.101.1 → 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.
Files changed (70) hide show
  1. package/dist/advanced.d.mts +3 -3
  2. package/dist/advanced.d.ts +3 -3
  3. package/dist/advanced.js +23 -22
  4. package/dist/advanced.mjs +4 -3
  5. package/dist/{chunk-QPRI2NII.js → chunk-2P4KXFB6.js} +6 -0
  6. package/dist/{chunk-4G5UWFC3.mjs → chunk-3V4DVXV3.mjs} +6 -1
  7. package/dist/{chunk-YHPMFTMN.mjs → chunk-C2JSNJUC.mjs} +406 -95
  8. package/dist/chunk-CNN7Z2IP.js +125 -0
  9. package/dist/{chunk-DKLHCZ5M.mjs → chunk-GERXZQSX.mjs} +487 -11
  10. package/dist/chunk-GOHSXBKW.mjs +105 -0
  11. package/dist/{chunk-7H6IL7CX.mjs → chunk-H7ACMHM3.mjs} +40 -15
  12. package/dist/{chunk-Z3K2D3TE.mjs → chunk-J6PNHDHL.mjs} +453 -483
  13. package/dist/{chunk-NIOUSKQQ.js → chunk-JG5CQNCB.js} +5 -0
  14. package/dist/{chunk-YER7DIOM.js → chunk-JSWJ4XDE.js} +471 -519
  15. package/dist/{chunk-DLW3RWRK.mjs → chunk-M4URVKHE.mjs} +46 -12
  16. package/dist/{chunk-WMEC5JWN.js → chunk-NNG6IFFX.js} +50 -13
  17. package/dist/{chunk-ICCCSVN3.js → chunk-QOWPGS7Z.js} +42 -16
  18. package/dist/{chunk-YDA46OZ6.js → chunk-R6OLQ33I.js} +560 -80
  19. package/dist/{chunk-H5SSGN7W.js → chunk-VIL6IQCG.js} +408 -97
  20. package/dist/{chunk-O3YUHLZL.mjs → chunk-VNPEYLB2.mjs} +5 -0
  21. package/dist/{client-Db554902.d.ts → client-BfpNjJ_a.d.mts} +93 -299
  22. package/dist/{client-CdTx7X_X.d.mts → client-DHBwvh7U.d.ts} +93 -299
  23. package/dist/{client-WkUcvRvO.d.mts → client-DpqRobY9.d.mts} +2 -2
  24. package/dist/{client-D40kI8z2.d.ts → client-Dqg2mc-7.d.ts} +2 -2
  25. package/dist/{index-D3UXgAYl.d.ts → index-C8uDqLwJ.d.ts} +14 -4
  26. package/dist/{index-BjWUkYgY.d.mts → index-e2y6AK70.d.mts} +14 -4
  27. package/dist/index.d.mts +92 -8
  28. package/dist/index.d.ts +92 -8
  29. package/dist/index.js +225 -188
  30. package/dist/index.mjs +7 -6
  31. package/dist/link-cuNVYc2s.d.mts +297 -0
  32. package/dist/link-cuNVYc2s.d.ts +297 -0
  33. package/dist/mock/cli.mjs +412 -94
  34. package/dist/mock/library.js +412 -94
  35. package/dist/mock/library.mjs +412 -94
  36. package/dist/mock/msw.js +412 -94
  37. package/dist/mock/msw.mjs +412 -94
  38. package/dist/{product-DwKdC_to.d.mts → payment-H5LoIvXU.d.mts} +207 -7
  39. package/dist/{product-DwKdC_to.d.ts → payment-H5LoIvXU.d.ts} +207 -7
  40. package/dist/{price-CiQUd_XX.d.mts → price-BvePgDXe.d.mts} +1 -1
  41. package/dist/{price-D9EOj8y8.d.ts → price-C2RqscMY.d.ts} +1 -1
  42. package/dist/react.d.mts +6 -4
  43. package/dist/react.d.ts +6 -4
  44. package/dist/react.js +203 -198
  45. package/dist/react.mjs +11 -6
  46. package/dist/{server-CeDb93WA.d.ts → server-C7FyLdrz.d.mts} +11 -9
  47. package/dist/{server-D-nSkrUr.d.mts → server-DoXIpSd7.d.ts} +11 -9
  48. package/dist/server.d.mts +4 -4
  49. package/dist/server.d.ts +4 -4
  50. package/dist/server.js +11 -10
  51. package/dist/server.mjs +5 -4
  52. package/dist/testing/msw.d.mts +2 -2
  53. package/dist/testing/msw.d.ts +2 -2
  54. package/dist/testing/msw.js +4 -3
  55. package/dist/testing/msw.mjs +3 -2
  56. package/dist/testing/suite.d.mts +6 -6
  57. package/dist/testing/suite.d.ts +6 -6
  58. package/dist/testing/suite.js +26 -25
  59. package/dist/testing/suite.mjs +7 -6
  60. package/dist/testing.d.mts +175 -45
  61. package/dist/testing.d.ts +175 -45
  62. package/dist/testing.js +86 -81
  63. package/dist/testing.mjs +8 -7
  64. package/dist/utils.d.mts +4 -4
  65. package/dist/utils.d.ts +4 -4
  66. package/dist/utils.js +37 -29
  67. package/dist/utils.mjs +2 -2
  68. package/package.json +7 -1
  69. package/dist/payment-CRqjGrx6.d.mts +0 -113
  70. package/dist/payment-DO1Z1Ip6.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("/business/by-handle/:handle", (c) => tryRoute(c, () => deps.business.byHandle(c.req.param("handle"))));
2260
- app.get("/business/by-domain", (c) => tryRoute(c, () => deps.business.byDomain(c.req.query("domain") ?? "")));
2261
- app.get("/business/settings", (c) => tryRoute(c, () => deps.business.settings(deps.defaultBusinessId)));
2262
- app.get("/business/locations", (c) => tryRoute(c, () => deps.business.locations(deps.defaultBusinessId)));
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("/catalogue/products/:product_id", (c) => tryRoute(c, () => deps.catalogue.getProduct(c.req.param("product_id"))));
2278
- app.get("/catalogue/products/:product_id/variants", (c) => tryRoute(c, () => deps.catalogue.getProductVariants(c.req.param("product_id"))));
2279
- app.get("/catalogue/products/:product_id/variant-axes", (c) => tryRoute(c, () => deps.catalogue.getProductVariantAxes(c.req.param("product_id"))));
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(c, () => deps.catalogue.getProductVariantById(c.req.param("product_id"), c.req.param("variant_id")))
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(c.req.param("product_id"), body.axis_selections ?? body.properties ?? {})
2320
+ () => deps.catalogue.findProductVariant(
2321
+ c.req.param("product_id"),
2322
+ body.axis_selections ?? body.properties ?? {}
2323
+ )
2289
2324
  );
2290
2325
  });
2291
- app.get("/catalogue/products/:product_id/add-ons", (c) => tryRoute(c, () => deps.catalogue.getProductAddOns(c.req.param("product_id"))));
2292
- app.get("/catalogue/categories", (c) => tryRoute(c, () => deps.catalogue.listCategories(deps.defaultBusinessId)));
2293
- app.get("/catalogue/categories/:category_id", (c) => tryRoute(c, () => deps.catalogue.getCategory(c.req.param("category_id"))));
2294
- app.get("/catalogue/categories/:category_id/products", (c) => tryRoute(c, () => deps.catalogue.getCategoryProducts(c.req.param("category_id"))));
2295
- app.get("/catalogue/categories/:category_id/attributes", (c) => tryRoute(c, () => deps.catalogue.getCategoryAttributes(c.req.param("category_id"))));
2296
- app.get("/catalogue/categories/:category_id/deals", (c) => tryRoute(c, () => deps.catalogue.getCategoryDeals(c.req.param("category_id"))));
2297
- app.get("/catalogue/collections", (c) => tryRoute(c, () => deps.catalogue.listCollections(deps.defaultBusinessId)));
2298
- app.get("/catalogue/collections/:collection_id", (c) => tryRoute(c, () => deps.catalogue.getCollection(c.req.param("collection_id"))));
2299
- app.get("/catalogue/collections/:collection_id/products", (c) => tryRoute(c, () => deps.catalogue.getCollectionProducts(c.req.param("collection_id"))));
2300
- app.get("/catalogue/collections/:collection_id/attributes", (c) => tryRoute(c, () => deps.catalogue.getCollectionAttributes(c.req.param("collection_id"))));
2301
- app.get("/catalogue/collections/:collection_id/deals", (c) => tryRoute(c, () => deps.catalogue.getCollectionDeals(c.req.param("collection_id"))));
2302
- app.get("/catalogue/bundles", (c) => tryRoute(c, () => deps.catalogue.listBundles(deps.defaultBusinessId)));
2303
- app.get("/catalogue/bundles/:bundle_id", (c) => tryRoute(c, () => deps.catalogue.getBundle(c.req.param("bundle_id"))));
2304
- app.get("/catalogue/composites", (c) => tryRoute(c, () => deps.catalogue.listComposites(deps.defaultBusinessId)));
2305
- app.get("/catalogue/composites/by-product/:product_id", (c) => tryRoute(c, () => deps.catalogue.getCompositeByProduct(c.req.param("product_id"))));
2306
- app.get("/catalogue/composites/:composite_id", (c) => tryRoute(c, () => deps.catalogue.getComposite(c.req.param("composite_id"))));
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(c, () => deps.catalogue.calculateCompositePrice(c.req.param("composite_id"), body));
2392
+ return tryRoute(
2393
+ c,
2394
+ () => deps.catalogue.calculateCompositePrice(c.req.param("composite_id"), body)
2395
+ );
2310
2396
  });
2311
- app.get("/catalogue/taxonomies", (c) => tryRoute(c, () => deps.catalogue.listTaxonomies(deps.defaultBusinessId)));
2312
- app.get("/catalogue/taxonomies/search", (c) => tryRoute(c, () => deps.catalogue.searchTaxonomies(deps.defaultBusinessId, c.req.query("q") ?? "")));
2313
- app.get("/catalogue/taxonomies/:taxonomy_id", (c) => tryRoute(c, () => deps.catalogue.getTaxonomy(c.req.param("taxonomy_id"))));
2314
- app.get("/catalogue/taxonomies/:taxonomy_id/attributes", (c) => tryRoute(c, () => deps.catalogue.getTaxonomyAttributes(c.req.param("taxonomy_id"))));
2315
- app.get("/catalogue/taxonomies/:taxonomy_id/path", (c) => tryRoute(c, () => deps.catalogue.getTaxonomyPath(c.req.param("taxonomy_id"))));
2316
- app.get("/catalogue/attributes", (c) => tryRoute(c, () => deps.catalogue.listAttributes(deps.defaultBusinessId)));
2317
- app.get("/catalogue/properties/facets", (c) => tryRoute(c, () => deps.catalogue.listPropertyFacets(deps.defaultBusinessId)));
2318
- app.get("/catalogue/tags", (c) => tryRoute(c, () => deps.catalogue.listTags(deps.defaultBusinessId)));
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("/catalogue/menu/categories/:category_id", (c) => tryRoute(c, () => deps.lite.getMenuCategory(c.req.param("category_id"))));
2321
- app.get("/catalogue/menu/items/:item_id", (c) => tryRoute(c, () => deps.catalogue.getProduct(c.req.param("item_id"))));
2322
- app.get("/catalogue/knowledge-base/articles", (c) => tryRoute(c, () => ({ articles: deps.catalogue.listKnowledgeArticles(deps.defaultBusinessId) })));
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, () => ({ results: deps.catalogue.searchKnowledgeBase(deps.defaultBusinessId, c.req.query("q") ?? ""), query: c.req.query("q") ?? "" }))
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 { schedules: p?.metadata?.["time_profiles"] ?? [] };
2474
+ return {
2475
+ schedules: p?.metadata?.["time_profiles"] ?? []
2476
+ };
2347
2477
  })
2348
2478
  );
2349
- app.get("/catalogue/deals", (c) => tryRoute(c, () => deps.catalogue.listDeals(deps.defaultBusinessId)));
2350
- app.get("/catalogue/deals/on-sale", (c) => tryRoute(c, () => deps.catalogue.listOnSale(deps.defaultBusinessId)));
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(c, () => deps.catalogue.validateDiscount(body.discount_code ?? body.code ?? "", deps.defaultBusinessId));
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("/catalogue/products/:product_id/deals", (c) => tryRoute(c, () => deps.catalogue.getProductDeals(c.req.param("product_id"))));
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("/catalogue/quotes/:quote_id", (c) => tryRoute(c, () => deps.catalogue.getQuote(c.req.param("quote_id"))));
2361
- app.post("/catalogue/quotes/:quote_id/refresh", (c) => tryRoute(c, () => deps.catalogue.refreshQuote(c.req.param("quote_id"))));
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(c, () => deps.cart.updateQuantity(c.var.session, c.req.param("cart_item_id"), body.quantity));
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("/cart/items/:cart_item_id", (c) => tryRoute(c, () => deps.cart.removeItem(c.var.session, c.req.param("cart_item_id"))));
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("/cart/coupons/current", (c) => tryRoute(c, () => deps.cart.removeCoupon(c.var.session)));
2386
- app.get("/orders", (c) => tryRoute(c, () => deps.orders.list(c.var.session, { limit: getQueryNum(c, "limit"), status: c.req.query("status") })));
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("/orders/:order_id/payment-status", (c) => tryRoute(c, () => deps.orders.getPaymentStatus(c.req.param("order_id"))));
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("/orders/:order_id/verify-payment", (c) => tryRoute(c, () => deps.orders.verifyPayment(c.req.param("order_id"))));
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("/subscriptions/:subscription_id", (c) => tryRoute(c, () => deps.subscriptions.get(c.req.param("subscription_id"))));
2400
- app.post("/subscriptions/:subscription_id/cancel", (c) => tryRoute(c, () => deps.subscriptions.cancel(c.req.param("subscription_id"))));
2401
- app.post("/subscriptions/:subscription_id/pause", (c) => tryRoute(c, () => deps.subscriptions.pause(c.req.param("subscription_id"))));
2402
- app.post("/subscriptions/:subscription_id/resume", (c) => tryRoute(c, () => deps.subscriptions.resume(c.req.param("subscription_id"))));
2403
- app.post("/subscriptions/:subscription_id/skip", (c) => tryRoute(c, () => deps.subscriptions.skipNext(c.req.param("subscription_id"))));
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("/inventory/products/:product_id/stock", (c) => tryRoute(c, () => deps.inventory.productStock(c.req.param("product_id"))));
2458
- app.get("/inventory/variants/:variant_id/stock", (c) => tryRoute(c, () => deps.inventory.variantStock(c.req.param("variant_id"))));
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(c, () => deps.inventory.productAvailability(c.req.param("product_id"), getQueryNum(c, "quantity") ?? 1))
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(c, () => deps.inventory.variantAvailability(c.req.param("variant_id"), getQueryNum(c, "quantity") ?? 1))
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(c, () => deps.places.autocomplete({ query: body.input ?? body.query ?? "", country: body.country }));
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("/scheduling/services", (c) => tryRoute(c, () => deps.scheduling.listServices(deps.defaultBusinessId)));
2499
- app.get("/scheduling/services/:service_id", (c) => tryRoute(c, () => deps.scheduling.getService(c.req.param("service_id"))));
2500
- app.get("/scheduling/slots", (c) => tryRoute(c, () => deps.scheduling.getSlots(c.req.query("service_id") ?? "", { date: c.req.query("date") })));
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(c, () => deps.scheduling.checkSlot(c.req.query("service_id") ?? "", c.req.query("start") ?? "", c.req.query("end") ?? ""))
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("/scheduling/bookings/:booking_id", (c) => tryRoute(c, () => deps.scheduling.getBooking(c.req.param("booking_id"))));
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("/lite/resources/:resource_id", (c) => tryRoute(c, () => deps.lite.getResource(c.req.param("resource_id"))));
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("/lite/menu/categories/:category_id", (c) => tryRoute(c, () => deps.lite.getMenuCategory(c.req.param("category_id"))));
2520
- app.get("/fx/rate", (c) => tryRoute(c, () => deps.fx.getRate(c.req.query("from") ?? "USD", c.req.query("to") ?? "GHS")));
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(c, () => deps.activity.recordEvents(deps.defaultBusinessId, body.analytics_session_id ?? c.var.session.id, body.events ?? []));
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("/activity/state", (c) => tryRoute(c, () => deps.activity.getState(deps.defaultBusinessId, c.var.session.id)));
2546
- app.get("/activity/recommendations", (c) => tryRoute(c, () => deps.activity.getRecommendations(deps.defaultBusinessId)));
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(c, () => deps.support.openConversation(deps.defaultBusinessId, c.var.session.customer_id))
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(c, () => deps.support.peekConversation(deps.defaultBusinessId, c.var.session.customer_id))
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(c, () => deps.support.listMessages(c.req.query("conversation_id") ?? "", { limit: getQueryNum(c, "limit") }))
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({ note: "WebSocket connection \u2014 connect via ws:// at the same path", supported: false }, 426)
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
  }
@@ -4727,6 +5014,7 @@ function toUICart(registry, cart) {
4727
5014
  tax_rate: cart.tax_rate,
4728
5015
  service_charge_rate: cart.service_charge_rate,
4729
5016
  tax_inclusive: false,
5017
+ price_display_mode: "unspecified",
4730
5018
  deposit_required: false,
4731
5019
  deposit_amount: "0.00"
4732
5020
  },
@@ -4886,6 +5174,7 @@ function createCartService(opts) {
4886
5174
  tax_jurisdiction_label: label,
4887
5175
  tax_inclusive: false,
4888
5176
  tax_rate: cart.tax_rate,
5177
+ price_display_mode: "unspecified",
4889
5178
  delivery_fee_details: null,
4890
5179
  address_info: body.address_info
4891
5180
  };
@@ -5041,9 +5330,11 @@ function createCheckoutService(opts) {
5041
5330
  if (c.items.length === 0) throw validation("Cart is empty", { code: "CART_EMPTY" });
5042
5331
  const orderId = ids.order();
5043
5332
  const orderNumber = ids.orderNumber();
5333
+ const paymentId = ids.payment();
5044
5334
  const reference = ids.payment();
5045
5335
  const requiresAuth = body.payment_method === "mobile_money";
5046
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";
5047
5338
  const order = {
5048
5339
  id: orderId,
5049
5340
  business_id: c.business_id,
@@ -5067,6 +5358,7 @@ function createCheckoutService(opts) {
5067
5358
  items: c.items,
5068
5359
  applied_discount_ids: c.applied_discount_ids,
5069
5360
  applied_discount_codes: c.applied_discount_codes,
5361
+ payment_id: paymentId,
5070
5362
  payment_reference: reference,
5071
5363
  metadata: body.metadata,
5072
5364
  created_at: clock.iso(),
@@ -5083,31 +5375,57 @@ function createCheckoutService(opts) {
5083
5375
  const result = {
5084
5376
  order_id: orderId,
5085
5377
  order_number: orderNumber,
5086
- payment_status: requiresAuth ? "pending" : "succeeded",
5378
+ payment_id: paymentId,
5379
+ payment_status: requiresAuth || isCard ? "pending" : "succeeded",
5087
5380
  payment_reference: reference,
5088
5381
  requires_authorization: requiresAuth,
5089
5382
  authorization_type: requiresAuth ? "otp" : void 0,
5090
- next_action: requiresAuth ? { type: "authorization", authorization_type: "otp", display_text: "Approve on your mobile money app" } : { type: "none" },
5091
- provider: body.payment_method,
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,
5092
5389
  bill_token: billToken
5093
5390
  };
5094
5391
  if (isCard) {
5095
- result.next_action = { type: "redirect", authorization_url: `https://mock.cimplify.io/pay/${reference}` };
5096
- result.authorization_url = `https://mock.cimplify.io/pay/${reference}`;
5097
- result.client_secret = `pi_${orderId.slice(-12)}_secret_${Math.random().toString(36).slice(2, 18)}`;
5098
5392
  const proc = globalThis.process;
5099
- result.public_key = proc?.env?.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY ?? "pk_test_mock_publishable_key";
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
+ };
5100
5401
  }
5101
5402
  return result;
5102
5403
  },
5103
5404
  authorize(body) {
5104
- const order = registry.orders.get(body.order_id);
5105
- if (!order) throw notFound(`Order ${body.order_id} not found`);
5106
- const updated = { ...order, payment_state: "paid", status: "confirmed", updated_at: clock.iso() };
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
+ };
5107
5417
  registry.orders.put(order.id, updated);
5108
5418
  bus.emit("order.payment.captured", { order_id: order.id }, order.business_id);
5109
5419
  bus.emit("order.confirmed", { order_id: order.id }, order.business_id);
5110
- return { status: "succeeded", order_id: order.id };
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
+ };
5111
5429
  }
5112
5430
  };
5113
5431
  }