@voyantjs/checkout 0.3.1 → 0.4.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/README.md +10 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/routes.d.ts +36 -8
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +5 -1
- package/dist/service.d.ts +38 -3
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +85 -6
- package/dist/validation.d.ts +93 -2
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +32 -2
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -8,8 +8,14 @@ This package sits above `@voyantjs/finance` and `@voyantjs/notifications`. It do
|
|
|
8
8
|
|
|
9
9
|
- previews a booking collection plan
|
|
10
10
|
- creates bank-transfer collection documents (`proforma` by default)
|
|
11
|
+
- supports exact-amount collection overrides by falling back to invoice-backed
|
|
12
|
+
collection when the requested amount does not match an existing schedule
|
|
11
13
|
- creates card collection `payment_sessions`
|
|
12
14
|
- supports schedule-backed or invoice-backed card collection
|
|
15
|
+
- can start the provider flow in the same checkout request when a payment
|
|
16
|
+
starter is configured
|
|
17
|
+
- can return customer-safe bank-transfer instructions when a bank-transfer
|
|
18
|
+
resolver is configured
|
|
13
19
|
- optionally sends invoice or payment-session notifications
|
|
14
20
|
|
|
15
21
|
## Routes
|
|
@@ -21,6 +27,10 @@ This package sits above `@voyantjs/finance` and `@voyantjs/notifications`. It do
|
|
|
21
27
|
## Notes
|
|
22
28
|
|
|
23
29
|
- payment-provider plugins like Netopia remain optional
|
|
30
|
+
- provider startup is injected through `paymentStarters` or
|
|
31
|
+
`resolvePaymentStarters`
|
|
32
|
+
- bank-transfer instructions are injected through `bankTransferDetails` or
|
|
33
|
+
`resolveBankTransferDetails`
|
|
24
34
|
- email-provider choice remains app-owned
|
|
25
35
|
- projects can override the default collection policy when mounting checkout
|
|
26
36
|
- `createCheckoutHonoModule()` now mounts checkout through Voyant's module
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { checkoutModule, createCheckoutAdminRoutes, createCheckoutHonoModule, createCheckoutRoutes, } from "./routes.js";
|
|
2
|
-
export type { CheckoutCollectionPlan, CheckoutPolicyOptions, CheckoutReminderRunList, CheckoutReminderRunSummary, InitiatedCheckoutCollection, } from "./service.js";
|
|
2
|
+
export type { CheckoutBankTransferDetails, CheckoutCollectionPlan, CheckoutPaymentStarter, CheckoutPolicyOptions, CheckoutProviderStartResult, CheckoutReminderRunList, CheckoutReminderRunSummary, CheckoutRuntimeOptions, InitiatedCheckoutCollection, } from "./service.js";
|
|
3
3
|
export { initiateCheckoutCollection, listBookingReminderRuns, previewCheckoutCollection, resolvePaymentSessionTarget, } from "./service.js";
|
|
4
|
-
export type { CheckoutCollectionPlanRecord, CheckoutReminderRunListQuery, CheckoutReminderRunRecord, InitiateCheckoutCollectionInput, InitiatedCheckoutCollectionRecord, PreviewCheckoutCollectionInput, } from "./validation.js";
|
|
5
|
-
export { checkoutCollectionInvoiceSchema, checkoutCollectionMethodSchema, checkoutCollectionPlanSchema, checkoutCollectionScheduleSchema, checkoutCollectionStageSchema, checkoutInvoiceDocumentTypeSchema, checkoutNotificationDeliverySchema, checkoutPaymentSessionTargetSchema, checkoutReminderRunListQuerySchema, checkoutReminderRunListResponseSchema, checkoutReminderRunSchema, initiateCheckoutCollectionSchema, initiatedCheckoutCollectionSchema, previewCheckoutCollectionSchema, } from "./validation.js";
|
|
4
|
+
export type { CheckoutBankTransferInstructionsRecord, CheckoutCollectionPlanRecord, CheckoutProviderStartInput, CheckoutProviderStartResultRecord, CheckoutReminderRunListQuery, CheckoutReminderRunRecord, InitiateCheckoutCollectionInput, InitiatedCheckoutCollectionRecord, PreviewCheckoutCollectionInput, } from "./validation.js";
|
|
5
|
+
export { checkoutBankTransferInstructionsSchema, checkoutCollectionInvoiceSchema, checkoutCollectionMethodSchema, checkoutCollectionPlanSchema, checkoutCollectionScheduleSchema, checkoutCollectionStageSchema, checkoutInvoiceDocumentTypeSchema, checkoutNotificationDeliverySchema, checkoutPaymentSessionTargetSchema, checkoutProviderStartInputSchema, checkoutProviderStartResultSchema, checkoutReminderRunListQuerySchema, checkoutReminderRunListResponseSchema, checkoutReminderRunSchema, initiateCheckoutCollectionSchema, initiatedCheckoutCollectionSchema, previewCheckoutCollectionSchema, } from "./validation.js";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,aAAa,CAAA;AACpB,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,yBAAyB,EACzB,2BAA2B,GAC5B,MAAM,cAAc,CAAA;AACrB,YAAY,EACV,4BAA4B,EAC5B,4BAA4B,EAC5B,yBAAyB,EACzB,+BAA+B,EAC/B,iCAAiC,EACjC,8BAA8B,GAC/B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,+BAA+B,EAC/B,8BAA8B,EAC9B,4BAA4B,EAC5B,gCAAgC,EAChC,6BAA6B,EAC7B,iCAAiC,EACjC,kCAAkC,EAClC,kCAAkC,EAClC,kCAAkC,EAClC,qCAAqC,EACrC,yBAAyB,EACzB,gCAAgC,EAChC,iCAAiC,EACjC,+BAA+B,GAChC,MAAM,iBAAiB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,aAAa,CAAA;AACpB,YAAY,EACV,2BAA2B,EAC3B,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,2BAA2B,EAC3B,uBAAuB,EACvB,0BAA0B,EAC1B,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,yBAAyB,EACzB,2BAA2B,GAC5B,MAAM,cAAc,CAAA;AACrB,YAAY,EACV,sCAAsC,EACtC,4BAA4B,EAC5B,0BAA0B,EAC1B,iCAAiC,EACjC,4BAA4B,EAC5B,yBAAyB,EACzB,+BAA+B,EAC/B,iCAAiC,EACjC,8BAA8B,GAC/B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,sCAAsC,EACtC,+BAA+B,EAC/B,8BAA8B,EAC9B,4BAA4B,EAC5B,gCAAgC,EAChC,6BAA6B,EAC7B,iCAAiC,EACjC,kCAAkC,EAClC,kCAAkC,EAClC,gCAAgC,EAChC,iCAAiC,EACjC,kCAAkC,EAClC,qCAAqC,EACrC,yBAAyB,EACzB,gCAAgC,EAChC,iCAAiC,EACjC,+BAA+B,GAChC,MAAM,iBAAiB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { checkoutModule, createCheckoutAdminRoutes, createCheckoutHonoModule, createCheckoutRoutes, } from "./routes.js";
|
|
2
2
|
export { initiateCheckoutCollection, listBookingReminderRuns, previewCheckoutCollection, resolvePaymentSessionTarget, } from "./service.js";
|
|
3
|
-
export { checkoutCollectionInvoiceSchema, checkoutCollectionMethodSchema, checkoutCollectionPlanSchema, checkoutCollectionScheduleSchema, checkoutCollectionStageSchema, checkoutInvoiceDocumentTypeSchema, checkoutNotificationDeliverySchema, checkoutPaymentSessionTargetSchema, checkoutReminderRunListQuerySchema, checkoutReminderRunListResponseSchema, checkoutReminderRunSchema, initiateCheckoutCollectionSchema, initiatedCheckoutCollectionSchema, previewCheckoutCollectionSchema, } from "./validation.js";
|
|
3
|
+
export { checkoutBankTransferInstructionsSchema, checkoutCollectionInvoiceSchema, checkoutCollectionMethodSchema, checkoutCollectionPlanSchema, checkoutCollectionScheduleSchema, checkoutCollectionStageSchema, checkoutInvoiceDocumentTypeSchema, checkoutNotificationDeliverySchema, checkoutPaymentSessionTargetSchema, checkoutProviderStartInputSchema, checkoutProviderStartResultSchema, checkoutReminderRunListQuerySchema, checkoutReminderRunListResponseSchema, checkoutReminderRunSchema, initiateCheckoutCollectionSchema, initiatedCheckoutCollectionSchema, previewCheckoutCollectionSchema, } from "./validation.js";
|
package/dist/routes.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Module } from "@voyantjs/core";
|
|
|
2
2
|
import type { HonoModule } from "@voyantjs/hono/module";
|
|
3
3
|
import type { NotificationProvider } from "@voyantjs/notifications";
|
|
4
4
|
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
5
|
-
import { type CheckoutPolicyOptions } from "./service.js";
|
|
5
|
+
import { type CheckoutBankTransferDetails, type CheckoutPaymentStarter, type CheckoutPolicyOptions } from "./service.js";
|
|
6
6
|
type Env = {
|
|
7
7
|
Bindings: Record<string, unknown>;
|
|
8
8
|
Variables: {
|
|
@@ -14,6 +14,10 @@ export declare function createCheckoutRoutes(options?: {
|
|
|
14
14
|
policy?: CheckoutPolicyOptions;
|
|
15
15
|
providers?: ReadonlyArray<NotificationProvider>;
|
|
16
16
|
resolveProviders?: (bindings: Record<string, unknown>) => ReadonlyArray<NotificationProvider>;
|
|
17
|
+
paymentStarters?: Record<string, CheckoutPaymentStarter>;
|
|
18
|
+
resolvePaymentStarters?: (bindings: Record<string, unknown>) => Record<string, CheckoutPaymentStarter>;
|
|
19
|
+
bankTransferDetails?: CheckoutBankTransferDetails | null;
|
|
20
|
+
resolveBankTransferDetails?: (bindings: Record<string, unknown>) => CheckoutBankTransferDetails | null;
|
|
17
21
|
}): import("hono/hono-base").HonoBase<Env, {
|
|
18
22
|
"/v1/checkout/bookings/:bookingId/collection-plan": {
|
|
19
23
|
$post: {
|
|
@@ -282,25 +286,25 @@ export declare function createCheckoutRoutes(options?: {
|
|
|
282
286
|
} | null;
|
|
283
287
|
channel: "email" | "sms";
|
|
284
288
|
provider: string;
|
|
285
|
-
targetType: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "
|
|
289
|
+
targetType: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "organization" | "person" | "payment_session";
|
|
286
290
|
targetId: string | null;
|
|
287
291
|
templateId: string | null;
|
|
288
292
|
invoiceId: string | null;
|
|
289
293
|
failedAt: string | null;
|
|
290
294
|
errorMessage: string | null;
|
|
295
|
+
subject: string | null;
|
|
296
|
+
sentAt: string | null;
|
|
291
297
|
fromAddress: string | null;
|
|
292
298
|
templateSlug: string | null;
|
|
293
299
|
paymentSessionId: string | null;
|
|
294
300
|
providerMessageId: string | null;
|
|
295
301
|
toAddress: string;
|
|
296
|
-
subject: string | null;
|
|
297
302
|
htmlBody: string | null;
|
|
298
303
|
textBody: string | null;
|
|
299
304
|
payloadData: {
|
|
300
305
|
[x: string]: import("hono/utils/types").JSONValue;
|
|
301
306
|
} | null;
|
|
302
307
|
scheduledFor: string | null;
|
|
303
|
-
sentAt: string | null;
|
|
304
308
|
} | null;
|
|
305
309
|
paymentSessionNotification: {
|
|
306
310
|
id: string;
|
|
@@ -315,25 +319,49 @@ export declare function createCheckoutRoutes(options?: {
|
|
|
315
319
|
} | null;
|
|
316
320
|
channel: "email" | "sms";
|
|
317
321
|
provider: string;
|
|
318
|
-
targetType: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "
|
|
322
|
+
targetType: "other" | "booking" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "organization" | "person" | "payment_session";
|
|
319
323
|
targetId: string | null;
|
|
320
324
|
templateId: string | null;
|
|
321
325
|
invoiceId: string | null;
|
|
322
326
|
failedAt: string | null;
|
|
323
327
|
errorMessage: string | null;
|
|
328
|
+
subject: string | null;
|
|
329
|
+
sentAt: string | null;
|
|
324
330
|
fromAddress: string | null;
|
|
325
331
|
templateSlug: string | null;
|
|
326
332
|
paymentSessionId: string | null;
|
|
327
333
|
providerMessageId: string | null;
|
|
328
334
|
toAddress: string;
|
|
329
|
-
subject: string | null;
|
|
330
335
|
htmlBody: string | null;
|
|
331
336
|
textBody: string | null;
|
|
332
337
|
payloadData: {
|
|
333
338
|
[x: string]: import("hono/utils/types").JSONValue;
|
|
334
339
|
} | null;
|
|
335
340
|
scheduledFor: string | null;
|
|
336
|
-
|
|
341
|
+
} | null;
|
|
342
|
+
bankTransferInstructions: {
|
|
343
|
+
provider: string | null;
|
|
344
|
+
invoiceId: string;
|
|
345
|
+
invoiceNumber: string;
|
|
346
|
+
documentType: "invoice" | "proforma";
|
|
347
|
+
amountCents: number;
|
|
348
|
+
currency: string;
|
|
349
|
+
dueDate: string | null;
|
|
350
|
+
beneficiary: string;
|
|
351
|
+
iban: string;
|
|
352
|
+
bankName: string | null;
|
|
353
|
+
notes: string | null;
|
|
354
|
+
} | null;
|
|
355
|
+
providerStart: {
|
|
356
|
+
provider: string;
|
|
357
|
+
paymentSessionId: string;
|
|
358
|
+
redirectUrl: string | null;
|
|
359
|
+
externalReference: string | null;
|
|
360
|
+
providerSessionId: string | null;
|
|
361
|
+
providerPaymentId: string | null;
|
|
362
|
+
response: {
|
|
363
|
+
[x: string]: import("hono/utils/types").JSONValue;
|
|
364
|
+
} | null;
|
|
337
365
|
} | null;
|
|
338
366
|
};
|
|
339
367
|
};
|
|
@@ -367,7 +395,7 @@ export declare function createCheckoutAdminRoutes(): import("hono/hono-base").Ho
|
|
|
367
395
|
reminderRuleId: string;
|
|
368
396
|
reminderRuleSlug: string | null;
|
|
369
397
|
reminderRuleName: string | null;
|
|
370
|
-
targetType: "booking_payment_schedule";
|
|
398
|
+
targetType: "booking_payment_schedule" | "invoice";
|
|
371
399
|
targetId: string;
|
|
372
400
|
bookingId: string | null;
|
|
373
401
|
paymentSessionId: string | null;
|
package/dist/routes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAEnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,EACL,KAAK,qBAAqB,EAI3B,MAAM,cAAc,CAAA;AAOrB,KAAK,GAAG,GAAG;IACT,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;AAED,wBAAgB,oBAAoB,CAClC,OAAO,GAAE;IACP,MAAM,CAAC,EAAE,qBAAqB,CAAA;IAC9B,SAAS,CAAC,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAA;IAC/C,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,aAAa,CAAC,oBAAoB,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAEnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gEAyDP;AAED,wBAAgB,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8CAQxC;AAED,eAAO,MAAM,cAAc,EAAE,MAE5B,CAAA;AAED,wBAAgB,wBAAwB,CACtC,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,GACnD,UAAU,CAMZ"}
|
package/dist/routes.js
CHANGED
|
@@ -20,7 +20,11 @@ export function createCheckoutRoutes(options = {}) {
|
|
|
20
20
|
.post("/v1/checkout/bookings/:bookingId/initiate-collection", async (c) => {
|
|
21
21
|
try {
|
|
22
22
|
const dispatcher = createNotificationService(options.resolveProviders?.(c.env) ?? options.providers ?? []);
|
|
23
|
-
const result = await initiateCheckoutCollection(c.get("db"), c.req.param("bookingId"), initiateCheckoutCollectionSchema.parse(await c.req.json()), options.policy, dispatcher
|
|
23
|
+
const result = await initiateCheckoutCollection(c.get("db"), c.req.param("bookingId"), initiateCheckoutCollectionSchema.parse(await c.req.json()), options.policy, dispatcher, {
|
|
24
|
+
bindings: c.env,
|
|
25
|
+
paymentStarters: options.resolvePaymentStarters?.(c.env) ?? options.paymentStarters ?? {},
|
|
26
|
+
bankTransferDetails: options.resolveBankTransferDetails?.(c.env) ?? options.bankTransferDetails ?? null,
|
|
27
|
+
});
|
|
24
28
|
if (!result) {
|
|
25
29
|
return c.json({ error: "Booking not found" }, 404);
|
|
26
30
|
}
|
package/dist/service.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { bookingPaymentSchedules, invoices, type PaymentSession } from "@voyantjs/finance";
|
|
2
2
|
import type { NotificationDelivery, NotificationService } from "@voyantjs/notifications";
|
|
3
3
|
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
4
|
-
import type { CheckoutReminderRunListQuery, InitiateCheckoutCollectionInput, PreviewCheckoutCollectionInput } from "./validation.js";
|
|
4
|
+
import type { CheckoutBankTransferInstructionsRecord, CheckoutProviderStartInput, CheckoutReminderRunListQuery, InitiateCheckoutCollectionInput, PreviewCheckoutCollectionInput } from "./validation.js";
|
|
5
5
|
export interface CheckoutPolicyOptions {
|
|
6
6
|
defaultCardCollectionTarget?: "schedule" | "invoice";
|
|
7
7
|
defaultReminderCardCollectionTarget?: "schedule" | "invoice";
|
|
@@ -29,19 +29,54 @@ export interface CheckoutCollectionPlan {
|
|
|
29
29
|
currency: string;
|
|
30
30
|
recommendedAction: "create_bank_transfer_document" | "create_payment_session" | "create_invoice_then_payment_session" | "none";
|
|
31
31
|
}
|
|
32
|
+
export interface CheckoutBankTransferDetails {
|
|
33
|
+
provider?: string | null;
|
|
34
|
+
beneficiary: string;
|
|
35
|
+
iban: string;
|
|
36
|
+
bankName?: string | null;
|
|
37
|
+
currency?: string | null;
|
|
38
|
+
notes?: string | null;
|
|
39
|
+
}
|
|
40
|
+
export interface CheckoutProviderStartResult {
|
|
41
|
+
provider: string;
|
|
42
|
+
paymentSessionId: string;
|
|
43
|
+
redirectUrl: string | null;
|
|
44
|
+
externalReference: string | null;
|
|
45
|
+
providerSessionId: string | null;
|
|
46
|
+
providerPaymentId: string | null;
|
|
47
|
+
response: Record<string, unknown> | null;
|
|
48
|
+
}
|
|
49
|
+
export interface CheckoutPaymentStarterContext {
|
|
50
|
+
db: PostgresJsDatabase;
|
|
51
|
+
bookingId: string;
|
|
52
|
+
plan: CheckoutCollectionPlan;
|
|
53
|
+
invoice: typeof invoices.$inferSelect | null;
|
|
54
|
+
paymentSession: PaymentSession;
|
|
55
|
+
input: InitiateCheckoutCollectionInput;
|
|
56
|
+
startProvider: CheckoutProviderStartInput;
|
|
57
|
+
bindings: Record<string, unknown>;
|
|
58
|
+
}
|
|
59
|
+
export type CheckoutPaymentStarter = (context: CheckoutPaymentStarterContext) => Promise<CheckoutProviderStartResult>;
|
|
32
60
|
export interface InitiatedCheckoutCollection {
|
|
33
61
|
plan: CheckoutCollectionPlan;
|
|
34
62
|
invoice: typeof invoices.$inferSelect | null;
|
|
35
63
|
paymentSession: PaymentSession | null;
|
|
36
64
|
invoiceNotification: NotificationDelivery | null;
|
|
37
65
|
paymentSessionNotification: NotificationDelivery | null;
|
|
66
|
+
bankTransferInstructions: CheckoutBankTransferInstructionsRecord | null;
|
|
67
|
+
providerStart: CheckoutProviderStartResult | null;
|
|
68
|
+
}
|
|
69
|
+
export interface CheckoutRuntimeOptions {
|
|
70
|
+
bindings?: Record<string, unknown>;
|
|
71
|
+
bankTransferDetails?: CheckoutBankTransferDetails | null;
|
|
72
|
+
paymentStarters?: Record<string, CheckoutPaymentStarter>;
|
|
38
73
|
}
|
|
39
74
|
export interface CheckoutReminderRunSummary {
|
|
40
75
|
id: string;
|
|
41
76
|
reminderRuleId: string;
|
|
42
77
|
reminderRuleSlug: string | null;
|
|
43
78
|
reminderRuleName: string | null;
|
|
44
|
-
targetType: "booking_payment_schedule";
|
|
79
|
+
targetType: "booking_payment_schedule" | "invoice";
|
|
45
80
|
targetId: string;
|
|
46
81
|
bookingId: string | null;
|
|
47
82
|
paymentSessionId: string | null;
|
|
@@ -65,6 +100,6 @@ export interface CheckoutReminderRunList {
|
|
|
65
100
|
}
|
|
66
101
|
export declare function resolvePaymentSessionTarget(method: "card" | "bank_transfer", stage: "initial" | "reminder" | "manual", override: "schedule" | "invoice" | undefined, options: CheckoutPolicyOptions): "invoice" | "schedule";
|
|
67
102
|
export declare function previewCheckoutCollection(db: PostgresJsDatabase, bookingId: string, input: PreviewCheckoutCollectionInput, options?: CheckoutPolicyOptions): Promise<CheckoutCollectionPlan | null>;
|
|
68
|
-
export declare function initiateCheckoutCollection(db: PostgresJsDatabase, bookingId: string, input: InitiateCheckoutCollectionInput, options?: CheckoutPolicyOptions, dispatcher?: NotificationService): Promise<InitiatedCheckoutCollection | null>;
|
|
103
|
+
export declare function initiateCheckoutCollection(db: PostgresJsDatabase, bookingId: string, input: InitiateCheckoutCollectionInput, options?: CheckoutPolicyOptions, dispatcher?: NotificationService, runtime?: CheckoutRuntimeOptions): Promise<InitiatedCheckoutCollection | null>;
|
|
69
104
|
export declare function listBookingReminderRuns(db: PostgresJsDatabase, bookingId: string, query: CheckoutReminderRunListQuery): Promise<CheckoutReminderRunList>;
|
|
70
105
|
//# sourceMappingURL=service.d.ts.map
|
package/dist/service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EAIvB,QAAQ,EACR,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAQxF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,OAAO,KAAK,EACV,4BAA4B,EAC5B,+BAA+B,EAC/B,8BAA8B,EAC/B,MAAM,iBAAiB,CAAA;AAExB,MAAM,WAAW,qBAAqB;IACpC,2BAA2B,CAAC,EAAE,UAAU,GAAG,SAAS,CAAA;IACpD,mCAAmC,CAAC,EAAE,UAAU,GAAG,SAAS,CAAA;IAC5D,+BAA+B,CAAC,EAAE,UAAU,GAAG,SAAS,CAAA;IACxD,kBAAkB,CAAC,EAAE;QACnB,WAAW,EAAE,MAAM,GAAG,YAAY,GAAG,cAAc,CAAA;QACnD,YAAY,EAAE,MAAM,CAAA;QACpB,yBAAyB,EAAE,MAAM,CAAA;QACjC,oBAAoB,EAAE,OAAO,CAAA;QAC7B,eAAe,EAAE,OAAO,CAAA;QACxB,aAAa,EACT,SAAS,GACT,aAAa,GACb,SAAS,GACT,cAAc,GACd,eAAe,GACf,SAAS,GACT,eAAe,CAAA;QACnB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAA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AA0B,EAAE,CAAA;IAClC,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf;AA4BD,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,GAAG,eAAe,EAChC,KAAK,EAAE,SAAS,GAAG,UAAU,GAAG,QAAQ,EACxC,QAAQ,EAAE,UAAU,GAAG,SAAS,GAAG,SAAS,EAC5C,OAAO,EAAE,qBAAqB,0BAM/B;AAyLD,wBAAsB,yBAAyB,CAC7C,EAAE,EAAE,kBAAkB,EACtB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,8BAA8B,EACrC,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CA4ExC;AAkED,wBAAsB,0BAA0B,CAC9C,EAAE,EAAE,kBAAkB,EACtB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,+BAA+B,EACtC,OAAO,GAAE,qBAA0B,EACnC,UAAU,CAAC,EAAE,mBAAmB,EAChC,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,2BAA2B,GAAG,IAAI,CAAC,CA6I7C;AAED,wBAAsB,uBAAuB,CAC3C,EAAE,EAAE,kBAAkB,EACtB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,4BAA4B,GAClC,OAAO,CAAC,uBAAuB,CAAC,CAwElC"}
|
package/dist/service.js
CHANGED
|
@@ -56,6 +56,32 @@ function lineDescription(booking, schedule, stage) {
|
|
|
56
56
|
}
|
|
57
57
|
return `Booking ${booking.bookingNumber} ${kind}`;
|
|
58
58
|
}
|
|
59
|
+
function normalizeExactAmountCents(amountCents) {
|
|
60
|
+
return typeof amountCents === "number" && Number.isFinite(amountCents) && amountCents > 0
|
|
61
|
+
? Math.round(amountCents)
|
|
62
|
+
: null;
|
|
63
|
+
}
|
|
64
|
+
function toInvoiceDueDateTime(value) {
|
|
65
|
+
return value ? `${value}T00:00:00.000Z` : null;
|
|
66
|
+
}
|
|
67
|
+
function buildBankTransferInstructions(invoice, details) {
|
|
68
|
+
if (!details) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
provider: details.provider ?? null,
|
|
73
|
+
invoiceId: invoice.id,
|
|
74
|
+
invoiceNumber: invoice.invoiceNumber,
|
|
75
|
+
documentType: invoice.invoiceType === "proforma" ? "proforma" : "invoice",
|
|
76
|
+
amountCents: invoice.balanceDueCents,
|
|
77
|
+
currency: details.currency ?? invoice.currency,
|
|
78
|
+
dueDate: toInvoiceDueDateTime(invoice.dueDate),
|
|
79
|
+
beneficiary: details.beneficiary,
|
|
80
|
+
iban: details.iban,
|
|
81
|
+
bankName: details.bankName ?? null,
|
|
82
|
+
notes: details.notes ?? null,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
59
85
|
async function loadBookingContext(db, bookingId) {
|
|
60
86
|
const [booking] = await db.select().from(bookings).where(eq(bookings.id, bookingId)).limit(1);
|
|
61
87
|
if (!booking)
|
|
@@ -133,12 +159,30 @@ export async function previewCheckoutCollection(db, bookingId, input, options =
|
|
|
133
159
|
if (!context)
|
|
134
160
|
return null;
|
|
135
161
|
const schedules = await ensurePaymentPlanIfNeeded(db, bookingId, context.schedules, input, options);
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
162
|
+
let paymentSessionTarget = resolvePaymentSessionTarget(input.method, input.stage, input.paymentSessionTarget, options);
|
|
163
|
+
let documentType = resolveDocumentType(input.method, paymentSessionTarget, options);
|
|
164
|
+
let selectedSchedule = pickSchedule(schedules, input.scheduleId);
|
|
165
|
+
let selectedInvoice = pickInvoice(context.outstandingInvoices, input.invoiceId);
|
|
166
|
+
const requestedAmountCents = normalizeExactAmountCents(input.amountCents);
|
|
140
167
|
let amountCents = 0;
|
|
141
|
-
if (
|
|
168
|
+
if (requestedAmountCents !== null) {
|
|
169
|
+
amountCents = requestedAmountCents;
|
|
170
|
+
if (paymentSessionTarget === "schedule" &&
|
|
171
|
+
selectedSchedule &&
|
|
172
|
+
selectedSchedule.amountCents === requestedAmountCents) {
|
|
173
|
+
selectedInvoice = null;
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
paymentSessionTarget = "invoice";
|
|
177
|
+
documentType = resolveDocumentType(input.method, paymentSessionTarget, options);
|
|
178
|
+
selectedInvoice =
|
|
179
|
+
selectedInvoice && selectedInvoice.balanceDueCents === requestedAmountCents
|
|
180
|
+
? selectedInvoice
|
|
181
|
+
: null;
|
|
182
|
+
selectedSchedule = null;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
else if (paymentSessionTarget === "invoice") {
|
|
142
186
|
amountCents =
|
|
143
187
|
selectedInvoice?.balanceDueCents ??
|
|
144
188
|
selectedSchedule?.amountCents ??
|
|
@@ -223,7 +267,7 @@ async function createCollectionInvoice(db, context, plan, notes) {
|
|
|
223
267
|
});
|
|
224
268
|
return invoice;
|
|
225
269
|
}
|
|
226
|
-
export async function initiateCheckoutCollection(db, bookingId, input, options = {}, dispatcher) {
|
|
270
|
+
export async function initiateCheckoutCollection(db, bookingId, input, options = {}, dispatcher, runtime = {}) {
|
|
227
271
|
const context = await loadBookingContext(db, bookingId);
|
|
228
272
|
if (!context)
|
|
229
273
|
return null;
|
|
@@ -237,8 +281,11 @@ export async function initiateCheckoutCollection(db, bookingId, input, options =
|
|
|
237
281
|
let paymentSession = null;
|
|
238
282
|
let invoiceNotification = null;
|
|
239
283
|
let paymentSessionNotification = null;
|
|
284
|
+
let bankTransferInstructions = null;
|
|
285
|
+
let providerStart = null;
|
|
240
286
|
if (input.method === "bank_transfer") {
|
|
241
287
|
invoice = await createCollectionInvoice(db, context, plan, input.notes ?? null);
|
|
288
|
+
bankTransferInstructions = buildBankTransferInstructions(invoice, runtime.bankTransferDetails ?? null);
|
|
242
289
|
if (dispatcher && input.invoiceNotification) {
|
|
243
290
|
invoiceNotification = await notificationsService.sendInvoiceNotification(db, dispatcher, invoice.id, input.invoiceNotification);
|
|
244
291
|
}
|
|
@@ -276,12 +323,44 @@ export async function initiateCheckoutCollection(db, bookingId, input, options =
|
|
|
276
323
|
paymentSessionNotification = await notificationsService.sendPaymentSessionNotification(db, dispatcher, paymentSession.id, input.paymentSessionNotification);
|
|
277
324
|
}
|
|
278
325
|
}
|
|
326
|
+
if (input.startProvider) {
|
|
327
|
+
if (input.method !== "card") {
|
|
328
|
+
throw new Error("Provider start is only available for card collections");
|
|
329
|
+
}
|
|
330
|
+
if (!paymentSession) {
|
|
331
|
+
throw new Error("No payment session available for provider start");
|
|
332
|
+
}
|
|
333
|
+
const starter = runtime.paymentStarters?.[input.startProvider.provider];
|
|
334
|
+
if (!starter) {
|
|
335
|
+
throw new Error(`Payment provider "${input.startProvider.provider}" is not configured`);
|
|
336
|
+
}
|
|
337
|
+
providerStart = await starter({
|
|
338
|
+
db,
|
|
339
|
+
bookingId,
|
|
340
|
+
plan,
|
|
341
|
+
invoice: invoice ?? null,
|
|
342
|
+
paymentSession,
|
|
343
|
+
input,
|
|
344
|
+
startProvider: input.startProvider,
|
|
345
|
+
bindings: runtime.bindings ?? {},
|
|
346
|
+
});
|
|
347
|
+
if (providerStart.paymentSessionId !== paymentSession.id) {
|
|
348
|
+
const updatedSession = await financeService.getPaymentSessionById(db, providerStart.paymentSessionId);
|
|
349
|
+
paymentSession = updatedSession ?? paymentSession;
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
const updatedSession = await financeService.getPaymentSessionById(db, paymentSession.id);
|
|
353
|
+
paymentSession = updatedSession ?? paymentSession;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
279
356
|
return {
|
|
280
357
|
plan,
|
|
281
358
|
invoice: invoice ?? null,
|
|
282
359
|
paymentSession,
|
|
283
360
|
invoiceNotification,
|
|
284
361
|
paymentSessionNotification,
|
|
362
|
+
bankTransferInstructions,
|
|
363
|
+
providerStart,
|
|
285
364
|
};
|
|
286
365
|
}
|
|
287
366
|
export async function listBookingReminderRuns(db, bookingId, query) {
|
package/dist/validation.d.ts
CHANGED
|
@@ -16,6 +16,10 @@ export declare const checkoutInvoiceDocumentTypeSchema: z.ZodEnum<{
|
|
|
16
16
|
invoice: "invoice";
|
|
17
17
|
proforma: "proforma";
|
|
18
18
|
}>;
|
|
19
|
+
export declare const checkoutProviderStartInputSchema: z.ZodObject<{
|
|
20
|
+
provider: z.ZodString;
|
|
21
|
+
payload: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
22
|
+
}, z.core.$strip>;
|
|
19
23
|
export declare const previewCheckoutCollectionSchema: z.ZodObject<{
|
|
20
24
|
method: z.ZodEnum<{
|
|
21
25
|
bank_transfer: "bank_transfer";
|
|
@@ -28,6 +32,7 @@ export declare const previewCheckoutCollectionSchema: z.ZodObject<{
|
|
|
28
32
|
}>>;
|
|
29
33
|
scheduleId: z.ZodOptional<z.ZodString>;
|
|
30
34
|
invoiceId: z.ZodOptional<z.ZodString>;
|
|
35
|
+
amountCents: z.ZodOptional<z.ZodNumber>;
|
|
31
36
|
ensureDefaultPaymentPlan: z.ZodDefault<z.ZodBoolean>;
|
|
32
37
|
paymentSessionTarget: z.ZodOptional<z.ZodEnum<{
|
|
33
38
|
invoice: "invoice";
|
|
@@ -69,6 +74,7 @@ export declare const initiateCheckoutCollectionSchema: z.ZodObject<{
|
|
|
69
74
|
}>>;
|
|
70
75
|
scheduleId: z.ZodOptional<z.ZodString>;
|
|
71
76
|
invoiceId: z.ZodOptional<z.ZodString>;
|
|
77
|
+
amountCents: z.ZodOptional<z.ZodNumber>;
|
|
72
78
|
ensureDefaultPaymentPlan: z.ZodDefault<z.ZodBoolean>;
|
|
73
79
|
paymentSessionTarget: z.ZodOptional<z.ZodEnum<{
|
|
74
80
|
invoice: "invoice";
|
|
@@ -165,6 +171,17 @@ export declare const initiateCheckoutCollectionSchema: z.ZodObject<{
|
|
|
165
171
|
subject: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
166
172
|
html: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
167
173
|
text: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
174
|
+
attachments: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
175
|
+
filename: z.ZodString;
|
|
176
|
+
contentBase64: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
177
|
+
path: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
178
|
+
contentType: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
179
|
+
disposition: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
|
|
180
|
+
attachment: "attachment";
|
|
181
|
+
inline: "inline";
|
|
182
|
+
}>>>;
|
|
183
|
+
contentId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
184
|
+
}, z.core.$strip>>>>;
|
|
168
185
|
data: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
169
186
|
metadata: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
170
187
|
scheduledFor: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
@@ -182,10 +199,25 @@ export declare const initiateCheckoutCollectionSchema: z.ZodObject<{
|
|
|
182
199
|
subject: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
183
200
|
html: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
184
201
|
text: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
202
|
+
attachments: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
203
|
+
filename: z.ZodString;
|
|
204
|
+
contentBase64: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
205
|
+
path: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
206
|
+
contentType: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
207
|
+
disposition: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
|
|
208
|
+
attachment: "attachment";
|
|
209
|
+
inline: "inline";
|
|
210
|
+
}>>>;
|
|
211
|
+
contentId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
212
|
+
}, z.core.$strip>>>>;
|
|
185
213
|
data: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
186
214
|
metadata: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
187
215
|
scheduledFor: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
188
216
|
}, z.core.$strip>>;
|
|
217
|
+
startProvider: z.ZodOptional<z.ZodObject<{
|
|
218
|
+
provider: z.ZodString;
|
|
219
|
+
payload: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
220
|
+
}, z.core.$strip>>;
|
|
189
221
|
notes: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
190
222
|
}, z.core.$strip>;
|
|
191
223
|
export declare const checkoutCollectionScheduleSchema: z.ZodObject<{
|
|
@@ -237,6 +269,31 @@ export declare const checkoutNotificationDeliverySchema: z.ZodObject<{
|
|
|
237
269
|
failedAt: z.ZodNullable<z.ZodString>;
|
|
238
270
|
errorMessage: z.ZodNullable<z.ZodString>;
|
|
239
271
|
}, z.core.$strip>;
|
|
272
|
+
export declare const checkoutBankTransferInstructionsSchema: z.ZodObject<{
|
|
273
|
+
provider: z.ZodNullable<z.ZodString>;
|
|
274
|
+
invoiceId: z.ZodString;
|
|
275
|
+
invoiceNumber: z.ZodString;
|
|
276
|
+
documentType: z.ZodEnum<{
|
|
277
|
+
invoice: "invoice";
|
|
278
|
+
proforma: "proforma";
|
|
279
|
+
}>;
|
|
280
|
+
amountCents: z.ZodNumber;
|
|
281
|
+
currency: z.ZodString;
|
|
282
|
+
dueDate: z.ZodNullable<z.ZodString>;
|
|
283
|
+
beneficiary: z.ZodString;
|
|
284
|
+
iban: z.ZodString;
|
|
285
|
+
bankName: z.ZodNullable<z.ZodString>;
|
|
286
|
+
notes: z.ZodNullable<z.ZodString>;
|
|
287
|
+
}, z.core.$strip>;
|
|
288
|
+
export declare const checkoutProviderStartResultSchema: z.ZodObject<{
|
|
289
|
+
provider: z.ZodString;
|
|
290
|
+
paymentSessionId: z.ZodString;
|
|
291
|
+
redirectUrl: z.ZodNullable<z.ZodString>;
|
|
292
|
+
externalReference: z.ZodNullable<z.ZodString>;
|
|
293
|
+
providerSessionId: z.ZodNullable<z.ZodString>;
|
|
294
|
+
providerPaymentId: z.ZodNullable<z.ZodString>;
|
|
295
|
+
response: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
296
|
+
}, z.core.$strip>;
|
|
240
297
|
export declare const checkoutCollectionPlanSchema: z.ZodObject<{
|
|
241
298
|
bookingId: z.ZodString;
|
|
242
299
|
method: z.ZodEnum<{
|
|
@@ -465,6 +522,31 @@ export declare const initiatedCheckoutCollectionSchema: z.ZodObject<{
|
|
|
465
522
|
failedAt: z.ZodNullable<z.ZodString>;
|
|
466
523
|
errorMessage: z.ZodNullable<z.ZodString>;
|
|
467
524
|
}, z.core.$strip>>;
|
|
525
|
+
bankTransferInstructions: z.ZodNullable<z.ZodObject<{
|
|
526
|
+
provider: z.ZodNullable<z.ZodString>;
|
|
527
|
+
invoiceId: z.ZodString;
|
|
528
|
+
invoiceNumber: z.ZodString;
|
|
529
|
+
documentType: z.ZodEnum<{
|
|
530
|
+
invoice: "invoice";
|
|
531
|
+
proforma: "proforma";
|
|
532
|
+
}>;
|
|
533
|
+
amountCents: z.ZodNumber;
|
|
534
|
+
currency: z.ZodString;
|
|
535
|
+
dueDate: z.ZodNullable<z.ZodString>;
|
|
536
|
+
beneficiary: z.ZodString;
|
|
537
|
+
iban: z.ZodString;
|
|
538
|
+
bankName: z.ZodNullable<z.ZodString>;
|
|
539
|
+
notes: z.ZodNullable<z.ZodString>;
|
|
540
|
+
}, z.core.$strip>>;
|
|
541
|
+
providerStart: z.ZodNullable<z.ZodObject<{
|
|
542
|
+
provider: z.ZodString;
|
|
543
|
+
paymentSessionId: z.ZodString;
|
|
544
|
+
redirectUrl: z.ZodNullable<z.ZodString>;
|
|
545
|
+
externalReference: z.ZodNullable<z.ZodString>;
|
|
546
|
+
providerSessionId: z.ZodNullable<z.ZodString>;
|
|
547
|
+
providerPaymentId: z.ZodNullable<z.ZodString>;
|
|
548
|
+
response: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
549
|
+
}, z.core.$strip>>;
|
|
468
550
|
}, z.core.$strip>;
|
|
469
551
|
export declare const checkoutReminderRunListQuerySchema: z.ZodObject<{
|
|
470
552
|
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
@@ -481,7 +563,10 @@ export declare const checkoutReminderRunSchema: z.ZodObject<{
|
|
|
481
563
|
reminderRuleId: z.ZodString;
|
|
482
564
|
reminderRuleSlug: z.ZodNullable<z.ZodString>;
|
|
483
565
|
reminderRuleName: z.ZodNullable<z.ZodString>;
|
|
484
|
-
targetType: z.
|
|
566
|
+
targetType: z.ZodEnum<{
|
|
567
|
+
invoice: "invoice";
|
|
568
|
+
booking_payment_schedule: "booking_payment_schedule";
|
|
569
|
+
}>;
|
|
485
570
|
targetId: z.ZodString;
|
|
486
571
|
bookingId: z.ZodNullable<z.ZodString>;
|
|
487
572
|
paymentSessionId: z.ZodNullable<z.ZodString>;
|
|
@@ -516,7 +601,10 @@ export declare const checkoutReminderRunListResponseSchema: z.ZodObject<{
|
|
|
516
601
|
reminderRuleId: z.ZodString;
|
|
517
602
|
reminderRuleSlug: z.ZodNullable<z.ZodString>;
|
|
518
603
|
reminderRuleName: z.ZodNullable<z.ZodString>;
|
|
519
|
-
targetType: z.
|
|
604
|
+
targetType: z.ZodEnum<{
|
|
605
|
+
invoice: "invoice";
|
|
606
|
+
booking_payment_schedule: "booking_payment_schedule";
|
|
607
|
+
}>;
|
|
520
608
|
targetId: z.ZodString;
|
|
521
609
|
bookingId: z.ZodNullable<z.ZodString>;
|
|
522
610
|
paymentSessionId: z.ZodNullable<z.ZodString>;
|
|
@@ -553,6 +641,9 @@ export type PreviewCheckoutCollectionInput = z.infer<typeof previewCheckoutColle
|
|
|
553
641
|
export type InitiateCheckoutCollectionInput = z.infer<typeof initiateCheckoutCollectionSchema>;
|
|
554
642
|
export type CheckoutCollectionPlanRecord = z.infer<typeof checkoutCollectionPlanSchema>;
|
|
555
643
|
export type InitiatedCheckoutCollectionRecord = z.infer<typeof initiatedCheckoutCollectionSchema>;
|
|
644
|
+
export type CheckoutProviderStartInput = z.infer<typeof checkoutProviderStartInputSchema>;
|
|
645
|
+
export type CheckoutBankTransferInstructionsRecord = z.infer<typeof checkoutBankTransferInstructionsSchema>;
|
|
646
|
+
export type CheckoutProviderStartResultRecord = z.infer<typeof checkoutProviderStartResultSchema>;
|
|
556
647
|
export type CheckoutReminderRunListQuery = z.infer<typeof checkoutReminderRunListQuerySchema>;
|
|
557
648
|
export type CheckoutReminderRunRecord = z.infer<typeof checkoutReminderRunSchema>;
|
|
558
649
|
//# sourceMappingURL=validation.d.ts.map
|
package/dist/validation.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,8BAA8B;;;EAAoC,CAAA;AAC/E,eAAO,MAAM,6BAA6B;;;;EAA4C,CAAA;AACtF,eAAO,MAAM,kCAAkC;;;EAAkC,CAAA;AACjF,eAAO,MAAM,iCAAiC;;;EAAkC,CAAA;AAChF,eAAO,MAAM,gCAAgC;;;iBAG3C,CAAA;AAQF,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAS1C,C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AA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAA;AAC9F,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAA;AACvF,MAAM,MAAM,iCAAiC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAA;AACjG,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAA;AACzF,MAAM,MAAM,sCAAsC,GAAG,CAAC,CAAC,KAAK,CAC1D,OAAO,sCAAsC,CAC9C,CAAA;AACD,MAAM,MAAM,iCAAiC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAA;AACjG,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAA;AAC7F,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA"}
|
package/dist/validation.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { applyDefaultBookingPaymentPlanSchema, createPaymentSessionFromInvoiceSchema, createPaymentSessionFromScheduleSchema, publicPaymentSessionSchema, } from "@voyantjs/finance";
|
|
2
|
-
import { notificationChannelSchema, notificationDeliveryStatusSchema, notificationReminderRunStatusSchema, sendInvoiceNotificationSchema, sendPaymentSessionNotificationSchema, } from "@voyantjs/notifications";
|
|
2
|
+
import { notificationChannelSchema, notificationDeliveryStatusSchema, notificationReminderRunStatusSchema, notificationReminderTargetTypeSchema, sendInvoiceNotificationSchema, sendPaymentSessionNotificationSchema, } from "@voyantjs/notifications";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
export const checkoutCollectionMethodSchema = z.enum(["card", "bank_transfer"]);
|
|
5
5
|
export const checkoutCollectionStageSchema = z.enum(["initial", "reminder", "manual"]);
|
|
6
6
|
export const checkoutPaymentSessionTargetSchema = z.enum(["schedule", "invoice"]);
|
|
7
7
|
export const checkoutInvoiceDocumentTypeSchema = z.enum(["proforma", "invoice"]);
|
|
8
|
+
export const checkoutProviderStartInputSchema = z.object({
|
|
9
|
+
provider: z.string().min(1).max(255),
|
|
10
|
+
payload: z.record(z.string(), z.unknown()).optional().nullable(),
|
|
11
|
+
});
|
|
8
12
|
const planOverrideSchema = applyDefaultBookingPaymentPlanSchema.partial();
|
|
9
13
|
const paginationSchema = z.object({
|
|
10
14
|
limit: z.coerce.number().int().min(1).max(100).default(20),
|
|
@@ -15,6 +19,7 @@ export const previewCheckoutCollectionSchema = z.object({
|
|
|
15
19
|
stage: checkoutCollectionStageSchema.default("initial"),
|
|
16
20
|
scheduleId: z.string().optional(),
|
|
17
21
|
invoiceId: z.string().optional(),
|
|
22
|
+
amountCents: z.number().int().min(1).optional(),
|
|
18
23
|
ensureDefaultPaymentPlan: z.boolean().default(true),
|
|
19
24
|
paymentSessionTarget: checkoutPaymentSessionTargetSchema.optional(),
|
|
20
25
|
paymentPlan: planOverrideSchema.optional(),
|
|
@@ -25,6 +30,7 @@ export const initiateCheckoutCollectionSchema = previewCheckoutCollectionSchema.
|
|
|
25
30
|
.optional(),
|
|
26
31
|
paymentSessionNotification: sendPaymentSessionNotificationSchema.optional(),
|
|
27
32
|
invoiceNotification: sendInvoiceNotificationSchema.optional(),
|
|
33
|
+
startProvider: checkoutProviderStartInputSchema.optional(),
|
|
28
34
|
notes: z.string().optional().nullable(),
|
|
29
35
|
});
|
|
30
36
|
export const checkoutCollectionScheduleSchema = z.object({
|
|
@@ -68,6 +74,28 @@ export const checkoutNotificationDeliverySchema = z.object({
|
|
|
68
74
|
failedAt: z.string().nullable(),
|
|
69
75
|
errorMessage: z.string().nullable(),
|
|
70
76
|
});
|
|
77
|
+
export const checkoutBankTransferInstructionsSchema = z.object({
|
|
78
|
+
provider: z.string().nullable(),
|
|
79
|
+
invoiceId: z.string(),
|
|
80
|
+
invoiceNumber: z.string(),
|
|
81
|
+
documentType: checkoutInvoiceDocumentTypeSchema,
|
|
82
|
+
amountCents: z.number().int(),
|
|
83
|
+
currency: z.string(),
|
|
84
|
+
dueDate: z.string().nullable(),
|
|
85
|
+
beneficiary: z.string(),
|
|
86
|
+
iban: z.string(),
|
|
87
|
+
bankName: z.string().nullable(),
|
|
88
|
+
notes: z.string().nullable(),
|
|
89
|
+
});
|
|
90
|
+
export const checkoutProviderStartResultSchema = z.object({
|
|
91
|
+
provider: z.string(),
|
|
92
|
+
paymentSessionId: z.string(),
|
|
93
|
+
redirectUrl: z.string().nullable(),
|
|
94
|
+
externalReference: z.string().nullable(),
|
|
95
|
+
providerSessionId: z.string().nullable(),
|
|
96
|
+
providerPaymentId: z.string().nullable(),
|
|
97
|
+
response: z.record(z.string(), z.unknown()).nullable(),
|
|
98
|
+
});
|
|
71
99
|
export const checkoutCollectionPlanSchema = z.object({
|
|
72
100
|
bookingId: z.string(),
|
|
73
101
|
method: checkoutCollectionMethodSchema,
|
|
@@ -92,6 +120,8 @@ export const initiatedCheckoutCollectionSchema = z.object({
|
|
|
92
120
|
paymentSession: publicPaymentSessionSchema.nullable(),
|
|
93
121
|
invoiceNotification: checkoutNotificationDeliverySchema.nullable(),
|
|
94
122
|
paymentSessionNotification: checkoutNotificationDeliverySchema.nullable(),
|
|
123
|
+
bankTransferInstructions: checkoutBankTransferInstructionsSchema.nullable(),
|
|
124
|
+
providerStart: checkoutProviderStartResultSchema.nullable(),
|
|
95
125
|
});
|
|
96
126
|
export const checkoutReminderRunListQuerySchema = paginationSchema.extend({
|
|
97
127
|
status: notificationReminderRunStatusSchema.optional(),
|
|
@@ -101,7 +131,7 @@ export const checkoutReminderRunSchema = z.object({
|
|
|
101
131
|
reminderRuleId: z.string(),
|
|
102
132
|
reminderRuleSlug: z.string().nullable(),
|
|
103
133
|
reminderRuleName: z.string().nullable(),
|
|
104
|
-
targetType:
|
|
134
|
+
targetType: notificationReminderTargetTypeSchema,
|
|
105
135
|
targetId: z.string(),
|
|
106
136
|
bookingId: z.string().nullable(),
|
|
107
137
|
paymentSessionId: z.string().nullable(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voyantjs/checkout",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"license": "FSL-1.1-Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"drizzle-orm": "^0.45.2",
|
|
26
26
|
"hono": "^4.12.10",
|
|
27
27
|
"zod": "^4.3.6",
|
|
28
|
-
"@voyantjs/bookings": "0.
|
|
29
|
-
"@voyantjs/core": "0.
|
|
30
|
-
"@voyantjs/finance": "0.
|
|
31
|
-
"@voyantjs/hono": "0.
|
|
32
|
-
"@voyantjs/notifications": "0.
|
|
28
|
+
"@voyantjs/bookings": "0.4.0",
|
|
29
|
+
"@voyantjs/core": "0.4.0",
|
|
30
|
+
"@voyantjs/finance": "0.4.0",
|
|
31
|
+
"@voyantjs/hono": "0.4.0",
|
|
32
|
+
"@voyantjs/notifications": "0.4.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"typescript": "^6.0.2",
|