@nextblock-cms/ecom 0.12.8 → 0.12.11

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("react"),r=require("@nextblock-cms/ui"),j=require("lucide-react"),g=require("react-dom");function k({initialEnabledProviders:s,configStatus:i,credentials:t,saveAction:a,saveCredentialsAction:l}){const[d,c]=b.useState(s),[o,h]=b.useState(s);(o.stripe!==s.stripe||o.freemius!==s.freemius)&&(h(s),c(s));const p=i?.stripe?.hasKeys,m=i?.freemius?.hasKeys;return e.jsxs("div",{className:"space-y-6 max-w-3xl p-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Payment Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Enter your provider API keys, then enable the providers your store needs. Physical products use Stripe and digital products use Freemius."})]}),e.jsx(N,{credentials:t,saveAction:l}),e.jsxs("form",{action:a,className:"space-y-6",children:[e.jsx("input",{type:"hidden",name:"stripe_enabled",value:d.stripe?"true":"false"}),e.jsx("input",{type:"hidden",name:"freemius_enabled",value:d.freemius?"true":"false"}),e.jsxs(r.Card,{children:[e.jsxs(r.CardHeader,{children:[e.jsx(r.CardTitle,{children:"Payment Providers"}),e.jsx(r.CardDescription,{children:"You can run both providers at the same time. Each product picks its provider from its product type."})]}),e.jsxs(r.CardContent,{className:"space-y-6",children:[e.jsx(f,{id:"stripe-enabled",label:"Stripe for Physical Products",description:"Use Stripe Checkout for physical merchandise and other shippable goods.",checked:d.stripe,disabled:!p,onCheckedChange:u=>c(x=>({...x,stripe:u})),ready:p,children:p?e.jsxs("div",{className:"mt-2 text-sm text-green-600 flex items-center gap-2",children:[e.jsx(j.CheckCircle2,{className:"w-4 h-4"}),e.jsx("span",{children:"Ready to process physical product checkout"})]}):e.jsx(y,{provider:"Stripe",missingKeys:i.stripe.missing,docsUrl:"https://dashboard.stripe.com/apikeys",docsLabel:"Stripe Dashboard -> Developers -> API Keys"})}),e.jsx(f,{id:"freemius-enabled",label:"Freemius for Digital Products",description:"Use Freemius for software licenses, SaaS plans, and other digital products.",checked:d.freemius,disabled:!m,onCheckedChange:u=>c(x=>({...x,freemius:u})),ready:m,children:m?e.jsxs("div",{className:"mt-2 text-sm text-green-600 flex items-center gap-2",children:[e.jsx(j.CheckCircle2,{className:"w-4 h-4"}),e.jsx("span",{children:"Ready to process digital product checkout"})]}):e.jsx(y,{provider:"Freemius",missingKeys:i.freemius.missing,docsUrl:"https://dashboard.freemius.com/",docsLabel:"Freemius Dashboard -> Developers -> Credentials"})}),e.jsx("div",{className:"flex justify-end pt-4",children:e.jsx(v,{})})]})]})]})]})}function v(){const{pending:s}=g.useFormStatus();return e.jsx(r.Button,{type:"submit",disabled:s,children:s?"Saving...":"Save Changes"})}function n({id:s,label:i,type:t="text",defaultValue:a,placeholder:l,hint:d}){return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r.Label,{htmlFor:s,children:i}),e.jsx(r.Input,{id:s,name:s,type:t,defaultValue:a,placeholder:l,autoComplete:t==="password"?"new-password":"off"}),d&&e.jsx("p",{className:"text-xs text-muted-foreground",children:d})]})}function N({credentials:s,saveAction:i}){const t="•••••••• (stored — leave blank to keep)";return e.jsxs(r.Card,{children:[e.jsxs(r.CardHeader,{children:[e.jsx(r.CardTitle,{children:"Provider API Keys"}),e.jsxs(r.CardDescription,{children:["Keys are encrypted at rest and used DB-first (these override any ",e.jsx("code",{children:".env"})," ","values). Leave a secret blank to keep the stored value."]})]}),e.jsx(r.CardContent,{children:e.jsxs("form",{action:i,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Stripe (physical products)"}),e.jsxs("div",{className:"rounded-md border border-dashed p-3 text-xs text-muted-foreground space-y-1.5",children:[e.jsxs("p",{children:["In the Stripe Dashboard (Developers → Webhooks → Add endpoint), set the endpoint URL to ",e.jsx("code",{children:"https://your-domain/api/webhooks/stripe"}),", then paste that endpoint's signing secret below."]}),e.jsxs("p",{children:["For local testing, forward events with the Stripe CLI:"," ",e.jsx("code",{children:"stripe listen --forward-to localhost:4200/api/webhooks/stripe"})," ","(or ",e.jsx("code",{children:"npm run stripe"}),"). Use the ",e.jsx("code",{children:"whsec_…"})," secret it prints on startup as the signing secret below — it differs from a Dashboard endpoint's."]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsx(n,{id:"stripe_publishableKey",label:"Publishable key",defaultValue:s.stripe.publishableKey,placeholder:"pk_live_…"}),e.jsx(n,{id:"stripe_secretKey",label:"Secret key",type:"password",placeholder:s.stripe.hasSecretKey?t:"sk_live_…"}),e.jsx(n,{id:"stripe_webhookSecret",label:"Webhook signing secret",type:"password",placeholder:s.stripe.hasWebhookSecret?t:"whsec_…"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Freemius (digital products)"}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsx(n,{id:"freemius_developerId",label:"Developer ID",defaultValue:s.freemius.developerId}),e.jsx(n,{id:"freemius_productId",label:"Product ID",defaultValue:s.freemius.productId}),e.jsx(n,{id:"freemius_publicKey",label:"Public key",defaultValue:s.freemius.publicKey,placeholder:"pk_…"}),e.jsx(n,{id:"freemius_secretKey",label:"Secret key",type:"password",placeholder:s.freemius.hasSecretKey?t:"sk_…"}),e.jsx(n,{id:"freemius_apiKey",label:"API key",type:"password",placeholder:s.freemius.hasApiKey?t:"API key"})]})]}),s.envFallbackActive&&e.jsx("p",{className:"text-xs text-amber-700",children:"Stripe keys are currently read from environment variables. Saving here moves them into the database and takes precedence."}),e.jsx("div",{className:"flex justify-end",children:e.jsx(v,{})})]})})]})}function f({id:s,label:i,description:t,checked:a,disabled:l,ready:d,onCheckedChange:c,children:o}){return e.jsx("div",{className:"rounded-md border p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(r.Checkbox,{id:s,checked:a,disabled:l,onCheckedChange:h=>c(!!h),className:"mt-1"}),e.jsxs("div",{className:"grid gap-1.5 leading-none w-full",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsx(r.Label,{htmlFor:s,className:"font-semibold text-base cursor-pointer",children:i}),e.jsx("span",{className:`text-xs font-medium ${a?"text-foreground":"text-muted-foreground"}`,children:a?"Enabled":"Disabled"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t}),!d&&e.jsx("p",{className:"text-xs text-amber-700",children:"This provider cannot be enabled until all required environment variables are present."}),o]})]})})}function y({provider:s,missingKeys:i,docsUrl:t,docsLabel:a}){return e.jsxs("div",{className:"mt-3 text-sm p-4 rounded-md border border-destructive/20 bg-destructive/5 text-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2 font-semibold text-destructive mb-2",children:[e.jsx(j.AlertCircle,{className:"w-4 h-4"}),e.jsx("span",{children:"Configuration Required"})]}),e.jsxs("p",{className:"mb-2",children:["The ",s," integration still needs the following:"]}),e.jsx("ul",{className:"list-disc list-inside bg-white/50 dark:bg-black/20 p-2 rounded mb-3 text-xs",children:i.map(l=>e.jsx("li",{children:l},l))}),e.jsx("p",{className:"mb-2",children:e.jsx("strong",{children:"How to fix:"})}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 ml-1 mb-3",children:[e.jsxs("li",{children:["Get your API keys from"," ",e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"underline font-medium hover:text-destructive/80",children:a}),"."]}),e.jsxs("li",{children:["Enter them in the ",e.jsx("strong",{children:"Provider API Keys"})," section above and save."]}),e.jsx("li",{children:"This provider can then be enabled."})]})]})}exports.PaymentsClient=k;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),f=require("react"),k=require("next/navigation"),r=require("@nextblock-cms/ui"),b=require("lucide-react"),N=require("react-dom");function C({initialEnabledProviders:s,configStatus:i,credentials:t,saveAction:a,saveCredentialsAction:d}){const o=k.useRouter(),[h,p]=f.useTransition(),[c,j]=f.useState(s),m=i?.stripe?.hasKeys,u=i?.freemius?.hasKeys;function g(){const n=new FormData;n.set("stripe_enabled",c.stripe?"true":"false"),n.set("freemius_enabled",c.freemius?"true":"false"),p(async()=>{await a(n),o.refresh()})}return e.jsxs("div",{className:"space-y-6 max-w-3xl p-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Payment Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Enter your provider API keys, then enable the providers your store needs. Physical products use Stripe and digital products use Freemius."})]}),e.jsx(S,{credentials:t,saveAction:d}),e.jsx("div",{className:"space-y-6",children:e.jsxs(r.Card,{children:[e.jsxs(r.CardHeader,{children:[e.jsx(r.CardTitle,{children:"Payment Providers"}),e.jsx(r.CardDescription,{children:"You can run both providers at the same time. Each product picks its provider from its product type."})]}),e.jsxs(r.CardContent,{className:"space-y-6",children:[e.jsx(v,{id:"stripe-enabled",label:"Stripe for Physical Products",description:"Use Stripe Checkout for physical merchandise and other shippable goods.",checked:c.stripe,disabled:!m,onCheckedChange:n=>j(x=>({...x,stripe:n})),ready:m,children:m?e.jsxs("div",{className:"mt-2 text-sm text-green-600 flex items-center gap-2",children:[e.jsx(b.CheckCircle2,{className:"w-4 h-4"}),e.jsx("span",{children:"Ready to process physical product checkout"})]}):e.jsx(y,{provider:"Stripe",missingKeys:i.stripe.missing,docsUrl:"https://dashboard.stripe.com/apikeys",docsLabel:"Stripe Dashboard -> Developers -> API Keys"})}),e.jsx(v,{id:"freemius-enabled",label:"Freemius for Digital Products",description:"Use Freemius for software licenses, SaaS plans, and other digital products.",checked:c.freemius,disabled:!u,onCheckedChange:n=>j(x=>({...x,freemius:n})),ready:u,children:u?e.jsxs("div",{className:"mt-2 text-sm text-green-600 flex items-center gap-2",children:[e.jsx(b.CheckCircle2,{className:"w-4 h-4"}),e.jsx("span",{children:"Ready to process digital product checkout"})]}):e.jsx(y,{provider:"Freemius",missingKeys:i.freemius.missing,docsUrl:"https://dashboard.freemius.com/",docsLabel:"Freemius Dashboard -> Developers -> Credentials"})}),e.jsx("div",{className:"flex justify-end pt-4",children:e.jsx(r.Button,{type:"button",disabled:h,onClick:g,children:h?"Saving...":"Save Changes"})})]})]})})]})}function w(){const{pending:s}=N.useFormStatus();return e.jsx(r.Button,{type:"submit",disabled:s,children:s?"Saving...":"Save Changes"})}function l({id:s,label:i,type:t="text",defaultValue:a,placeholder:d,hint:o}){return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r.Label,{htmlFor:s,children:i}),e.jsx(r.Input,{id:s,name:s,type:t,defaultValue:a,placeholder:d,autoComplete:t==="password"?"new-password":"off"}),o&&e.jsx("p",{className:"text-xs text-muted-foreground",children:o})]})}function S({credentials:s,saveAction:i}){const t="•••••••• (stored — leave blank to keep)";return e.jsxs(r.Card,{children:[e.jsxs(r.CardHeader,{children:[e.jsx(r.CardTitle,{children:"Provider API Keys"}),e.jsxs(r.CardDescription,{children:["Keys are encrypted at rest and used DB-first (these override any ",e.jsx("code",{children:".env"})," ","values). Leave a secret blank to keep the stored value."]})]}),e.jsx(r.CardContent,{children:e.jsxs("form",{action:i,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Stripe (physical products)"}),e.jsxs("div",{className:"rounded-md border border-dashed p-3 text-xs text-muted-foreground space-y-1.5",children:[e.jsxs("p",{children:["In the Stripe Dashboard (Developers → Webhooks → Add endpoint), set the endpoint URL to ",e.jsx("code",{children:"https://your-domain/api/webhooks/stripe"}),", then paste that endpoint's signing secret below."]}),e.jsxs("p",{children:["For local testing, forward events with the Stripe CLI:"," ",e.jsx("code",{children:"stripe listen --forward-to localhost:4200/api/webhooks/stripe"})," ","(or ",e.jsx("code",{children:"npm run stripe"}),"). Use the ",e.jsx("code",{children:"whsec_…"})," secret it prints on startup as the signing secret below — it differs from a Dashboard endpoint's."]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsx(l,{id:"stripe_publishableKey",label:"Publishable key",defaultValue:s.stripe.publishableKey,placeholder:"pk_live_…"}),e.jsx(l,{id:"stripe_secretKey",label:"Secret key",type:"password",placeholder:s.stripe.hasSecretKey?t:"sk_live_…"}),e.jsx(l,{id:"stripe_webhookSecret",label:"Webhook signing secret",type:"password",placeholder:s.stripe.hasWebhookSecret?t:"whsec_…"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Freemius (digital products)"}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsx(l,{id:"freemius_developerId",label:"Developer ID",defaultValue:s.freemius.developerId}),e.jsx(l,{id:"freemius_productId",label:"Product ID",defaultValue:s.freemius.productId}),e.jsx(l,{id:"freemius_publicKey",label:"Public key",defaultValue:s.freemius.publicKey,placeholder:"pk_…"}),e.jsx(l,{id:"freemius_secretKey",label:"Secret key",type:"password",placeholder:s.freemius.hasSecretKey?t:"sk_…"}),e.jsx(l,{id:"freemius_apiKey",label:"API key",type:"password",placeholder:s.freemius.hasApiKey?t:"API key"})]})]}),s.envFallbackActive&&e.jsx("p",{className:"text-xs text-amber-700",children:"Stripe keys are currently read from environment variables. Saving here moves them into the database and takes precedence."}),e.jsx("div",{className:"flex justify-end",children:e.jsx(w,{})})]})})]})}function v({id:s,label:i,description:t,checked:a,disabled:d,ready:o,onCheckedChange:h,children:p}){return e.jsx("div",{className:"rounded-md border p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(r.Checkbox,{id:s,checked:a,disabled:d,onCheckedChange:c=>h(!!c),className:"mt-1"}),e.jsxs("div",{className:"grid gap-1.5 leading-none w-full",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsx(r.Label,{htmlFor:s,className:"font-semibold text-base cursor-pointer",children:i}),e.jsx("span",{className:`text-xs font-medium ${a?"text-foreground":"text-muted-foreground"}`,children:a?"Enabled":"Disabled"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t}),!o&&e.jsx("p",{className:"text-xs text-amber-700",children:"This provider cannot be enabled until all required environment variables are present."}),p]})]})})}function y({provider:s,missingKeys:i,docsUrl:t,docsLabel:a}){return e.jsxs("div",{className:"mt-3 text-sm p-4 rounded-md border border-destructive/20 bg-destructive/5 text-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2 font-semibold text-destructive mb-2",children:[e.jsx(b.AlertCircle,{className:"w-4 h-4"}),e.jsx("span",{children:"Configuration Required"})]}),e.jsxs("p",{className:"mb-2",children:["The ",s," integration still needs the following:"]}),e.jsx("ul",{className:"list-disc list-inside bg-white/50 dark:bg-black/20 p-2 rounded mb-3 text-xs",children:i.map(d=>e.jsx("li",{children:d},d))}),e.jsx("p",{className:"mb-2",children:e.jsx("strong",{children:"How to fix:"})}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 ml-1 mb-3",children:[e.jsxs("li",{children:["Get your API keys from"," ",e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"underline font-medium hover:text-destructive/80",children:a}),"."]}),e.jsxs("li",{children:["Enter them in the ",e.jsx("strong",{children:"Provider API Keys"})," section above and save."]}),e.jsx("li",{children:"This provider can then be enabled."})]})]})}exports.PaymentsClient=C;
@@ -1,144 +1,131 @@
1
1
  'use client';
2
2
  import { jsxs as r, jsx as e } from "react/jsx-runtime";
3
- import { useState as b } from "react";
4
- import { Card as x, CardHeader as N, CardTitle as k, CardDescription as w, CardContent as C, Checkbox as K, Label as S, Button as _, Input as I } from "@nextblock-cms/ui";
5
- import { CheckCircle2 as y, AlertCircle as D } from "lucide-react";
6
- import { useFormStatus as F } from "react-dom";
7
- function T({
3
+ import { useTransition as _, useState as D } from "react";
4
+ import { useRouter as I } from "next/navigation";
5
+ import { Card as x, CardHeader as k, CardTitle as N, CardDescription as w, CardContent as C, Button as S, Checkbox as F, Label as P, Input as A } from "@nextblock-cms/ui";
6
+ import { CheckCircle2 as v, AlertCircle as R } from "lucide-react";
7
+ import { useFormStatus as L } from "react-dom";
8
+ function G({
8
9
  initialEnabledProviders: s,
9
- configStatus: i,
10
- credentials: t,
10
+ configStatus: t,
11
+ credentials: i,
11
12
  saveAction: a,
12
- saveCredentialsAction: l
13
+ saveCredentialsAction: d
13
14
  }) {
14
- const [d, o] = b(s), [c, p] = b(s);
15
- (c.stripe !== s.stripe || c.freemius !== s.freemius) && (p(s), o(s));
16
- const h = i?.stripe?.hasKeys, m = i?.freemius?.hasKeys;
15
+ const o = I(), [h, p] = _(), [c, f] = D(s), m = t?.stripe?.hasKeys, u = t?.freemius?.hasKeys;
16
+ function K() {
17
+ const n = new FormData();
18
+ n.set("stripe_enabled", c.stripe ? "true" : "false"), n.set("freemius_enabled", c.freemius ? "true" : "false"), p(async () => {
19
+ await a(n), o.refresh();
20
+ });
21
+ }
17
22
  return /* @__PURE__ */ r("div", { className: "space-y-6 max-w-3xl p-8", children: [
18
23
  /* @__PURE__ */ r("div", { children: [
19
24
  /* @__PURE__ */ e("h1", { className: "text-3xl font-bold tracking-tight", children: "Payment Settings" }),
20
25
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "Enter your provider API keys, then enable the providers your store needs. Physical products use Stripe and digital products use Freemius." })
21
26
  ] }),
22
- /* @__PURE__ */ e(A, { credentials: t, saveAction: l }),
23
- /* @__PURE__ */ r("form", { action: a, className: "space-y-6", children: [
24
- /* @__PURE__ */ e(
25
- "input",
26
- {
27
- type: "hidden",
28
- name: "stripe_enabled",
29
- value: d.stripe ? "true" : "false"
30
- }
31
- ),
32
- /* @__PURE__ */ e(
33
- "input",
34
- {
35
- type: "hidden",
36
- name: "freemius_enabled",
37
- value: d.freemius ? "true" : "false"
38
- }
39
- ),
40
- /* @__PURE__ */ r(x, { children: [
41
- /* @__PURE__ */ r(N, { children: [
42
- /* @__PURE__ */ e(k, { children: "Payment Providers" }),
43
- /* @__PURE__ */ e(w, { children: "You can run both providers at the same time. Each product picks its provider from its product type." })
44
- ] }),
45
- /* @__PURE__ */ r(C, { className: "space-y-6", children: [
46
- /* @__PURE__ */ e(
47
- v,
48
- {
49
- id: "stripe-enabled",
50
- label: "Stripe for Physical Products",
51
- description: "Use Stripe Checkout for physical merchandise and other shippable goods.",
52
- checked: d.stripe,
53
- disabled: !h,
54
- onCheckedChange: (u) => o((f) => ({
55
- ...f,
56
- stripe: u
57
- })),
58
- ready: h,
59
- children: h ? /* @__PURE__ */ r("div", { className: "mt-2 text-sm text-green-600 flex items-center gap-2", children: [
60
- /* @__PURE__ */ e(y, { className: "w-4 h-4" }),
61
- /* @__PURE__ */ e("span", { children: "Ready to process physical product checkout" })
62
- ] }) : /* @__PURE__ */ e(
63
- g,
64
- {
65
- provider: "Stripe",
66
- missingKeys: i.stripe.missing,
67
- docsUrl: "https://dashboard.stripe.com/apikeys",
68
- docsLabel: "Stripe Dashboard -> Developers -> API Keys"
69
- }
70
- )
71
- }
72
- ),
73
- /* @__PURE__ */ e(
74
- v,
75
- {
76
- id: "freemius-enabled",
77
- label: "Freemius for Digital Products",
78
- description: "Use Freemius for software licenses, SaaS plans, and other digital products.",
79
- checked: d.freemius,
80
- disabled: !m,
81
- onCheckedChange: (u) => o((f) => ({
82
- ...f,
83
- freemius: u
84
- })),
85
- ready: m,
86
- children: m ? /* @__PURE__ */ r("div", { className: "mt-2 text-sm text-green-600 flex items-center gap-2", children: [
87
- /* @__PURE__ */ e(y, { className: "w-4 h-4" }),
88
- /* @__PURE__ */ e("span", { children: "Ready to process digital product checkout" })
89
- ] }) : /* @__PURE__ */ e(
90
- g,
91
- {
92
- provider: "Freemius",
93
- missingKeys: i.freemius.missing,
94
- docsUrl: "https://dashboard.freemius.com/",
95
- docsLabel: "Freemius Dashboard -> Developers -> Credentials"
96
- }
97
- )
98
- }
99
- ),
100
- /* @__PURE__ */ e("div", { className: "flex justify-end pt-4", children: /* @__PURE__ */ e(P, {}) })
101
- ] })
27
+ /* @__PURE__ */ e(U, { credentials: i, saveAction: d }),
28
+ /* @__PURE__ */ e("div", { className: "space-y-6", children: /* @__PURE__ */ r(x, { children: [
29
+ /* @__PURE__ */ r(k, { children: [
30
+ /* @__PURE__ */ e(N, { children: "Payment Providers" }),
31
+ /* @__PURE__ */ e(w, { children: "You can run both providers at the same time. Each product picks its provider from its product type." })
32
+ ] }),
33
+ /* @__PURE__ */ r(C, { className: "space-y-6", children: [
34
+ /* @__PURE__ */ e(
35
+ y,
36
+ {
37
+ id: "stripe-enabled",
38
+ label: "Stripe for Physical Products",
39
+ description: "Use Stripe Checkout for physical merchandise and other shippable goods.",
40
+ checked: c.stripe,
41
+ disabled: !m,
42
+ onCheckedChange: (n) => f((b) => ({
43
+ ...b,
44
+ stripe: n
45
+ })),
46
+ ready: m,
47
+ children: m ? /* @__PURE__ */ r("div", { className: "mt-2 text-sm text-green-600 flex items-center gap-2", children: [
48
+ /* @__PURE__ */ e(v, { className: "w-4 h-4" }),
49
+ /* @__PURE__ */ e("span", { children: "Ready to process physical product checkout" })
50
+ ] }) : /* @__PURE__ */ e(
51
+ g,
52
+ {
53
+ provider: "Stripe",
54
+ missingKeys: t.stripe.missing,
55
+ docsUrl: "https://dashboard.stripe.com/apikeys",
56
+ docsLabel: "Stripe Dashboard -> Developers -> API Keys"
57
+ }
58
+ )
59
+ }
60
+ ),
61
+ /* @__PURE__ */ e(
62
+ y,
63
+ {
64
+ id: "freemius-enabled",
65
+ label: "Freemius for Digital Products",
66
+ description: "Use Freemius for software licenses, SaaS plans, and other digital products.",
67
+ checked: c.freemius,
68
+ disabled: !u,
69
+ onCheckedChange: (n) => f((b) => ({
70
+ ...b,
71
+ freemius: n
72
+ })),
73
+ ready: u,
74
+ children: u ? /* @__PURE__ */ r("div", { className: "mt-2 text-sm text-green-600 flex items-center gap-2", children: [
75
+ /* @__PURE__ */ e(v, { className: "w-4 h-4" }),
76
+ /* @__PURE__ */ e("span", { children: "Ready to process digital product checkout" })
77
+ ] }) : /* @__PURE__ */ e(
78
+ g,
79
+ {
80
+ provider: "Freemius",
81
+ missingKeys: t.freemius.missing,
82
+ docsUrl: "https://dashboard.freemius.com/",
83
+ docsLabel: "Freemius Dashboard -> Developers -> Credentials"
84
+ }
85
+ )
86
+ }
87
+ ),
88
+ /* @__PURE__ */ e("div", { className: "flex justify-end pt-4", children: /* @__PURE__ */ e(S, { type: "button", disabled: h, onClick: K, children: h ? "Saving..." : "Save Changes" }) })
102
89
  ] })
103
- ] })
90
+ ] }) })
104
91
  ] });
105
92
  }
106
- function P() {
107
- const { pending: s } = F();
108
- return /* @__PURE__ */ e(_, { type: "submit", disabled: s, children: s ? "Saving..." : "Save Changes" });
93
+ function T() {
94
+ const { pending: s } = L();
95
+ return /* @__PURE__ */ e(S, { type: "submit", disabled: s, children: s ? "Saving..." : "Save Changes" });
109
96
  }
110
- function n({
97
+ function l({
111
98
  id: s,
112
- label: i,
113
- type: t = "text",
99
+ label: t,
100
+ type: i = "text",
114
101
  defaultValue: a,
115
- placeholder: l,
116
- hint: d
102
+ placeholder: d,
103
+ hint: o
117
104
  }) {
118
105
  return /* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
119
- /* @__PURE__ */ e(S, { htmlFor: s, children: i }),
106
+ /* @__PURE__ */ e(P, { htmlFor: s, children: t }),
120
107
  /* @__PURE__ */ e(
121
- I,
108
+ A,
122
109
  {
123
110
  id: s,
124
111
  name: s,
125
- type: t,
112
+ type: i,
126
113
  defaultValue: a,
127
- placeholder: l,
128
- autoComplete: t === "password" ? "new-password" : "off"
114
+ placeholder: d,
115
+ autoComplete: i === "password" ? "new-password" : "off"
129
116
  }
130
117
  ),
131
- d && /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: d })
118
+ o && /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: o })
132
119
  ] });
133
120
  }
134
- function A({
121
+ function U({
135
122
  credentials: s,
136
- saveAction: i
123
+ saveAction: t
137
124
  }) {
138
- const t = "•••••••• (stored — leave blank to keep)";
125
+ const i = "•••••••• (stored — leave blank to keep)";
139
126
  return /* @__PURE__ */ r(x, { children: [
140
- /* @__PURE__ */ r(N, { children: [
141
- /* @__PURE__ */ e(k, { children: "Provider API Keys" }),
127
+ /* @__PURE__ */ r(k, { children: [
128
+ /* @__PURE__ */ e(N, { children: "Provider API Keys" }),
142
129
  /* @__PURE__ */ r(w, { children: [
143
130
  "Keys are encrypted at rest and used DB-first (these override any ",
144
131
  /* @__PURE__ */ e("code", { children: ".env" }),
@@ -146,7 +133,7 @@ function A({
146
133
  "values). Leave a secret blank to keep the stored value."
147
134
  ] })
148
135
  ] }),
149
- /* @__PURE__ */ e(C, { children: /* @__PURE__ */ r("form", { action: i, className: "space-y-6", children: [
136
+ /* @__PURE__ */ e(C, { children: /* @__PURE__ */ r("form", { action: t, className: "space-y-6", children: [
150
137
  /* @__PURE__ */ r("div", { className: "space-y-4", children: [
151
138
  /* @__PURE__ */ e("h3", { className: "text-sm font-semibold", children: "Stripe (physical products)" }),
152
139
  /* @__PURE__ */ r("div", { className: "rounded-md border border-dashed p-3 text-xs text-muted-foreground space-y-1.5", children: [
@@ -169,7 +156,7 @@ function A({
169
156
  ] }),
170
157
  /* @__PURE__ */ r("div", { className: "grid gap-4 sm:grid-cols-2", children: [
171
158
  /* @__PURE__ */ e(
172
- n,
159
+ l,
173
160
  {
174
161
  id: "stripe_publishableKey",
175
162
  label: "Publishable key",
@@ -178,21 +165,21 @@ function A({
178
165
  }
179
166
  ),
180
167
  /* @__PURE__ */ e(
181
- n,
168
+ l,
182
169
  {
183
170
  id: "stripe_secretKey",
184
171
  label: "Secret key",
185
172
  type: "password",
186
- placeholder: s.stripe.hasSecretKey ? t : "sk_live_…"
173
+ placeholder: s.stripe.hasSecretKey ? i : "sk_live_…"
187
174
  }
188
175
  ),
189
176
  /* @__PURE__ */ e(
190
- n,
177
+ l,
191
178
  {
192
179
  id: "stripe_webhookSecret",
193
180
  label: "Webhook signing secret",
194
181
  type: "password",
195
- placeholder: s.stripe.hasWebhookSecret ? t : "whsec_…"
182
+ placeholder: s.stripe.hasWebhookSecret ? i : "whsec_…"
196
183
  }
197
184
  )
198
185
  ] })
@@ -201,7 +188,7 @@ function A({
201
188
  /* @__PURE__ */ e("h3", { className: "text-sm font-semibold", children: "Freemius (digital products)" }),
202
189
  /* @__PURE__ */ r("div", { className: "grid gap-4 sm:grid-cols-2", children: [
203
190
  /* @__PURE__ */ e(
204
- n,
191
+ l,
205
192
  {
206
193
  id: "freemius_developerId",
207
194
  label: "Developer ID",
@@ -209,7 +196,7 @@ function A({
209
196
  }
210
197
  ),
211
198
  /* @__PURE__ */ e(
212
- n,
199
+ l,
213
200
  {
214
201
  id: "freemius_productId",
215
202
  label: "Product ID",
@@ -217,7 +204,7 @@ function A({
217
204
  }
218
205
  ),
219
206
  /* @__PURE__ */ e(
220
- n,
207
+ l,
221
208
  {
222
209
  id: "freemius_publicKey",
223
210
  label: "Public key",
@@ -226,54 +213,54 @@ function A({
226
213
  }
227
214
  ),
228
215
  /* @__PURE__ */ e(
229
- n,
216
+ l,
230
217
  {
231
218
  id: "freemius_secretKey",
232
219
  label: "Secret key",
233
220
  type: "password",
234
- placeholder: s.freemius.hasSecretKey ? t : "sk_…"
221
+ placeholder: s.freemius.hasSecretKey ? i : "sk_…"
235
222
  }
236
223
  ),
237
224
  /* @__PURE__ */ e(
238
- n,
225
+ l,
239
226
  {
240
227
  id: "freemius_apiKey",
241
228
  label: "API key",
242
229
  type: "password",
243
- placeholder: s.freemius.hasApiKey ? t : "API key"
230
+ placeholder: s.freemius.hasApiKey ? i : "API key"
244
231
  }
245
232
  )
246
233
  ] })
247
234
  ] }),
248
235
  s.envFallbackActive && /* @__PURE__ */ e("p", { className: "text-xs text-amber-700", children: "Stripe keys are currently read from environment variables. Saving here moves them into the database and takes precedence." }),
249
- /* @__PURE__ */ e("div", { className: "flex justify-end", children: /* @__PURE__ */ e(P, {}) })
236
+ /* @__PURE__ */ e("div", { className: "flex justify-end", children: /* @__PURE__ */ e(T, {}) })
250
237
  ] }) })
251
238
  ] });
252
239
  }
253
- function v({
240
+ function y({
254
241
  id: s,
255
- label: i,
256
- description: t,
242
+ label: t,
243
+ description: i,
257
244
  checked: a,
258
- disabled: l,
259
- ready: d,
260
- onCheckedChange: o,
261
- children: c
245
+ disabled: d,
246
+ ready: o,
247
+ onCheckedChange: h,
248
+ children: p
262
249
  }) {
263
250
  return /* @__PURE__ */ e("div", { className: "rounded-md border p-4", children: /* @__PURE__ */ r("div", { className: "flex items-start gap-3", children: [
264
251
  /* @__PURE__ */ e(
265
- K,
252
+ F,
266
253
  {
267
254
  id: s,
268
255
  checked: a,
269
- disabled: l,
270
- onCheckedChange: (p) => o(!!p),
256
+ disabled: d,
257
+ onCheckedChange: (c) => h(!!c),
271
258
  className: "mt-1"
272
259
  }
273
260
  ),
274
261
  /* @__PURE__ */ r("div", { className: "grid gap-1.5 leading-none w-full", children: [
275
262
  /* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-3 flex-wrap", children: [
276
- /* @__PURE__ */ e(S, { htmlFor: s, className: "font-semibold text-base cursor-pointer", children: i }),
263
+ /* @__PURE__ */ e(P, { htmlFor: s, className: "font-semibold text-base cursor-pointer", children: t }),
277
264
  /* @__PURE__ */ e(
278
265
  "span",
279
266
  {
@@ -282,21 +269,21 @@ function v({
282
269
  }
283
270
  )
284
271
  ] }),
285
- /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t }),
286
- !d && /* @__PURE__ */ e("p", { className: "text-xs text-amber-700", children: "This provider cannot be enabled until all required environment variables are present." }),
287
- c
272
+ /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: i }),
273
+ !o && /* @__PURE__ */ e("p", { className: "text-xs text-amber-700", children: "This provider cannot be enabled until all required environment variables are present." }),
274
+ p
288
275
  ] })
289
276
  ] }) });
290
277
  }
291
278
  function g({
292
279
  provider: s,
293
- missingKeys: i,
294
- docsUrl: t,
280
+ missingKeys: t,
281
+ docsUrl: i,
295
282
  docsLabel: a
296
283
  }) {
297
284
  return /* @__PURE__ */ r("div", { className: "mt-3 text-sm p-4 rounded-md border border-destructive/20 bg-destructive/5 text-foreground", children: [
298
285
  /* @__PURE__ */ r("div", { className: "flex items-center gap-2 font-semibold text-destructive mb-2", children: [
299
- /* @__PURE__ */ e(D, { className: "w-4 h-4" }),
286
+ /* @__PURE__ */ e(R, { className: "w-4 h-4" }),
300
287
  /* @__PURE__ */ e("span", { children: "Configuration Required" })
301
288
  ] }),
302
289
  /* @__PURE__ */ r("p", { className: "mb-2", children: [
@@ -304,7 +291,7 @@ function g({
304
291
  s,
305
292
  " integration still needs the following:"
306
293
  ] }),
307
- /* @__PURE__ */ e("ul", { className: "list-disc list-inside bg-white/50 dark:bg-black/20 p-2 rounded mb-3 text-xs", children: i.map((l) => /* @__PURE__ */ e("li", { children: l }, l)) }),
294
+ /* @__PURE__ */ e("ul", { className: "list-disc list-inside bg-white/50 dark:bg-black/20 p-2 rounded mb-3 text-xs", children: t.map((d) => /* @__PURE__ */ e("li", { children: d }, d)) }),
308
295
  /* @__PURE__ */ e("p", { className: "mb-2", children: /* @__PURE__ */ e("strong", { children: "How to fix:" }) }),
309
296
  /* @__PURE__ */ r("ol", { className: "list-decimal list-inside space-y-1 ml-1 mb-3", children: [
310
297
  /* @__PURE__ */ r("li", { children: [
@@ -313,7 +300,7 @@ function g({
313
300
  /* @__PURE__ */ e(
314
301
  "a",
315
302
  {
316
- href: t,
303
+ href: i,
317
304
  target: "_blank",
318
305
  rel: "noopener noreferrer",
319
306
  className: "underline font-medium hover:text-destructive/80",
@@ -332,5 +319,5 @@ function g({
332
319
  ] });
333
320
  }
334
321
  export {
335
- T as PaymentsClient
322
+ G as PaymentsClient
336
323
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextblock-cms/ecom",
3
- "version": "0.12.8",
3
+ "version": "0.12.11",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -10,9 +10,9 @@
10
10
  },
11
11
  "type": "module",
12
12
  "dependencies": {
13
- "@nextblock-cms/db": "^0.12.8",
14
- "@nextblock-cms/ui": "^0.12.8",
15
- "@nextblock-cms/utils": "^0.12.8",
13
+ "@nextblock-cms/db": "^0.12.11",
14
+ "@nextblock-cms/ui": "^0.12.11",
15
+ "@nextblock-cms/utils": "^0.12.11",
16
16
  "@freemius/checkout": "^1.4.1",
17
17
  "@freemius/sdk": "^0.3.0",
18
18
  "@hookform/resolvers": "^5.2.2",