@voyantjs/checkout-react 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +4 -0
- package/dist/hooks/use-checkout-payment-link-config.d.ts +19 -0
- package/dist/hooks/use-checkout-payment-link-config.d.ts.map +1 -0
- package/dist/hooks/use-checkout-payment-link-config.js +26 -0
- package/dist/hooks/use-collect-payment.d.ts +167 -0
- package/dist/hooks/use-collect-payment.d.ts.map +1 -0
- package/dist/hooks/use-collect-payment.js +77 -0
- package/dist/hooks/use-initiate-checkout-collection.d.ts +228 -0
- package/dist/hooks/use-initiate-checkout-collection.d.ts.map +1 -0
- package/dist/hooks/use-initiate-checkout-collection.js +35 -0
- package/dist/hooks/use-preview-checkout-collection.d.ts +65 -0
- package/dist/hooks/use-preview-checkout-collection.d.ts.map +1 -0
- package/dist/hooks/use-preview-checkout-collection.js +27 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/provider.d.ts +2 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +1 -0
- package/dist/types.d.ts +53 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { type CheckoutPaymentLinkConfig, useCheckoutPaymentLinkConfig, } from "./use-checkout-payment-link-config.js";
|
|
2
|
+
export { type CollectPaymentInput, useCollectPayment, type UseCollectPaymentOptions, } from "./use-collect-payment.js";
|
|
3
|
+
export { useInitiateCheckoutCollection } from "./use-initiate-checkout-collection.js";
|
|
4
|
+
export { usePreviewCheckoutCollection } from "./use-preview-checkout-collection.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,yBAAyB,EAC9B,4BAA4B,GAC7B,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EACL,KAAK,mBAAmB,EACxB,iBAAiB,EACjB,KAAK,wBAAwB,GAC9B,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAA;AACrF,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { useCheckoutPaymentLinkConfig, } from "./use-checkout-payment-link-config.js";
|
|
2
|
+
export { useCollectPayment, } from "./use-collect-payment.js";
|
|
3
|
+
export { useInitiateCheckoutCollection } from "./use-initiate-checkout-collection.js";
|
|
4
|
+
export { usePreviewCheckoutCollection } from "./use-preview-checkout-collection.js";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface CheckoutPaymentLinkConfig {
|
|
2
|
+
bankTransfer: {
|
|
3
|
+
provider?: string | null;
|
|
4
|
+
beneficiary: string;
|
|
5
|
+
iban: string;
|
|
6
|
+
bankName?: string | null;
|
|
7
|
+
currency?: string | null;
|
|
8
|
+
notes?: string | null;
|
|
9
|
+
} | null;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Fetch the template-side bank-transfer block for the public payment-link
|
|
13
|
+
* landing page. Templates expose this at
|
|
14
|
+
* `/v1/public/payment-link-config` (added to `publicPaths`); when the
|
|
15
|
+
* endpoint is unavailable or unconfigured, callers fall back to hiding
|
|
16
|
+
* the bank-transfer tab.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useCheckoutPaymentLinkConfig(): import("@tanstack/react-query").UseQueryResult<CheckoutPaymentLinkConfig, Error>;
|
|
19
|
+
//# sourceMappingURL=use-checkout-payment-link-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-checkout-payment-link-config.d.ts","sourceRoot":"","sources":["../../src/hooks/use-checkout-payment-link-config.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,yBAAyB;IACxC,YAAY,EAAE;QACZ,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;QACxB,WAAW,EAAE,MAAM,CAAA;QACnB,IAAI,EAAE,MAAM,CAAA;QACZ,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;QACxB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;QACxB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KACtB,GAAG,IAAI,CAAA;CACT;AAMD;;;;;;GAMG;AACH,wBAAgB,4BAA4B,qFAe3C"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantCheckoutContext } from "../provider.js";
|
|
4
|
+
/**
|
|
5
|
+
* Fetch the template-side bank-transfer block for the public payment-link
|
|
6
|
+
* landing page. Templates expose this at
|
|
7
|
+
* `/v1/public/payment-link-config` (added to `publicPaths`); when the
|
|
8
|
+
* endpoint is unavailable or unconfigured, callers fall back to hiding
|
|
9
|
+
* the bank-transfer tab.
|
|
10
|
+
*/
|
|
11
|
+
export function useCheckoutPaymentLinkConfig() {
|
|
12
|
+
const { baseUrl, fetcher } = useVoyantCheckoutContext();
|
|
13
|
+
return useQuery({
|
|
14
|
+
queryKey: ["checkout-payment-link-config"],
|
|
15
|
+
queryFn: async () => {
|
|
16
|
+
const response = await fetcher(`${baseUrl}/v1/public/payment-link-config`, {
|
|
17
|
+
headers: { Accept: "application/json" },
|
|
18
|
+
});
|
|
19
|
+
if (!response.ok)
|
|
20
|
+
throw new Error(`config fetch failed: ${response.status}`);
|
|
21
|
+
const body = (await response.json());
|
|
22
|
+
return body.data;
|
|
23
|
+
},
|
|
24
|
+
staleTime: 5 * 60 * 1000,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import type { PaymentChoice } from "../types.js";
|
|
2
|
+
export interface UseCollectPaymentOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Provider id registered in checkout's `paymentStarters` map. Only used
|
|
5
|
+
* when the choice is `send_link`. Defaults to `"netopia"` since that's
|
|
6
|
+
* the only processor in tree today; pass explicitly when adding others.
|
|
7
|
+
*/
|
|
8
|
+
cardProvider?: string;
|
|
9
|
+
/** Payer email — used as the recipient for the payment-link notification. */
|
|
10
|
+
payerEmail?: string | null;
|
|
11
|
+
/** Payer name — passed through to the payment session (display only). */
|
|
12
|
+
payerName?: string | null;
|
|
13
|
+
/** Optional vertical-supplied notes attached to the collection. */
|
|
14
|
+
notes?: string | null;
|
|
15
|
+
}
|
|
16
|
+
export interface CollectPaymentInput {
|
|
17
|
+
choice: PaymentChoice;
|
|
18
|
+
amountCents: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Higher-level collection hook: takes a `PaymentChoice` from `<PaymentStep>`
|
|
22
|
+
* and translates it into the appropriate `initiateCheckoutCollection` call.
|
|
23
|
+
*
|
|
24
|
+
* Routes:
|
|
25
|
+
* - `send_link` → `method: "card"` + `startProvider` + email notification
|
|
26
|
+
* - `bank_transfer` → `method: "bank_transfer"` (returns IBAN block)
|
|
27
|
+
* - any other → throws (the picker should disable the submit button
|
|
28
|
+
* for choices the parent doesn't want to wire here)
|
|
29
|
+
*
|
|
30
|
+
* The `saved_method` / `new_card` / `hold` / `extra` choices are vertical-
|
|
31
|
+
* specific and not handled by this generic mapping. Verticals that need them
|
|
32
|
+
* call `useInitiateCheckoutCollection` directly with their own request body.
|
|
33
|
+
*/
|
|
34
|
+
export declare function useCollectPayment(bookingId: string, options?: UseCollectPaymentOptions): import("@tanstack/react-query").UseMutationResult<{
|
|
35
|
+
plan: {
|
|
36
|
+
bookingId: string;
|
|
37
|
+
method: "bank_transfer" | "card";
|
|
38
|
+
stage: "manual" | "initial" | "reminder";
|
|
39
|
+
paymentSessionTarget: "invoice" | "schedule" | null;
|
|
40
|
+
documentType: "invoice" | "proforma" | null;
|
|
41
|
+
willCreateDefaultPaymentPlan: boolean;
|
|
42
|
+
selectedSchedule: {
|
|
43
|
+
id: string;
|
|
44
|
+
bookingId: string;
|
|
45
|
+
bookingItemId: string | null;
|
|
46
|
+
scheduleType: string;
|
|
47
|
+
status: string;
|
|
48
|
+
dueDate: string;
|
|
49
|
+
currency: string;
|
|
50
|
+
amountCents: number;
|
|
51
|
+
notes: string | null;
|
|
52
|
+
} | null;
|
|
53
|
+
selectedInvoice: {
|
|
54
|
+
id: string;
|
|
55
|
+
invoiceNumber: string;
|
|
56
|
+
invoiceType: string;
|
|
57
|
+
bookingId: string;
|
|
58
|
+
personId: string | null;
|
|
59
|
+
organizationId: string | null;
|
|
60
|
+
status: string;
|
|
61
|
+
currency: string;
|
|
62
|
+
totalCents: number;
|
|
63
|
+
paidCents: number;
|
|
64
|
+
balanceDueCents: number;
|
|
65
|
+
issueDate: string;
|
|
66
|
+
dueDate: string;
|
|
67
|
+
notes: string | null;
|
|
68
|
+
createdAt: string;
|
|
69
|
+
updatedAt: string;
|
|
70
|
+
} | null;
|
|
71
|
+
amountCents: number;
|
|
72
|
+
currency: string;
|
|
73
|
+
recommendedAction: "none" | "create_bank_transfer_document" | "create_payment_session" | "create_invoice_then_payment_session";
|
|
74
|
+
};
|
|
75
|
+
invoice: {
|
|
76
|
+
id: string;
|
|
77
|
+
invoiceNumber: string;
|
|
78
|
+
invoiceType: string;
|
|
79
|
+
bookingId: string;
|
|
80
|
+
personId: string | null;
|
|
81
|
+
organizationId: string | null;
|
|
82
|
+
status: string;
|
|
83
|
+
currency: string;
|
|
84
|
+
totalCents: number;
|
|
85
|
+
paidCents: number;
|
|
86
|
+
balanceDueCents: number;
|
|
87
|
+
issueDate: string;
|
|
88
|
+
dueDate: string;
|
|
89
|
+
notes: string | null;
|
|
90
|
+
createdAt: string;
|
|
91
|
+
updatedAt: string;
|
|
92
|
+
} | null;
|
|
93
|
+
paymentSession: {
|
|
94
|
+
id: string;
|
|
95
|
+
targetType: "other" | "booking" | "order" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "flight_order";
|
|
96
|
+
targetId: string | null;
|
|
97
|
+
bookingId: string | null;
|
|
98
|
+
invoiceId: string | null;
|
|
99
|
+
bookingPaymentScheduleId: string | null;
|
|
100
|
+
bookingGuaranteeId: string | null;
|
|
101
|
+
status: "pending" | "expired" | "cancelled" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
|
|
102
|
+
provider: string | null;
|
|
103
|
+
providerSessionId: string | null;
|
|
104
|
+
providerPaymentId: string | null;
|
|
105
|
+
externalReference: string | null;
|
|
106
|
+
clientReference: string | null;
|
|
107
|
+
currency: string;
|
|
108
|
+
amountCents: number;
|
|
109
|
+
paymentMethod: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill" | null;
|
|
110
|
+
payerEmail: string | null;
|
|
111
|
+
payerName: string | null;
|
|
112
|
+
redirectUrl: string | null;
|
|
113
|
+
returnUrl: string | null;
|
|
114
|
+
cancelUrl: string | null;
|
|
115
|
+
expiresAt: string | null;
|
|
116
|
+
completedAt: string | null;
|
|
117
|
+
failureCode: string | null;
|
|
118
|
+
failureMessage: string | null;
|
|
119
|
+
} | null;
|
|
120
|
+
invoiceNotification: {
|
|
121
|
+
id: string;
|
|
122
|
+
templateSlug: string | null;
|
|
123
|
+
channel: "email" | "sms";
|
|
124
|
+
provider: string;
|
|
125
|
+
status: "pending" | "cancelled" | "failed" | "sent";
|
|
126
|
+
toAddress: string;
|
|
127
|
+
subject: string | null;
|
|
128
|
+
sentAt: string | null;
|
|
129
|
+
failedAt: string | null;
|
|
130
|
+
errorMessage: string | null;
|
|
131
|
+
} | null;
|
|
132
|
+
paymentSessionNotification: {
|
|
133
|
+
id: string;
|
|
134
|
+
templateSlug: string | null;
|
|
135
|
+
channel: "email" | "sms";
|
|
136
|
+
provider: string;
|
|
137
|
+
status: "pending" | "cancelled" | "failed" | "sent";
|
|
138
|
+
toAddress: string;
|
|
139
|
+
subject: string | null;
|
|
140
|
+
sentAt: string | null;
|
|
141
|
+
failedAt: string | null;
|
|
142
|
+
errorMessage: string | null;
|
|
143
|
+
} | null;
|
|
144
|
+
bankTransferInstructions: {
|
|
145
|
+
provider: string | null;
|
|
146
|
+
invoiceId: string;
|
|
147
|
+
invoiceNumber: string;
|
|
148
|
+
documentType: "invoice" | "proforma";
|
|
149
|
+
amountCents: number;
|
|
150
|
+
currency: string;
|
|
151
|
+
dueDate: string | null;
|
|
152
|
+
beneficiary: string;
|
|
153
|
+
iban: string;
|
|
154
|
+
bankName: string | null;
|
|
155
|
+
notes: string | null;
|
|
156
|
+
} | null;
|
|
157
|
+
providerStart: {
|
|
158
|
+
provider: string;
|
|
159
|
+
paymentSessionId: string;
|
|
160
|
+
redirectUrl: string | null;
|
|
161
|
+
externalReference: string | null;
|
|
162
|
+
providerSessionId: string | null;
|
|
163
|
+
providerPaymentId: string | null;
|
|
164
|
+
response: Record<string, unknown> | null;
|
|
165
|
+
} | null;
|
|
166
|
+
}, Error, CollectPaymentInput, unknown>;
|
|
167
|
+
//# sourceMappingURL=use-collect-payment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-collect-payment.d.ts","sourceRoot":"","sources":["../../src/hooks/use-collect-payment.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,6EAA6E;IAC7E,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACtB;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,aAAa,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,wBAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wCAsC1F"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantCheckoutContext } from "../provider.js";
|
|
4
|
+
/**
|
|
5
|
+
* Higher-level collection hook: takes a `PaymentChoice` from `<PaymentStep>`
|
|
6
|
+
* and translates it into the appropriate `initiateCheckoutCollection` call.
|
|
7
|
+
*
|
|
8
|
+
* Routes:
|
|
9
|
+
* - `send_link` → `method: "card"` + `startProvider` + email notification
|
|
10
|
+
* - `bank_transfer` → `method: "bank_transfer"` (returns IBAN block)
|
|
11
|
+
* - any other → throws (the picker should disable the submit button
|
|
12
|
+
* for choices the parent doesn't want to wire here)
|
|
13
|
+
*
|
|
14
|
+
* The `saved_method` / `new_card` / `hold` / `extra` choices are vertical-
|
|
15
|
+
* specific and not handled by this generic mapping. Verticals that need them
|
|
16
|
+
* call `useInitiateCheckoutCollection` directly with their own request body.
|
|
17
|
+
*/
|
|
18
|
+
export function useCollectPayment(bookingId, options = {}) {
|
|
19
|
+
const { baseUrl, fetcher } = useVoyantCheckoutContext();
|
|
20
|
+
const qc = useQueryClient();
|
|
21
|
+
const { cardProvider = "netopia", payerEmail, payerName, notes } = options;
|
|
22
|
+
return useMutation({
|
|
23
|
+
mutationFn: async ({ choice, amountCents, }) => {
|
|
24
|
+
const body = mapChoiceToRequest(choice, amountCents, {
|
|
25
|
+
cardProvider,
|
|
26
|
+
payerEmail,
|
|
27
|
+
payerName,
|
|
28
|
+
notes,
|
|
29
|
+
});
|
|
30
|
+
const response = await fetcher(`${baseUrl}/v1/admin/checkout/bookings/${bookingId}/initiate-collection`, {
|
|
31
|
+
method: "POST",
|
|
32
|
+
headers: { "Content-Type": "application/json" },
|
|
33
|
+
body: JSON.stringify(body),
|
|
34
|
+
});
|
|
35
|
+
const json = (await response.json());
|
|
36
|
+
if (!response.ok) {
|
|
37
|
+
const message = "error" in json ? json.error : `Collection failed: ${response.status}`;
|
|
38
|
+
throw new Error(message);
|
|
39
|
+
}
|
|
40
|
+
return json.data;
|
|
41
|
+
},
|
|
42
|
+
onSuccess: () => {
|
|
43
|
+
qc.invalidateQueries({ queryKey: ["bookings", bookingId] });
|
|
44
|
+
qc.invalidateQueries({ queryKey: ["public-booking-payments", bookingId] });
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function mapChoiceToRequest(choice, amountCents, ctx) {
|
|
49
|
+
if (choice.type === "send_link") {
|
|
50
|
+
return {
|
|
51
|
+
method: "card",
|
|
52
|
+
stage: "manual",
|
|
53
|
+
amountCents,
|
|
54
|
+
ensureDefaultPaymentPlan: true,
|
|
55
|
+
paymentSession: {
|
|
56
|
+
provider: ctx.cardProvider,
|
|
57
|
+
payerEmail: ctx.payerEmail ?? undefined,
|
|
58
|
+
payerName: ctx.payerName ?? undefined,
|
|
59
|
+
},
|
|
60
|
+
startProvider: { provider: ctx.cardProvider },
|
|
61
|
+
paymentSessionNotification: ctx.payerEmail
|
|
62
|
+
? { channel: "email", to: ctx.payerEmail, templateSlug: "payment-link" }
|
|
63
|
+
: undefined,
|
|
64
|
+
notes: ctx.notes ?? undefined,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (choice.type === "bank_transfer") {
|
|
68
|
+
return {
|
|
69
|
+
method: "bank_transfer",
|
|
70
|
+
stage: "manual",
|
|
71
|
+
amountCents,
|
|
72
|
+
ensureDefaultPaymentPlan: true,
|
|
73
|
+
notes: ctx.notes ?? undefined,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
throw new Error(`useCollectPayment doesn't handle choice type "${choice.type}" — call useInitiateCheckoutCollection directly with a vertical-specific request.`);
|
|
77
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin-side: kick off a checkout collection against a booking. Mounts at
|
|
3
|
+
* `/v1/admin/checkout/bookings/:bookingId/initiate-collection` (the public
|
|
4
|
+
* mirror is gated behind `actor=customer` and only reachable from a public
|
|
5
|
+
* storefront / customer portal).
|
|
6
|
+
*
|
|
7
|
+
* Invalidates booking + public-booking-payments queries on success so the
|
|
8
|
+
* caller's payments summary re-fetches automatically.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useInitiateCheckoutCollection(bookingId: string): import("@tanstack/react-query").UseMutationResult<{
|
|
11
|
+
plan: {
|
|
12
|
+
bookingId: string;
|
|
13
|
+
method: "bank_transfer" | "card";
|
|
14
|
+
stage: "manual" | "initial" | "reminder";
|
|
15
|
+
paymentSessionTarget: "invoice" | "schedule" | null;
|
|
16
|
+
documentType: "invoice" | "proforma" | null;
|
|
17
|
+
willCreateDefaultPaymentPlan: boolean;
|
|
18
|
+
selectedSchedule: {
|
|
19
|
+
id: string;
|
|
20
|
+
bookingId: string;
|
|
21
|
+
bookingItemId: string | null;
|
|
22
|
+
scheduleType: string;
|
|
23
|
+
status: string;
|
|
24
|
+
dueDate: string;
|
|
25
|
+
currency: string;
|
|
26
|
+
amountCents: number;
|
|
27
|
+
notes: string | null;
|
|
28
|
+
} | null;
|
|
29
|
+
selectedInvoice: {
|
|
30
|
+
id: string;
|
|
31
|
+
invoiceNumber: string;
|
|
32
|
+
invoiceType: string;
|
|
33
|
+
bookingId: string;
|
|
34
|
+
personId: string | null;
|
|
35
|
+
organizationId: string | null;
|
|
36
|
+
status: string;
|
|
37
|
+
currency: string;
|
|
38
|
+
totalCents: number;
|
|
39
|
+
paidCents: number;
|
|
40
|
+
balanceDueCents: number;
|
|
41
|
+
issueDate: string;
|
|
42
|
+
dueDate: string;
|
|
43
|
+
notes: string | null;
|
|
44
|
+
createdAt: string;
|
|
45
|
+
updatedAt: string;
|
|
46
|
+
} | null;
|
|
47
|
+
amountCents: number;
|
|
48
|
+
currency: string;
|
|
49
|
+
recommendedAction: "none" | "create_bank_transfer_document" | "create_payment_session" | "create_invoice_then_payment_session";
|
|
50
|
+
};
|
|
51
|
+
invoice: {
|
|
52
|
+
id: string;
|
|
53
|
+
invoiceNumber: string;
|
|
54
|
+
invoiceType: string;
|
|
55
|
+
bookingId: string;
|
|
56
|
+
personId: string | null;
|
|
57
|
+
organizationId: string | null;
|
|
58
|
+
status: string;
|
|
59
|
+
currency: string;
|
|
60
|
+
totalCents: number;
|
|
61
|
+
paidCents: number;
|
|
62
|
+
balanceDueCents: number;
|
|
63
|
+
issueDate: string;
|
|
64
|
+
dueDate: string;
|
|
65
|
+
notes: string | null;
|
|
66
|
+
createdAt: string;
|
|
67
|
+
updatedAt: string;
|
|
68
|
+
} | null;
|
|
69
|
+
paymentSession: {
|
|
70
|
+
id: string;
|
|
71
|
+
targetType: "other" | "booking" | "order" | "invoice" | "booking_payment_schedule" | "booking_guarantee" | "flight_order";
|
|
72
|
+
targetId: string | null;
|
|
73
|
+
bookingId: string | null;
|
|
74
|
+
invoiceId: string | null;
|
|
75
|
+
bookingPaymentScheduleId: string | null;
|
|
76
|
+
bookingGuaranteeId: string | null;
|
|
77
|
+
status: "pending" | "expired" | "cancelled" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
|
|
78
|
+
provider: string | null;
|
|
79
|
+
providerSessionId: string | null;
|
|
80
|
+
providerPaymentId: string | null;
|
|
81
|
+
externalReference: string | null;
|
|
82
|
+
clientReference: string | null;
|
|
83
|
+
currency: string;
|
|
84
|
+
amountCents: number;
|
|
85
|
+
paymentMethod: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill" | null;
|
|
86
|
+
payerEmail: string | null;
|
|
87
|
+
payerName: string | null;
|
|
88
|
+
redirectUrl: string | null;
|
|
89
|
+
returnUrl: string | null;
|
|
90
|
+
cancelUrl: string | null;
|
|
91
|
+
expiresAt: string | null;
|
|
92
|
+
completedAt: string | null;
|
|
93
|
+
failureCode: string | null;
|
|
94
|
+
failureMessage: string | null;
|
|
95
|
+
} | null;
|
|
96
|
+
invoiceNotification: {
|
|
97
|
+
id: string;
|
|
98
|
+
templateSlug: string | null;
|
|
99
|
+
channel: "email" | "sms";
|
|
100
|
+
provider: string;
|
|
101
|
+
status: "pending" | "cancelled" | "failed" | "sent";
|
|
102
|
+
toAddress: string;
|
|
103
|
+
subject: string | null;
|
|
104
|
+
sentAt: string | null;
|
|
105
|
+
failedAt: string | null;
|
|
106
|
+
errorMessage: string | null;
|
|
107
|
+
} | null;
|
|
108
|
+
paymentSessionNotification: {
|
|
109
|
+
id: string;
|
|
110
|
+
templateSlug: string | null;
|
|
111
|
+
channel: "email" | "sms";
|
|
112
|
+
provider: string;
|
|
113
|
+
status: "pending" | "cancelled" | "failed" | "sent";
|
|
114
|
+
toAddress: string;
|
|
115
|
+
subject: string | null;
|
|
116
|
+
sentAt: string | null;
|
|
117
|
+
failedAt: string | null;
|
|
118
|
+
errorMessage: string | null;
|
|
119
|
+
} | null;
|
|
120
|
+
bankTransferInstructions: {
|
|
121
|
+
provider: string | null;
|
|
122
|
+
invoiceId: string;
|
|
123
|
+
invoiceNumber: string;
|
|
124
|
+
documentType: "invoice" | "proforma";
|
|
125
|
+
amountCents: number;
|
|
126
|
+
currency: string;
|
|
127
|
+
dueDate: string | null;
|
|
128
|
+
beneficiary: string;
|
|
129
|
+
iban: string;
|
|
130
|
+
bankName: string | null;
|
|
131
|
+
notes: string | null;
|
|
132
|
+
} | null;
|
|
133
|
+
providerStart: {
|
|
134
|
+
provider: string;
|
|
135
|
+
paymentSessionId: string;
|
|
136
|
+
redirectUrl: string | null;
|
|
137
|
+
externalReference: string | null;
|
|
138
|
+
providerSessionId: string | null;
|
|
139
|
+
providerPaymentId: string | null;
|
|
140
|
+
response: Record<string, unknown> | null;
|
|
141
|
+
} | null;
|
|
142
|
+
}, Error, {
|
|
143
|
+
method: "bank_transfer" | "card";
|
|
144
|
+
stage: "manual" | "initial" | "reminder";
|
|
145
|
+
ensureDefaultPaymentPlan: boolean;
|
|
146
|
+
scheduleId?: string | undefined;
|
|
147
|
+
invoiceId?: string | undefined;
|
|
148
|
+
amountCents?: number | undefined;
|
|
149
|
+
paymentSessionTarget?: "invoice" | "schedule" | undefined;
|
|
150
|
+
paymentPlan?: {
|
|
151
|
+
depositMode?: "percentage" | "none" | "fixed_amount" | undefined;
|
|
152
|
+
depositValue?: number | undefined;
|
|
153
|
+
depositDueDate?: string | null | undefined;
|
|
154
|
+
balanceDueDaysBeforeStart?: number | undefined;
|
|
155
|
+
clearExistingPending?: boolean | undefined;
|
|
156
|
+
createGuarantee?: boolean | undefined;
|
|
157
|
+
guaranteeType?: "other" | "voucher" | "bank_transfer" | "credit_card" | "deposit" | "preauth" | "card_on_file" | "agency_letter" | undefined;
|
|
158
|
+
notes?: string | null | undefined;
|
|
159
|
+
} | undefined;
|
|
160
|
+
paymentSession?: {
|
|
161
|
+
provider?: string | null | undefined;
|
|
162
|
+
paymentMethod?: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill" | null | undefined;
|
|
163
|
+
payerPersonId?: string | null | undefined;
|
|
164
|
+
payerOrganizationId?: string | null | undefined;
|
|
165
|
+
payerEmail?: string | null | undefined;
|
|
166
|
+
payerName?: string | null | undefined;
|
|
167
|
+
externalReference?: string | null | undefined;
|
|
168
|
+
idempotencyKey?: string | null | undefined;
|
|
169
|
+
clientReference?: string | null | undefined;
|
|
170
|
+
returnUrl?: string | null | undefined;
|
|
171
|
+
cancelUrl?: string | null | undefined;
|
|
172
|
+
callbackUrl?: string | null | undefined;
|
|
173
|
+
expiresAt?: string | null | undefined;
|
|
174
|
+
notes?: string | null | undefined;
|
|
175
|
+
providerPayload?: Record<string, unknown> | null | undefined;
|
|
176
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
177
|
+
} | undefined;
|
|
178
|
+
paymentSessionNotification?: {
|
|
179
|
+
channel: "email" | "sms";
|
|
180
|
+
templateId?: string | null | undefined;
|
|
181
|
+
templateSlug?: string | null | undefined;
|
|
182
|
+
provider?: string | null | undefined;
|
|
183
|
+
to?: string | null | undefined;
|
|
184
|
+
from?: string | null | undefined;
|
|
185
|
+
subject?: string | null | undefined;
|
|
186
|
+
html?: string | null | undefined;
|
|
187
|
+
text?: string | null | undefined;
|
|
188
|
+
attachments?: {
|
|
189
|
+
filename: string;
|
|
190
|
+
contentBase64?: string | null | undefined;
|
|
191
|
+
path?: string | null | undefined;
|
|
192
|
+
contentType?: string | null | undefined;
|
|
193
|
+
disposition?: "attachment" | "inline" | null | undefined;
|
|
194
|
+
contentId?: string | null | undefined;
|
|
195
|
+
}[] | null | undefined;
|
|
196
|
+
data?: Record<string, unknown> | null | undefined;
|
|
197
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
198
|
+
scheduledFor?: string | null | undefined;
|
|
199
|
+
} | undefined;
|
|
200
|
+
invoiceNotification?: {
|
|
201
|
+
channel: "email" | "sms";
|
|
202
|
+
templateId?: string | null | undefined;
|
|
203
|
+
templateSlug?: string | null | undefined;
|
|
204
|
+
provider?: string | null | undefined;
|
|
205
|
+
to?: string | null | undefined;
|
|
206
|
+
from?: string | null | undefined;
|
|
207
|
+
subject?: string | null | undefined;
|
|
208
|
+
html?: string | null | undefined;
|
|
209
|
+
text?: string | null | undefined;
|
|
210
|
+
attachments?: {
|
|
211
|
+
filename: string;
|
|
212
|
+
contentBase64?: string | null | undefined;
|
|
213
|
+
path?: string | null | undefined;
|
|
214
|
+
contentType?: string | null | undefined;
|
|
215
|
+
disposition?: "attachment" | "inline" | null | undefined;
|
|
216
|
+
contentId?: string | null | undefined;
|
|
217
|
+
}[] | null | undefined;
|
|
218
|
+
data?: Record<string, unknown> | null | undefined;
|
|
219
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
220
|
+
scheduledFor?: string | null | undefined;
|
|
221
|
+
} | undefined;
|
|
222
|
+
startProvider?: {
|
|
223
|
+
provider: string;
|
|
224
|
+
payload?: Record<string, unknown> | null | undefined;
|
|
225
|
+
} | undefined;
|
|
226
|
+
notes?: string | null | undefined;
|
|
227
|
+
}, unknown>;
|
|
228
|
+
//# sourceMappingURL=use-initiate-checkout-collection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-initiate-checkout-collection.d.ts","sourceRoot":"","sources":["../../src/hooks/use-initiate-checkout-collection.ts"],"names":[],"mappings":"AAcA;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA8B9D"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantCheckoutContext } from "../provider.js";
|
|
4
|
+
/**
|
|
5
|
+
* Admin-side: kick off a checkout collection against a booking. Mounts at
|
|
6
|
+
* `/v1/admin/checkout/bookings/:bookingId/initiate-collection` (the public
|
|
7
|
+
* mirror is gated behind `actor=customer` and only reachable from a public
|
|
8
|
+
* storefront / customer portal).
|
|
9
|
+
*
|
|
10
|
+
* Invalidates booking + public-booking-payments queries on success so the
|
|
11
|
+
* caller's payments summary re-fetches automatically.
|
|
12
|
+
*/
|
|
13
|
+
export function useInitiateCheckoutCollection(bookingId) {
|
|
14
|
+
const { baseUrl, fetcher } = useVoyantCheckoutContext();
|
|
15
|
+
const qc = useQueryClient();
|
|
16
|
+
return useMutation({
|
|
17
|
+
mutationFn: async (input) => {
|
|
18
|
+
const response = await fetcher(`${baseUrl}/v1/admin/checkout/bookings/${bookingId}/initiate-collection`, {
|
|
19
|
+
method: "POST",
|
|
20
|
+
headers: { "Content-Type": "application/json" },
|
|
21
|
+
body: JSON.stringify(input),
|
|
22
|
+
});
|
|
23
|
+
const body = (await response.json());
|
|
24
|
+
if (!response.ok) {
|
|
25
|
+
const message = "error" in body ? body.error : `Checkout failed: ${response.status}`;
|
|
26
|
+
throw new Error(message);
|
|
27
|
+
}
|
|
28
|
+
return body.data;
|
|
29
|
+
},
|
|
30
|
+
onSuccess: () => {
|
|
31
|
+
qc.invalidateQueries({ queryKey: ["bookings", bookingId] });
|
|
32
|
+
qc.invalidateQueries({ queryKey: ["public-booking-payments", bookingId] });
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin-side: preview the collection plan for a booking before initiating.
|
|
3
|
+
* Returns what the operator will collect (deposit / balance / custom amount),
|
|
4
|
+
* which schedule or invoice the session will target, and which method is
|
|
5
|
+
* about to be used. Useful for an "About to charge X" confirmation step.
|
|
6
|
+
*/
|
|
7
|
+
export declare function usePreviewCheckoutCollection(bookingId: string): import("@tanstack/react-query").UseMutationResult<{
|
|
8
|
+
bookingId: string;
|
|
9
|
+
method: "bank_transfer" | "card";
|
|
10
|
+
stage: "manual" | "initial" | "reminder";
|
|
11
|
+
paymentSessionTarget: "invoice" | "schedule" | null;
|
|
12
|
+
documentType: "invoice" | "proforma" | null;
|
|
13
|
+
willCreateDefaultPaymentPlan: boolean;
|
|
14
|
+
selectedSchedule: {
|
|
15
|
+
id: string;
|
|
16
|
+
bookingId: string;
|
|
17
|
+
bookingItemId: string | null;
|
|
18
|
+
scheduleType: string;
|
|
19
|
+
status: string;
|
|
20
|
+
dueDate: string;
|
|
21
|
+
currency: string;
|
|
22
|
+
amountCents: number;
|
|
23
|
+
notes: string | null;
|
|
24
|
+
} | null;
|
|
25
|
+
selectedInvoice: {
|
|
26
|
+
id: string;
|
|
27
|
+
invoiceNumber: string;
|
|
28
|
+
invoiceType: string;
|
|
29
|
+
bookingId: string;
|
|
30
|
+
personId: string | null;
|
|
31
|
+
organizationId: string | null;
|
|
32
|
+
status: string;
|
|
33
|
+
currency: string;
|
|
34
|
+
totalCents: number;
|
|
35
|
+
paidCents: number;
|
|
36
|
+
balanceDueCents: number;
|
|
37
|
+
issueDate: string;
|
|
38
|
+
dueDate: string;
|
|
39
|
+
notes: string | null;
|
|
40
|
+
createdAt: string;
|
|
41
|
+
updatedAt: string;
|
|
42
|
+
} | null;
|
|
43
|
+
amountCents: number;
|
|
44
|
+
currency: string;
|
|
45
|
+
recommendedAction: "none" | "create_bank_transfer_document" | "create_payment_session" | "create_invoice_then_payment_session";
|
|
46
|
+
}, Error, {
|
|
47
|
+
method: "bank_transfer" | "card";
|
|
48
|
+
stage: "manual" | "initial" | "reminder";
|
|
49
|
+
ensureDefaultPaymentPlan: boolean;
|
|
50
|
+
scheduleId?: string | undefined;
|
|
51
|
+
invoiceId?: string | undefined;
|
|
52
|
+
amountCents?: number | undefined;
|
|
53
|
+
paymentSessionTarget?: "invoice" | "schedule" | undefined;
|
|
54
|
+
paymentPlan?: {
|
|
55
|
+
depositMode?: "percentage" | "none" | "fixed_amount" | undefined;
|
|
56
|
+
depositValue?: number | undefined;
|
|
57
|
+
depositDueDate?: string | null | undefined;
|
|
58
|
+
balanceDueDaysBeforeStart?: number | undefined;
|
|
59
|
+
clearExistingPending?: boolean | undefined;
|
|
60
|
+
createGuarantee?: boolean | undefined;
|
|
61
|
+
guaranteeType?: "other" | "voucher" | "bank_transfer" | "credit_card" | "deposit" | "preauth" | "card_on_file" | "agency_letter" | undefined;
|
|
62
|
+
notes?: string | null | undefined;
|
|
63
|
+
} | undefined;
|
|
64
|
+
} | undefined, unknown>;
|
|
65
|
+
//# sourceMappingURL=use-preview-checkout-collection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-preview-checkout-collection.d.ts","sourceRoot":"","sources":["../../src/hooks/use-preview-checkout-collection.ts"],"names":[],"mappings":"AAcA;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAyB7D"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantCheckoutContext } from "../provider.js";
|
|
4
|
+
/**
|
|
5
|
+
* Admin-side: preview the collection plan for a booking before initiating.
|
|
6
|
+
* Returns what the operator will collect (deposit / balance / custom amount),
|
|
7
|
+
* which schedule or invoice the session will target, and which method is
|
|
8
|
+
* about to be used. Useful for an "About to charge X" confirmation step.
|
|
9
|
+
*/
|
|
10
|
+
export function usePreviewCheckoutCollection(bookingId) {
|
|
11
|
+
const { baseUrl, fetcher } = useVoyantCheckoutContext();
|
|
12
|
+
return useMutation({
|
|
13
|
+
mutationFn: async (input) => {
|
|
14
|
+
const response = await fetcher(`${baseUrl}/v1/admin/checkout/bookings/${bookingId}/collection-plan`, {
|
|
15
|
+
method: "POST",
|
|
16
|
+
headers: { "Content-Type": "application/json" },
|
|
17
|
+
body: input ? JSON.stringify(input) : "{}",
|
|
18
|
+
});
|
|
19
|
+
const body = (await response.json());
|
|
20
|
+
if (!response.ok) {
|
|
21
|
+
const message = "error" in body ? body.error : `Preview failed: ${response.status}`;
|
|
22
|
+
throw new Error(message);
|
|
23
|
+
}
|
|
24
|
+
return body.data;
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@voyantjs/checkout-react` — admin React hooks for the checkout
|
|
3
|
+
* orchestration layer (`@voyantjs/checkout`) plus the universal payment
|
|
4
|
+
* choice / capability types consumed by `<PaymentStep>` in
|
|
5
|
+
* `@voyantjs/checkout-ui`.
|
|
6
|
+
*
|
|
7
|
+
* Public-side hooks (`usePublicPaymentSession`,
|
|
8
|
+
* `usePublicBookingPaymentOptions`) are re-exported from
|
|
9
|
+
* `@voyantjs/finance-react` so consumers don't have to import from two
|
|
10
|
+
* places.
|
|
11
|
+
*
|
|
12
|
+
* See `docs/architecture/payments-architecture.md`.
|
|
13
|
+
*/
|
|
14
|
+
export { usePublicBookingPaymentOptions, usePublicBookingPayments, usePublicPaymentSession, } from "@voyantjs/finance-react";
|
|
15
|
+
export * from "./hooks/index.js";
|
|
16
|
+
export { useVoyantCheckoutContext, type VoyantCheckoutContextValue, VoyantCheckoutProvider, type VoyantCheckoutProviderProps, } from "./provider.js";
|
|
17
|
+
export { type PaymentChoice, type PaymentStepCapabilities, type PaymentStepExtraOption, type SavedPaymentAccount, } from "./types.js";
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,8BAA8B,EAC9B,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,yBAAyB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,OAAO,EACL,wBAAwB,EACxB,KAAK,0BAA0B,EAC/B,sBAAsB,EACtB,KAAK,2BAA2B,GACjC,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,GACzB,MAAM,YAAY,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@voyantjs/checkout-react` — admin React hooks for the checkout
|
|
3
|
+
* orchestration layer (`@voyantjs/checkout`) plus the universal payment
|
|
4
|
+
* choice / capability types consumed by `<PaymentStep>` in
|
|
5
|
+
* `@voyantjs/checkout-ui`.
|
|
6
|
+
*
|
|
7
|
+
* Public-side hooks (`usePublicPaymentSession`,
|
|
8
|
+
* `usePublicBookingPaymentOptions`) are re-exported from
|
|
9
|
+
* `@voyantjs/finance-react` so consumers don't have to import from two
|
|
10
|
+
* places.
|
|
11
|
+
*
|
|
12
|
+
* See `docs/architecture/payments-architecture.md`.
|
|
13
|
+
*/
|
|
14
|
+
export { usePublicBookingPaymentOptions, usePublicBookingPayments, usePublicPaymentSession, } from "@voyantjs/finance-react";
|
|
15
|
+
export * from "./hooks/index.js";
|
|
16
|
+
export { useVoyantCheckoutContext, VoyantCheckoutProvider, } from "./provider.js";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { useVoyantReactContext as useVoyantCheckoutContext, type VoyantReactContextValue as VoyantCheckoutContextValue, VoyantReactProvider as VoyantCheckoutProvider, type VoyantReactProviderProps as VoyantCheckoutProviderProps, } from "@voyantjs/react";
|
|
2
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,IAAI,wBAAwB,EACjD,KAAK,uBAAuB,IAAI,0BAA0B,EAC1D,mBAAmB,IAAI,sBAAsB,EAC7C,KAAK,wBAAwB,IAAI,2BAA2B,GAC7D,MAAM,iBAAiB,CAAA"}
|
package/dist/provider.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useVoyantReactContext as useVoyantCheckoutContext, VoyantReactProvider as VoyantCheckoutProvider, } from "@voyantjs/react";
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { PublicBookingPaymentOptions } from "@voyantjs/finance/public-validation";
|
|
2
|
+
/**
|
|
3
|
+
* Saved payment instrument as the picker needs it — the canonical finance
|
|
4
|
+
* projection (`PublicBookingPaymentOptions["accounts"][number]`). Verticals
|
|
5
|
+
* that already query that endpoint can pass elements through unchanged.
|
|
6
|
+
*/
|
|
7
|
+
export type SavedPaymentAccount = PublicBookingPaymentOptions["accounts"][number];
|
|
8
|
+
/**
|
|
9
|
+
* Universal payment-choice contract used by the `<PaymentStep>` UI in
|
|
10
|
+
* `@voyantjs/checkout-ui` and the `useCollectPayment` hook here. The hook
|
|
11
|
+
* translates a `PaymentChoice` into an `initiateCheckoutCollection` request,
|
|
12
|
+
* so this type is the seam between presentational picker and orchestration.
|
|
13
|
+
*
|
|
14
|
+
* See `docs/architecture/payments-architecture.md` §Core Rule 3.
|
|
15
|
+
*/
|
|
16
|
+
export type PaymentChoice = {
|
|
17
|
+
type: "saved_method";
|
|
18
|
+
method: SavedPaymentAccount;
|
|
19
|
+
} | {
|
|
20
|
+
type: "new_card";
|
|
21
|
+
cardholderName?: string;
|
|
22
|
+
cardToken: string;
|
|
23
|
+
expiry?: string;
|
|
24
|
+
} | {
|
|
25
|
+
type: "send_link";
|
|
26
|
+
} | {
|
|
27
|
+
type: "bank_transfer";
|
|
28
|
+
} | {
|
|
29
|
+
type: "hold";
|
|
30
|
+
} | {
|
|
31
|
+
type: "extra";
|
|
32
|
+
optionId: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* What the active processor + template offer for the payment step. Honest
|
|
36
|
+
* booleans — the parent decides each value from what's actually wired
|
|
37
|
+
* (`paymentStarters` registered in checkout, `bankTransferDetails`
|
|
38
|
+
* configured, saved methods present, etc.).
|
|
39
|
+
*
|
|
40
|
+
* See `docs/architecture/payments-architecture.md` §Core Rule 7.
|
|
41
|
+
*/
|
|
42
|
+
export interface PaymentStepCapabilities {
|
|
43
|
+
chargeSavedCard?: boolean;
|
|
44
|
+
newCard?: boolean;
|
|
45
|
+
sendLink?: boolean;
|
|
46
|
+
bankTransfer?: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface PaymentStepExtraOption {
|
|
49
|
+
id: string;
|
|
50
|
+
label: string;
|
|
51
|
+
description: string;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAA;AAEtF;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,2BAA2B,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAA;AAEjF;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,MAAM,EAAE,mBAAmB,CAAA;CAAE,GACrD;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GACjF;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvC;;;;;;;GAOG;AACH,MAAM,WAAW,uBAAuB;IACtC,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;CACpB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@voyantjs/checkout-react",
|
|
3
|
+
"version": "0.19.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/voyantjs/voyant.git",
|
|
8
|
+
"directory": "packages/checkout-react"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./src/index.ts",
|
|
14
|
+
"./provider": "./src/provider.tsx",
|
|
15
|
+
"./hooks": "./src/hooks/index.ts"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc -p tsconfig.json",
|
|
19
|
+
"clean": "rm -rf dist",
|
|
20
|
+
"prepack": "pnpm run build",
|
|
21
|
+
"typecheck": "tsc --noEmit",
|
|
22
|
+
"lint": "biome check src/",
|
|
23
|
+
"test": "vitest run --passWithNoTests"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@voyantjs/checkout": "workspace:*",
|
|
27
|
+
"@voyantjs/finance": "workspace:*",
|
|
28
|
+
"@tanstack/react-query": "^5.0.0",
|
|
29
|
+
"react": "^19.0.0",
|
|
30
|
+
"react-dom": "^19.0.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@tanstack/react-query": "^5.96.2",
|
|
34
|
+
"@types/react": "^19.2.14",
|
|
35
|
+
"@types/react-dom": "^19.2.3",
|
|
36
|
+
"@voyantjs/checkout": "workspace:*",
|
|
37
|
+
"@voyantjs/finance": "workspace:*",
|
|
38
|
+
"@voyantjs/finance-react": "workspace:*",
|
|
39
|
+
"@voyantjs/react": "workspace:*",
|
|
40
|
+
"@voyantjs/voyant-typescript-config": "workspace:*",
|
|
41
|
+
"react": "^19.2.4",
|
|
42
|
+
"react-dom": "^19.2.4",
|
|
43
|
+
"typescript": "^6.0.2",
|
|
44
|
+
"vitest": "^4.1.2"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@voyantjs/finance-react": "workspace:*",
|
|
48
|
+
"@voyantjs/react": "workspace:*"
|
|
49
|
+
},
|
|
50
|
+
"files": [
|
|
51
|
+
"dist"
|
|
52
|
+
],
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public",
|
|
55
|
+
"exports": {
|
|
56
|
+
".": {
|
|
57
|
+
"types": "./dist/index.d.ts",
|
|
58
|
+
"import": "./dist/index.js",
|
|
59
|
+
"default": "./dist/index.js"
|
|
60
|
+
},
|
|
61
|
+
"./provider": {
|
|
62
|
+
"types": "./dist/provider.d.ts",
|
|
63
|
+
"import": "./dist/provider.js",
|
|
64
|
+
"default": "./dist/provider.js"
|
|
65
|
+
},
|
|
66
|
+
"./hooks": {
|
|
67
|
+
"types": "./dist/hooks/index.d.ts",
|
|
68
|
+
"import": "./dist/hooks/index.js",
|
|
69
|
+
"default": "./dist/hooks/index.js"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"main": "./dist/index.js",
|
|
73
|
+
"types": "./dist/index.d.ts"
|
|
74
|
+
}
|
|
75
|
+
}
|