@blocklet/payment-react 1.18.0 → 1.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/es/checkout/donate.js +40 -10
  2. package/es/checkout/form.d.ts +2 -1
  3. package/es/checkout/form.js +32 -45
  4. package/es/components/payment-beneficiaries.d.ts +24 -0
  5. package/es/components/payment-beneficiaries.js +70 -0
  6. package/es/index.d.ts +2 -1
  7. package/es/index.js +3 -1
  8. package/es/locales/en.js +13 -1
  9. package/es/locales/zh.js +13 -1
  10. package/es/payment/donation-form.d.ts +24 -0
  11. package/es/payment/donation-form.js +603 -0
  12. package/es/payment/error.d.ts +1 -1
  13. package/es/payment/error.js +11 -1
  14. package/es/payment/form/index.d.ts +9 -3
  15. package/es/payment/form/index.js +39 -4
  16. package/es/payment/product-donation.js +98 -57
  17. package/es/payment/skeleton/donation.d.ts +1 -0
  18. package/es/payment/skeleton/donation.js +30 -0
  19. package/es/theme/index.js +3 -0
  20. package/es/types/index.d.ts +2 -0
  21. package/lib/checkout/donate.js +76 -10
  22. package/lib/checkout/form.d.ts +2 -1
  23. package/lib/checkout/form.js +39 -49
  24. package/lib/components/payment-beneficiaries.d.ts +24 -0
  25. package/lib/components/payment-beneficiaries.js +113 -0
  26. package/lib/index.d.ts +2 -1
  27. package/lib/index.js +8 -0
  28. package/lib/locales/en.js +13 -1
  29. package/lib/locales/zh.js +13 -1
  30. package/lib/payment/donation-form.d.ts +24 -0
  31. package/lib/payment/donation-form.js +644 -0
  32. package/lib/payment/error.d.ts +1 -1
  33. package/lib/payment/error.js +2 -2
  34. package/lib/payment/form/index.d.ts +9 -3
  35. package/lib/payment/form/index.js +35 -2
  36. package/lib/payment/product-donation.js +140 -73
  37. package/lib/payment/skeleton/donation.d.ts +1 -0
  38. package/lib/payment/skeleton/donation.js +66 -0
  39. package/lib/theme/index.js +3 -0
  40. package/lib/types/index.d.ts +2 -0
  41. package/package.json +3 -3
  42. package/src/checkout/donate.tsx +54 -11
  43. package/src/checkout/form.tsx +17 -31
  44. package/src/components/payment-beneficiaries.tsx +97 -0
  45. package/src/index.ts +2 -0
  46. package/src/locales/en.tsx +12 -0
  47. package/src/locales/zh.tsx +12 -0
  48. package/src/payment/donation-form.tsx +646 -0
  49. package/src/payment/error.tsx +13 -4
  50. package/src/payment/form/index.tsx +46 -4
  51. package/src/payment/product-donation.tsx +91 -40
  52. package/src/payment/skeleton/donation.tsx +35 -0
  53. package/src/theme/index.tsx +3 -0
  54. package/src/types/index.ts +2 -0
