@voyantjs/checkout-ui 0.19.0 → 0.20.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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may accept and charge a
167
+ fee for, the acceptance of support, warranty, indemnity, or
168
+ other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 PixelMakers Studio SRL
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -25,8 +25,23 @@ export interface CollectPaymentDialogProps {
25
25
  defaultAmountCents?: number | null;
26
26
  defaultPayerEmail?: string | null;
27
27
  defaultPayerName?: string | null;
28
+ /**
29
+ * Language for the processor's hosted payment page. Pass the picked
30
+ * person's `preferredLanguage`, the booking locale, or the active admin
31
+ * locale. Falls back to the processor's deploy-wide default when omitted.
32
+ */
33
+ defaultPayerLanguage?: string | null;
34
+ /**
35
+ * Per-session overrides for where the customer's browser lands after
36
+ * payment success / cancel on the processor's hosted page. Storefront
37
+ * flows usually pass their own confirmation route; operator-initiated
38
+ * send-link flows usually leave these unset and let the deploy-wide
39
+ * `NETOPIA_REDIRECT_URL` point at the public `/pay/:sessionId` landing.
40
+ */
41
+ returnUrl?: string | null;
42
+ cancelUrl?: string | null;
28
43
  /** Card processor id registered in checkout's `paymentStarters`. */
29
44
  cardProvider?: string;
30
45
  }
31
- export declare function CollectPaymentDialog({ open, onOpenChange, bookingId, defaultCurrency, defaultAmountCents, defaultPayerEmail, defaultPayerName, cardProvider, }: CollectPaymentDialogProps): import("react/jsx-runtime").JSX.Element;
46
+ export declare function CollectPaymentDialog({ open, onOpenChange, bookingId, defaultCurrency, defaultAmountCents, defaultPayerEmail, defaultPayerName, defaultPayerLanguage, returnUrl, cancelUrl, cardProvider, }: CollectPaymentDialogProps): import("react/jsx-runtime").JSX.Element;
32
47
  //# sourceMappingURL=collect-payment-dialog.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"collect-payment-dialog.d.ts","sourceRoot":"","sources":["../../src/components/collect-payment-dialog.tsx"],"names":[],"mappings":"AAqBA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,MAAM,CAAA;IACvB,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,oEAAoE;IACpE,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AASD,wBAAgB,oBAAoB,CAAC,EACnC,IAAI,EACJ,YAAY,EACZ,SAAS,EACT,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,GACb,EAAE,yBAAyB,2CA6H3B"}
1
+ {"version":3,"file":"collect-payment-dialog.d.ts","sourceRoot":"","sources":["../../src/components/collect-payment-dialog.tsx"],"names":[],"mappings":"AAqBA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,MAAM,CAAA;IACvB,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpC;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,oEAAoE;IACpE,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAaD,wBAAgB,oBAAoB,CAAC,EACnC,IAAI,EACJ,YAAY,EACZ,SAAS,EACT,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,SAAS,EACT,SAAS,EACT,YAAY,GACb,EAAE,yBAAyB,2CA8G3B"}
@@ -9,13 +9,17 @@ import { CheckCircle2, Copy, ExternalLink, Loader2 } from "lucide-react";
9
9
  import { useMemo, useState } from "react";
10
10
  import { toast } from "sonner";
11
11
  import { PaymentStep } from "./payment-step.js";
12
+ /**
13
+ * Operator dialog defaults to immediate-charge disabled. Templates that
14
+ * have wired a processor with stored-token support can override via
15
+ * `<PaymentStep>` directly; this dialog is the simple "produce a link to
16
+ * share" flow.
17
+ */
12
18
  const CAPABILITIES = {
13
19
  chargeSavedCard: false,
14
20
  newCard: false,
15
- sendLink: true,
16
- bankTransfer: true,
17
21
  };
