@nextblock-cms/ecom 0.10.2 → 0.10.3
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/lib/components/CustomerProfileForm.cjs.js +1 -1
- package/lib/components/CustomerProfileForm.es.js +162 -159
- package/lib/freemius-coupons.cjs.js +1 -1
- package/lib/freemius-coupons.es.js +51 -49
- package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -1
- package/lib/pages/cms/payments/PaymentsClient.d.ts +4 -1
- package/lib/pages/cms/payments/PaymentsClient.es.js +255 -127
- package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -1
- package/lib/pages/cms/payments/PaymentsPage.es.js +20 -16
- package/lib/pages/cms/payments/actions.cjs.js +1 -1
- package/lib/pages/cms/payments/actions.d.ts +1 -0
- package/lib/pages/cms/payments/actions.es.js +41 -13
- package/lib/pages/cms/payments/queries.cjs.js +1 -1
- package/lib/pages/cms/payments/queries.es.js +13 -24
- package/lib/payment-config.cjs.js +1 -0
- package/lib/payment-config.d.ts +57 -0
- package/lib/payment-config.es.js +137 -0
- package/lib/providers/freemius.cjs.js +2 -2
- package/lib/providers/freemius.es.js +108 -107
- package/lib/providers/stripe.cjs.js +1 -1
- package/lib/providers/stripe.es.js +167 -167
- package/lib/stripe/checkout.cjs.js +1 -1
- package/lib/stripe/checkout.es.js +14 -14
- package/lib/stripe/client.cjs.js +1 -1
- package/lib/stripe/client.d.ts +1 -1
- package/lib/stripe/client.es.js +8 -5
- package/lib/stripe/order-sync.cjs.js +1 -1
- package/lib/stripe/order-sync.es.js +50 -50
- package/lib/stripe/webhooks.cjs.js +1 -1
- package/lib/stripe/webhooks.es.js +12 -10
- package/package.json +4 -4
- package/server.cjs.js +1 -1
- package/server.d.ts +1 -0
- package/server.es.js +188 -178
|
@@ -1,188 +1,316 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsxs as r, jsx as e } from "react/jsx-runtime";
|
|
3
|
-
import { useState as
|
|
4
|
-
import { Card as
|
|
5
|
-
import { CheckCircle2 as
|
|
6
|
-
import { useFormStatus as
|
|
7
|
-
function
|
|
8
|
-
initialEnabledProviders:
|
|
3
|
+
import { useState as P } from "react";
|
|
4
|
+
import { Card as v, CardHeader as y, CardTitle as g, CardDescription as x, CardContent as N, Checkbox as w, 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 T({
|
|
8
|
+
initialEnabledProviders: s,
|
|
9
9
|
configStatus: t,
|
|
10
|
-
|
|
10
|
+
credentials: i,
|
|
11
|
+
saveAction: a,
|
|
12
|
+
saveCredentialsAction: l
|
|
11
13
|
}) {
|
|
12
|
-
const [
|
|
13
|
-
return /* @__PURE__ */ r("
|
|
14
|
-
/* @__PURE__ */ e(
|
|
15
|
-
"input",
|
|
16
|
-
{
|
|
17
|
-
type: "hidden",
|
|
18
|
-
name: "stripe_enabled",
|
|
19
|
-
value: s.stripe ? "true" : "false"
|
|
20
|
-
}
|
|
21
|
-
),
|
|
22
|
-
/* @__PURE__ */ e(
|
|
23
|
-
"input",
|
|
24
|
-
{
|
|
25
|
-
type: "hidden",
|
|
26
|
-
name: "freemius_enabled",
|
|
27
|
-
value: s.freemius ? "true" : "false"
|
|
28
|
-
}
|
|
29
|
-
),
|
|
14
|
+
const [d, m] = P(s), c = t?.stripe?.hasKeys, o = t?.freemius?.hasKeys;
|
|
15
|
+
return /* @__PURE__ */ r("div", { className: "space-y-6 max-w-3xl p-8", children: [
|
|
30
16
|
/* @__PURE__ */ r("div", { children: [
|
|
31
17
|
/* @__PURE__ */ e("h1", { className: "text-3xl font-bold tracking-tight", children: "Payment Settings" }),
|
|
32
|
-
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "
|
|
18
|
+
/* @__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." })
|
|
33
19
|
] }),
|
|
34
|
-
/* @__PURE__ */
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
20
|
+
/* @__PURE__ */ e(F, { credentials: i, saveAction: l }),
|
|
21
|
+
/* @__PURE__ */ r("form", { action: a, className: "space-y-6", children: [
|
|
22
|
+
/* @__PURE__ */ e(
|
|
23
|
+
"input",
|
|
24
|
+
{
|
|
25
|
+
type: "hidden",
|
|
26
|
+
name: "stripe_enabled",
|
|
27
|
+
value: d.stripe ? "true" : "false"
|
|
28
|
+
}
|
|
29
|
+
),
|
|
30
|
+
/* @__PURE__ */ e(
|
|
31
|
+
"input",
|
|
32
|
+
{
|
|
33
|
+
type: "hidden",
|
|
34
|
+
name: "freemius_enabled",
|
|
35
|
+
value: d.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: d.stripe,
|
|
51
|
+
disabled: !c,
|
|
52
|
+
onCheckedChange: (p) => m((h) => ({
|
|
53
|
+
...h,
|
|
54
|
+
stripe: p
|
|
55
|
+
})),
|
|
56
|
+
ready: c,
|
|
57
|
+
children: c ? /* @__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: d.freemius,
|
|
78
|
+
disabled: !o,
|
|
79
|
+
onCheckedChange: (p) => m((h) => ({
|
|
80
|
+
...h,
|
|
81
|
+
freemius: p
|
|
82
|
+
})),
|
|
83
|
+
ready: o,
|
|
84
|
+
children: o ? /* @__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(C, {}) })
|
|
99
|
+
] })
|
|
95
100
|
] })
|
|
96
101
|
] })
|
|
97
102
|
] });
|
|
98
103
|
}
|
|
99
|
-
function
|
|
100
|
-
const { pending:
|
|
101
|
-
return /* @__PURE__ */ e(
|
|
104
|
+
function C() {
|
|
105
|
+
const { pending: s } = I();
|
|
106
|
+
return /* @__PURE__ */ e(S, { type: "submit", disabled: s, children: s ? "Saving..." : "Save Changes" });
|
|
102
107
|
}
|
|
103
|
-
function
|
|
104
|
-
id:
|
|
108
|
+
function n({
|
|
109
|
+
id: s,
|
|
105
110
|
label: t,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
children:
|
|
111
|
+
type: i = "text",
|
|
112
|
+
defaultValue: a,
|
|
113
|
+
placeholder: l,
|
|
114
|
+
hint: d
|
|
115
|
+
}) {
|
|
116
|
+
return /* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
|
|
117
|
+
/* @__PURE__ */ e(k, { htmlFor: s, children: t }),
|
|
118
|
+
/* @__PURE__ */ e(
|
|
119
|
+
K,
|
|
120
|
+
{
|
|
121
|
+
id: s,
|
|
122
|
+
name: s,
|
|
123
|
+
type: i,
|
|
124
|
+
defaultValue: a,
|
|
125
|
+
placeholder: l,
|
|
126
|
+
autoComplete: i === "password" ? "new-password" : "off"
|
|
127
|
+
}
|
|
128
|
+
),
|
|
129
|
+
d && /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: d })
|
|
130
|
+
] });
|
|
131
|
+
}
|
|
132
|
+
function F({
|
|
133
|
+
credentials: s,
|
|
134
|
+
saveAction: t
|
|
135
|
+
}) {
|
|
136
|
+
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: [
|
|
141
|
+
"Keys are encrypted at rest and used DB-first (these override any ",
|
|
142
|
+
/* @__PURE__ */ e("code", { children: ".env" }),
|
|
143
|
+
" ",
|
|
144
|
+
"values). Leave a secret blank to keep the stored value."
|
|
145
|
+
] })
|
|
146
|
+
] }),
|
|
147
|
+
/* @__PURE__ */ e(N, { children: /* @__PURE__ */ r("form", { action: t, className: "space-y-6", children: [
|
|
148
|
+
/* @__PURE__ */ r("div", { className: "space-y-4", children: [
|
|
149
|
+
/* @__PURE__ */ e("h3", { className: "text-sm font-semibold", children: "Stripe (physical products)" }),
|
|
150
|
+
/* @__PURE__ */ r("div", { className: "grid gap-4 sm:grid-cols-2", children: [
|
|
151
|
+
/* @__PURE__ */ e(
|
|
152
|
+
n,
|
|
153
|
+
{
|
|
154
|
+
id: "stripe_publishableKey",
|
|
155
|
+
label: "Publishable key",
|
|
156
|
+
defaultValue: s.stripe.publishableKey,
|
|
157
|
+
placeholder: "pk_live_…"
|
|
158
|
+
}
|
|
159
|
+
),
|
|
160
|
+
/* @__PURE__ */ e(
|
|
161
|
+
n,
|
|
162
|
+
{
|
|
163
|
+
id: "stripe_secretKey",
|
|
164
|
+
label: "Secret key",
|
|
165
|
+
type: "password",
|
|
166
|
+
placeholder: s.stripe.hasSecretKey ? i : "sk_live_…"
|
|
167
|
+
}
|
|
168
|
+
),
|
|
169
|
+
/* @__PURE__ */ e(
|
|
170
|
+
n,
|
|
171
|
+
{
|
|
172
|
+
id: "stripe_webhookSecret",
|
|
173
|
+
label: "Webhook signing secret",
|
|
174
|
+
type: "password",
|
|
175
|
+
placeholder: s.stripe.hasWebhookSecret ? i : "whsec_…"
|
|
176
|
+
}
|
|
177
|
+
)
|
|
178
|
+
] })
|
|
179
|
+
] }),
|
|
180
|
+
/* @__PURE__ */ r("div", { className: "space-y-4", children: [
|
|
181
|
+
/* @__PURE__ */ e("h3", { className: "text-sm font-semibold", children: "Freemius (digital products)" }),
|
|
182
|
+
/* @__PURE__ */ r("div", { className: "grid gap-4 sm:grid-cols-2", children: [
|
|
183
|
+
/* @__PURE__ */ e(
|
|
184
|
+
n,
|
|
185
|
+
{
|
|
186
|
+
id: "freemius_developerId",
|
|
187
|
+
label: "Developer ID",
|
|
188
|
+
defaultValue: s.freemius.developerId
|
|
189
|
+
}
|
|
190
|
+
),
|
|
191
|
+
/* @__PURE__ */ e(
|
|
192
|
+
n,
|
|
193
|
+
{
|
|
194
|
+
id: "freemius_productId",
|
|
195
|
+
label: "Product ID",
|
|
196
|
+
defaultValue: s.freemius.productId
|
|
197
|
+
}
|
|
198
|
+
),
|
|
199
|
+
/* @__PURE__ */ e(
|
|
200
|
+
n,
|
|
201
|
+
{
|
|
202
|
+
id: "freemius_publicKey",
|
|
203
|
+
label: "Public key",
|
|
204
|
+
defaultValue: s.freemius.publicKey,
|
|
205
|
+
placeholder: "pk_…"
|
|
206
|
+
}
|
|
207
|
+
),
|
|
208
|
+
/* @__PURE__ */ e(
|
|
209
|
+
n,
|
|
210
|
+
{
|
|
211
|
+
id: "freemius_secretKey",
|
|
212
|
+
label: "Secret key",
|
|
213
|
+
type: "password",
|
|
214
|
+
placeholder: s.freemius.hasSecretKey ? i : "sk_…"
|
|
215
|
+
}
|
|
216
|
+
),
|
|
217
|
+
/* @__PURE__ */ e(
|
|
218
|
+
n,
|
|
219
|
+
{
|
|
220
|
+
id: "freemius_apiKey",
|
|
221
|
+
label: "API key",
|
|
222
|
+
type: "password",
|
|
223
|
+
placeholder: s.freemius.hasApiKey ? i : "API key"
|
|
224
|
+
}
|
|
225
|
+
)
|
|
226
|
+
] })
|
|
227
|
+
] }),
|
|
228
|
+
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." }),
|
|
229
|
+
/* @__PURE__ */ e("div", { className: "flex justify-end", children: /* @__PURE__ */ e(C, {}) })
|
|
230
|
+
] }) })
|
|
231
|
+
] });
|
|
232
|
+
}
|
|
233
|
+
function b({
|
|
234
|
+
id: s,
|
|
235
|
+
label: t,
|
|
236
|
+
description: i,
|
|
237
|
+
checked: a,
|
|
238
|
+
disabled: l,
|
|
239
|
+
ready: d,
|
|
240
|
+
onCheckedChange: m,
|
|
241
|
+
children: c
|
|
112
242
|
}) {
|
|
113
243
|
return /* @__PURE__ */ e("div", { className: "rounded-md border p-4", children: /* @__PURE__ */ r("div", { className: "flex items-start gap-3", children: [
|
|
114
244
|
/* @__PURE__ */ e(
|
|
115
|
-
|
|
245
|
+
w,
|
|
116
246
|
{
|
|
117
|
-
id:
|
|
118
|
-
checked:
|
|
119
|
-
disabled:
|
|
120
|
-
onCheckedChange: (
|
|
247
|
+
id: s,
|
|
248
|
+
checked: a,
|
|
249
|
+
disabled: l,
|
|
250
|
+
onCheckedChange: (o) => m(!!o),
|
|
121
251
|
className: "mt-1"
|
|
122
252
|
}
|
|
123
253
|
),
|
|
124
254
|
/* @__PURE__ */ r("div", { className: "grid gap-1.5 leading-none w-full", children: [
|
|
125
255
|
/* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-3 flex-wrap", children: [
|
|
126
|
-
/* @__PURE__ */ e(
|
|
256
|
+
/* @__PURE__ */ e(k, { htmlFor: s, className: "font-semibold text-base cursor-pointer", children: t }),
|
|
127
257
|
/* @__PURE__ */ e(
|
|
128
258
|
"span",
|
|
129
259
|
{
|
|
130
|
-
className: `text-xs font-medium ${
|
|
131
|
-
children:
|
|
260
|
+
className: `text-xs font-medium ${a ? "text-foreground" : "text-muted-foreground"}`,
|
|
261
|
+
children: a ? "Enabled" : "Disabled"
|
|
132
262
|
}
|
|
133
263
|
)
|
|
134
264
|
] }),
|
|
135
|
-
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children:
|
|
136
|
-
!
|
|
137
|
-
|
|
265
|
+
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: i }),
|
|
266
|
+
!d && /* @__PURE__ */ e("p", { className: "text-xs text-amber-700", children: "This provider cannot be enabled until all required environment variables are present." }),
|
|
267
|
+
c
|
|
138
268
|
] })
|
|
139
269
|
] }) });
|
|
140
270
|
}
|
|
141
|
-
function
|
|
142
|
-
provider:
|
|
271
|
+
function f({
|
|
272
|
+
provider: s,
|
|
143
273
|
missingKeys: t,
|
|
144
|
-
docsUrl:
|
|
145
|
-
docsLabel:
|
|
274
|
+
docsUrl: i,
|
|
275
|
+
docsLabel: a
|
|
146
276
|
}) {
|
|
147
277
|
return /* @__PURE__ */ r("div", { className: "mt-3 text-sm p-4 rounded-md border border-destructive/20 bg-destructive/5 text-foreground", children: [
|
|
148
278
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-2 font-semibold text-destructive mb-2", children: [
|
|
149
|
-
/* @__PURE__ */ e(
|
|
279
|
+
/* @__PURE__ */ e(_, { className: "w-4 h-4" }),
|
|
150
280
|
/* @__PURE__ */ e("span", { children: "Configuration Required" })
|
|
151
281
|
] }),
|
|
152
282
|
/* @__PURE__ */ r("p", { className: "mb-2", children: [
|
|
153
283
|
"The ",
|
|
154
|
-
|
|
155
|
-
" integration
|
|
284
|
+
s,
|
|
285
|
+
" integration still needs the following:"
|
|
156
286
|
] }),
|
|
157
|
-
/* @__PURE__ */ e("ul", { className: "list-disc list-inside bg-white/50 dark:bg-black/20 p-2 rounded mb-3
|
|
287
|
+
/* @__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)) }),
|
|
158
288
|
/* @__PURE__ */ e("p", { className: "mb-2", children: /* @__PURE__ */ e("strong", { children: "How to fix:" }) }),
|
|
159
289
|
/* @__PURE__ */ r("ol", { className: "list-decimal list-inside space-y-1 ml-1 mb-3", children: [
|
|
160
290
|
/* @__PURE__ */ r("li", { children: [
|
|
161
|
-
"
|
|
291
|
+
"Get your API keys from",
|
|
162
292
|
" ",
|
|
163
293
|
/* @__PURE__ */ e(
|
|
164
294
|
"a",
|
|
165
295
|
{
|
|
166
|
-
href:
|
|
296
|
+
href: i,
|
|
167
297
|
target: "_blank",
|
|
168
298
|
rel: "noopener noreferrer",
|
|
169
299
|
className: "underline font-medium hover:text-destructive/80",
|
|
170
|
-
children:
|
|
300
|
+
children: a
|
|
171
301
|
}
|
|
172
302
|
),
|
|
173
303
|
"."
|
|
174
304
|
] }),
|
|
175
|
-
/* @__PURE__ */ e("li", { children: "Copy your API keys." }),
|
|
176
305
|
/* @__PURE__ */ r("li", { children: [
|
|
177
|
-
"
|
|
178
|
-
/* @__PURE__ */ e("
|
|
179
|
-
"
|
|
306
|
+
"Enter them in the ",
|
|
307
|
+
/* @__PURE__ */ e("strong", { children: "Provider API Keys" }),
|
|
308
|
+
" section above and save."
|
|
180
309
|
] }),
|
|
181
|
-
/* @__PURE__ */ e("li", { children: "
|
|
182
|
-
/* @__PURE__ */ e("li", { children: "Restart your development server." })
|
|
310
|
+
/* @__PURE__ */ e("li", { children: "This provider can then be enabled." })
|
|
183
311
|
] })
|
|
184
312
|
] });
|
|
185
313
|
}
|
|
186
314
|
export {
|
|
187
|
-
|
|
315
|
+
T as PaymentsClient
|
|
188
316
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),n=require("./actions.cjs.js"),s=require("./queries.cjs.js"),c=require("../../../payment-config.cjs.js"),l=require("./PaymentsClient.cjs.js");async function y(){const[i,e,a]=await Promise.all([s.getEnabledPaymentProviders(),s.getStoreConfigStatus(),c.getPaymentCredentialsView()]);async function r(t){"use server";const o={stripe:t.get("stripe_enabled")==="true"&&e.stripe.hasKeys,freemius:t.get("freemius_enabled")==="true"&&e.freemius.hasKeys};await n.updatePaymentSettings(o)}return u.jsx(l.PaymentsClient,{initialEnabledProviders:i,configStatus:e,credentials:a,saveAction:r,saveCredentialsAction:n.savePaymentProviderCredentials})}exports.PaymentsPage=y;
|
|
@@ -1,29 +1,33 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { updatePaymentSettings as
|
|
3
|
-
import { getEnabledPaymentProviders as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { savePaymentProviderCredentials as o, updatePaymentSettings as m } from "./actions.es.js";
|
|
3
|
+
import { getEnabledPaymentProviders as d, getStoreConfigStatus as l } from "./queries.es.js";
|
|
4
|
+
import { getPaymentCredentialsView as u } from "../../../payment-config.es.js";
|
|
5
|
+
import { PaymentsClient as P } from "./PaymentsClient.es.js";
|
|
6
|
+
async function v() {
|
|
7
|
+
const [i, e, s] = await Promise.all([
|
|
8
|
+
d(),
|
|
9
|
+
l(),
|
|
10
|
+
u()
|
|
9
11
|
]);
|
|
10
|
-
async function
|
|
12
|
+
async function n(t) {
|
|
11
13
|
"use server";
|
|
12
|
-
const
|
|
14
|
+
const r = {
|
|
13
15
|
stripe: t.get("stripe_enabled") === "true" && e.stripe.hasKeys,
|
|
14
16
|
freemius: t.get("freemius_enabled") === "true" && e.freemius.hasKeys
|
|
15
17
|
};
|
|
16
|
-
await
|
|
18
|
+
await m(r);
|
|
17
19
|
}
|
|
18
|
-
return /* @__PURE__ */
|
|
19
|
-
|
|
20
|
+
return /* @__PURE__ */ a(
|
|
21
|
+
P,
|
|
20
22
|
{
|
|
21
|
-
initialEnabledProviders:
|
|
23
|
+
initialEnabledProviders: i,
|
|
22
24
|
configStatus: e,
|
|
23
|
-
|
|
25
|
+
credentials: s,
|
|
26
|
+
saveAction: n,
|
|
27
|
+
saveCredentialsAction: o
|
|
24
28
|
}
|
|
25
29
|
);
|
|
26
30
|
}
|
|
27
31
|
export {
|
|
28
|
-
|
|
32
|
+
v as PaymentsPage
|
|
29
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@nextblock-cms/db/server"),i=require("next/cache"),o=require("../../../payment-config.cjs.js");async function d(){const e=await n.createClient(),{data:{user:t}}=await e.auth.getUser();if(!t)throw new Error("Unauthorized");const{data:r}=await e.from("profiles").select("role").eq("id",t.id).single();if(!r||r.role!=="ADMIN")throw new Error("Forbidden")}async function c(e){await d(),await o.savePaymentCredentials({stripe:{publishableKey:String(e.get("stripe_publishableKey")??""),secretKey:String(e.get("stripe_secretKey")??""),webhookSecret:String(e.get("stripe_webhookSecret")??"")},freemius:{developerId:String(e.get("freemius_developerId")??""),publicKey:String(e.get("freemius_publicKey")??""),productId:String(e.get("freemius_productId")??""),secretKey:String(e.get("freemius_secretKey")??""),apiKey:String(e.get("freemius_apiKey")??"")}}),i.revalidatePath("/cms/payments")}async function u(e){const t=await n.createClient(),{data:{user:r}}=await t.auth.getUser();if(!r)throw new Error("Unauthorized");const{data:s}=await t.from("profiles").select("role").eq("id",r.id).single();if(!s||s.role!=="ADMIN")throw new Error("Forbidden");const{error:a}=await t.from("site_settings").upsert({key:"enabled_payment_providers",value:e});if(a)throw console.error("Error updating payment providers:",a),new Error("Failed to update settings");return i.revalidatePath("/cms/payments"),i.revalidatePath("/cms/taxes"),i.revalidatePath("/","layout"),{success:!0}}exports.savePaymentProviderCredentials=c;exports.updatePaymentSettings=u;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EnabledPaymentProviders } from '../../../types';
|
|
2
|
+
export declare function savePaymentProviderCredentials(formData: FormData): Promise<void>;
|
|
2
3
|
export declare function updatePaymentSettings(enabledProviders: EnabledPaymentProviders): Promise<{
|
|
3
4
|
success: boolean;
|
|
4
5
|
}>;
|
|
@@ -1,23 +1,51 @@
|
|
|
1
1
|
'use server';
|
|
2
|
-
import { createClient as
|
|
3
|
-
import { revalidatePath as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { createClient as o } from "@nextblock-cms/db/server";
|
|
3
|
+
import { revalidatePath as i } from "next/cache";
|
|
4
|
+
import { savePaymentCredentials as a } from "../../../payment-config.es.js";
|
|
5
|
+
async function d() {
|
|
6
|
+
const e = await o(), {
|
|
7
|
+
data: { user: r }
|
|
7
8
|
} = await e.auth.getUser();
|
|
9
|
+
if (!r)
|
|
10
|
+
throw new Error("Unauthorized");
|
|
11
|
+
const { data: t } = await e.from("profiles").select("role").eq("id", r.id).single();
|
|
12
|
+
if (!t || t.role !== "ADMIN")
|
|
13
|
+
throw new Error("Forbidden");
|
|
14
|
+
}
|
|
15
|
+
async function l(e) {
|
|
16
|
+
await d(), await a({
|
|
17
|
+
stripe: {
|
|
18
|
+
publishableKey: String(e.get("stripe_publishableKey") ?? ""),
|
|
19
|
+
secretKey: String(e.get("stripe_secretKey") ?? ""),
|
|
20
|
+
webhookSecret: String(e.get("stripe_webhookSecret") ?? "")
|
|
21
|
+
},
|
|
22
|
+
freemius: {
|
|
23
|
+
developerId: String(e.get("freemius_developerId") ?? ""),
|
|
24
|
+
publicKey: String(e.get("freemius_publicKey") ?? ""),
|
|
25
|
+
productId: String(e.get("freemius_productId") ?? ""),
|
|
26
|
+
secretKey: String(e.get("freemius_secretKey") ?? ""),
|
|
27
|
+
apiKey: String(e.get("freemius_apiKey") ?? "")
|
|
28
|
+
}
|
|
29
|
+
}), i("/cms/payments");
|
|
30
|
+
}
|
|
31
|
+
async function g(e) {
|
|
32
|
+
const r = await o(), {
|
|
33
|
+
data: { user: t }
|
|
34
|
+
} = await r.auth.getUser();
|
|
8
35
|
if (!t)
|
|
9
36
|
throw new Error("Unauthorized");
|
|
10
|
-
const { data:
|
|
11
|
-
if (!
|
|
37
|
+
const { data: s } = await r.from("profiles").select("role").eq("id", t.id).single();
|
|
38
|
+
if (!s || s.role !== "ADMIN")
|
|
12
39
|
throw new Error("Forbidden");
|
|
13
|
-
const { error:
|
|
40
|
+
const { error: n } = await r.from("site_settings").upsert({
|
|
14
41
|
key: "enabled_payment_providers",
|
|
15
|
-
value:
|
|
42
|
+
value: e
|
|
16
43
|
});
|
|
17
|
-
if (
|
|
18
|
-
throw console.error("Error updating payment providers:",
|
|
19
|
-
return
|
|
44
|
+
if (n)
|
|
45
|
+
throw console.error("Error updating payment providers:", n), new Error("Failed to update settings");
|
|
46
|
+
return i("/cms/payments"), i("/cms/taxes"), i("/", "layout"), { success: !0 };
|
|
20
47
|
}
|
|
21
48
|
export {
|
|
22
|
-
|
|
49
|
+
l as savePaymentProviderCredentials,
|
|
50
|
+
g as updatePaymentSettings
|
|
23
51
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@nextblock-cms/db/server"),r=require("../../../types.cjs.js"),s=require("../../../payment-config.cjs.js");async function o(){return s.getPaymentConfigStatus()}async function n(){const e=a.createClient(),{data:t,error:i}=await e.from("site_settings").select("value").eq("key","enabled_payment_providers").maybeSingle();return i||!t?{...r.DEFAULT_ENABLED_PAYMENT_PROVIDERS}:r.normalizeEnabledPaymentProviders(t.value)}async function u(){const e=await n();return e.stripe?"stripe":e.freemius?"freemius":"stripe"}exports.getEnabledPaymentProviders=n;exports.getPaymentSettings=u;exports.getStoreConfigStatus=o;
|
|
@@ -1,30 +1,19 @@
|
|
|
1
|
-
import { createClient as
|
|
2
|
-
import { DEFAULT_ENABLED_PAYMENT_PROVIDERS as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const s = [];
|
|
7
|
-
return process.env.FREEMIUS_PUBLIC_KEY || s.push("FREEMIUS_PUBLIC_KEY"), process.env.FREEMIUS_SECRET_KEY || s.push("FREEMIUS_SECRET_KEY"), {
|
|
8
|
-
stripe: {
|
|
9
|
-
hasKeys: e.length === 0,
|
|
10
|
-
missing: e
|
|
11
|
-
},
|
|
12
|
-
freemius: {
|
|
13
|
-
hasKeys: s.length === 0,
|
|
14
|
-
missing: s
|
|
15
|
-
}
|
|
16
|
-
};
|
|
1
|
+
import { createClient as n } from "@nextblock-cms/db/server";
|
|
2
|
+
import { DEFAULT_ENABLED_PAYMENT_PROVIDERS as i, normalizeEnabledPaymentProviders as a } from "../../../types.es.js";
|
|
3
|
+
import { getPaymentConfigStatus as s } from "../../../payment-config.es.js";
|
|
4
|
+
async function c() {
|
|
5
|
+
return s();
|
|
17
6
|
}
|
|
18
|
-
async function
|
|
19
|
-
const e =
|
|
20
|
-
return
|
|
7
|
+
async function o() {
|
|
8
|
+
const e = n(), { data: t, error: r } = await e.from("site_settings").select("value").eq("key", "enabled_payment_providers").maybeSingle();
|
|
9
|
+
return r || !t ? { ...i } : a(t.value);
|
|
21
10
|
}
|
|
22
|
-
async function
|
|
23
|
-
const e = await
|
|
11
|
+
async function l() {
|
|
12
|
+
const e = await o();
|
|
24
13
|
return e.stripe ? "stripe" : e.freemius ? "freemius" : "stripe";
|
|
25
14
|
}
|
|
26
15
|
export {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
o as getEnabledPaymentProviders,
|
|
17
|
+
l as getPaymentSettings,
|
|
18
|
+
c as getStoreConfigStatus
|
|
30
19
|
};
|