@@ -0,0 +1,644 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Root = void 0;
7
+ module.exports = DonationForm;
8
+ var _jsxRuntime = require("react/jsx-runtime");
9
+ var _context = require("@arcblock/ux/lib/Locale/context");
10
+ var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
11
+ var _Header = _interopRequireDefault(require("@blocklet/ui-react/lib/Header"));
12
+ var _iconsMaterial = require("@mui/icons-material");
13
+ var _material = require("@mui/material");
14
+ var _system = require("@mui/system");
15
+ var _util = require("@ocap/util");
16
+ var _ahooks = require("ahooks");
17
+ var _react = require("react");
18
+ var _reactHookForm = require("react-hook-form");
19
+ var _ufo = require("ufo");
20
+ var _payment = require("../contexts/payment");
21
+ var _api = _interopRequireDefault(require("../libs/api"));
22
+ var _util2 = require("../libs/util");
23
+ var _error = _interopRequireDefault(require("./error"));
24
+ var _form = _interopRequireDefault(require("./form"));
25
+ var _success = _interopRequireDefault(require("./success"));
26
+ var _mobile = require("../hooks/mobile");
27
+ var _productDonation = _interopRequireDefault(require("./product-donation"));
28
+ var _confirm = _interopRequireDefault(require("../components/confirm"));
29
+ var _paymentBeneficiaries = _interopRequireDefault(require("../components/payment-beneficiaries"));
30
+ var _donation = _interopRequireDefault(require("./skeleton/donation"));
31
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
32
+ const getBenefits = async (id, url) => {
33
+ const {
34
+ data
35
+ } = await _api.default.get(`/api/payment-links/${id}/benefits?${url ? `url=${url}` : ""}`);
36
+ return data;
37
+ };
38
+ PaymentInner.defaultProps = {
39
+ completed: false,
40
+ showCheckoutSummary: true,
41
+ formRender: {}
42
+ };
43
+ function PaymentInner({
44
+ checkoutSession,
45
+ paymentMethods,
46
+ paymentLink,
47
+ paymentIntent,
48
+ customer,
49
+ completed,
50
+ mode,
51
+ onPaid,
52
+ onError,
53
+ onChange,
54
+ action,
55
+ formRender,
56
+ benefits
57
+ }) {
58
+ const {
59
+ t
60
+ } = (0, _context.useLocaleContext)();
61
+ const {
62
+ settings,
63
+ session
64
+ } = (0, _payment.usePaymentContext)();
65
+ const [state, setState] = (0, _ahooks.useSetState)({
66
+ checkoutSession,
67
+ submitting: false,
68
+ paying: false,
69
+ paid: false,
70
+ paymentIntent,
71
+ stripeContext: void 0,
72
+ customer,
73
+ customerLimited: false,
74
+ stripePaying: false
75
+ });
76
+ const query = (0, _util2.getQueryParams)(window.location.href);
77
+ const defaultCurrencyId = query.currencyId || state.checkoutSession.currency_id || state.checkoutSession.line_items[0]?.price.currency_id;
78
+ const defaultMethodId = paymentMethods.find(m => m.payment_currencies.some(c => c.id === defaultCurrencyId))?.id;
79
+ const items = state.checkoutSession.line_items;
80
+ const donationSettings = paymentLink?.donation_settings;
81
+ const [benefitsState, setBenefitsState] = (0, _ahooks.useSetState)({
82
+ open: false,
83
+ amount: "0"
84
+ });
85
+ const methods = (0, _reactHookForm.useForm)({
86
+ defaultValues: {
87
+ customer_name: customer?.name || session?.user?.fullName || "",
88
+ customer_email: customer?.email || session?.user?.email || "",
89
+ customer_phone: customer?.phone || session?.user?.phone || "",
90
+ payment_method: defaultMethodId,
91
+ payment_currency: defaultCurrencyId,
92
+ billing_address: Object.assign({
93
+ country: "",
94
+ state: "",
95
+ city: "",
96
+ line1: "",
97
+ line2: "",
98
+ postal_code: ""
99
+ }, customer?.address || {}, {
100
+ country: (0, _util2.isValidCountry)(customer?.address?.country || "") ? customer?.address?.country : "us"
101
+ })
102
+ }
103
+ });
104
+ (0, _react.useEffect)(() => {
105
+ if (!(0, _util2.isMobileSafari)()) {
106
+ return () => {};
107
+ }
108
+ let scrollTop = 0;
109
+ const focusinHandler = () => {
110
+ scrollTop = window.scrollY;
111
+ };
112
+ const focusoutHandler = () => {
113
+ window.scrollTo(0, scrollTop);
114
+ };
115
+ document.body.addEventListener("focusin", focusinHandler);
116
+ document.body.addEventListener("focusout", focusoutHandler);
117
+ return () => {
118
+ document.body.removeEventListener("focusin", focusinHandler);
119
+ document.body.removeEventListener("focusout", focusoutHandler);
120
+ };
121
+ }, []);
122
+ (0, _react.useEffect)(() => {
123
+ if (!methods || query.currencyId) {
124
+ return;
125
+ }
126
+ if (state.checkoutSession.currency_id !== defaultCurrencyId) {
127
+ methods.setValue("payment_currency", state.checkoutSession.currency_id);
128
+ }
129
+ }, [state.checkoutSession, defaultCurrencyId, query.currencyId]);
130
+ const currencyId = (0, _reactHookForm.useWatch)({
131
+ control: methods.control,
132
+ name: "payment_currency",
133
+ defaultValue: defaultCurrencyId
134
+ });
135
+ const currency = (0, _util2.findCurrency)(paymentMethods, currencyId) || settings.baseCurrency;
136
+ (0, _react.useEffect)(() => {
137
+ if (onChange) {
138
+ onChange(methods.getValues());
139
+ }
140
+ }, [currencyId]);
141
+ const onChangeAmount = async ({
142
+ priceId,
143
+ amount
144
+ }) => {
145
+ const amountStr = (0, _util.fromTokenToUnit)(amount, currency.decimal).toString();
146
+ setBenefitsState({
147
+ amount: amountStr
148
+ });
149
+ try {
150
+ const {
151
+ data
152
+ } = await _api.default.put(`/api/checkout-sessions/${state.checkoutSession.id}/amount`, {
153
+ priceId,
154
+ amount: amountStr
155
+ });
156
+ setState({
157
+ checkoutSession: data
158
+ });
159
+ } catch (err) {
160
+ console.error(err);
161
+ _Toast.default.error((0, _util2.formatError)(err));
162
+ }
163
+ };
164
+ const handlePaid = result => {
165
+ setState({
166
+ checkoutSession: result.checkoutSession
167
+ });
168
+ onPaid(result);
169
+ };
170
+ const renderBenefits = () => {
171
+ if (!benefits) {
172
+ return null;
173
+ }
174
+ if (benefits.length === 1) {
175
+ return t("payment.checkout.donation.benefits.one", {
176
+ name: benefits[0].name
177
+ });
178
+ }
179
+ return t("payment.checkout.donation.benefits.multiple", {
180
+ count: benefits.length
181
+ });
182
+ };
183
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_reactHookForm.FormProvider, {
184
+ ...methods,
185
+ children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
186
+ className: "cko-container",
187
+ sx: {
188
+ gap: {
189
+ sm: mode === "standalone" ? 0 : mode === "inline" ? 4 : 8
190
+ }
191
+ },
192
+ children: [completed ? /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
193
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_success.default, {
194
+ mode,
195
+ payee: (0, _util2.getStatementDescriptor)(state.checkoutSession.line_items),
196
+ action: state.checkoutSession.mode,
197
+ invoiceId: state.checkoutSession.invoice_id,
198
+ subscriptionId: state.checkoutSession.subscription_id,
199
+ message: paymentLink?.after_completion?.hosted_confirmation?.custom_message || t("payment.checkout.completed.donate")
200
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Divider, {
201
+ sx: {
202
+ mt: {
203
+ xs: "16px",
204
+ md: "-24px"
205
+ },
206
+ mb: {
207
+ xs: "16px",
208
+ md: "16px"
209
+ }
210
+ }
211
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
212
+ direction: "row",
213
+ justifyContent: "flex-end",
214
+ alignItems: "center",
215
+ flexWrap: "wrap",
216
+ gap: 1,
217
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
218
+ variant: "outlined",
219
+ size: "large",
220
+ onClick: formRender?.onCancel,
221
+ sx: {
222
+ width: "fit-content",
223
+ minWidth: 120
224
+ },
225
+ children: t("common.close")
226
+ })
227
+ })]
228
+ }) : /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
229
+ children: [benefitsState.open && /* @__PURE__ */(0, _jsxRuntime.jsx)(_paymentBeneficiaries.default, {
230
+ data: benefits,
231
+ currency,
232
+ totalAmount: benefitsState.amount
233
+ }), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
234
+ sx: {
235
+ display: benefitsState.open ? "none" : "block"
236
+ },
237
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
238
+ title: t("payment.checkout.orderSummary"),
239
+ sx: {
240
+ color: "text.primary",
241
+ fontSize: "18px",
242
+ fontWeight: "500",
243
+ lineHeight: "24px",
244
+ mb: 2
245
+ },
246
+ children: t("payment.checkout.donation.tipAmount")
247
+ }), items.map(x => /* @__PURE__ */(0, _jsxRuntime.jsx)(_productDonation.default, {
248
+ item: x,
249
+ settings: donationSettings,
250
+ onChange: onChangeAmount,
251
+ currency
252
+ }, `${x.price_id}-${currency.id}`))]
253
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Divider, {
254
+ sx: {
255
+ mt: {
256
+ xs: "32px",
257
+ md: "0"
258
+ },
259
+ mb: {
260
+ xs: "16px",
261
+ md: "-8px"
262
+ }
263
+ }
264
+ }), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
265
+ direction: "row",
266
+ justifyContent: "space-between",
267
+ alignItems: "center",
268
+ flexWrap: "wrap",
269
+ gap: 1,
270
+ children: [benefits && benefits.length > 0 && (benefitsState.open ? /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
271
+ onClick: () => setBenefitsState({
272
+ open: false
273
+ }),
274
+ sx: {
275
+ cursor: "pointer",
276
+ color: "text.secondary",
277
+ "&:hover": {
278
+ color: "text.primary"
279
+ },
280
+ display: "flex",
281
+ alignItems: "center"
282
+ },
283
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_iconsMaterial.ArrowBackOutlined, {
284
+ className: "benefits-arrow",
285
+ sx: {
286
+ fontSize: "18px",
287
+ mr: 0.5
288
+ }
289
+ }), t("common.back")]
290
+ }) : /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
291
+ display: "flex",
292
+ gap: 0.5,
293
+ alignItems: "center",
294
+ onClick: () => setBenefitsState({
295
+ open: true
296
+ }),
297
+ sx: {
298
+ color: "text.secondary",
299
+ cursor: "pointer",
300
+ "& .benefits-arrow": {
301
+ opacity: 0,
302
+ transform: "translateX(-4px)",
303
+ transition: "all 0.2s"
304
+ },
305
+ "&:hover": {
306
+ color: "text.primary",
307
+ "& .benefits-arrow": {
308
+ opacity: 1,
309
+ transform: "translateX(0)"
310
+ }
311
+ }
312
+ },
313
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_iconsMaterial.HelpOutlineOutlined, {
314
+ sx: {
315
+ fontSize: "18px"
316
+ }
317
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
318
+ children: renderBenefits()
319
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_iconsMaterial.ArrowForwardOutlined, {
320
+ className: "benefits-arrow",
321
+ sx: {
322
+ fontSize: "18px"
323
+ }
324
+ })]
325
+ })), benefitsState.open ? null : /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
326
+ display: "flex",
327
+ gap: 2,
328
+ sx: {
329
+ flex: {
330
+ xs: 1,
331
+ md: "auto"
332
+ },
333
+ justifyContent: "flex-end"
334
+ },
335
+ children: [formRender?.cancel, /* @__PURE__ */(0, _jsxRuntime.jsx)(_form.default, {
336
+ currencyId,
337
+ checkoutSession: state.checkoutSession,
338
+ paymentMethods,
339
+ paymentIntent,
340
+ paymentLink,
341
+ customer,
342
+ onPaid: handlePaid,
343
+ onError,
344
+ mode,
345
+ action,
346
+ onlyShowBtn: true
347
+ })]
348
+ })]
349
+ })]
350
+ }), state.customerLimited && /* @__PURE__ */(0, _jsxRuntime.jsx)(_confirm.default, {
351
+ onConfirm: () => window.open((0, _ufo.joinURL)((0, _util2.getPrefix)(), `/customer/invoice/past-due?referer=${encodeURIComponent(window.location.href)}`), "_self"),
352
+ onCancel: () => setState({
353
+ customerLimited: false
354
+ }),
355
+ confirm: t("payment.customer.pastDue.alert.confirm"),
356
+ title: t("payment.customer.pastDue.alert.title"),
357
+ message: t("payment.customer.pastDue.alert.description"),
358
+ color: "primary"
359
+ })]
360
+ })
361
+ });
362
+ }
363
+ DonationForm.defaultProps = {
364
+ completed: false,
365
+ error: null,
366
+ showCheckoutSummary: true,
367
+ formRender: {}
368
+ };
369
+ function DonationForm({
370
+ checkoutSession,
371
+ paymentMethods,
372
+ paymentIntent,
373
+ paymentLink,
374
+ customer,
375
+ completed,
376
+ error,
377
+ mode,
378
+ onPaid,
379
+ onError,
380
+ onChange,
381
+ goBack,
382
+ action,
383
+ showCheckoutSummary = true,
384
+ formRender,
385
+ id
386
+ }) {
387
+ const {
388
+ t
389
+ } = (0, _context.useLocaleContext)();
390
+ const {
391
+ refresh,
392
+ livemode,
393
+ setLivemode
394
+ } = (0, _payment.usePaymentContext)();
395
+ const {
396
+ isMobile
397
+ } = (0, _mobile.useMobile)();
398
+ const [delay, setDelay] = (0, _react.useState)(false);
399
+ const isMobileSafariEnv = (0, _util2.isMobileSafari)();
400
+ const paymentLinkId = id.startsWith("plink_") ? id : void 0;
401
+ const {
402
+ data: benefits,
403
+ loading: benefitLoading
404
+ } = (0, _ahooks.useRequest)(() => {
405
+ if (paymentLinkId) {
406
+ return getBenefits(paymentLinkId);
407
+ }
408
+ return Promise.resolve([]);
409
+ }, {
410
+ refreshDeps: [paymentLinkId || paymentLink?.id],
411
+ ready: !!paymentLinkId || !!paymentLink?.id
412
+ });
413
+ (0, _ahooks.useMount)(() => {
414
+ setTimeout(() => {
415
+ setDelay(true);
416
+ }, 500);
417
+ });
418
+ (0, _react.useEffect)(() => {
419
+ if (checkoutSession) {
420
+ if (livemode !== checkoutSession.livemode) {
421
+ setLivemode(checkoutSession.livemode);
422
+ }
423
+ }
424
+ }, [checkoutSession, livemode, setLivemode, refresh]);
425
+ const renderContent = () => {
426
+ const footer = /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
427
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Divider, {
428
+ sx: {
429
+ mt: {
430
+ xs: "16px",
431
+ md: "-24px"
432
+ },
433
+ mb: {
434
+ xs: "16px",
435
+ md: "-16px"
436
+ }
437
+ }
438
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
439
+ direction: "row",
440
+ justifyContent: "flex-end",
441
+ alignItems: "center",
442
+ flexWrap: "wrap",
443
+ gap: 1,
444
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
445
+ variant: "outlined",
446
+ size: "large",
447
+ onClick: formRender?.onCancel,
448
+ children: t("common.cancel")
449
+ })
450
+ })]
451
+ });
452
+ if (error) {
453
+ return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
454
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_error.default, {
455
+ mode,
456
+ title: "Oops",
457
+ description: (0, _util2.formatError)(error),
458
+ button: null
459
+ }), footer]
460
+ });
461
+ }
462
+ if (!checkoutSession || !delay || !paymentLink || benefitLoading) {
463
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_donation.default, {});
464
+ }
465
+ if (checkoutSession?.expires_at <= Math.round(Date.now() / 1e3)) {
466
+ return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
467
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_error.default, {
468
+ mode,
469
+ title: t("payment.checkout.expired.title"),
470
+ description: t("payment.checkout.expired.description"),
471
+ button: null
472
+ }), footer]
473
+ });
474
+ }
475
+ if (!checkoutSession.line_items.length) {
476
+ return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
477
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_error.default, {
478
+ mode,
479
+ title: t("payment.checkout.emptyItems.title"),
480
+ description: t("payment.checkout.emptyItems.description"),
481
+ button: null
482
+ }), footer]
483
+ });
484
+ }
485
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(PaymentInner, {
486
+ formRender,
487
+ checkoutSession,
488
+ paymentMethods,
489
+ paymentLink,
490
+ paymentIntent,
491
+ completed: completed || checkoutSession.status === "complete",
492
+ customer,
493
+ onPaid,
494
+ onError,
495
+ onChange,
496
+ goBack,
497
+ mode,
498
+ action,
499
+ showCheckoutSummary,
500
+ benefits
501
+ });
502
+ };
503
+ return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
504
+ display: "flex",
505
+ flexDirection: "column",
506
+ sx: {
507
+ height: mode === "standalone" ? "100vh" : "auto",
508
+ overflow: isMobileSafariEnv ? "visible" : "hidden"
509
+ },
510
+ children: [mode === "standalone" ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_Header.default, {
511
+ meta: void 0,
512
+ addons: void 0,
513
+ sessionManagerProps: void 0,
514
+ homeLink: void 0,
515
+ theme: void 0,
516
+ hideNavMenu: void 0,
517
+ maxWidth: false,
518
+ sx: {
519
+ borderBottom: "1px solid var(--stroke-border-base, #EFF1F5)"
520
+ }
521
+ }) : null, /* @__PURE__ */(0, _jsxRuntime.jsxs)(Root, {
522
+ mode,
523
+ sx: {
524
+ flex: 1,
525
+ overflow: {
526
+ xs: isMobileSafariEnv ? "visible" : "auto",
527
+ md: "hidden"
528
+ },
529
+ ...(isMobile && mode === "standalone" ? {
530
+ ".cko-payment-submit-btn": {
531
+ position: "fixed",
532
+ bottom: 20,
533
+ left: 0,
534
+ right: 0,
535
+ zIndex: 999,
536
+ background: "#fff",
537
+ padding: "10px",
538
+ textAlign: "center",
539
+ button: {
540
+ color: "#fff",
541
+ maxWidth: 542
542
+ }
543
+ }
544
+ } : {})
545
+ },
546
+ children: [goBack && /* @__PURE__ */(0, _jsxRuntime.jsx)(_iconsMaterial.ArrowBackOutlined, {
547
+ sx: {
548
+ mr: 0.5,
549
+ color: "text.secondary",
550
+ alignSelf: "flex-start",
551
+ margin: "16px 0",
552
+ cursor: "pointer"
553
+ },
554
+ onClick: goBack,
555
+ fontSize: "medium"
556
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
557
+ className: "cko-container",
558
+ sx: {
559
+ gap: {
560
+ sm: mode === "standalone" ? 0 : mode === "inline" ? 4 : 8
561
+ }
562
+ },
563
+ children: renderContent()
564
+ })]
565
+ })]
566
+ });
567
+ }
568
+ const Root = exports.Root = (0, _system.styled)(_material.Box)`
569
+ box-sizing: border-box;
570
+ display: flex;
571
+ flex-direction: column;
572
+ align-items: center;
573
+ overflow: hidden;
574
+ position: relative;
575
+
576
+ .cko-container {
577
+ overflow: hidden;
578
+ width: 100%;
579
+ display: flex;
580
+ flex-direction: column;
581
+ justify-content: center;
582
+ position: relative;
583
+ flex: 1;
584
+ }
585
+
586
+ .cko-overview {
587
+ position: relative;
588
+ flex-direction: column;
589
+ display: ${props => props.mode.endsWith("-minimal") ? "none" : "flex"};
590
+ background: var(--backgrounds-bg-base);
591
+ min-height: 'auto';
592
+ }
593
+
594
+ .cko-footer {
595
+ display: ${props => props.mode.endsWith("-minimal") ? "none" : "block"};
596
+ text-align: center;
597
+ margin-top: 20px;
598
+ }
599
+
600
+ .cko-payment-form {
601
+ .MuiFormLabel-root {
602
+ color: var(--foregrounds-fg-base, #010714);
603
+ font-weight: 500;
604
+ margin-top: 12px;
605
+ margin-bottom: 4px;
606
+ }
607
+ .MuiBox-root {
608
+ margin: 0;
609
+ }
610
+ .MuiFormHelperText-root {
611
+ margin-left: 14px;
612
+ }
613
+ }
614
+
615
+ @media (max-width: ${({
616
+ theme
617
+ }) => theme.breakpoints.values.md}px) {
618
+ padding-top: 0;
619
+ overflow: auto;
620
+
621
+ .cko-container {
622
+ flex-direction: column;
623
+ justify-content: flex-start;
624
+ gap: 0;
625
+ overflow: visible;
626
+ min-width: 200px;
627
+ }
628
+
629
+ .cko-overview {
630
+ width: 100%;
631
+ min-height: auto;
632
+ flex: none;
633
+ }
634
+
635
+ .cko-footer {
636
+ position: relative;
637
+ margin-bottom: 4px;
638
+ margin-top: 0;
639
+ bottom: 0;
640
+ left: 0;
641
+ transform: translateX(0);
642
+ }
643
+ }
644
+ `;
@@ -3,7 +3,7 @@ type ModeType = LiteralUnion<'standalone' | 'inline' | 'popup' | 'inline-minimal
3
3
  type Props = {
4
4
  title: string;
5
5
  description: string;
6
- button?: string;
6
+ button?: string | React.ReactNode;
7
7
  mode?: ModeType;
8
8
  };
