@unseen_fi/ui 0.1.0 → 0.1.1

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.
@@ -13,4 +13,4 @@ import type { UnseenPayButtonProps } from "./types";
13
13
  * />
14
14
  * ```
15
15
  */
16
- export declare function UnseenPayButton({ amount, mint, reference, description, expiresIn, onSuccess, onError, onCreated, label, className, disabled, }: UnseenPayButtonProps): import("react/jsx-runtime").JSX.Element;
16
+ export declare function UnseenPayButton({ amount, mint, reference, description, expiresIn, onSuccess, onError, onCreated, createPaymentSession, label, className, disabled, }: UnseenPayButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -21,14 +21,14 @@ const wallets_1 = require("./wallets");
21
21
  * />
22
22
  * ```
23
23
  */
24
- function UnseenPayButton({ amount, mint, reference, description, expiresIn, onSuccess, onError, onCreated, label = "Pay with Unseen", className, disabled, }) {
24
+ function UnseenPayButton({ amount, mint, reference, description, expiresIn, onSuccess, onError, onCreated, createPaymentSession, label = "Pay with Unseen", className, disabled, }) {
25
25
  const [modalOpen, setModalOpen] = (0, react_1.useState)(false);
26
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("button", { className: className, style: className ? undefined : defaultButtonStyle, onClick: () => setModalOpen(true), disabled: disabled, children: [(0, jsx_runtime_1.jsx)(ShieldIcon, {}), label] }), modalOpen && ((0, jsx_runtime_1.jsx)(UnseenModal, { amount: amount, mint: mint, reference: reference, description: description, expiresIn: expiresIn, onSuccess: (p) => {
26
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("button", { className: className, style: className ? undefined : defaultButtonStyle, onClick: () => setModalOpen(true), disabled: disabled, children: [(0, jsx_runtime_1.jsx)(ShieldIcon, {}), label] }), modalOpen && ((0, jsx_runtime_1.jsx)(UnseenModal, { amount: amount, mint: mint, reference: reference, description: description, expiresIn: expiresIn, createPaymentSession: createPaymentSession, onSuccess: (p) => {
27
27
  onSuccess?.(p);
28
28
  setModalOpen(false);
29
29
  }, onError: onError, onCreated: onCreated, onClose: () => setModalOpen(false) }))] }));
30
30
  }
31
- function UnseenModal({ amount, mint, reference, description, expiresIn, onSuccess, onError, onCreated, onClose, }) {
31
+ function UnseenModal({ amount, mint, reference, description, expiresIn, createPaymentSession, onSuccess, onError, onCreated, onClose, }) {
32
32
  const { baseUrl } = (0, context_1.useUnseenConfig)();
33
33
  const { payment, createPayment } = (0, hooks_1.usePayment)();
34
34
  const { verify } = (0, hooks_1.useVerify)();
@@ -39,7 +39,11 @@ function UnseenModal({ amount, mint, reference, description, expiresIn, onSucces
39
39
  // ─── Create payment on mount ────────────────────────────────────────────
40
40
  (0, react_1.useEffect)(() => {
41
41
  let cancelled = false;
42
- createPayment({ amount, reference, description, mint, expiresIn })
42
+ // Prefer the server-side creator (storefront / no-apiKey flow) when supplied.
43
+ const initiator = createPaymentSession
44
+ ? () => createPaymentSession({ amount, reference, description, mint, expiresIn })
45
+ : () => createPayment({ amount, reference, description, mint, expiresIn });
46
+ initiator()
43
47
  .then((p) => {
44
48
  if (cancelled)
45
49
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unseen_fi/ui",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "React components for Unseen Pay — wallet picker modal, QR checkout, and payment button",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",