18
- export function CollectPaymentDialog({ open, onOpenChange, bookingId, defaultCurrency, defaultAmountCents, defaultPayerEmail, defaultPayerName, cardProvider, }) {
22
+ export function CollectPaymentDialog({ open, onOpenChange, bookingId, defaultCurrency, defaultAmountCents, defaultPayerEmail, defaultPayerName, defaultPayerLanguage, returnUrl, cancelUrl, cardProvider, }) {
19
23
  const [amountCents, setAmountCents] = useState(defaultAmountCents ?? 0);
20
24
  const [choice, setChoice] = useState(null);
21
25
  const [result, setResult] = useState(null);
@@ -23,6 +27,9 @@ export function CollectPaymentDialog({ open, onOpenChange, bookingId, defaultCur
23
27
  cardProvider,
24
28
  payerEmail: defaultPayerEmail,
25
29
  payerName: defaultPayerName,
30
+ payerLanguage: defaultPayerLanguage,
31
+ returnUrl,
32
+ cancelUrl,
26
33
  });
27
34
  const amountInputValue = useMemo(() => (amountCents > 0 ? (amountCents / 100).toFixed(2) : ""), [amountCents]);
28
35
  function reset() {
@@ -32,10 +39,8 @@ export function CollectPaymentDialog({ open, onOpenChange, bookingId, defaultCur
32
39
  collect.reset();
33
40
  }
34
41
  async function submit() {
35
- if (!choice)
36
- return;
37
- if (choice.type !== "send_link" && choice.type !== "bank_transfer") {
38
- toast.error("Pick 'Send payment link' or 'Bank transfer' to collect now.");
42
+ if (!choice || choice.type !== "hold") {
43
+ toast.error("Pick 'Hold — generate payment link' to produce a shareable link.");
39
44
  return;
40
45
  }
41
46
  if (amountCents <= 0) {
@@ -45,9 +50,7 @@ export function CollectPaymentDialog({ open, onOpenChange, bookingId, defaultCur
45
50
  try {
46
51
  const data = await collect.mutateAsync({ choice, amountCents });
47
52
  setResult(data);
48
- toast.success(choice.type === "send_link"
49
- ? "Payment link sent — customer received the email."
50
- : "Bank-transfer instructions ready below.");
53
+ toast.success("Payment link ready — copy or share it with the customer.");
51
54
  }
52
55
  catch (err) {
53
56
  toast.error(err.message);
@@ -57,26 +60,18 @@ export function CollectPaymentDialog({ open, onOpenChange, bookingId, defaultCur
57
60
  onOpenChange(next);
58
61
  if (!next)
59
62
  reset();
60
- }, children: _jsxs(DialogContent, { className: "max-w-xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Collect payment" }), _jsx(DialogDescription, { children: "Pick how the customer will pay. Card flows redirect to the configured processor; bank-transfer surfaces IBAN instructions you can pass on." })] }), result ? (_jsx(ResultPanel, { result: result })) : (_jsxs("div", { className: "flex flex-col gap-5", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsxs(Label, { htmlFor: "collect-amount", children: ["Amount (", defaultCurrency, ")"] }), _jsx(Input, { id: "collect-amount", type: "number", inputMode: "decimal", step: "0.01", min: "0", value: amountInputValue, onChange: (e) => {
63
+ }, children: _jsxs(DialogContent, { className: "max-w-xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Generate payment link" }), _jsx(DialogDescription, { children: "Hold the booking and produce a payment link the customer can open to pay by card or bank transfer. Share it however you prefer (email, chat, etc.)." })] }), result ? (_jsx(ResultPanel, { result: result })) : (_jsxs("div", { className: "flex flex-col gap-5", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsxs(Label, { htmlFor: "collect-amount", children: ["Amount (", defaultCurrency, ")"] }), _jsx(Input, { id: "collect-amount", type: "number", inputMode: "decimal", step: "0.01", min: "0", value: amountInputValue, onChange: (e) => {
61
64
  const raw = Number.parseFloat(e.target.value);
62
65
  setAmountCents(Number.isFinite(raw) ? Math.round(raw * 100) : 0);
63
- } }), _jsx("p", { className: "text-muted-foreground text-xs", children: "Defaults to the booking's sell amount. Override for a deposit or partial collection." })] }), _jsx(PaymentStep, { value: choice, onChange: setChoice, capabilities: CAPABILITIES, hideHoldOption: true })] })), _jsx(DialogFooter, { children: result ? (_jsx(Button, { onClick: () => onOpenChange(false), children: "Done" })) : (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", onClick: () => onOpenChange(false), disabled: collect.isPending, children: "Cancel" }), _jsxs(Button, { onClick: submit, disabled: collect.isPending ||
64
- !choice ||
65
- (choice.type !== "send_link" && choice.type !== "bank_transfer"), children: [collect.isPending && _jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }), choice?.type === "bank_transfer" ? "Generate instructions" : "Send payment link"] })] })) })] }) }));
66
+ } }), _jsx("p", { className: "text-muted-foreground text-xs", children: "Defaults to the booking's sell amount. Override for a deposit or partial collection." })] }), _jsx(PaymentStep, { value: choice, onChange: setChoice, capabilities: CAPABILITIES })] })), _jsx(DialogFooter, { children: result ? (_jsx(Button, { onClick: () => onOpenChange(false), children: "Done" })) : (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", onClick: () => onOpenChange(false), disabled: collect.isPending, children: "Cancel" }), _jsxs(Button, { onClick: submit, disabled: collect.isPending || choice?.type !== "hold", children: [collect.isPending && _jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }), "Generate link"] })] })) })] }) }));
66
67
  }
67
68
  function ResultPanel({ result }) {
68
- if (result.plan.method === "card") {
69
- const url = result.providerStart?.redirectUrl ?? result.paymentSession?.redirectUrl ?? null;
70
- return (_jsxs("div", { className: "flex flex-col gap-4 rounded-xl border bg-card p-5", children: [_jsxs("div", { className: "flex items-center gap-2 text-emerald-700", children: [_jsx(CheckCircle2, { className: "h-5 w-5" }), _jsx("span", { className: "font-medium", children: "Payment link ready" })] }), _jsx("p", { className: "text-muted-foreground text-sm", children: "The customer received an email with the link. You can also share it directly:" }), url ? (_jsxs("div", { className: "flex items-center gap-2 rounded-md border bg-muted/30 p-3 font-mono text-xs", children: [_jsx("span", { className: "flex-1 break-all", children: url }), _jsx("button", { type: "button", "aria-label": "Copy link", className: "text-muted-foreground hover:text-foreground", onClick: () => {
71
- navigator.clipboard?.writeText(url).catch(() => undefined);
72
- }, children: _jsx(Copy, { className: "h-3.5 w-3.5" }) }), _jsx("a", { href: url, target: "_blank", rel: "noreferrer", "aria-label": "Open link", className: "text-muted-foreground hover:text-foreground", children: _jsx(ExternalLink, { className: "h-3.5 w-3.5" }) })] })) : (_jsxs("p", { className: "text-muted-foreground text-xs", children: ["The processor didn't return an immediate redirect URL. The session id is", " ", _jsx("span", { className: "font-mono", children: result.paymentSession?.id ?? "—" }), "."] }))] }));
73
- }
74
- const ins = result.bankTransferInstructions;
75
- if (!ins) {
76
- return (_jsxs("div", { className: "rounded-xl border border-amber-500/40 bg-amber-500/5 p-5 text-sm", children: ["Bank-transfer instructions are not configured for this template. Set", _jsx("span", { className: "font-mono", children: " BANK_TRANSFER_BENEFICIARY " }), "and friends in ", _jsx("span", { className: "font-mono", children: ".dev.vars" }), "."] }));
69
+ const sessionId = result.paymentSession?.id ?? null;
70
+ const landingUrl = sessionId && typeof window !== "undefined" ? `${window.location.origin}/pay/${sessionId}` : null;
71
+ if (!landingUrl) {
72
+ return (_jsxs("div", { className: "rounded-xl border border-amber-500/40 bg-amber-500/5 p-5 text-sm", children: ["The session was created but no link could be built. Session id:", " ", _jsx("span", { className: "font-mono", children: sessionId ?? "—" }), "."] }));
77
73
  }
78
- return (_jsxs("div", { className: "flex flex-col gap-4 rounded-xl border bg-card p-5", children: [_jsxs("div", { className: "flex items-center gap-2 text-emerald-700", children: [_jsx(CheckCircle2, { className: "h-5 w-5" }), _jsx("span", { className: "font-medium", children: "Bank-transfer instructions" })] }), _jsxs("dl", { className: "grid grid-cols-1 gap-2 text-sm", children: [_jsx(Row, { label: "Beneficiary", children: ins.beneficiary }), _jsx(Row, { label: "IBAN", children: _jsx("span", { className: "font-mono", children: ins.iban }) }), ins.bankName && _jsx(Row, { label: "Bank", children: ins.bankName }), _jsx(Row, { label: "Reference", children: _jsx("span", { className: "font-mono", children: ins.invoiceNumber }) })] }), ins.notes && _jsx("p", { className: "text-muted-foreground text-xs", children: ins.notes })] }));
79
- }
80
- function Row({ label, children }) {
81
- return (_jsxs("div", { className: "flex items-baseline justify-between gap-3 border-b py-1.5 last:border-b-0", children: [_jsx("dt", { className: "text-muted-foreground text-xs uppercase tracking-wider", children: label }), _jsx("dd", { children: children })] }));
74
+ return (_jsxs("div", { className: "flex flex-col gap-4 rounded-xl border bg-card p-5", children: [_jsxs("div", { className: "flex items-center gap-2 text-emerald-700", children: [_jsx(CheckCircle2, { className: "h-5 w-5" }), _jsx("span", { className: "font-medium", children: "Payment link ready" })] }), _jsx("p", { className: "text-muted-foreground text-sm", children: "Share this link with the customer. They'll choose card or bank transfer on the page." }), _jsxs("div", { className: "flex items-center gap-2 rounded-md border bg-muted/30 p-3 font-mono text-xs", children: [_jsx("span", { className: "flex-1 break-all", children: landingUrl }), _jsx("button", { type: "button", "aria-label": "Copy link", className: "text-muted-foreground hover:text-foreground", onClick: () => {
75
+ navigator.clipboard?.writeText(landingUrl).catch(() => undefined);
76
+ }, children: _jsx(Copy, { className: "h-3.5 w-3.5" }) }), _jsx("a", { href: landingUrl, target: "_blank", rel: "noreferrer", "aria-label": "Open link", className: "text-muted-foreground hover:text-foreground", children: _jsx(ExternalLink, { className: "h-3.5 w-3.5" }) })] })] }));
82
77
  }
@@ -35,6 +35,16 @@ export interface PaymentLinkLandingPageProps {
35
35
  * itself doesn't carry a description today).
36
36
  */
37
37
  description?: string;
38
+ /**
39
+ * Fired when the customer clicks "Try again" on a failed payment.
40
+ * Should create a fresh `payment_session` (the original one is dead)
41
+ * and redirect the customer to its landing page. The parent typically
42
+ * POSTs to `/v1/public/payment-link/:sessionId/retry` and navigates to
43
+ * `/pay/{newSessionId}` with the result. When omitted, the failed
44
+ * panel renders no retry CTA at all (clearer than a button that
45
+ * re-opens the dead processor URL).
46
+ */
47
+ onRetry?: () => Promise<void> | void;
38
48
  }
39
49
  export interface BankTransferInstructions {
40
50
  beneficiaryName: string;
@@ -50,5 +60,5 @@ export interface BankTransferInstructions {
50
60
  /** Free-text notes — surfaced under the IBAN block. */
51
61
  notes?: string;
52
62
  }
53
- export declare function PaymentLinkLandingPage({ session, bankTransferInstructions, brandHeader, brandFooter, onPayByCard, description, }: PaymentLinkLandingPageProps): import("react/jsx-runtime").JSX.Element;
63
+ export declare function PaymentLinkLandingPage({ session, bankTransferInstructions, brandHeader, brandFooter, onPayByCard, onRetry, description, }: PaymentLinkLandingPageProps): import("react/jsx-runtime").JSX.Element;
54
64
  //# sourceMappingURL=payment-link-landing-page.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"payment-link-landing-page.d.ts","sourceRoot":"","sources":["../../src/components/payment-link-landing-page.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAK/E,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAA;AAEhD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,oBAAoB,CAAA;IAC7B,2EAA2E;IAC3E,wBAAwB,CAAC,EAAE,wBAAwB,CAAA;IACnD,gEAAgE;IAChE,WAAW,CAAC,EAAE,SAAS,CAAA;IACvB,yDAAyD;IACzD,WAAW,CAAC,EAAE,SAAS,CAAA;IACvB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;IACxB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,wBAAwB;IACvC,eAAe,EAAE,MAAM,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,wBAAgB,sBAAsB,CAAC,EACrC,OAAO,EACP,wBAAwB,EACxB,WAAW,EACX,WAAW,EACX,WAAW,EACX,WAAW,GACZ,EAAE,2BAA2B,2CAa7B"}
1
+ {"version":3,"file":"payment-link-landing-page.d.ts","sourceRoot":"","sources":["../../src/components/payment-link-landing-page.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAa/E,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAA;AAOhD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,oBAAoB,CAAA;IAC7B,2EAA2E;IAC3E,wBAAwB,CAAC,EAAE,wBAAwB,CAAA;IACnD,gEAAgE;IAChE,WAAW,CAAC,EAAE,SAAS,CAAA;IACvB,yDAAyD;IACzD,WAAW,CAAC,EAAE,SAAS,CAAA;IACvB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;IACxB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;CACrC;AAED,MAAM,WAAW,wBAAwB;IACvC,eAAe,EAAE,MAAM,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,wBAAgB,sBAAsB,CAAC,EACrC,OAAO,EACP,wBAAwB,EACxB,WAAW,EACX,WAAW,EACX,WAAW,EACX,OAAO,EACP,WAAW,GACZ,EAAE,2BAA2B,2CAc7B"}
@@ -1,23 +1,23 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { Button } from "@voyantjs/ui/components/button";
4
4
  import { Tabs, TabsContent, TabsList, TabsTrigger } from "@voyantjs/ui/components/tabs";
5
5
  import { cn } from "@voyantjs/ui/lib/utils";
6
- import { Building2, CheckCircle2, CircleAlert, Copy, CreditCard, ExternalLink, Loader2 } from "lucide-react";
6
+ import { Building2, CheckCircle2, CircleAlert, Copy, CreditCard, ExternalLink, Loader2, } from "lucide-react";
7
7
  import { useState } from "react";
8
- export function PaymentLinkLandingPage({ session, bankTransferInstructions, brandHeader, brandFooter, onPayByCard, description, }) {
9
- return (_jsxs("div", { className: "mx-auto flex min-h-screen w-full max-w-2xl flex-col gap-6 px-4 py-8", children: [brandHeader, _jsx(Header, { session: session, description: description }), _jsx(Body, { session: session, bankTransferInstructions: bankTransferInstructions, onPayByCard: onPayByCard }), brandFooter] }));
8
+ export function PaymentLinkLandingPage({ session, bankTransferInstructions, brandHeader, brandFooter, onPayByCard, onRetry, description, }) {
9
+ return (_jsxs("div", { className: "mx-auto flex min-h-screen w-full max-w-2xl flex-col gap-6 px-4 py-8", children: [brandHeader, _jsx(Header, { session: session, description: description }), _jsx(Body, { session: session, bankTransferInstructions: bankTransferInstructions, onPayByCard: onPayByCard, onRetry: onRetry }), brandFooter] }));
10
10
  }
11
11
  // ─────────────────────────────────────────────────────────────────────────────
12
- function Header({ session, description, }) {
13
- return (_jsxs("header", { className: "flex flex-col gap-2 border-b pb-4", children: [_jsx("h1", { className: "font-semibold text-2xl", children: description ?? defaultDescription(session) }), _jsxs("div", { className: "flex items-baseline gap-3", children: [_jsx("span", { className: "font-semibold text-3xl tabular-nums", children: formatMoneyCents(session.amountCents, session.currency) }), session.expiresAt && session.status !== "paid" && (_jsxs("span", { className: "text-muted-foreground text-sm", children: ["Expires ", formatDateTime(session.expiresAt)] }))] })] }));
12
+ function Header({ session, description }) {
13
+ return (_jsxs("header", { className: "flex flex-col gap-2 border-b pb-4", children: [_jsx("h1", { className: "font-semibold text-2xl", children: description ?? defaultDescription(session) }), session.notes && _jsx("p", { className: "text-muted-foreground text-sm", children: session.notes }), _jsxs("div", { className: "flex items-baseline gap-3", children: [_jsx("span", { className: "font-semibold text-3xl tabular-nums", children: formatMoneyCents(session.amountCents, session.currency) }), session.expiresAt && session.status !== "paid" && (_jsxs("span", { className: "text-muted-foreground text-sm", children: ["Expires ", formatDateTime(session.expiresAt)] }))] })] }));
14
14
  }
15
- function Body({ session, bankTransferInstructions, onPayByCard, }) {
15
+ function Body({ session, bankTransferInstructions, onPayByCard, onRetry, }) {
16
16
  // Terminal states — short-circuit body to a status panel.
17
17
  if (session.status === "paid")
18
18
  return _jsx(TerminalState, { status: "paid", reason: null });
19
19
  if (session.status === "failed") {
20
- return (_jsx(TerminalState, { status: "failed", reason: session.failureMessage ?? null, retryUrl: session.redirectUrl ?? null }));
20
+ return (_jsx(TerminalState, { status: "failed", reason: session.failureMessage ?? null, onRetry: onRetry }));
21
21
  }
22
22
  if (session.status === "expired")
23
23
  return _jsx(TerminalState, { status: "expired", reason: null });
@@ -26,7 +26,9 @@ function Body({ session, bankTransferInstructions, onPayByCard, }) {
26
26
  if (session.status === "processing" || session.status === "authorized") {
27
27
  return _jsx(ProcessingState, {});
28
28
  }
29
- const cardAvailable = Boolean(session.redirectUrl) || session.status === "requires_redirect";
29
+ const cardAvailable = Boolean(session.redirectUrl) ||
30
+ Boolean(session.provider) ||
31
+ session.status === "requires_redirect";
30
32
  const bankAvailable = Boolean(bankTransferInstructions);
31
33
  // No method available — soft fallback (rare; signals a misconfigured
32
34
  // session that has neither a redirect URL nor a bank-transfer block).
@@ -44,12 +46,39 @@ function Body({ session, bankTransferInstructions, onPayByCard, }) {
44
46
  return (_jsxs(Tabs, { defaultValue: "card", className: "w-full", children: [_jsxs(TabsList, { className: "grid w-full grid-cols-2", children: [_jsxs(TabsTrigger, { value: "card", children: [_jsx(CreditCard, { className: "mr-2 h-4 w-4" }), "Pay by card"] }), _jsxs(TabsTrigger, { value: "bank", children: [_jsx(Building2, { className: "mr-2 h-4 w-4" }), "Bank transfer"] })] }), _jsx(TabsContent, { value: "card", className: "mt-4", children: _jsx(CardPanel, { session: session, onPayByCard: onPayByCard }) }), _jsx(TabsContent, { value: "bank", className: "mt-4", children: bankTransferInstructions && (_jsx(BankTransferPanel, { session: session, instructions: bankTransferInstructions })) })] }));
45
47
  }
46
48
  function CardPanel({ session, onPayByCard, }) {
47
- return (_jsxs("div", { className: "rounded-xl border bg-card p-5 shadow-sm", children: [_jsx("p", { className: "mb-4 text-muted-foreground text-sm", children: "You'll be redirected to the secure payment page hosted by the card processor." }), _jsxs(Button, { className: "w-full", onClick: () => {
48
- if (onPayByCard)
49
- onPayByCard();
50
- else if (session.redirectUrl)
51
- window.location.href = session.redirectUrl;
52
- }, children: ["Pay ", formatMoneyCents(session.amountCents, session.currency), _jsx(ExternalLink, { className: "ml-2 h-4 w-4" })] })] }));
49
+ const [starting, setStarting] = useState(false);
50
+ const [error, setError] = useState(null);
51
+ const handleClick = async () => {
52
+ if (onPayByCard) {
53
+ onPayByCard();
54
+ return;
55
+ }
56
+ if (session.redirectUrl) {
57
+ window.location.href = session.redirectUrl;
58
+ return;
59
+ }
60
+ // Lazy-start the configured processor. The template exposes a public
61
+ // endpoint that calls e.g. `netopia.startPaymentSession` on demand and
62
+ // returns the redirect URL.
63
+ setStarting(true);
64
+ setError(null);
65
+ try {
66
+ const res = await fetch(`/api/v1/public/payment-link/${session.id}/start-card`, {
67
+ method: "POST",
68
+ headers: { Accept: "application/json" },
69
+ });
70
+ const body = (await res.json());
71
+ if (!res.ok || !body.data?.redirectUrl) {
72
+ throw new Error(body.error ?? "Card payment couldn't be prepared.");
73
+ }
74
+ window.location.href = body.data.redirectUrl;
75
+ }
76
+ catch (err) {
77
+ setError(err.message);
78
+ setStarting(false);
79
+ }
80
+ };
81
+ return (_jsxs("div", { className: "rounded-xl border bg-card p-5 shadow-sm", children: [_jsx("p", { className: "mb-4 text-muted-foreground text-sm", children: "You'll be redirected to the secure payment page hosted by the card processor." }), _jsxs(Button, { className: "w-full", disabled: starting, onClick: handleClick, children: [starting && _jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }), "Pay ", formatMoneyCents(session.amountCents, session.currency), !starting && _jsx(ExternalLink, { className: "ml-2 h-4 w-4" })] }), error && (_jsxs("p", { className: "mt-3 text-destructive text-xs", children: [error, " If the issue persists, please pay by bank transfer or contact your travel agent."] }))] }));
53
82
  }
54
83
  function BankTransferPanel({ session, instructions, }) {
55
84
  const reference = instructions.reference ?? session.externalReference ?? session.clientReference ?? session.id;
@@ -72,7 +101,9 @@ function CopyButton({ value }) {
72
101
  }
73
102
  }, children: copied ? (_jsx(CheckCircle2, { className: "h-3.5 w-3.5 text-emerald-600" })) : (_jsx(Copy, { className: "h-3.5 w-3.5" })) }));
74
103
  }
75
- function TerminalState({ status, reason, retryUrl, }) {
104
+ function TerminalState({ status, reason, onRetry, }) {
105
+ const [retrying, setRetrying] = useState(false);
106
+ const [retryError, setRetryError] = useState(null);
76
107
  const cfg = {
77
108
  paid: {
78
109
  icon: _jsx(CheckCircle2, { className: "h-10 w-10 text-emerald-600" }),
@@ -99,9 +130,17 @@ function TerminalState({ status, reason, retryUrl, }) {
99
130
  tone: "border-border bg-muted/20",
100
131
  },
101
132
  }[status];
102
- return (_jsxs("div", { className: cn("flex flex-col items-center gap-3 rounded-xl border p-8 text-center", cfg.tone), children: [cfg.icon, _jsx("h2", { className: "font-semibold text-lg", children: cfg.title }), _jsx("p", { className: "max-w-md text-muted-foreground text-sm", children: cfg.body }), status === "failed" && retryUrl && (_jsxs(Button, { className: "mt-2", onClick: () => {
103
- window.location.href = retryUrl;
104
- }, children: ["Try again", _jsx(ExternalLink, { className: "ml-2 h-4 w-4" })] }))] }));
133
+ return (_jsxs("div", { className: cn("flex flex-col items-center gap-3 rounded-xl border p-8 text-center", cfg.tone), children: [cfg.icon, _jsx("h2", { className: "font-semibold text-lg", children: cfg.title }), _jsx("p", { className: "max-w-md text-muted-foreground text-sm", children: cfg.body }), status === "failed" && onRetry && (_jsxs(_Fragment, { children: [_jsxs(Button, { className: "mt-2", disabled: retrying, onClick: async () => {
134
+ setRetrying(true);
135
+ setRetryError(null);
136
+ try {
137
+ await onRetry();
138
+ }
139
+ catch (err) {
140
+ setRetryError(err.message);
141
+ setRetrying(false);
142
+ }
143
+ }, children: [retrying && _jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }), "Try again"] }), retryError && _jsx("p", { className: "text-destructive text-xs", children: retryError })] }))] }));
105
144
  }
106
145
  function ProcessingState() {
107
146
  return (_jsxs("div", { className: "flex flex-col items-center gap-3 rounded-xl border bg-card p-8 text-center", children: [_jsx(Loader2, { className: "h-10 w-10 animate-spin text-muted-foreground" }), _jsx("h2", { className: "font-semibold text-lg", children: "Processing payment\u2026" }), _jsx("p", { className: "max-w-md text-muted-foreground text-sm", children: "We're confirming the payment with the processor. This usually takes a few seconds." })] }));
@@ -1,4 +1,4 @@
1
- import type { PaymentChoice, PaymentStepCapabilities, PaymentStepExtraOption as CheckoutPaymentStepExtraOption, SavedPaymentAccount } from "@voyantjs/checkout-react";
1
+ import type { PaymentStepExtraOption as CheckoutPaymentStepExtraOption, PaymentChoice, PaymentStepCapabilities, SavedPaymentAccount } from "@voyantjs/checkout-react";
2
2
  import { type ReactNode } from "react";
3
3
  /**
4
4
  * UI-side extension of the `PaymentStepExtraOption` from checkout-react —
@@ -25,25 +25,18 @@ export interface PaymentStepProps {
25
25
  extraOptions?: ReadonlyArray<PaymentStepExtraOption>;
26
26
  /** Hide the universal "Hold — pay later" option (some verticals don't support it). */
27
27
  hideHoldOption?: boolean;
28
- /**
29
- * Optional callback fired when the operator picks "Send payment link".
30
- * The parent wires it to `useInitiateCheckoutCollection` (or whichever
31
- * checkout endpoint applies for the vertical).
32
- */
33
- onRequestPaymentLink?: () => void;
34
28
  }
35
29
  /**
36
- * Universal capability-gated payment picker. Renders sections based on
37
- * what the parent declares is actually wired, plus optional vertical-
38
- * specific extras and the universal Hold option.
30
+ * Admin-side payment picker. Renders the sections the parent has wired:
39
31
  *
40
- * Sections, in order:
41
32
  * - Saved cards on file ← capabilities.chargeSavedCard
42
- * - Send payment link ← capabilities.sendLink
43
33
  * - Charge a new card now ← capabilities.newCard
44
- * - Bank transfer ← capabilities.bankTransfer
45
34
  * - Vertical-specific extras ← always rendered (e.g. "Issue on credit")
46
- * - Hold seats pay later ← always rendered (unless hideHoldOption)
35
+ * - Hold — generate payment link ← always rendered (unless hideHoldOption)
36
+ *
37
+ * The customer's card-vs-bank-transfer decision happens on the public
38
+ * `/pay/:sessionId` landing page, not here. That keeps the admin UI to
39
+ * three real choices: charge now, vertical action, or hold + share link.
47
40
  */
48
- export declare function PaymentStep({ value, onChange, capabilities, savedMethods, loadingSavedMethods, extraOptions, hideHoldOption, onRequestPaymentLink, }: PaymentStepProps): import("react/jsx-runtime").JSX.Element;
41
+ export declare function PaymentStep({ value, onChange, capabilities, savedMethods, loadingSavedMethods, extraOptions, hideHoldOption, }: PaymentStepProps): import("react/jsx-runtime").JSX.Element;
49
42
  //# sourceMappingURL=payment-step.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"payment-step.d.ts","sourceRoot":"","sources":["../../src/components/payment-step.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,uBAAuB,EACvB,sBAAsB,IAAI,8BAA8B,EACxD,mBAAmB,EACpB,MAAM,0BAA0B,CAAA;AAMjC,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAA;AAEhD;;;GAGG;AACH,MAAM,WAAW,sBAAuB,SAAQ,8BAA8B;IAC5E,IAAI,CAAC,EAAE,SAAS,CAAA;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,aAAa,GAAG,IAAI,CAAA;IAC3B,QAAQ,EAAE,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI,KAAK,IAAI,CAAA;IAE9C;;;OAGG;IACH,YAAY,EAAE,uBAAuB,CAAA;IAErC,oFAAoF;IACpF,YAAY,CAAC,EAAE,mBAAmB,EAAE,CAAA;IACpC,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAE7B;;;OAGG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC,sBAAsB,CAAC,CAAA;IAEpD,sFAAsF;IACtF,cAAc,CAAC,EAAE,OAAO,CAAA;IAExB;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,IAAI,CAAA;CAClC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,oBAAoB,GACrB,EAAE,gBAAgB,2CA+BlB"}
1
+ {"version":3,"file":"payment-step.d.ts","sourceRoot":"","sources":["../../src/components/payment-step.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,sBAAsB,IAAI,8BAA8B,EACxD,aAAa,EACb,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,0BAA0B,CAAA;AAMjC,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAA;AAEhD;;;GAGG;AACH,MAAM,WAAW,sBAAuB,SAAQ,8BAA8B;IAC5E,IAAI,CAAC,EAAE,SAAS,CAAA;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,aAAa,GAAG,IAAI,CAAA;IAC3B,QAAQ,EAAE,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI,KAAK,IAAI,CAAA;IAE9C;;;OAGG;IACH,YAAY,EAAE,uBAAuB,CAAA;IAErC,oFAAoF;IACpF,YAAY,CAAC,EAAE,mBAAmB,EAAE,CAAA;IACpC,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAE7B;;;OAGG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC,sBAAsB,CAAC,CAAA;IAEpD,sFAAsF;IACtF,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,cAAc,GACf,EAAE,gBAAgB,2CA4BlB"}
@@ -4,23 +4,22 @@ import { Input } from "@voyantjs/ui/components/input";
4
4
  import { Label } from "@voyantjs/ui/components/label";
5
5
  import { RadioGroup, RadioGroupItem } from "@voyantjs/ui/components/radio-group";
6
6
  import { cn } from "@voyantjs/ui/lib/utils";
7
- import { Banknote, CreditCard, Link2, Wallet } from "lucide-react";
7
+ import { Banknote, CreditCard, Wallet } from "lucide-react";
8
8
  import { useState } from "react";
9
9
  /**
10
- * Universal capability-gated payment picker. Renders sections based on
11
- * what the parent declares is actually wired, plus optional vertical-
12
- * specific extras and the universal Hold option.
10
+ * Admin-side payment picker. Renders the sections the parent has wired:
13
11
  *
14
- * Sections, in order:
15
12
  * - Saved cards on file ← capabilities.chargeSavedCard
16
- * - Send payment link ← capabilities.sendLink
17
13
  * - Charge a new card now ← capabilities.newCard
18
- * - Bank transfer ← capabilities.bankTransfer
19
14
  * - Vertical-specific extras ← always rendered (e.g. "Issue on credit")
20
- * - Hold seats pay later ← always rendered (unless hideHoldOption)
15
+ * - Hold — generate payment link ← always rendered (unless hideHoldOption)
16
+ *
17
+ * The customer's card-vs-bank-transfer decision happens on the public
18
+ * `/pay/:sessionId` landing page, not here. That keeps the admin UI to
19
+ * three real choices: charge now, vertical action, or hold + share link.
21
20
  */
22
- export function PaymentStep({ value, onChange, capabilities, savedMethods, loadingSavedMethods, extraOptions, hideHoldOption, onRequestPaymentLink, }) {
23
- return (_jsxs("div", { className: "flex flex-col gap-5", children: [_jsxs("div", { children: [_jsx("h2", { className: "font-semibold text-base", children: "Payment" }), _jsx("p", { className: "text-muted-foreground text-sm", children: "Pick a saved method or use a different payment option." })] }), capabilities.chargeSavedCard && (_jsx(SavedMethodsSection, { loading: loadingSavedMethods, methods: savedMethods ?? [], selectedId: value?.type === "saved_method" ? value.method.id : null, onSelect: (method) => onChange({ type: "saved_method", method }) })), _jsx(AltMethodsSection, { value: value, onChange: onChange, showNewCard: !!capabilities.newCard, showPaymentLink: !!capabilities.sendLink, showBankTransfer: !!capabilities.bankTransfer, extraOptions: extraOptions ?? [], hideHoldOption: hideHoldOption, onRequestPaymentLink: onRequestPaymentLink })] }));
21
+ export function PaymentStep({ value, onChange, capabilities, savedMethods, loadingSavedMethods, extraOptions, hideHoldOption, }) {
22
+ return (_jsxs("div", { className: "flex flex-col gap-5", children: [_jsxs("div", { children: [_jsx("h2", { className: "font-semibold text-base", children: "Payment" }), _jsx("p", { className: "text-muted-foreground text-sm", children: "Pick a saved method or use a different payment option." })] }), capabilities.chargeSavedCard && (_jsx(SavedMethodsSection, { loading: loadingSavedMethods, methods: savedMethods ?? [], selectedId: value?.type === "saved_method" ? value.method.id : null, onSelect: (method) => onChange({ type: "saved_method", method }) })), _jsx(AltMethodsSection, { value: value, onChange: onChange, showNewCard: !!capabilities.newCard, extraOptions: extraOptions ?? [], hideHoldOption: hideHoldOption })] }));
24
23
  }
25
24
  // ─────────────────────────────────────────────────────────────────────────────
26
25
  function SavedMethodsSection({ loading, methods, selectedId, onSelect, }) {
@@ -28,10 +27,10 @@ function SavedMethodsSection({ loading, methods, selectedId, onSelect, }) {
28
27
  const selected = selectedId === m.id;
29
28
  return (_jsx("li", { children: _jsxs("button", { type: "button", onClick: () => onSelect(m), className: cn("flex w-full items-center gap-3 rounded-md border bg-background p-3 text-left transition-colors", selected
30
29
  ? "border-primary ring-2 ring-primary/20"
31
- : "hover:border-primary/40 hover:bg-accent/30"), children: [_jsx(BrandTile, { brand: m.brand }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col leading-tight", children: [_jsxs("span", { className: "font-medium text-sm", children: [m.label, m.last4 && (_jsxs(_Fragment, { children: [" ···· ", _jsx("span", { className: "font-mono", children: m.last4 })] })), m.isDefault && (_jsx("span", { className: "ml-2 rounded-full bg-primary/10 px-1.5 py-0.5 font-medium text-[9px] text-primary uppercase tracking-wider", children: "Default" }))] }), m.expiryMonth && m.expiryYear && (_jsxs("span", { className: "text-muted-foreground text-xs", children: ["Expires ", String(m.expiryMonth).padStart(2, "0"), "/", m.expiryYear] }))] }), selected && (_jsx("span", { className: "font-medium text-primary text-xs", children: "Selected" }))] }) }, m.id));
30
+ : "hover:border-primary/40 hover:bg-accent/30"), children: [_jsx(BrandTile, { brand: m.brand }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col leading-tight", children: [_jsxs("span", { className: "font-medium text-sm", children: [m.label, m.last4 && (_jsxs(_Fragment, { children: [" ···· ", _jsx("span", { className: "font-mono", children: m.last4 })] })), m.isDefault && (_jsx("span", { className: "ml-2 rounded-full bg-primary/10 px-1.5 py-0.5 font-medium text-[9px] text-primary uppercase tracking-wider", children: "Default" }))] }), m.expiryMonth && m.expiryYear && (_jsxs("span", { className: "text-muted-foreground text-xs", children: ["Expires ", String(m.expiryMonth).padStart(2, "0"), "/", m.expiryYear] }))] }), selected && _jsx("span", { className: "font-medium text-primary text-xs", children: "Selected" })] }) }, m.id));
32
31
  }) }))] }));
33
32
  }
34
- function AltMethodsSection({ value, onChange, showNewCard, showPaymentLink, showBankTransfer, extraOptions, hideHoldOption, onRequestPaymentLink, }) {
33
+ function AltMethodsSection({ value, onChange, showNewCard, extraOptions, hideHoldOption, }) {
35
34
  const [newCardName, setNewCardName] = useState("");
36
35
  const [newCardNumber, setNewCardNumber] = useState("");
37
36
  const [newCardExp, setNewCardExp] = useState("");
@@ -42,10 +41,6 @@ function AltMethodsSection({ value, onChange, showNewCard, showPaymentLink, show
42
41
  return null;
43
42
  if (value.type === "new_card")
44
43
  return "new_card";
45
- if (value.type === "send_link")
46
- return "send_link";
47
- if (value.type === "bank_transfer")
48
- return "bank_transfer";
49
44
  if (value.type === "hold")
50
45
  return "hold";
51
46
  if (value.type === "extra")
@@ -64,13 +59,6 @@ function AltMethodsSection({ value, onChange, showNewCard, showPaymentLink, show
64
59
  ...(newCardExp ? { expiry: newCardExp } : {}),
65
60
  });
66
61
  }
67
- else if (id === "send_link") {
68
- onChange({ type: "send_link" });
69
- onRequestPaymentLink?.();
70
- }
71
- else if (id === "bank_transfer") {
72
- onChange({ type: "bank_transfer" });
73
- }
74
62
  else if (id.startsWith("extra:")) {
75
63
  onChange({ type: "extra", optionId: id.slice("extra:".length) });
76
64
  }
@@ -78,14 +66,10 @@ function AltMethodsSection({ value, onChange, showNewCard, showPaymentLink, show
78
66
  return (_jsxs("section", { className: "rounded-xl border bg-card p-5 shadow-sm", children: [_jsx("header", { className: "mb-3 flex items-center justify-between", children: _jsx("h3", { className: "font-medium text-sm", children: "Other payment options" }) }), _jsxs(RadioGroup, { value: activeId ?? "__none", onValueChange: (v) => {
79
67
  if (!v)
80
68
  return;
81
- if (v === "send_link" ||
82
- v === "new_card" ||
83
- v === "bank_transfer" ||
84
- v === "hold" ||
85
- v.startsWith("extra:")) {
69
+ if (v === "new_card" || v === "hold" || v.startsWith("extra:")) {
86
70
  setAlt(v);
87
71
  }
88
- }, className: "flex flex-col gap-2", children: [showPaymentLink && (_jsx(AltRow, { id: "send_link", icon: _jsx(Link2, { className: "h-4 w-4 text-muted-foreground" }), title: "Send payment link to customer", body: "Hold the order, generate a payment link, and email it for the customer to pay.", active: activeId === "send_link" })), showNewCard && (_jsx(AltRow, { id: "new_card", icon: _jsx(CreditCard, { className: "h-4 w-4 text-muted-foreground" }), title: "New credit / debit card", body: "Charge a one-off card now.", active: activeId === "new_card", children: activeId === "new_card" && (_jsxs("div", { className: "mt-3 grid grid-cols-1 gap-3 md:grid-cols-3", children: [_jsx(Field, { label: "Cardholder name", children: _jsx(Input, { value: newCardName, onChange: (e) => {
72
+ }, className: "flex flex-col gap-2", children: [showNewCard && (_jsx(AltRow, { id: "new_card", icon: _jsx(CreditCard, { className: "h-4 w-4 text-muted-foreground" }), title: "New credit / debit card", body: "Charge a one-off card now.", active: activeId === "new_card", children: activeId === "new_card" && (_jsxs("div", { className: "mt-3 grid grid-cols-1 gap-3 md:grid-cols-3", children: [_jsx(Field, { label: "Cardholder name", children: _jsx(Input, { value: newCardName, onChange: (e) => {
89
73
  setNewCardName(e.target.value);
90
74
  if (value?.type === "new_card") {
91
75
  onChange({ ...value, cardholderName: e.target.value });
@@ -100,12 +84,13 @@ function AltMethodsSection({ value, onChange, showNewCard, showPaymentLink, show
100
84
  if (value?.type === "new_card") {
101
85
  onChange({ ...value, expiry: e.target.value });
102
86
  }
103
- }, placeholder: "08/29" }) })] })) })), showBankTransfer && (_jsx(AltRow, { id: "bank_transfer", icon: _jsx(Banknote, { className: "h-4 w-4 text-muted-foreground" }), title: "Bank transfer", body: "Hold the order; customer pays by wire to the IBAN shown on the payment page.", active: activeId === "bank_transfer" })), extraOptions.map((opt) => (_jsx(AltRow, { id: `extra:${opt.id}`, icon: opt.icon, title: opt.label, body: opt.description, active: activeId === `extra:${opt.id}` }, opt.id))), !hideHoldOption && (_jsx(AltRow, { id: "hold", icon: _jsx(Wallet, { className: "h-4 w-4 text-muted-foreground" }), title: "Hold \u2014 pay later", body: "Lock the order; pay before the deadline to confirm.", active: activeId === "hold" }))] }), showNewCard && (_jsxs("p", { className: "mt-4 flex items-start gap-1.5 text-[11px] text-muted-foreground", children: [_jsx(Banknote, { className: "mt-0.5 h-3 w-3" }), "Card numbers entered here are tokenized in production via the processor's hosted form \u2014 never sent through this UI."] }))] }));
87
+ }, placeholder: "08/29" }) })] })) })), extraOptions.map((opt) => (_jsx(AltRow, { id: `extra:${opt.id}`, icon: opt.icon, title: opt.label, body: opt.description, active: activeId === `extra:${opt.id}` }, opt.id))), !hideHoldOption && (_jsx(AltRow, { id: "hold", icon: _jsx(Wallet, { className: "h-4 w-4 text-muted-foreground" }), title: "Hold \u2014 generate payment link", body: "Lock the order and generate a payment link the customer can open to pay by card or bank transfer. Share it however you prefer.", active: activeId === "hold" }))] }), showNewCard && (_jsxs("p", { className: "mt-4 flex items-start gap-1.5 text-[11px] text-muted-foreground", children: [_jsx(Banknote, { className: "mt-0.5 h-3 w-3" }), "Card numbers entered here are tokenized in production via the processor's hosted form \u2014 never sent through this UI."] }))] }));
104
88
  }
105
89
  function AltRow({ id, icon, title, body, active, children, }) {
106
- return (_jsxs("label", { className: cn("flex cursor-pointer items-start gap-3 rounded-md border bg-background p-3 transition-colors", active ? "border-primary bg-primary/5" : "hover:border-primary/40"), children: [_jsx(RadioGroupItem, { value: id, className: "mt-0.5" }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [_jsxs("span", { className: "flex items-center gap-2 font-medium text-sm", children: [icon, title] }), _jsx("span", { className: "text-muted-foreground text-xs", children: body }), children] })] }));
90
+ const inputId = `payment-step-${id}`;
91
+ return (_jsxs("div", { className: cn("flex items-start gap-3 rounded-md border bg-background p-3 transition-colors", active ? "border-primary bg-primary/5" : "hover:border-primary/40"), children: [_jsx(RadioGroupItem, { id: inputId, value: id, className: "mt-0.5" }), _jsxs("label", { htmlFor: inputId, className: "flex min-w-0 flex-1 cursor-pointer flex-col gap-1", children: [_jsxs("span", { className: "flex items-center gap-2 font-medium text-sm", children: [icon, title] }), _jsx("span", { className: "text-muted-foreground text-xs", children: body }), children] })] }));
107
92
  }
108
- function Field({ label, children, }) {
93
+ function Field({ label, children }) {
109
94
  return (_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx(Label, { className: "text-[11px] uppercase tracking-wider text-muted-foreground", children: label }), children] }));
110
95
  }
111
96
  function BrandTile({ brand }) {
package/dist/index.d.ts CHANGED
@@ -14,8 +14,8 @@
14
14
  *
15
15
  * See `docs/architecture/payments-architecture.md`.
16
16
  */
17
- export { type PaymentChoice, type PaymentStepCapabilities, type SavedPaymentAccount, } from "@voyantjs/checkout-react";
18
- export { type CollectPaymentDialogProps, CollectPaymentDialog, } from "./components/collect-payment-dialog.js";
17
+ export type { PaymentChoice, PaymentStepCapabilities, SavedPaymentAccount, } from "@voyantjs/checkout-react";
18
+ export { CollectPaymentDialog, type CollectPaymentDialogProps, } from "./components/collect-payment-dialog.js";
19
19
  export { type BankTransferInstructions, PaymentLinkLandingPage, type PaymentLinkLandingPageProps, } from "./components/payment-link-landing-page.js";
20
20
  export { PaymentStep, type PaymentStepExtraOption, type PaymentStepProps, } from "./components/payment-step.js";
21
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,GACzB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACL,KAAK,yBAAyB,EAC9B,oBAAoB,GACrB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EACL,KAAK,wBAAwB,EAC7B,sBAAsB,EACtB,KAAK,2BAA2B,GACjC,MAAM,2CAA2C,CAAA;AAClD,OAAO,EACL,WAAW,EACX,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,GACtB,MAAM,8BAA8B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,YAAY,EACV,aAAa,EACb,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACL,oBAAoB,EACpB,KAAK,yBAAyB,GAC/B,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EACL,KAAK,wBAAwB,EAC7B,sBAAsB,EACtB,KAAK,2BAA2B,GACjC,MAAM,2CAA2C,CAAA;AAClD,OAAO,EACL,WAAW,EACX,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,GACtB,MAAM,8BAA8B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyantjs/checkout-ui",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,68 +10,62 @@
10
10
  "type": "module",
11
11
  "sideEffects": false,
12
12
  "exports": {
13
- ".": "./src/index.ts",
14
- "./styles.css": "./src/styles.css",
15
- "./components/*": "./src/components/*.tsx"
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"
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js",
16
+ "default": "./dist/index.js"
17
+ },
18
+ "./styles.css": {
19
+ "default": "./src/styles.css"
20
+ },
21
+ "./components/*": {
22
+ "types": "./dist/components/*.d.ts",
23
+ "import": "./dist/components/*.js",
24
+ "default": "./dist/components/*.js"
25
+ }
24
26
  },
25
27
  "peerDependencies": {
26
- "@voyantjs/checkout": "workspace:*",
27
- "@voyantjs/checkout-react": "workspace:*",
28
- "@voyantjs/finance": "workspace:*",
29
- "@voyantjs/finance-react": "workspace:*",
30
- "@voyantjs/ui": "workspace:*",
31
28
  "@tanstack/react-query": "^5.0.0",
32
29
  "react": "^19.0.0",
33
30
  "react-dom": "^19.0.0",
34
- "sonner": "^2.0.0"
31
+ "sonner": "^2.0.0",
32
+ "@voyantjs/checkout": "0.20.0",
33
+ "@voyantjs/checkout-react": "0.20.0",
34
+ "@voyantjs/finance": "0.20.0",
35
+ "@voyantjs/finance-react": "0.20.0",
36
+ "@voyantjs/ui": "0.20.0"
35
37
  },
36
38
  "devDependencies": {
37
39
  "@tanstack/react-query": "^5.96.2",
38
40
  "@types/react": "^19.2.14",
39
41
  "@types/react-dom": "^19.2.3",
40
- "@voyantjs/checkout": "workspace:*",
41
- "@voyantjs/checkout-react": "workspace:*",
42
- "@voyantjs/finance": "workspace:*",
43
- "@voyantjs/finance-react": "workspace:*",
44
- "@voyantjs/ui": "workspace:*",
45
- "@voyantjs/voyant-typescript-config": "workspace:*",
46
42
  "lucide-react": "^0.475.0",
47
43
  "react": "^19.2.4",
48
44
  "react-dom": "^19.2.4",
49
45
  "sonner": "^2.0.7",
50
46
  "typescript": "^6.0.2",
51
- "vitest": "^4.1.2"
47
+ "vitest": "^4.1.2",
48
+ "@voyantjs/checkout": "0.20.0",
49
+ "@voyantjs/checkout-react": "0.20.0",
50
+ "@voyantjs/finance": "0.20.0",
51
+ "@voyantjs/finance-react": "0.20.0",
52
+ "@voyantjs/ui": "0.20.0",
53
+ "@voyantjs/voyant-typescript-config": "0.1.0"
52
54
  },
53
55
  "files": [
54
56
  "dist",
55
57
  "src/styles.css"
56
58
  ],
57
59
  "publishConfig": {
58
- "access": "public",
59
- "exports": {
60
- ".": {
61
- "types": "./dist/index.d.ts",
62
- "import": "./dist/index.js",
63
- "default": "./dist/index.js"
64
- },
65
- "./styles.css": {
66
- "default": "./src/styles.css"
67
- },
68
- "./components/*": {
69
- "types": "./dist/components/*.d.ts",
70
- "import": "./dist/components/*.js",
71
- "default": "./dist/components/*.js"
72
- }
73
- },
74
- "main": "./dist/index.js",
75
- "types": "./dist/index.d.ts"
76
- }
77
- }
60
+ "access": "public"
61
+ },
62
+ "scripts": {
63
+ "build": "tsc -p tsconfig.json",
64
+ "clean": "rm -rf dist",
65
+ "typecheck": "tsc --noEmit",
66
+ "lint": "biome check src/",
67
+ "test": "vitest run --passWithNoTests"
68
+ },
69
+ "main": "./dist/index.js",
70
+ "types": "./dist/index.d.ts"
71
+ }