@voyant-travel/finance 0.138.3 → 0.138.4
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.
|
@@ -37,6 +37,7 @@ export type CheckoutRouteRuntime = {
|
|
|
37
37
|
listBookingReminderRuns?: CheckoutRoutesOptions["listBookingReminderRuns"];
|
|
38
38
|
};
|
|
39
39
|
export declare const CHECKOUT_ROUTE_RUNTIME_CONTAINER_KEY = "providers.finance.checkout.runtime";
|
|
40
|
+
export declare const CHECKOUT_ROUTE_RUNTIME_NOT_CONFIGURED_MESSAGE = "Checkout payment links require a configured checkout provider. Configure a Finance checkout runtime with a card payment starter before generating payment links.";
|
|
40
41
|
export declare function createCheckoutRoutes(options?: CheckoutRoutesOptions): import("hono/hono-base").HonoBase<Env, {
|
|
41
42
|
"/bookings/:bookingId/collection-plan": {
|
|
42
43
|
$post: {
|
|
@@ -353,6 +354,17 @@ export declare function createCheckoutRoutes(options?: CheckoutRoutesOptions): i
|
|
|
353
354
|
};
|
|
354
355
|
outputFormat: "json";
|
|
355
356
|
status: 201;
|
|
357
|
+
} | {
|
|
358
|
+
input: {
|
|
359
|
+
param: {
|
|
360
|
+
bookingId: string;
|
|
361
|
+
};
|
|
362
|
+
};
|
|
363
|
+
output: {
|
|
364
|
+
error: string;
|
|
365
|
+
};
|
|
366
|
+
outputFormat: "json";
|
|
367
|
+
status: 501;
|
|
356
368
|
} | {
|
|
357
369
|
input: {
|
|
358
370
|
param: {
|
|
@@ -581,6 +593,13 @@ export declare function createCheckoutRoutes(options?: CheckoutRoutesOptions): i
|
|
|
581
593
|
};
|
|
582
594
|
outputFormat: "json";
|
|
583
595
|
status: 201;
|
|
596
|
+
} | {
|
|
597
|
+
input: {};
|
|
598
|
+
output: {
|
|
599
|
+
error: string;
|
|
600
|
+
};
|
|
601
|
+
outputFormat: "json";
|
|
602
|
+
status: 501;
|
|
584
603
|
} | {
|
|
585
604
|
input: {};
|
|
586
605
|
output: {
|
|
@@ -907,6 +926,17 @@ export declare function createCheckoutAdminRoutes(options?: CheckoutRoutesOption
|
|
|
907
926
|
};
|
|
908
927
|
outputFormat: "json";
|
|
909
928
|
status: 201;
|
|
929
|
+
} | {
|
|
930
|
+
input: {
|
|
931
|
+
param: {
|
|
932
|
+
bookingId: string;
|
|
933
|
+
};
|
|
934
|
+
};
|
|
935
|
+
output: {
|
|
936
|
+
error: string;
|
|
937
|
+
};
|
|
938
|
+
outputFormat: "json";
|
|
939
|
+
status: 501;
|
|
910
940
|
} | {
|
|
911
941
|
input: {
|
|
912
942
|
param: {
|
|
@@ -1135,6 +1165,13 @@ export declare function createCheckoutAdminRoutes(options?: CheckoutRoutesOption
|
|
|
1135
1165
|
};
|
|
1136
1166
|
outputFormat: "json";
|
|
1137
1167
|
status: 201;
|
|
1168
|
+
} | {
|
|
1169
|
+
input: {};
|
|
1170
|
+
output: {
|
|
1171
|
+
error: string;
|
|
1172
|
+
};
|
|
1173
|
+
outputFormat: "json";
|
|
1174
|
+
status: 501;
|
|
1138
1175
|
} | {
|
|
1139
1176
|
input: {};
|
|
1140
1177
|
output: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkout-routes.d.ts","sourceRoot":"","sources":["../src/checkout-routes.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAQ1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,EAEL,KAAK,2BAA2B,EAChC,KAAK,8BAA8B,EACnC,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAG3B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAEL,KAAK,4BAA4B,EACjC,KAAK,yBAAyB,EAI/B,MAAM,0BAA0B,CAAA;AAEjC,KAAK,GAAG,GAAG;IACT,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,SAAS,EAAE;QACT,SAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAc5E;AAuBD,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,OAAO,GAAE,qBAA0B,GAClC,oBAAoB,CAYtB;AAED,eAAO,MAAM,2BAA2B,6BAAuB,CAAA;AAC/D,eAAO,MAAM,gCAAgC,kCAA4B,CAAA;AACzE,eAAO,MAAM,gCAAgC,kCAA4B,CAAA;AACzE,eAAO,MAAM,4CAA4C,uCAAuC,CAAA"}
|
package/dist/checkout-routes.js
CHANGED
|
@@ -4,6 +4,12 @@ import { Hono } from "hono";
|
|
|
4
4
|
import { bootstrapCheckoutCollection, initiateCheckoutCollection, previewCheckoutCollection, } from "./checkout-service.js";
|
|
5
5
|
import { bootstrapCheckoutCollectionSchema, checkoutReminderRunListQuerySchema, initiateCheckoutCollectionSchema, previewCheckoutCollectionSchema, } from "./checkout-validation.js";
|
|
6
6
|
export const CHECKOUT_ROUTE_RUNTIME_CONTAINER_KEY = "providers.finance.checkout.runtime";
|
|
7
|
+
export const CHECKOUT_ROUTE_RUNTIME_NOT_CONFIGURED_MESSAGE = "Checkout payment links require a configured checkout provider. Configure a Finance checkout runtime with a card payment starter before generating payment links.";
|
|
8
|
+
class CheckoutRouteRuntimeNotConfiguredError extends Error {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(CHECKOUT_ROUTE_RUNTIME_NOT_CONFIGURED_MESSAGE);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
7
13
|
function runtimeEnv(c) {
|
|
8
14
|
return c.env;
|
|
9
15
|
}
|
|
@@ -26,9 +32,8 @@ function attachCollectionRoutes(app, options) {
|
|
|
26
32
|
// Pin the middleware to this module's Env so Hono doesn't intersect the
|
|
27
33
|
// middleware's default VoyantBindings into the handlers' `c.env` type.
|
|
28
34
|
const collectionIdempotency = () => idempotencyKey();
|
|
29
|
-
function getRuntime(bindings,
|
|
30
|
-
return (
|
|
31
|
-
buildCheckoutRouteRuntime(bindings, options));
|
|
35
|
+
function getRuntime(bindings, container) {
|
|
36
|
+
return resolveCheckoutRouteRuntime(bindings, options, container);
|
|
32
37
|
}
|
|
33
38
|
return (app
|
|
34
39
|
// Mostly a read, but `ensureDefaultPaymentPlan` can materialize a
|
|
@@ -49,8 +54,10 @@ function attachCollectionRoutes(app, options) {
|
|
|
49
54
|
})
|
|
50
55
|
.post("/bookings/:bookingId/initiate-collection", collectionIdempotency(), async (c) => {
|
|
51
56
|
try {
|
|
52
|
-
const
|
|
53
|
-
const
|
|
57
|
+
const input = await parseJsonBody(c, initiateCheckoutCollectionSchema);
|
|
58
|
+
const runtime = getRuntime(c.env, c.var.container);
|
|
59
|
+
assertCheckoutRuntimeSupportsCollection(runtime, input);
|
|
60
|
+
const result = await initiateCheckoutCollection(c.get("db"), c.req.param("bookingId"), input, options.policy, runtime);
|
|
54
61
|
if (!result) {
|
|
55
62
|
return c.json({ error: "Booking not found" }, 404);
|
|
56
63
|
}
|
|
@@ -61,13 +68,18 @@ function attachCollectionRoutes(app, options) {
|
|
|
61
68
|
if (message.includes("Booking not found")) {
|
|
62
69
|
return c.json({ error: message }, 404);
|
|
63
70
|
}
|
|
71
|
+
if (error instanceof CheckoutRouteRuntimeNotConfiguredError) {
|
|
72
|
+
return c.json({ error: message }, 501);
|
|
73
|
+
}
|
|
64
74
|
return c.json({ error: message }, 409);
|
|
65
75
|
}
|
|
66
76
|
})
|
|
67
77
|
.post("/collections/bootstrap", collectionIdempotency(), async (c) => {
|
|
68
78
|
try {
|
|
69
|
-
const
|
|
70
|
-
const
|
|
79
|
+
const input = await parseJsonBody(c, bootstrapCheckoutCollectionSchema);
|
|
80
|
+
const runtime = getRuntime(c.env, c.var.container);
|
|
81
|
+
assertCheckoutRuntimeSupportsCollection(runtime, input);
|
|
82
|
+
const result = await bootstrapCheckoutCollection(c.get("db"), input, options.policy, runtime);
|
|
71
83
|
if (!result) {
|
|
72
84
|
return c.json({ error: "Booking session not found" }, 404);
|
|
73
85
|
}
|
|
@@ -78,6 +90,9 @@ function attachCollectionRoutes(app, options) {
|
|
|
78
90
|
if (message.includes("Booking not found")) {
|
|
79
91
|
return c.json({ error: message }, 404);
|
|
80
92
|
}
|
|
93
|
+
if (error instanceof CheckoutRouteRuntimeNotConfiguredError) {
|
|
94
|
+
return c.json({ error: message }, 501);
|
|
95
|
+
}
|
|
81
96
|
return c.json({ error: message }, 409);
|
|
82
97
|
}
|
|
83
98
|
}));
|
|
@@ -91,8 +106,7 @@ export function createCheckoutRoutes(options = {}) {
|
|
|
91
106
|
export function createCheckoutAdminRoutes(options = {}) {
|
|
92
107
|
const app = new Hono().get("/bookings/:bookingId/reminder-runs", async (c) => {
|
|
93
108
|
const query = parseQuery(c, checkoutReminderRunListQuerySchema);
|
|
94
|
-
const runtime = c.var.container
|
|
95
|
-
buildCheckoutRouteRuntime(c.env, options);
|
|
109
|
+
const runtime = resolveCheckoutRouteRuntime(c.env, options, c.var.container);
|
|
96
110
|
if (!runtime.listBookingReminderRuns) {
|
|
97
111
|
return c.json({ data: [], total: 0, limit: query.limit, offset: query.offset });
|
|
98
112
|
}
|
|
@@ -100,6 +114,17 @@ export function createCheckoutAdminRoutes(options = {}) {
|
|
|
100
114
|
});
|
|
101
115
|
return attachCollectionRoutes(app, options);
|
|
102
116
|
}
|
|
117
|
+
function resolveCheckoutRouteRuntime(bindings, options, container) {
|
|
118
|
+
if (container?.has(CHECKOUT_ROUTE_RUNTIME_CONTAINER_KEY)) {
|
|
119
|
+
return container.resolve(CHECKOUT_ROUTE_RUNTIME_CONTAINER_KEY);
|
|
120
|
+
}
|
|
121
|
+
return buildCheckoutRouteRuntime(bindings, options);
|
|
122
|
+
}
|
|
123
|
+
function assertCheckoutRuntimeSupportsCollection(runtime, input) {
|
|
124
|
+
if (input.method === "card" && Object.keys(runtime.paymentStarters).length === 0) {
|
|
125
|
+
throw new CheckoutRouteRuntimeNotConfiguredError();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
103
128
|
export function buildCheckoutRouteRuntime(bindings, options = {}) {
|
|
104
129
|
return {
|
|
105
130
|
bindings,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voyant-travel/finance",
|
|
3
|
-
"version": "0.138.
|
|
3
|
+
"version": "0.138.4",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -108,9 +108,9 @@
|
|
|
108
108
|
"@voyant-travel/db": "^0.109.4",
|
|
109
109
|
"@voyant-travel/types": "^0.106.1",
|
|
110
110
|
"@voyant-travel/finance-contracts": "^0.105.8",
|
|
111
|
-
"@voyant-travel/
|
|
111
|
+
"@voyant-travel/utils": "^0.105.5",
|
|
112
112
|
"@voyant-travel/storage": "^0.106.0",
|
|
113
|
-
"@voyant-travel/
|
|
113
|
+
"@voyant-travel/hono": "^0.118.4"
|
|
114
114
|
},
|
|
115
115
|
"devDependencies": {
|
|
116
116
|
"drizzle-kit": "^0.31.10",
|