@aglyn/plugins-commerce 1.33.2 → 1.34.0
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/package.json +13 -13
- package/src/lib/components/cart.js +3 -1
- package/src/lib/components/cart.js.map +1 -1
- package/src/lib/components/console/catalog-organization-card.component.js +82 -69
- package/src/lib/components/console/catalog-organization-card.component.js.map +1 -1
- package/src/lib/components/console/discounts-card.component.js +46 -25
- package/src/lib/components/console/discounts-card.component.js.map +1 -1
- package/src/lib/components/console/gift-cards-card.component.js +81 -55
- package/src/lib/components/console/gift-cards-card.component.js.map +1 -1
- package/src/lib/components/console/host-coupons-card.component.js +36 -25
- package/src/lib/components/console/host-coupons-card.component.js.map +1 -1
- package/src/lib/components/console/locations-card.component.js +53 -32
- package/src/lib/components/console/locations-card.component.js.map +1 -1
- package/src/lib/components/console/member-posts-card.component.js +35 -32
- package/src/lib/components/console/member-posts-card.component.js.map +1 -1
- package/src/lib/components/console/new-store-tax-question.component.d.ts +17 -0
- package/src/lib/components/console/new-store-tax-question.component.js +197 -0
- package/src/lib/components/console/new-store-tax-question.component.js.map +1 -0
- package/src/lib/components/console/payments-settings-card.component.js +132 -5
- package/src/lib/components/console/payments-settings-card.component.js.map +1 -1
- package/src/lib/components/console/pos/pos-api.d.ts +6 -0
- package/src/lib/components/console/pos/pos-api.js.map +1 -1
- package/src/lib/components/console/pos/pos-tax-notice.component.d.ts +21 -0
- package/src/lib/components/console/pos/pos-tax-notice.component.js +59 -0
- package/src/lib/components/console/pos/pos-tax-notice.component.js.map +1 -0
- package/src/lib/components/console/pos-page.component.js +65 -17
- package/src/lib/components/console/pos-page.component.js.map +1 -1
- package/src/lib/components/console/registers-card.component.js +21 -13
- package/src/lib/components/console/registers-card.component.js.map +1 -1
- package/src/lib/components/console/reviews-moderation-card.component.js +108 -68
- package/src/lib/components/console/reviews-moderation-card.component.js.map +1 -1
- package/src/lib/components/console/site-member-purchases.component.js +5 -3
- package/src/lib/components/console/site-member-purchases.component.js.map +1 -1
- package/src/lib/components/console/subscription-detail-dialog.component.d.ts +2 -0
- package/src/lib/components/console/subscription-detail-dialog.component.js +1 -1
- package/src/lib/components/console/subscription-detail-dialog.component.js.map +1 -1
- package/src/lib/components/console/subscriptions-card.component.js +13 -5
- package/src/lib/components/console/subscriptions-card.component.js.map +1 -1
- package/src/lib/components/console/suppliers-card.component.js +47 -40
- package/src/lib/components/console/suppliers-card.component.js.map +1 -1
- package/src/lib/components/product-choice-cards.js +2 -1
- package/src/lib/components/product-choice-cards.js.map +1 -1
- package/src/lib/components/product-detail.js +9 -4
- package/src/lib/components/product-detail.js.map +1 -1
- package/src/lib/components/product-grid.js +3 -1
- package/src/lib/components/product-grid.js.map +1 -1
- package/src/lib/components/related-products.js +2 -1
- package/src/lib/components/related-products.js.map +1 -1
- package/src/lib/components/store-image-sizing.d.ts +46 -0
- package/src/lib/components/store-image-sizing.js +53 -0
- package/src/lib/components/store-image-sizing.js.map +1 -0
- package/src/lib/components/wishlist.js +2 -1
- package/src/lib/components/wishlist.js.map +1 -1
- package/src/lib/declarations.console-server.js +10 -0
- package/src/lib/declarations.console-server.js.map +1 -1
- package/src/lib/model/commerce-tax-step.d.ts +123 -0
- package/src/lib/model/commerce-tax-step.js +185 -0
- package/src/lib/model/commerce-tax-step.js.map +1 -0
- package/src/lib/model/index.d.ts +1 -0
- package/src/lib/model/index.js +1 -0
- package/src/lib/model/index.js.map +1 -1
- package/src/lib/model/payments-setup-status.d.ts +40 -0
- package/src/lib/model/payments-setup-status.js +63 -0
- package/src/lib/model/payments-setup-status.js.map +1 -1
- package/src/lib/model/subscription-view.d.ts +19 -0
- package/src/lib/model/subscription-view.js +16 -0
- package/src/lib/model/subscription-view.js.map +1 -1
- package/src/lib/model/tap-to-pay-launch.d.ts +103 -0
- package/src/lib/model/tap-to-pay-launch.js +148 -0
- package/src/lib/model/tap-to-pay-launch.js.map +1 -0
- package/src/lib/plugin.js +12 -0
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/server/billing-webhook.js +140 -116
- package/src/lib/server/billing-webhook.js.map +1 -1
- package/src/lib/server/checkout.js +15 -4
- package/src/lib/server/checkout.js.map +1 -1
- package/src/lib/server/connect-return.d.ts +83 -0
- package/src/lib/server/connect-return.js +105 -0
- package/src/lib/server/connect-return.js.map +1 -0
- package/src/lib/server/connect.d.ts +18 -0
- package/src/lib/server/connect.js +60 -6
- package/src/lib/server/connect.js.map +1 -1
- package/src/lib/server/new-store-tax.d.ts +10 -0
- package/src/lib/server/new-store-tax.js +43 -0
- package/src/lib/server/new-store-tax.js.map +1 -0
- package/src/lib/server/pos-payment.js +3 -2
- package/src/lib/server/pos-payment.js.map +1 -1
- package/src/lib/server/pos-tax-step.d.ts +43 -0
- package/src/lib/server/pos-tax-step.js +55 -0
- package/src/lib/server/pos-tax-step.js.map +1 -0
- package/src/lib/server/pos-terminal-connection-token.d.ts +10 -1
- package/src/lib/server/pos-terminal-connection-token.js +18 -7
- package/src/lib/server/pos-terminal-connection-token.js.map +1 -1
- package/src/lib/server/pos-terminal.d.ts +9 -0
- package/src/lib/server/pos-terminal.js +17 -1
- package/src/lib/server/pos-terminal.js.map +1 -1
- package/src/lib/server/tap-to-pay-launch-admin.d.ts +18 -0
- package/src/lib/server/tap-to-pay-launch-admin.js +204 -0
- package/src/lib/server/tap-to-pay-launch-admin.js.map +1 -0
- package/src/lib/server/tap-to-pay-launch.d.ts +114 -0
- package/src/lib/server/tap-to-pay-launch.js +408 -0
- package/src/lib/server/tap-to-pay-launch.js.map +1 -0
- package/src/lib/server.js +15 -0
- package/src/lib/server.js.map +1 -1
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ 'use client';
|
|
17
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
+
import { FormControl, FormControlLabel, FormHelperText, FormLabel, Radio, RadioGroup, Stack, TextField, Typography } from "@mui/material";
|
|
19
|
+
import { useEffect, useId, useState } from "react";
|
|
20
|
+
import { BUNDLE_ID } from "../../constants/bundle-common.js";
|
|
21
|
+
import { NEW_STORE_TAX_COPY as COPY, newStoreTaxProblem } from "../../model/commerce-tax-step.js";
|
|
22
|
+
/**
|
|
23
|
+
* "Do you charge sales tax?" in Create site (AGL-4061): the `hostCreateQuestions`
|
|
24
|
+
* zone, drawn where Commerce runs for the workspace, so on the store the site
|
|
25
|
+
* will have. Nothing is chosen for anyone: left unanswered, the store decides
|
|
26
|
+
* later in Products → Taxes, and its register and Card readers ask before the
|
|
27
|
+
* first sale. Answered, it is handed to the shell and saved once the site
|
|
28
|
+
* exists, as the Taxes editor saves it (`newStoreTaxSettings`).
|
|
29
|
+
*
|
|
30
|
+
* The three answers are the editor's three modes; Stripe Tax is offered on the
|
|
31
|
+
* same terms as there.
|
|
32
|
+
*/ export function NewStoreTaxQuestion(props) {
|
|
33
|
+
var _ref, _ref1, _ref2, _ref3;
|
|
34
|
+
const { answer, answered, disabled } = props;
|
|
35
|
+
const labelId = useId();
|
|
36
|
+
// Drawn again (the guided start comes back to its Start step), it starts
|
|
37
|
+
// from what it handed over before.
|
|
38
|
+
const [before] = useState(()=>savedAnswer(answered == null ? void 0 : answered(BUNDLE_ID)));
|
|
39
|
+
const [choice, setChoice] = useState((_ref = before == null ? void 0 : before.choice) != null ? _ref : null);
|
|
40
|
+
const [pct, setPct] = useState(String((_ref1 = before == null ? void 0 : before.pct) != null ? _ref1 : ''));
|
|
41
|
+
const [country, setCountry] = useState((_ref2 = before == null ? void 0 : before.country) != null ? _ref2 : '');
|
|
42
|
+
const [state, setState] = useState((_ref3 = before == null ? void 0 : before.state) != null ? _ref3 : '');
|
|
43
|
+
const [touched, setTouched] = useState(Boolean(before && newStoreTaxProblem(before)));
|
|
44
|
+
const typed = choice === 'manual' ? {
|
|
45
|
+
choice,
|
|
46
|
+
pct,
|
|
47
|
+
country,
|
|
48
|
+
state
|
|
49
|
+
} : choice ? {
|
|
50
|
+
choice
|
|
51
|
+
} : null;
|
|
52
|
+
const problem = newStoreTaxProblem(typed);
|
|
53
|
+
// Handed over as it stands, with what is wrong with it: a fixed rate still
|
|
54
|
+
// being typed holds the create back with that sentence instead of being
|
|
55
|
+
// dropped. Unanswered hands over nothing, and the store decides later. The
|
|
56
|
+
// answer stays with the shell when this goes away: the guided start leaves
|
|
57
|
+
// this step before it creates the site.
|
|
58
|
+
useEffect(()=>{
|
|
59
|
+
answer(BUNDLE_ID, typed, typed ? problem : null);
|
|
60
|
+
// `typed` is rebuilt every render; its parts are what change.
|
|
61
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
62
|
+
}, [
|
|
63
|
+
answer,
|
|
64
|
+
choice,
|
|
65
|
+
pct,
|
|
66
|
+
country,
|
|
67
|
+
state,
|
|
68
|
+
problem
|
|
69
|
+
]);
|
|
70
|
+
const option = (value, label, help)=>/*#__PURE__*/ _jsx(FormControlLabel, {
|
|
71
|
+
value: value,
|
|
72
|
+
control: /*#__PURE__*/ _jsx(Radio, {
|
|
73
|
+
size: "small"
|
|
74
|
+
}),
|
|
75
|
+
disabled: disabled,
|
|
76
|
+
label: /*#__PURE__*/ _jsxs(Stack, {
|
|
77
|
+
sx: {
|
|
78
|
+
py: 0.5
|
|
79
|
+
},
|
|
80
|
+
children: [
|
|
81
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
82
|
+
variant: "body2",
|
|
83
|
+
children: label
|
|
84
|
+
}),
|
|
85
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
86
|
+
variant: "caption",
|
|
87
|
+
color: "text.secondary",
|
|
88
|
+
children: help
|
|
89
|
+
})
|
|
90
|
+
]
|
|
91
|
+
})
|
|
92
|
+
});
|
|
93
|
+
return /*#__PURE__*/ _jsxs(FormControl, {
|
|
94
|
+
component: "fieldset",
|
|
95
|
+
"data-testid": "new-store-tax-question",
|
|
96
|
+
children: [
|
|
97
|
+
/*#__PURE__*/ _jsx(FormLabel, {
|
|
98
|
+
id: labelId,
|
|
99
|
+
component: "legend",
|
|
100
|
+
children: COPY.question
|
|
101
|
+
}),
|
|
102
|
+
/*#__PURE__*/ _jsx(FormHelperText, {
|
|
103
|
+
sx: {
|
|
104
|
+
mx: 0
|
|
105
|
+
},
|
|
106
|
+
children: COPY.lede
|
|
107
|
+
}),
|
|
108
|
+
/*#__PURE__*/ _jsxs(RadioGroup, {
|
|
109
|
+
"aria-labelledby": labelId,
|
|
110
|
+
value: choice != null ? choice : '',
|
|
111
|
+
onChange: (event)=>setChoice(event.target.value),
|
|
112
|
+
children: [
|
|
113
|
+
option('none', COPY.none, COPY.noneHelp),
|
|
114
|
+
option('manual', COPY.manual, COPY.manualHelp),
|
|
115
|
+
choice === 'manual' ? /*#__PURE__*/ _jsxs(Stack, {
|
|
116
|
+
direction: "row",
|
|
117
|
+
spacing: 1,
|
|
118
|
+
sx: {
|
|
119
|
+
pl: 4,
|
|
120
|
+
py: 1,
|
|
121
|
+
flexWrap: 'wrap',
|
|
122
|
+
rowGap: 1
|
|
123
|
+
},
|
|
124
|
+
children: [
|
|
125
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
126
|
+
label: COPY.rate,
|
|
127
|
+
value: pct,
|
|
128
|
+
onChange: (event)=>setPct(event.target.value),
|
|
129
|
+
onBlur: ()=>setTouched(true),
|
|
130
|
+
size: "small",
|
|
131
|
+
disabled: disabled,
|
|
132
|
+
placeholder: "8.25",
|
|
133
|
+
sx: {
|
|
134
|
+
width: 110
|
|
135
|
+
},
|
|
136
|
+
slotProps: {
|
|
137
|
+
htmlInput: {
|
|
138
|
+
inputMode: 'decimal'
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}),
|
|
142
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
143
|
+
label: COPY.country,
|
|
144
|
+
value: country,
|
|
145
|
+
onChange: (event)=>setCountry(event.target.value.toUpperCase().slice(0, 2)),
|
|
146
|
+
onBlur: ()=>setTouched(true),
|
|
147
|
+
size: "small",
|
|
148
|
+
disabled: disabled,
|
|
149
|
+
placeholder: "US",
|
|
150
|
+
sx: {
|
|
151
|
+
width: 100
|
|
152
|
+
}
|
|
153
|
+
}),
|
|
154
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
155
|
+
label: COPY.state,
|
|
156
|
+
value: state,
|
|
157
|
+
onChange: (event)=>setState(event.target.value.toUpperCase().slice(0, 3)),
|
|
158
|
+
onBlur: ()=>setTouched(true),
|
|
159
|
+
size: "small",
|
|
160
|
+
disabled: disabled,
|
|
161
|
+
placeholder: "TX",
|
|
162
|
+
sx: {
|
|
163
|
+
width: 100
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
]
|
|
167
|
+
}) : null,
|
|
168
|
+
option('stripe', COPY.stripe, COPY.stripeHelp)
|
|
169
|
+
]
|
|
170
|
+
}),
|
|
171
|
+
/*#__PURE__*/ _jsx(FormHelperText, {
|
|
172
|
+
sx: {
|
|
173
|
+
mx: 0
|
|
174
|
+
},
|
|
175
|
+
error: Boolean(touched && problem),
|
|
176
|
+
children: touched && problem ? problem : choice ? null : COPY.later
|
|
177
|
+
})
|
|
178
|
+
]
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
NewStoreTaxQuestion.displayName = 'NewStoreTaxQuestion';
|
|
182
|
+
/** An answer this question handed over before, or null for anything else. */ function savedAnswer(value) {
|
|
183
|
+
if (!value || typeof value !== 'object') return null;
|
|
184
|
+
const saved = value;
|
|
185
|
+
const choice = saved['choice'];
|
|
186
|
+
if (choice !== 'none' && choice !== 'manual' && choice !== 'stripe') return null;
|
|
187
|
+
const text = (field)=>typeof field === 'string' || typeof field === 'number' ? String(field) : '';
|
|
188
|
+
return {
|
|
189
|
+
choice,
|
|
190
|
+
pct: text(saved['pct']),
|
|
191
|
+
country: text(saved['country']),
|
|
192
|
+
state: text(saved['state'])
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
export default NewStoreTaxQuestion;
|
|
196
|
+
|
|
197
|
+
//# sourceMappingURL=new-store-tax-question.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/new-store-tax-question.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport type { ConsoleHostCreateQuestionsZoneProps } from '@aglyn/aglyn'\nimport {\n FormControl,\n FormControlLabel,\n FormHelperText,\n FormLabel,\n Radio,\n RadioGroup,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { useEffect, useId, useState } from 'react'\nimport { BUNDLE_ID } from '../../constants/bundle-common'\nimport {\n NEW_STORE_TAX_COPY as COPY,\n newStoreTaxProblem,\n type NewStoreTaxAnswer,\n type NewStoreTaxChoice,\n} from '../../model/commerce-tax-step'\n\n/**\n * \"Do you charge sales tax?\" in Create site (AGL-4061): the `hostCreateQuestions`\n * zone, drawn where Commerce runs for the workspace, so on the store the site\n * will have. Nothing is chosen for anyone: left unanswered, the store decides\n * later in Products → Taxes, and its register and Card readers ask before the\n * first sale. Answered, it is handed to the shell and saved once the site\n * exists, as the Taxes editor saves it (`newStoreTaxSettings`).\n *\n * The three answers are the editor's three modes; Stripe Tax is offered on the\n * same terms as there.\n */\nexport function NewStoreTaxQuestion(props: ConsoleHostCreateQuestionsZoneProps) {\n const { answer, answered, disabled } = props\n const labelId = useId()\n // Drawn again (the guided start comes back to its Start step), it starts\n // from what it handed over before.\n const [before] = useState(() => savedAnswer(answered?.(BUNDLE_ID)))\n const [choice, setChoice] = useState<NewStoreTaxChoice | null>(before?.choice ?? null)\n const [pct, setPct] = useState(String(before?.pct ?? ''))\n const [country, setCountry] = useState(before?.country ?? '')\n const [state, setState] = useState(before?.state ?? '')\n const [touched, setTouched] = useState(Boolean(before && newStoreTaxProblem(before)))\n const typed: NewStoreTaxAnswer | null =\n choice === 'manual' ? { choice, pct, country, state } : choice ? { choice } : null\n const problem = newStoreTaxProblem(typed)\n\n // Handed over as it stands, with what is wrong with it: a fixed rate still\n // being typed holds the create back with that sentence instead of being\n // dropped. Unanswered hands over nothing, and the store decides later. The\n // answer stays with the shell when this goes away: the guided start leaves\n // this step before it creates the site.\n useEffect(() => {\n answer(BUNDLE_ID, typed, typed ? problem : null)\n // `typed` is rebuilt every render; its parts are what change.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [answer, choice, pct, country, state, problem])\n\n const option = (value: NewStoreTaxChoice, label: string, help: string) => (\n <FormControlLabel\n value={value}\n control={<Radio size=\"small\" />}\n disabled={disabled}\n label={\n <Stack sx={{ py: 0.5 }}>\n <Typography variant=\"body2\">{label}</Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {help}\n </Typography>\n </Stack>\n }\n />\n )\n\n return (\n <FormControl component=\"fieldset\" data-testid=\"new-store-tax-question\">\n <FormLabel id={labelId} component=\"legend\">\n {COPY.question}\n </FormLabel>\n <FormHelperText sx={{ mx: 0 }}>{COPY.lede}</FormHelperText>\n <RadioGroup\n aria-labelledby={labelId}\n value={choice ?? ''}\n onChange={(event) => setChoice(event.target.value as NewStoreTaxChoice)}\n >\n {option('none', COPY.none, COPY.noneHelp)}\n {option('manual', COPY.manual, COPY.manualHelp)}\n {choice === 'manual' ? (\n <Stack direction=\"row\" spacing={1} sx={{ pl: 4, py: 1, flexWrap: 'wrap', rowGap: 1 }}>\n <TextField\n label={COPY.rate}\n value={pct}\n onChange={(event) => setPct(event.target.value)}\n onBlur={() => setTouched(true)}\n size=\"small\"\n disabled={disabled}\n placeholder=\"8.25\"\n sx={{ width: 110 }}\n slotProps={{ htmlInput: { inputMode: 'decimal' } }}\n />\n <TextField\n label={COPY.country}\n value={country}\n onChange={(event) => setCountry(event.target.value.toUpperCase().slice(0, 2))}\n onBlur={() => setTouched(true)}\n size=\"small\"\n disabled={disabled}\n placeholder=\"US\"\n sx={{ width: 100 }}\n />\n <TextField\n label={COPY.state}\n value={state}\n onChange={(event) => setState(event.target.value.toUpperCase().slice(0, 3))}\n onBlur={() => setTouched(true)}\n size=\"small\"\n disabled={disabled}\n placeholder=\"TX\"\n sx={{ width: 100 }}\n />\n </Stack>\n ) : null}\n {option('stripe', COPY.stripe, COPY.stripeHelp)}\n </RadioGroup>\n <FormHelperText sx={{ mx: 0 }} error={Boolean(touched && problem)}>\n {touched && problem ? problem : choice ? null : COPY.later}\n </FormHelperText>\n </FormControl>\n )\n}\nNewStoreTaxQuestion.displayName = 'NewStoreTaxQuestion'\n\n/** An answer this question handed over before, or null for anything else. */\nfunction savedAnswer(value: unknown): NewStoreTaxAnswer | null {\n if (!value || typeof value !== 'object') return null\n const saved = value as Record<string, unknown>\n const choice = saved['choice']\n if (choice !== 'none' && choice !== 'manual' && choice !== 'stripe') return null\n const text = (field: unknown) => (typeof field === 'string' || typeof field === 'number' ? String(field) : '')\n return { choice, pct: text(saved['pct']), country: text(saved['country']), state: text(saved['state']) }\n}\n\nexport default NewStoreTaxQuestion\n"],"names":["FormControl","FormControlLabel","FormHelperText","FormLabel","Radio","RadioGroup","Stack","TextField","Typography","useEffect","useId","useState","BUNDLE_ID","NEW_STORE_TAX_COPY","COPY","newStoreTaxProblem","NewStoreTaxQuestion","props","answer","answered","disabled","labelId","before","savedAnswer","choice","setChoice","pct","setPct","String","country","setCountry","state","setState","touched","setTouched","Boolean","typed","problem","option","value","label","help","control","size","sx","py","variant","color","component","data-testid","id","question","mx","lede","aria-labelledby","onChange","event","target","none","noneHelp","manual","manualHelp","direction","spacing","pl","flexWrap","rowGap","rate","onBlur","placeholder","width","slotProps","htmlInput","inputMode","toUpperCase","slice","stripe","stripeHelp","error","later","displayName","saved","text","field"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAGA,SACEA,WAAW,EACXC,gBAAgB,EAChBC,cAAc,EACdC,SAAS,EACTC,KAAK,EACLC,UAAU,EACVC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,SAAS,EAAEC,KAAK,EAAEC,QAAQ,QAAQ,QAAO;AAClD,SAASC,SAAS,QAAQ,mCAA+B;AACzD,SACEC,sBAAsBC,IAAI,EAC1BC,kBAAkB,QAGb,mCAA+B;AAEtC;;;;;;;;;;CAUC,GACD,OAAO,SAASC,oBAAoBC,KAA0C;;IAC5E,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,GAAGH;IACvC,MAAMI,UAAUX;IAChB,yEAAyE;IACzE,mCAAmC;IACnC,MAAM,CAACY,OAAO,GAAGX,SAAS,IAAMY,YAAYJ,4BAAAA,SAAWP;IACvD,MAAM,CAACY,QAAQC,UAAU,GAAGd,iBAAmCW,0BAAAA,OAAQE,MAAM,mBAAI;IACjF,MAAM,CAACE,KAAKC,OAAO,GAAGhB,SAASiB,gBAAON,0BAAAA,OAAQI,GAAG,oBAAI;IACrD,MAAM,CAACG,SAASC,WAAW,GAAGnB,kBAASW,0BAAAA,OAAQO,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OAAOV,KAAKiE,KAAK;;;;AAIlE;AACA/D,oBAAoBgE,WAAW,GAAG;AAElC,2EAA2E,GAC3E,SAASzD,YAAYgB,KAAc;IACjC,IAAI,CAACA,SAAS,OAAOA,UAAU,UAAU,OAAO;IAChD,MAAM0C,QAAQ1C;IACd,MAAMf,SAASyD,KAAK,CAAC,SAAS;IAC9B,IAAIzD,WAAW,UAAUA,WAAW,YAAYA,WAAW,UAAU,OAAO;IAC5E,MAAM0D,OAAO,CAACC,QAAoB,OAAOA,UAAU,YAAY,OAAOA,UAAU,WAAWvD,OAAOuD,SAAS;IAC3G,OAAO;QAAE3D;QAAQE,KAAKwD,KAAKD,KAAK,CAAC,MAAM;QAAGpD,SAASqD,KAAKD,KAAK,CAAC,UAAU;QAAGlD,OAAOmD,KAAKD,KAAK,CAAC,QAAQ;IAAE;AACzG;AAEA,eAAejE,oBAAmB"}
|
|
@@ -32,7 +32,7 @@ import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
|
|
|
32
32
|
import { PrerequisiteNotice } from "@aglyn/shared-ui-jsx/components/prerequisite-notice.component";
|
|
33
33
|
import { useCommerceEntitlement } from "./entitlement-gate.component.js";
|
|
34
34
|
import CheckoutTaxBlockedNotice from "./checkout-tax-blocked-notice.component.js";
|
|
35
|
-
import { CONNECT_REFRESH_GUARD_MS, CONNECT_RETURN_PARAM, paymentsRequirementsNotice, paymentsReturnResult } from "../../model/payments-setup-status.js";
|
|
35
|
+
import { CONNECT_REFRESH_GUARD_MS, CONNECT_RETURN_PARAM, paymentsRequirementsNotice, paymentsReturnResult, recheckPayments, stripeStillChecking } from "../../model/payments-setup-status.js";
|
|
36
36
|
/** Where the card remembers it already continued an expired Stripe link, so it never loops. */ const REFRESH_GUARD_KEY = 'aglyn.commerce.connectRefreshAt';
|
|
37
37
|
/** The connect return this page was opened with, read once and taken off the address. */ function useConnectReturn() {
|
|
38
38
|
const searchParams = useSearchParams();
|
|
@@ -56,6 +56,16 @@ import { CONNECT_REFRESH_GUARD_MS, CONNECT_RETURN_PARAM, paymentsRequirementsNot
|
|
|
56
56
|
]);
|
|
57
57
|
return value;
|
|
58
58
|
}
|
|
59
|
+
/** Whether the page is in view: a hidden tab asks Stripe nothing, and asks again when it comes back. */ function usePageVisible() {
|
|
60
|
+
const [visible, setVisible] = useState(()=>typeof document === 'undefined' || document.visibilityState !== 'hidden');
|
|
61
|
+
useEffect(()=>{
|
|
62
|
+
if (typeof document === 'undefined') return;
|
|
63
|
+
const update = ()=>setVisible(document.visibilityState !== 'hidden');
|
|
64
|
+
document.addEventListener('visibilitychange', update);
|
|
65
|
+
return ()=>document.removeEventListener('visibilitychange', update);
|
|
66
|
+
}, []);
|
|
67
|
+
return visible;
|
|
68
|
+
}
|
|
59
69
|
/** Whether an expired link was already continued a moment ago (then the owner presses the button). */ function refreshAlreadyContinued(now) {
|
|
60
70
|
try {
|
|
61
71
|
const at = Number(window.sessionStorage.getItem(REFRESH_GUARD_KEY));
|
|
@@ -248,8 +258,115 @@ import { CONNECT_REFRESH_GUARD_MS, CONNECT_RETURN_PARAM, paymentsRequirementsNot
|
|
|
248
258
|
isOwner,
|
|
249
259
|
handleConnect
|
|
250
260
|
]);
|
|
261
|
+
/**
|
|
262
|
+
* THE RESULT IS READ FROM STRIPE, AND READ AGAIN WHILE STRIPE CHECKS
|
|
263
|
+
* (AGL-4061). The card follows the live profile, which the
|
|
264
|
+
* `account.updated` webhook keeps; a webhook that is late, or missing on a
|
|
265
|
+
* local stack, left it saying Stripe still needed details the owner had
|
|
266
|
+
* just given, or "Not set up" for an account Stripe had enabled. So the
|
|
267
|
+
* owner's card asks Stripe (`sync`, which records what Stripe says now and
|
|
268
|
+
* mints nothing) back from Stripe's form (`?connect=done`) and on opening
|
|
269
|
+
* for a store with an account that is not ready; while Stripe is still
|
|
270
|
+
* checking it asks again (quick at first, then every 30 seconds, for up to
|
|
271
|
+
* 15 minutes) while the page is in view, and after that says Stripe is
|
|
272
|
+
* still checking, with Check again. The profile listen redraws the rest.
|
|
273
|
+
*/ const pageVisible = usePageVisible();
|
|
274
|
+
const [recheckRun, setRecheckRun] = useState(0);
|
|
275
|
+
const [syncing, setSyncing] = useState(false);
|
|
276
|
+
const [syncAnswer, setSyncAnswer] = useState(null);
|
|
277
|
+
const [recheckWaitedOut, setRecheckWaitedOut] = useState(false);
|
|
278
|
+
const [rechecking, setRechecking] = useState(false);
|
|
279
|
+
/** The store has a Stripe account that is not ready: worth asking Stripe about. */ const accountNotReady = paymentsState === 'charges-disabled';
|
|
280
|
+
const openSynced = useRef(false);
|
|
281
|
+
useEffect(()=>{
|
|
282
|
+
if (!ready || !isOwner || openSynced.current || connectReturn === 'refresh') return;
|
|
283
|
+
if (connectReturn !== 'done' && !accountNotReady) return;
|
|
284
|
+
openSynced.current = true;
|
|
285
|
+
setRecheckRun((run)=>run + 1);
|
|
286
|
+
}, [
|
|
287
|
+
connectReturn,
|
|
288
|
+
ready,
|
|
289
|
+
isOwner,
|
|
290
|
+
accountNotReady
|
|
291
|
+
]);
|
|
292
|
+
// Back in view with the account still not ready: Stripe may have answered meanwhile.
|
|
293
|
+
const wasVisible = useRef(pageVisible);
|
|
294
|
+
useEffect(()=>{
|
|
295
|
+
const cameBack = pageVisible && !wasVisible.current;
|
|
296
|
+
wasVisible.current = pageVisible;
|
|
297
|
+
if (cameBack && ready && isOwner && accountNotReady && openSynced.current) {
|
|
298
|
+
setRecheckRun((run)=>run + 1);
|
|
299
|
+
}
|
|
300
|
+
}, [
|
|
301
|
+
pageVisible,
|
|
302
|
+
ready,
|
|
303
|
+
isOwner,
|
|
304
|
+
accountNotReady
|
|
305
|
+
]);
|
|
306
|
+
// The signed-in person, read when a check is sent: a fresh user object must not restart a run.
|
|
307
|
+
const userRef = useRef(user);
|
|
308
|
+
userRef.current = user;
|
|
309
|
+
useEffect(()=>{
|
|
310
|
+
if (recheckRun === 0 || !pageVisible) return;
|
|
311
|
+
let cancelled = false;
|
|
312
|
+
const timers = new Set();
|
|
313
|
+
const wakers = new Set();
|
|
314
|
+
setRechecking(true);
|
|
315
|
+
setRecheckWaitedOut(false);
|
|
316
|
+
void recheckPayments({
|
|
317
|
+
sync: async ()=>{
|
|
318
|
+
const response = await authorizedFetch(userRef.current, '/api/commerce/connect', {
|
|
319
|
+
method: 'POST',
|
|
320
|
+
headers: {
|
|
321
|
+
'Content-Type': 'application/json'
|
|
322
|
+
},
|
|
323
|
+
body: JSON.stringify({
|
|
324
|
+
hostId,
|
|
325
|
+
sync: true
|
|
326
|
+
})
|
|
327
|
+
});
|
|
328
|
+
if (!response.ok) throw new Error(`Payments status check answered ${response.status}`);
|
|
329
|
+
return await response.json();
|
|
330
|
+
},
|
|
331
|
+
onChecking: (checking)=>{
|
|
332
|
+
if (!cancelled) setSyncing(checking);
|
|
333
|
+
},
|
|
334
|
+
onStatus: (answer)=>{
|
|
335
|
+
if (!cancelled) setSyncAnswer(answer);
|
|
336
|
+
},
|
|
337
|
+
cancelled: ()=>cancelled,
|
|
338
|
+
// Leaving ends the wait at once rather than after it.
|
|
339
|
+
sleep: (ms)=>new Promise((done)=>{
|
|
340
|
+
const timer = setTimeout(()=>{
|
|
341
|
+
timers.delete(timer);
|
|
342
|
+
wakers.delete(done);
|
|
343
|
+
done();
|
|
344
|
+
}, ms);
|
|
345
|
+
timers.add(timer);
|
|
346
|
+
wakers.add(done);
|
|
347
|
+
})
|
|
348
|
+
}).then((end)=>{
|
|
349
|
+
if (!cancelled && end === 'waited-out') setRecheckWaitedOut(true);
|
|
350
|
+
}).catch((error)=>console.warn('Payments status check with Stripe failed', error)).finally(()=>{
|
|
351
|
+
if (!cancelled) setRechecking(false);
|
|
352
|
+
});
|
|
353
|
+
return ()=>{
|
|
354
|
+
cancelled = true;
|
|
355
|
+
timers.forEach(clearTimeout);
|
|
356
|
+
wakers.forEach((wake)=>wake());
|
|
357
|
+
setSyncing(false);
|
|
358
|
+
setRechecking(false);
|
|
359
|
+
};
|
|
360
|
+
}, [
|
|
361
|
+
recheckRun,
|
|
362
|
+
pageVisible,
|
|
363
|
+
hostId
|
|
364
|
+
]);
|
|
365
|
+
/** What Stripe last said, while the profile still says not ready: it is checking the owner's details. */ const stripeVerifying = stripeState === 'loaded' && !chargesEnabled && !modeMismatch && !modeUnverified && stripeStillChecking(syncAnswer);
|
|
366
|
+
/** The re-checks ran out while Stripe was still checking, and nothing is asking now. */ const stripePending = stripeVerifying && recheckWaitedOut && !rechecking;
|
|
367
|
+
/** Asking Stripe now, or Stripe still checking within the run: never a stale "Not set up". */ const checkingStripe = stripeState === 'loaded' && !chargesEnabled && !modeMismatch && !modeUnverified && (syncing && !syncAnswer || stripeVerifying && !stripePending);
|
|
251
368
|
/** What Stripe still needs, as a standing notice (AGL-4245). */ const requirementsNotice = stripeState === 'loaded' && !modeMismatch && !modeUnverified ? paymentsRequirementsNotice(profile) : null;
|
|
252
|
-
/** The result of coming back from Stripe, from the live profile. */ const returnResult = !returnDismissed && stripeState === 'loaded' && !modeMismatch && !modeUnverified && !requirementsNotice ? connectReturn === 'done' ? paymentsReturnResult(profile, chargesEnabled) : connectReturn === 'refresh' && !chargesEnabled ? {
|
|
369
|
+
/** The result of coming back from Stripe, from the live profile; Stripe's own word on checking wins over it. */ const returnResult = !returnDismissed && !stripeVerifying && stripeState === 'loaded' && !modeMismatch && !modeUnverified && !requirementsNotice ? connectReturn === 'done' ? paymentsReturnResult(profile, chargesEnabled) : connectReturn === 'refresh' && !chargesEnabled ? {
|
|
253
370
|
severity: 'info',
|
|
254
371
|
text: 'The Stripe page had expired. Continue setup to pick up where you left off.',
|
|
255
372
|
continueSetup: true
|
|
@@ -288,8 +405,8 @@ import { CONNECT_REFRESH_GUARD_MS, CONNECT_RETURN_PARAM, paymentsRequirementsNot
|
|
|
288
405
|
}),
|
|
289
406
|
stripeState === 'error' ? null : /*#__PURE__*/ _jsx(Chip, {
|
|
290
407
|
size: "small",
|
|
291
|
-
label: stripeState === 'pending' ? 'Checking…' : chargesEnabled ? 'Charges enabled' : modeMismatch ? liveDeployment ? 'Test account' : 'Live account' : modeUnverified ? 'Not verified' : 'Not set up',
|
|
292
|
-
color: stripeState === 'pending' ? 'default' : chargesEnabled ? 'success' : modeMismatch || modeUnverified ? 'error' : 'warning',
|
|
408
|
+
label: stripeState === 'pending' || checkingStripe ? 'Checking…' : chargesEnabled ? 'Charges enabled' : modeMismatch ? liveDeployment ? 'Test account' : 'Live account' : modeUnverified ? 'Not verified' : stripePending ? 'Pending' : 'Not set up',
|
|
409
|
+
color: stripeState === 'pending' ? 'default' : checkingStripe || stripePending ? 'info' : chargesEnabled ? 'success' : modeMismatch || modeUnverified ? 'error' : 'warning',
|
|
293
410
|
variant: "outlined"
|
|
294
411
|
})
|
|
295
412
|
]
|
|
@@ -362,6 +479,16 @@ import { CONNECT_REFRESH_GUARD_MS, CONNECT_RETURN_PARAM, paymentsRequirementsNot
|
|
|
362
479
|
action: requirementsNotice.continueSetup ? continueButton : undefined,
|
|
363
480
|
children: requirementsNotice.text
|
|
364
481
|
}) : null,
|
|
482
|
+
stripeVerifying && !requirementsNotice ? /*#__PURE__*/ _jsx(Alert, {
|
|
483
|
+
severity: "info",
|
|
484
|
+
action: stripePending ? /*#__PURE__*/ _jsx(Button, {
|
|
485
|
+
color: "inherit",
|
|
486
|
+
size: "small",
|
|
487
|
+
onClick: ()=>setRecheckRun((run)=>run + 1),
|
|
488
|
+
children: 'Check again'
|
|
489
|
+
}) : undefined,
|
|
490
|
+
children: stripePending ? 'Stripe is still checking your details. Check again in a few minutes.' : 'Stripe is checking your details. This usually takes a minute.'
|
|
491
|
+
}) : null,
|
|
365
492
|
returnResult ? /*#__PURE__*/ _jsx(Alert, {
|
|
366
493
|
severity: returnResult.severity,
|
|
367
494
|
onClose: returnResult.continueSetup ? undefined : ()=>setReturnDismissed(true),
|
|
@@ -378,7 +505,7 @@ import { CONNECT_REFRESH_GUARD_MS, CONNECT_RETURN_PARAM, paymentsRequirementsNot
|
|
|
378
505
|
}) : null,
|
|
379
506
|
!planReady || stripeState !== 'loaded' ? null : isOwner ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
380
507
|
children: [
|
|
381
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
508
|
+
stripeVerifying ? null : /*#__PURE__*/ _jsx(Button, {
|
|
382
509
|
size: "small",
|
|
383
510
|
variant: chargesEnabled ? 'text' : 'contained',
|
|
384
511
|
color: "primary",
|