9
9
  declare function PaymentError({ title, description, button, mode }: Props): import("react").JSX.Element;
@@ -51,7 +51,7 @@ function PaymentError({
51
51
  textAlign: "center"
52
52
  },
53
53
  children: description
54
- }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
54
+ }), typeof button === "string" ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
55
55
  variant: "text",
56
56
  size: "small",
57
57
  sx: {
@@ -60,7 +60,7 @@ function PaymentError({
60
60
  component: _material.Link,
61
61
  href: window.blocklet?.appUrl,
62
62
  children: button
63
- })]
63
+ }) : button]
64
64
  })
65
65
  });
66
66
  }
@@ -1,8 +1,14 @@
1
1
  import 'react-international-phone/style.css';
2
2
  import type { CheckoutCallbacks, CheckoutContext } from '../../types';
3
- type PageData = CheckoutContext & CheckoutCallbacks;
4
- declare function PaymentForm({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, onPaid, onError, action, currencyId, }: PageData): import("react").JSX.Element;
3
+ export declare const waitForCheckoutComplete: (sessionId: string) => Promise<CheckoutContext>;
4
+ export declare const hasDidWallet: (user: any) => any;
5
+ type PageData = CheckoutContext & CheckoutCallbacks & {
6
+ onlyShowBtn?: boolean;
7
+ };
8
+ declare function PaymentForm({ checkoutSession, paymentMethods, paymentIntent, paymentLink, customer, onPaid, onError, action, currencyId, onlyShowBtn, }: PageData): import("react").JSX.Element;
5
9
  declare namespace PaymentForm {
6
- var defaultProps: {};
10
+ var defaultProps: {
11
+ onlyShowBtn: boolean;
12
+ };
7
13
  }
8
14
  export default PaymentForm;