@nextblock-cms/ecom 0.12.7 → 0.12.9

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