@forgeroute/ui 0.5.0 → 0.5.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.
- package/fesm2022/forgeroute-ui-offline.mjs +18 -2
- package/fesm2022/forgeroute-ui-offline.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-quickbooks.mjs +4953 -0
- package/fesm2022/forgeroute-ui-quickbooks.mjs.map +1 -0
- package/fesm2022/forgeroute-ui-square.mjs +4315 -0
- package/fesm2022/forgeroute-ui-square.mjs.map +1 -0
- package/fesm2022/forgeroute-ui-stripe.mjs +1209 -77
- package/fesm2022/forgeroute-ui-stripe.mjs.map +1 -1
- package/fesm2022/{forgeroute-ui-ui-labels.es-Bdh64Ql6.mjs → forgeroute-ui-ui-labels.es-C1Meg25h.mjs} +271 -2
- package/fesm2022/{forgeroute-ui-ui-labels.es-Bdh64Ql6.mjs.map → forgeroute-ui-ui-labels.es-C1Meg25h.mjs.map} +1 -1
- package/fesm2022/forgeroute-ui.mjs +1840 -5
- package/fesm2022/forgeroute-ui.mjs.map +1 -1
- package/package.json +9 -1
- package/types/forgeroute-ui-offline.d.ts +20 -0
- package/types/forgeroute-ui-quickbooks.d.ts +1482 -0
- package/types/forgeroute-ui-square.d.ts +1376 -0
- package/types/forgeroute-ui-stripe.d.ts +421 -4
- package/types/forgeroute-ui.d.ts +866 -11
|
@@ -0,0 +1,4315 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, InjectionToken, Injector, PLATFORM_ID, ViewEncapsulation, afterNextRender, computed, effect, forwardRef, inject, input, model, output, signal, untracked, viewChild } from "@angular/core";
|
|
3
|
+
import { AlertComponent, BadgeComponent, ButtonComponent, CheckboxComponent, DetailCardComponent, HintComponent, KpiCardComponent, LiveRegionComponent, ModalComponent, PAYMENT_AUTH_TIMEOUT_MS, PAYMENT_HOST_SILENCE_MS, PAYMENT_METHOD_PLUGIN, PAYMENT_READINESS_EVERY_MS, PAYMENT_READINESS_TIMEOUT_MS, PAYMENT_REQUEST_TIMEOUT_MS, PAYMENT_STATUS_CHECK_TIMEOUT_MS, PAYMENT_STATUS_FAIL_GRACE_MS, PAYMENT_STATUS_POLL_MAX_MS, PAYMENT_STATUS_POLL_MS, PaymentAttemptStatusComponent, PaymentMethodPlugin, PillTabsComponent, SkeletonComponent, StackComponent, TextComponent, TextInputComponent, UiLabelsService, callHost, classifyHostError, createPaymentProtection, formatCurrency, hostErrorMessage, isDarkPage, refusalLabelKey, uiText, warnQueuedPayment, wasQueuedOffline } from "@forgeroute/ui";
|
|
4
|
+
import { DOCUMENT, NgTemplateOutlet, isPlatformBrowser } from "@angular/common";
|
|
5
|
+
import * as i1 from "@angular/forms";
|
|
6
|
+
import { FormsModule } from "@angular/forms";
|
|
7
|
+
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
8
|
+
const SQUARE_SDK_URL = "https://web.squarecdn.com/v1/square.js";
|
|
9
|
+
const SQUARE_SANDBOX_SDK_URL = "https://sandbox.web.squarecdn.com/v1/square.js";
|
|
10
|
+
const SQUARE_LOAD_TIMEOUT_MS = 2e4;
|
|
11
|
+
function withSquareTimeout(step, makeError) {
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
const timer = setTimeout(() => reject(makeError()), SQUARE_LOAD_TIMEOUT_MS);
|
|
14
|
+
Promise.resolve(step).then((value) => {
|
|
15
|
+
clearTimeout(timer);
|
|
16
|
+
resolve(value);
|
|
17
|
+
}, (error) => {
|
|
18
|
+
clearTimeout(timer);
|
|
19
|
+
reject(error);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const OWN_SCRIPT_MARK = "data-forgeroute-square";
|
|
24
|
+
var SquareLoadError = class extends Error {
|
|
25
|
+
constructor(code) {
|
|
26
|
+
super(code);
|
|
27
|
+
this.code = code;
|
|
28
|
+
this.name = "SquareLoadError";
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const squareGlobal = () => window.Square;
|
|
32
|
+
const squareScript = {
|
|
33
|
+
pending: /* @__PURE__ */ new Map(),
|
|
34
|
+
active: null,
|
|
35
|
+
owners: /* @__PURE__ */ new Map(),
|
|
36
|
+
load(url) {
|
|
37
|
+
const switching = squareScript.active !== null && squareScript.active !== url;
|
|
38
|
+
if (squareGlobal() && !switching) return Promise.resolve();
|
|
39
|
+
for (const [other, inFlight] of squareScript.pending) if (other !== url) return inFlight.catch(() => void 0).then(() => squareScript.load(url));
|
|
40
|
+
const running = squareScript.pending.get(url);
|
|
41
|
+
if (running) return running;
|
|
42
|
+
const owner = {};
|
|
43
|
+
squareScript.owners.set(url, owner);
|
|
44
|
+
const promise = new Promise((resolve, reject) => {
|
|
45
|
+
const windowWithSquare = window;
|
|
46
|
+
const previous = switching ? windowWithSquare.Square : void 0;
|
|
47
|
+
const current = () => squareScript.owners.get(url) === owner;
|
|
48
|
+
let settled = false;
|
|
49
|
+
let loadTimer = null;
|
|
50
|
+
let script = null;
|
|
51
|
+
const finish = () => {
|
|
52
|
+
if (settled) return false;
|
|
53
|
+
settled = true;
|
|
54
|
+
if (loadTimer) {
|
|
55
|
+
clearTimeout(loadTimer);
|
|
56
|
+
loadTimer = null;
|
|
57
|
+
}
|
|
58
|
+
if (script) {
|
|
59
|
+
script.onload = null;
|
|
60
|
+
script.onerror = null;
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
};
|
|
64
|
+
const fail = () => {
|
|
65
|
+
if (!finish()) return;
|
|
66
|
+
if (current()) {
|
|
67
|
+
squareScript.pending.delete(url);
|
|
68
|
+
squareScript.owners.delete(url);
|
|
69
|
+
if (switching && previous && !windowWithSquare.Square) windowWithSquare.Square = previous;
|
|
70
|
+
}
|
|
71
|
+
reject(new SquareLoadError("script_failed"));
|
|
72
|
+
};
|
|
73
|
+
const done = () => {
|
|
74
|
+
if (!finish()) return;
|
|
75
|
+
if (current()) {
|
|
76
|
+
squareScript.active = url;
|
|
77
|
+
squareScript.pending.delete(url);
|
|
78
|
+
squareScript.owners.delete(url);
|
|
79
|
+
}
|
|
80
|
+
resolve();
|
|
81
|
+
};
|
|
82
|
+
const tags = Array.from(document.querySelectorAll("script")).filter((s) => s.getAttribute("src") === url);
|
|
83
|
+
let foreign = tags.filter((t) => !t.hasAttribute(OWN_SCRIPT_MARK));
|
|
84
|
+
if (switching) {
|
|
85
|
+
tags.forEach((t) => t.remove());
|
|
86
|
+
foreign = [];
|
|
87
|
+
delete windowWithSquare.Square;
|
|
88
|
+
} else tags.filter((t) => t.hasAttribute(OWN_SCRIPT_MARK)).forEach((t) => t.remove());
|
|
89
|
+
if (!switching && foreign.length) {
|
|
90
|
+
const started = Date.now();
|
|
91
|
+
const timer = setInterval(() => {
|
|
92
|
+
if (settled) {
|
|
93
|
+
clearInterval(timer);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (squareGlobal()) {
|
|
97
|
+
clearInterval(timer);
|
|
98
|
+
done();
|
|
99
|
+
} else if (Date.now() - started > 15e3) {
|
|
100
|
+
clearInterval(timer);
|
|
101
|
+
fail();
|
|
102
|
+
}
|
|
103
|
+
}, 50);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const own = document.createElement("script");
|
|
107
|
+
script = own;
|
|
108
|
+
own.src = url;
|
|
109
|
+
own.async = true;
|
|
110
|
+
own.setAttribute(OWN_SCRIPT_MARK, "");
|
|
111
|
+
loadTimer = setTimeout(() => {
|
|
112
|
+
own.remove();
|
|
113
|
+
fail();
|
|
114
|
+
}, SQUARE_LOAD_TIMEOUT_MS);
|
|
115
|
+
own.onload = () => {
|
|
116
|
+
if (squareGlobal()) done();
|
|
117
|
+
else {
|
|
118
|
+
own.remove();
|
|
119
|
+
fail();
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
own.onerror = () => {
|
|
123
|
+
own.remove();
|
|
124
|
+
fail();
|
|
125
|
+
};
|
|
126
|
+
document.head.appendChild(own);
|
|
127
|
+
});
|
|
128
|
+
squareScript.pending.set(url, promise);
|
|
129
|
+
return promise;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
const squareSdkUrl = (environment) => environment === "production" ? SQUARE_SDK_URL : SQUARE_SANDBOX_SDK_URL;
|
|
133
|
+
const defaultSquareLoader = async (config) => {
|
|
134
|
+
await squareScript.load(squareSdkUrl(config.environment));
|
|
135
|
+
const square = squareGlobal();
|
|
136
|
+
if (!square) throw new SquareLoadError("sdk_missing");
|
|
137
|
+
return square.payments(config.applicationId, config.locationId);
|
|
138
|
+
};
|
|
139
|
+
const SQUARE_LOADER = new InjectionToken("SQUARE_LOADER", {
|
|
140
|
+
providedIn: "root",
|
|
141
|
+
factory: () => defaultSquareLoader
|
|
142
|
+
});
|
|
143
|
+
const SQUARE_PAYMENT_DEFAULTS = new InjectionToken("SQUARE_PAYMENT_DEFAULTS", {
|
|
144
|
+
providedIn: "root",
|
|
145
|
+
factory: () => ({})
|
|
146
|
+
});
|
|
147
|
+
function provideSquarePayment(options = {}) {
|
|
148
|
+
const { loader, ...defaults } = options;
|
|
149
|
+
const providers = [{
|
|
150
|
+
provide: SQUARE_PAYMENT_DEFAULTS,
|
|
151
|
+
useValue: defaults
|
|
152
|
+
}];
|
|
153
|
+
if (loader) providers.push({
|
|
154
|
+
provide: SQUARE_LOADER,
|
|
155
|
+
useValue: loader
|
|
156
|
+
});
|
|
157
|
+
return providers;
|
|
158
|
+
}
|
|
159
|
+
const SQUARE_PAYMENT_ERROR_KEYS = {
|
|
160
|
+
GENERIC_DECLINE: "squareErrors.code.GENERIC_DECLINE",
|
|
161
|
+
CARD_DECLINED: "squareErrors.code.CARD_DECLINED",
|
|
162
|
+
CARD_DECLINED_CALL_ISSUER: "squareErrors.code.CARD_DECLINED_CALL_ISSUER",
|
|
163
|
+
CARD_DECLINED_VERIFICATION_REQUIRED: "squareErrors.code.CARD_DECLINED_VERIFICATION_REQUIRED",
|
|
164
|
+
INSUFFICIENT_FUNDS: "squareErrors.code.INSUFFICIENT_FUNDS",
|
|
165
|
+
CVV_FAILURE: "squareErrors.code.CVV_FAILURE",
|
|
166
|
+
VERIFY_CVV_FAILURE: "squareErrors.code.CVV_FAILURE",
|
|
167
|
+
ADDRESS_VERIFICATION_FAILURE: "squareErrors.code.ADDRESS_VERIFICATION_FAILURE",
|
|
168
|
+
VERIFY_AVS_FAILURE: "squareErrors.code.ADDRESS_VERIFICATION_FAILURE",
|
|
169
|
+
INVALID_EXPIRATION: "squareErrors.code.INVALID_EXPIRATION",
|
|
170
|
+
BAD_EXPIRATION: "squareErrors.code.INVALID_EXPIRATION",
|
|
171
|
+
CARD_EXPIRED: "squareErrors.code.CARD_EXPIRED",
|
|
172
|
+
INVALID_CARD: "squareErrors.code.INVALID_CARD",
|
|
173
|
+
PAN_FAILURE: "squareErrors.code.INVALID_CARD",
|
|
174
|
+
CARD_NOT_SUPPORTED: "squareErrors.code.CARD_NOT_SUPPORTED",
|
|
175
|
+
INVALID_ACCOUNT: "squareErrors.code.INVALID_ACCOUNT",
|
|
176
|
+
PAYMENT_LIMIT_EXCEEDED: "squareErrors.code.PAYMENT_LIMIT_EXCEEDED",
|
|
177
|
+
TRANSACTION_LIMIT: "squareErrors.code.PAYMENT_LIMIT_EXCEEDED",
|
|
178
|
+
BUYER_REFUSED_PAYMENT: "squareErrors.code.BUYER_REFUSED_PAYMENT",
|
|
179
|
+
CARDHOLDER_INSUFFICIENT_PERMISSIONS: "squareErrors.code.CARDHOLDER_INSUFFICIENT_PERMISSIONS",
|
|
180
|
+
IDEMPOTENCY_KEY_REUSED: "squareErrors.code.IDEMPOTENCY_KEY_REUSED",
|
|
181
|
+
RATE_LIMITED: "squareErrors.code.RATE_LIMITED",
|
|
182
|
+
UNAUTHORIZED: "squareErrors.code.UNAUTHORIZED",
|
|
183
|
+
ACCESS_TOKEN_EXPIRED: "squareErrors.code.UNAUTHORIZED",
|
|
184
|
+
ACCESS_TOKEN_REVOKED: "squareErrors.code.UNAUTHORIZED"
|
|
185
|
+
};
|
|
186
|
+
const SQUARE_FIELD_ERROR_KEYS = {
|
|
187
|
+
cardNumber: "squareErrors.field.cardNumber",
|
|
188
|
+
expirationDate: "squareErrors.field.expirationDate",
|
|
189
|
+
cvv: "squareErrors.field.cvv",
|
|
190
|
+
postalCode: "squareErrors.field.postalCode"
|
|
191
|
+
};
|
|
192
|
+
const SQUARE_TYPE_ERROR_KEYS = {
|
|
193
|
+
UNSUPPORTED_CARD_BRAND: "squareErrors.type.UNSUPPORTED_CARD_BRAND",
|
|
194
|
+
INVALID_APPLICATION_ID: "squareErrors.type.CONFIGURATION",
|
|
195
|
+
INVALID_LOCATION_ID: "squareErrors.type.CONFIGURATION",
|
|
196
|
+
PAYMENT_METHOD_NOT_SUPPORTED: "squareErrors.type.PAYMENT_METHOD_NOT_SUPPORTED"
|
|
197
|
+
};
|
|
198
|
+
function getSquarePaymentErrorMessage(code, options = {}) {
|
|
199
|
+
const fallback = options.fallback ?? uiText("squareErrors.defaultMessage");
|
|
200
|
+
const key = (code ?? "").toUpperCase();
|
|
201
|
+
const override = key ? options.overrides?.[code] ?? options.overrides?.[key] : void 0;
|
|
202
|
+
if (override) return override;
|
|
203
|
+
const table = SQUARE_PAYMENT_ERROR_KEYS[key];
|
|
204
|
+
return table ? uiText(table) : fallback;
|
|
205
|
+
}
|
|
206
|
+
function getSquareErrorMessage(error, options = {}) {
|
|
207
|
+
const fallback = options.fallback ?? uiText("squareErrors.defaultMessage");
|
|
208
|
+
if (!error) return fallback;
|
|
209
|
+
if (options.display === "square") return error.message || fallback;
|
|
210
|
+
const overrides = options.overrides ?? {};
|
|
211
|
+
for (const name of [
|
|
212
|
+
error.code,
|
|
213
|
+
error.type,
|
|
214
|
+
error.field
|
|
215
|
+
]) if (name && overrides[name]) return overrides[name];
|
|
216
|
+
if (error.code && SQUARE_PAYMENT_ERROR_KEYS[error.code.toUpperCase()]) return uiText(SQUARE_PAYMENT_ERROR_KEYS[error.code.toUpperCase()]);
|
|
217
|
+
if (error.field && SQUARE_FIELD_ERROR_KEYS[error.field]) return uiText(SQUARE_FIELD_ERROR_KEYS[error.field]);
|
|
218
|
+
const type = (error.type ?? "").toUpperCase();
|
|
219
|
+
if (SQUARE_TYPE_ERROR_KEYS[type]) return uiText(SQUARE_TYPE_ERROR_KEYS[type]);
|
|
220
|
+
if (type === "VALIDATION_ERROR" && error.message) return error.message;
|
|
221
|
+
return fallback;
|
|
222
|
+
}
|
|
223
|
+
function squareFailure(code, message, stage, squareMessage = "") {
|
|
224
|
+
return {
|
|
225
|
+
code,
|
|
226
|
+
message,
|
|
227
|
+
squareMessage,
|
|
228
|
+
stage
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
function messageOfThrown(err, fallback) {
|
|
232
|
+
const e = err;
|
|
233
|
+
if (typeof e?.error?.message === "string" && e.error.message) return e.error.message;
|
|
234
|
+
if (typeof e?.message === "string" && e.message) return e.message;
|
|
235
|
+
return fallback;
|
|
236
|
+
}
|
|
237
|
+
const upper = (v) => typeof v === "string" ? v.toUpperCase() : "";
|
|
238
|
+
const text = (v) => typeof v === "string" && v.trim() ? v : null;
|
|
239
|
+
function normalizeSquareDetails(details) {
|
|
240
|
+
const card = details?.card;
|
|
241
|
+
const cardType = upper(card?.cardType);
|
|
242
|
+
const prepaid = upper(card?.prepaidType);
|
|
243
|
+
return {
|
|
244
|
+
brand: text(card?.brand),
|
|
245
|
+
last4: text(card?.last4) ?? text(details?.lastFour) ?? text(details?.ach?.lastFour),
|
|
246
|
+
expMonth: typeof card?.expMonth === "number" ? card.expMonth : null,
|
|
247
|
+
expYear: typeof card?.expYear === "number" ? card.expYear : null,
|
|
248
|
+
cardType: cardType === "CREDIT" || cardType === "DEBIT" || cardType === "UNKNOWN" ? cardType : null,
|
|
249
|
+
prepaidType: prepaid === "PREPAID" || prepaid === "NOT_PREPAID" || prepaid === "UNKNOWN" ? prepaid : null,
|
|
250
|
+
bankName: text(details?.bankName) ?? text(details?.ach?.bankName),
|
|
251
|
+
accountType: text(details?.accountType) ?? text(details?.ach?.accountType)
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
function failureFromTokenResult(result, method, options = {}) {
|
|
255
|
+
const errors = (result.errors ?? []).filter((e) => !!e);
|
|
256
|
+
const first = errors[0];
|
|
257
|
+
const base = {
|
|
258
|
+
status: result.status,
|
|
259
|
+
...errors.length ? { errors } : {}
|
|
260
|
+
};
|
|
261
|
+
if (!first) {
|
|
262
|
+
const cancelled = result.status === "Cancel";
|
|
263
|
+
return {
|
|
264
|
+
...squareFailure(cancelled ? "cancelled" : method === "ach" ? "ach_failed" : "tokenize_failed", uiText(cancelled ? "squarePayment.msg.cancelled" : method === "ach" ? "squarePayment.msg.achFailed" : "squarePayment.msg.tokenizeFailed"), "tokenize"),
|
|
265
|
+
...base
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
const fallback = options.fallback ?? uiText(method === "ach" ? "squarePayment.msg.achFailed" : "squarePayment.msg.tokenizeFailed");
|
|
269
|
+
return {
|
|
270
|
+
...squareFailure(first.code || first.type || "tokenize_failed", getSquareErrorMessage(first, {
|
|
271
|
+
...options,
|
|
272
|
+
fallback
|
|
273
|
+
}), "tokenize", first.message ?? ""),
|
|
274
|
+
...base,
|
|
275
|
+
...first.field ? { field: first.field } : {}
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
function newIdempotencyKey() {
|
|
279
|
+
const c = typeof crypto !== "undefined" ? crypto : void 0;
|
|
280
|
+
return c && "randomUUID" in c ? c.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`;
|
|
281
|
+
}
|
|
282
|
+
const DARK_TEXT = "#e2e8f0";
|
|
283
|
+
const DARK_BACKGROUND = "#0f172a";
|
|
284
|
+
const DARK_BORDER = "#64748b";
|
|
285
|
+
function readSquareCardStyle(doc, element = doc.documentElement) {
|
|
286
|
+
const view = doc.defaultView;
|
|
287
|
+
const token = (name) => view ? view.getComputedStyle(element).getPropertyValue(name).trim() : "";
|
|
288
|
+
const dark = isDarkPage(doc);
|
|
289
|
+
const primary = token("--ui-square-color-primary");
|
|
290
|
+
const text = token("--ui-square-color-text") || (dark ? DARK_TEXT : "");
|
|
291
|
+
const background = token("--ui-square-color-background") || (dark ? DARK_BACKGROUND : "");
|
|
292
|
+
const border = token("--ui-square-color-border") || (dark ? DARK_BORDER : "");
|
|
293
|
+
const danger = token("--ui-square-color-danger");
|
|
294
|
+
const font = token("--ui-square-font-family");
|
|
295
|
+
const radius = token("--ui-square-border-radius");
|
|
296
|
+
const size = token("--ui-square-font-size-base");
|
|
297
|
+
const style = {};
|
|
298
|
+
const put = (selector, props) => {
|
|
299
|
+
const filled = Object.fromEntries(Object.entries(props).filter(([, v]) => !!v));
|
|
300
|
+
if (Object.keys(filled).length) style[selector] = filled;
|
|
301
|
+
};
|
|
302
|
+
put(".input-container", {
|
|
303
|
+
borderColor: border,
|
|
304
|
+
borderRadius: radius
|
|
305
|
+
});
|
|
306
|
+
put(".input-container.is-focus", { borderColor: primary });
|
|
307
|
+
put(".input-container.is-error", { borderColor: danger });
|
|
308
|
+
put(".message-text", { color: text });
|
|
309
|
+
put(".message-icon", { color: text });
|
|
310
|
+
put(".message-text.is-error", { color: danger });
|
|
311
|
+
put("input", {
|
|
312
|
+
backgroundColor: background,
|
|
313
|
+
color: text,
|
|
314
|
+
fontFamily: font,
|
|
315
|
+
fontSize: size
|
|
316
|
+
});
|
|
317
|
+
put("input::placeholder", { color: dark ? "#94a3b8" : "" });
|
|
318
|
+
return style;
|
|
319
|
+
}
|
|
320
|
+
const SQUARE_A11Y_MESSAGES = {
|
|
321
|
+
get loading() {
|
|
322
|
+
return uiText("squarePayment.a11y.loading");
|
|
323
|
+
},
|
|
324
|
+
get processing() {
|
|
325
|
+
return uiText("squarePayment.a11y.processing");
|
|
326
|
+
},
|
|
327
|
+
get tokenized() {
|
|
328
|
+
return uiText("squarePayment.a11y.tokenized");
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
let nextId = 0;
|
|
332
|
+
const jsonEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
333
|
+
function structuralEqual(a, b, inProgress = /* @__PURE__ */ new WeakMap()) {
|
|
334
|
+
if (Object.is(a, b)) return true;
|
|
335
|
+
if (typeof a !== "object" || typeof b !== "object" || !a || !b) return false;
|
|
336
|
+
if (inProgress.get(a)?.has(b)) return true;
|
|
337
|
+
if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false;
|
|
338
|
+
if (a instanceof Date) return b instanceof Date && a.getTime() === b.getTime();
|
|
339
|
+
if (a instanceof RegExp) return b instanceof RegExp && a.source === b.source && a.flags === b.flags;
|
|
340
|
+
const pairs = inProgress.get(a) ?? /* @__PURE__ */ new WeakSet();
|
|
341
|
+
pairs.add(b);
|
|
342
|
+
inProgress.set(a, pairs);
|
|
343
|
+
try {
|
|
344
|
+
if (a instanceof Map) {
|
|
345
|
+
const other = b;
|
|
346
|
+
return a.size === other.size && [...a].every(([k, v]) => other.has(k) && structuralEqual(v, other.get(k), inProgress));
|
|
347
|
+
}
|
|
348
|
+
if (a instanceof Set) {
|
|
349
|
+
const other = b;
|
|
350
|
+
if (a.size !== other.size) return false;
|
|
351
|
+
const rest = [...other];
|
|
352
|
+
for (const member of a) {
|
|
353
|
+
const at = rest.findIndex((candidate) => structuralEqual(member, candidate, inProgress));
|
|
354
|
+
if (at < 0) return false;
|
|
355
|
+
rest.splice(at, 1);
|
|
356
|
+
}
|
|
357
|
+
return true;
|
|
358
|
+
}
|
|
359
|
+
const keysA = Object.keys(a);
|
|
360
|
+
const keysB = Object.keys(b);
|
|
361
|
+
return keysA.length === keysB.length && keysA.every((k) => k in b && structuralEqual(a[k], b[k], inProgress));
|
|
362
|
+
} finally {
|
|
363
|
+
pairs.delete(b);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
var SquarePaymentComponent = class SquarePaymentComponent {
|
|
367
|
+
constructor() {
|
|
368
|
+
this.labels = inject(UiLabelsService);
|
|
369
|
+
this.loader = inject(SQUARE_LOADER);
|
|
370
|
+
this.defaults = inject(SQUARE_PAYMENT_DEFAULTS);
|
|
371
|
+
this.doc = inject(DOCUMENT);
|
|
372
|
+
this.isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
373
|
+
this.host = inject(ElementRef);
|
|
374
|
+
this.injector = inject(Injector);
|
|
375
|
+
this.mountOnly = input(false, ...ngDevMode ? [{ debugName: "mountOnly" }] : /* istanbul ignore next */ []);
|
|
376
|
+
this.mode = input("payment", ...ngDevMode ? [{ debugName: "mode" }] : /* istanbul ignore next */ []);
|
|
377
|
+
this.method = model("card", ...ngDevMode ? [{ debugName: "method" }] : /* istanbul ignore next */ []);
|
|
378
|
+
this.methods = input(null, ...ngDevMode ? [{ debugName: "methods" }] : /* istanbul ignore next */ []);
|
|
379
|
+
this.applicationId = input(null, ...ngDevMode ? [{ debugName: "applicationId" }] : /* istanbul ignore next */ []);
|
|
380
|
+
this.locationId = input(null, ...ngDevMode ? [{ debugName: "locationId" }] : /* istanbul ignore next */ []);
|
|
381
|
+
this.environment = input(null, ...ngDevMode ? [{ debugName: "environment" }] : /* istanbul ignore next */ []);
|
|
382
|
+
this.amount = input(null, ...ngDevMode ? [{ debugName: "amount" }] : /* istanbul ignore next */ []);
|
|
383
|
+
this.currency = input("USD", ...ngDevMode ? [{ debugName: "currency" }] : /* istanbul ignore next */ []);
|
|
384
|
+
this.billingContact = input(null, ...ngDevMode ? [{ debugName: "billingContact" }] : /* istanbul ignore next */ []);
|
|
385
|
+
this.verifyBuyer = input(null, ...ngDevMode ? [{ debugName: "verifyBuyer" }] : /* istanbul ignore next */ []);
|
|
386
|
+
this.accountHolderName = input("", ...ngDevMode ? [{ debugName: "accountHolderName" }] : /* istanbul ignore next */ []);
|
|
387
|
+
this.requireAchConsent = input(true, ...ngDevMode ? [{ debugName: "requireAchConsent" }] : /* istanbul ignore next */ []);
|
|
388
|
+
this.achConsentTextInput = input(null, {
|
|
389
|
+
...ngDevMode ? { debugName: "achConsentTextInput" } : /* istanbul ignore next */ {},
|
|
390
|
+
alias: "achConsentText"
|
|
391
|
+
});
|
|
392
|
+
this.achConsent = computed(() => this.achConsentTextInput() ?? this.labels.t(this.mode() === "setup" ? "squarePayment.achConsentSetup" : "squarePayment.achConsent"), ...ngDevMode ? [{ debugName: "achConsent" }] : /* istanbul ignore next */ []);
|
|
393
|
+
this.achRedirectUri = input(null, ...ngDevMode ? [{ debugName: "achRedirectUri" }] : /* istanbul ignore next */ []);
|
|
394
|
+
this.achTransactionId = input(null, ...ngDevMode ? [{ debugName: "achTransactionId" }] : /* istanbul ignore next */ []);
|
|
395
|
+
this.cardOptions = input(null, ...ngDevMode ? [{ debugName: "cardOptions" }] : /* istanbul ignore next */ []);
|
|
396
|
+
this.cardStyle = input(null, ...ngDevMode ? [{ debugName: "cardStyle" }] : /* istanbul ignore next */ []);
|
|
397
|
+
this.styleFromTokens = input(false, ...ngDevMode ? [{ debugName: "styleFromTokens" }] : /* istanbul ignore next */ []);
|
|
398
|
+
this.showStatus = input(true, ...ngDevMode ? [{ debugName: "showStatus" }] : /* istanbul ignore next */ []);
|
|
399
|
+
this.payableRef = input(null, ...ngDevMode ? [{ debugName: "payableRef" }] : /* istanbul ignore next */ []);
|
|
400
|
+
this.attemptKey = input(null, ...ngDevMode ? [{ debugName: "attemptKey" }] : /* istanbul ignore next */ []);
|
|
401
|
+
this.checkStatus = input(null, ...ngDevMode ? [{ debugName: "checkStatus" }] : /* istanbul ignore next */ []);
|
|
402
|
+
this.paid = input(false, ...ngDevMode ? [{ debugName: "paid" }] : /* istanbul ignore next */ []);
|
|
403
|
+
this.hostPending = input(false, ...ngDevMode ? [{ debugName: "hostPending" }] : /* istanbul ignore next */ []);
|
|
404
|
+
this.statusPollMs = input(PAYMENT_STATUS_POLL_MS, ...ngDevMode ? [{ debugName: "statusPollMs" }] : /* istanbul ignore next */ []);
|
|
405
|
+
this.statusPollMaxMs = input(PAYMENT_STATUS_POLL_MAX_MS, ...ngDevMode ? [{ debugName: "statusPollMaxMs" }] : /* istanbul ignore next */ []);
|
|
406
|
+
this.statusCheckTimeoutMs = input(PAYMENT_STATUS_CHECK_TIMEOUT_MS, ...ngDevMode ? [{ debugName: "statusCheckTimeoutMs" }] : /* istanbul ignore next */ []);
|
|
407
|
+
this.statusFailGraceMs = input(PAYMENT_STATUS_FAIL_GRACE_MS, ...ngDevMode ? [{ debugName: "statusFailGraceMs" }] : /* istanbul ignore next */ []);
|
|
408
|
+
this.allowStartOver = input(false, ...ngDevMode ? [{ debugName: "allowStartOver" }] : /* istanbul ignore next */ []);
|
|
409
|
+
this.offlineOverride = input(false, ...ngDevMode ? [{ debugName: "offlineOverride" }] : /* istanbul ignore next */ []);
|
|
410
|
+
this.hostSilenceMs = input(PAYMENT_HOST_SILENCE_MS, ...ngDevMode ? [{ debugName: "hostSilenceMs" }] : /* istanbul ignore next */ []);
|
|
411
|
+
this.readinessCheck = input(null, ...ngDevMode ? [{ debugName: "readinessCheck" }] : /* istanbul ignore next */ []);
|
|
412
|
+
this.readinessTimeoutMs = input(PAYMENT_READINESS_TIMEOUT_MS, ...ngDevMode ? [{ debugName: "readinessTimeoutMs" }] : /* istanbul ignore next */ []);
|
|
413
|
+
this.readinessEveryMs = input(PAYMENT_READINESS_EVERY_MS, ...ngDevMode ? [{ debugName: "readinessEveryMs" }] : /* istanbul ignore next */ []);
|
|
414
|
+
this.submitLabel = input("", ...ngDevMode ? [{ debugName: "submitLabel" }] : /* istanbul ignore next */ []);
|
|
415
|
+
this.showSubmit = input(true, ...ngDevMode ? [{ debugName: "showSubmit" }] : /* istanbul ignore next */ []);
|
|
416
|
+
this.disabled = input(false, ...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
|
|
417
|
+
this.pending = input(false, ...ngDevMode ? [{ debugName: "pending" }] : /* istanbul ignore next */ []);
|
|
418
|
+
this.labelInput = input(null, {
|
|
419
|
+
...ngDevMode ? { debugName: "labelInput" } : /* istanbul ignore next */ {},
|
|
420
|
+
alias: "label"
|
|
421
|
+
});
|
|
422
|
+
this.label = computed(() => this.labelInput() ?? this.labels.t("squarePayment.label"), ...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
|
|
423
|
+
this.required = input(false, ...ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []);
|
|
424
|
+
this.mountId = input("", ...ngDevMode ? [{ debugName: "mountId" }] : /* istanbul ignore next */ []);
|
|
425
|
+
this.mountClass = input("", ...ngDevMode ? [{ debugName: "mountClass" }] : /* istanbul ignore next */ []);
|
|
426
|
+
this.mountTestId = input("square-card-form", ...ngDevMode ? [{ debugName: "mountTestId" }] : /* istanbul ignore next */ []);
|
|
427
|
+
this.errorTestId = input("square-error", ...ngDevMode ? [{ debugName: "errorTestId" }] : /* istanbul ignore next */ []);
|
|
428
|
+
this.holderTestId = input("square-holder", ...ngDevMode ? [{ debugName: "holderTestId" }] : /* istanbul ignore next */ []);
|
|
429
|
+
this.showErrors = input(true, ...ngDevMode ? [{ debugName: "showErrors" }] : /* istanbul ignore next */ []);
|
|
430
|
+
this.errorDisplay = input("friendly", ...ngDevMode ? [{ debugName: "errorDisplay" }] : /* istanbul ignore next */ []);
|
|
431
|
+
this.errorMessages = input(null, ...ngDevMode ? [{ debugName: "errorMessages" }] : /* istanbul ignore next */ []);
|
|
432
|
+
this.errorFallback = input("", ...ngDevMode ? [{ debugName: "errorFallback" }] : /* istanbul ignore next */ []);
|
|
433
|
+
this.loadErrorMessageInput = input(null, {
|
|
434
|
+
...ngDevMode ? { debugName: "loadErrorMessageInput" } : /* istanbul ignore next */ {},
|
|
435
|
+
alias: "loadErrorMessage"
|
|
436
|
+
});
|
|
437
|
+
this.loadErrorMessage = computed(() => this.loadErrorMessageInput() ?? this.labels.t("squarePayment.loadErrorMessage"), ...ngDevMode ? [{ debugName: "loadErrorMessage" }] : /* istanbul ignore next */ []);
|
|
438
|
+
this.a11yMessages = input(null, ...ngDevMode ? [{ debugName: "a11yMessages" }] : /* istanbul ignore next */ []);
|
|
439
|
+
this.squareReady = output();
|
|
440
|
+
this.ready = output();
|
|
441
|
+
this.inFlightChange = output();
|
|
442
|
+
this.outcome = output();
|
|
443
|
+
this.attemptKeyChange = output();
|
|
444
|
+
this.readinessChange = output();
|
|
445
|
+
this.tokenized = output();
|
|
446
|
+
this.failed = output();
|
|
447
|
+
this.loadError = output();
|
|
448
|
+
this.loading = signal(false, ...ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []);
|
|
449
|
+
this.isReady = signal(false, ...ngDevMode ? [{ debugName: "isReady" }] : /* istanbul ignore next */ []);
|
|
450
|
+
this.submitting = signal(false, ...ngDevMode ? [{ debugName: "submitting" }] : /* istanbul ignore next */ []);
|
|
451
|
+
this.errorText = signal("", ...ngDevMode ? [{ debugName: "errorText" }] : /* istanbul ignore next */ []);
|
|
452
|
+
this.loadErrorText = signal("", ...ngDevMode ? [{ debugName: "loadErrorText" }] : /* istanbul ignore next */ []);
|
|
453
|
+
this.holder = signal("", ...ngDevMode ? [{ debugName: "holder" }] : /* istanbul ignore next */ []);
|
|
454
|
+
this.consent = signal(false, ...ngDevMode ? [{ debugName: "consent" }] : /* istanbul ignore next */ []);
|
|
455
|
+
this.attempted = signal(false, ...ngDevMode ? [{ debugName: "attempted" }] : /* istanbul ignore next */ []);
|
|
456
|
+
this.announcement = signal("", ...ngDevMode ? [{ debugName: "announcement" }] : /* istanbul ignore next */ []);
|
|
457
|
+
this.resetTick = signal(0, ...ngDevMode ? [{ debugName: "resetTick" }] : /* istanbul ignore next */ []);
|
|
458
|
+
this.errorId = `ui-square-error-${nextId++}`;
|
|
459
|
+
this.mountRef = viewChild("mount", ...ngDevMode ? [{ debugName: "mountRef" }] : /* istanbul ignore next */ []);
|
|
460
|
+
this.tabs = computed(() => {
|
|
461
|
+
const methods = this.methods();
|
|
462
|
+
if (!methods || methods.length < 2) return [];
|
|
463
|
+
return methods.map((m) => ({
|
|
464
|
+
key: m,
|
|
465
|
+
label: this.labels.t(m === "card" ? "squarePayment.method.card" : "squarePayment.method.ach")
|
|
466
|
+
}));
|
|
467
|
+
}, ...ngDevMode ? [{ debugName: "tabs" }] : /* istanbul ignore next */ []);
|
|
468
|
+
this.locked = computed(() => this.disabled() || this.submitting() || this.attempt.locked(), ...ngDevMode ? [{ debugName: "locked" }] : /* istanbul ignore next */ []);
|
|
469
|
+
this.mountHidden = computed(() => !this.mountOnly() && (this.loading() || this.pending() || !!this.loadErrorText()), ...ngDevMode ? [{ debugName: "mountHidden" }] : /* istanbul ignore next */ []);
|
|
470
|
+
this.mountLocked = computed(() => !this.mountOnly() && this.locked(), ...ngDevMode ? [{ debugName: "mountLocked" }] : /* istanbul ignore next */ []);
|
|
471
|
+
this.holderError = computed(() => this.attempted() && !this.holder().trim() ? this.labels.t("squarePayment.holderRequired") : "", ...ngDevMode ? [{ debugName: "holderError" }] : /* istanbul ignore next */ []);
|
|
472
|
+
this.effectiveSubmitLabel = computed(() => {
|
|
473
|
+
const given = this.submitLabel();
|
|
474
|
+
if (given) return given;
|
|
475
|
+
const setup = this.mode() === "setup";
|
|
476
|
+
return this.labels.t(this.method() === "ach" ? setup ? "squarePayment.submit.saveBank" : "squarePayment.submit.payBank" : setup ? "squarePayment.submit.saveCard" : "squarePayment.submit.pay");
|
|
477
|
+
}, ...ngDevMode ? [{ debugName: "effectiveSubmitLabel" }] : /* istanbul ignore next */ []);
|
|
478
|
+
this.submitDisabled = computed(() => this.disabled() || this.loading() || this.pending() || !this.isReady() || !!this.loadErrorText() || this.attempt.locked() || !this.readiness.ready(), ...ngDevMode ? [{ debugName: "submitDisabled" }] : /* istanbul ignore next */ []);
|
|
479
|
+
this.messages = computed(() => {
|
|
480
|
+
const given = Object.fromEntries(Object.entries(this.a11yMessages() ?? {}).filter(([, text]) => typeof text === "string"));
|
|
481
|
+
return {
|
|
482
|
+
...SQUARE_A11Y_MESSAGES,
|
|
483
|
+
...given
|
|
484
|
+
};
|
|
485
|
+
}, ...ngDevMode ? [{ debugName: "messages" }] : /* istanbul ignore next */ []);
|
|
486
|
+
this.statusText = computed(() => {
|
|
487
|
+
if (this.loading()) return this.messages().loading;
|
|
488
|
+
if (this.submitting()) return this.messages().processing;
|
|
489
|
+
return this.announcement();
|
|
490
|
+
}, ...ngDevMode ? [{ debugName: "statusText" }] : /* istanbul ignore next */ []);
|
|
491
|
+
this.connection = computed(() => ({
|
|
492
|
+
applicationId: this.applicationId() || this.defaults.applicationId || "",
|
|
493
|
+
locationId: this.locationId() || this.defaults.locationId || "",
|
|
494
|
+
environment: this.environment() ?? this.defaults.environment ?? "sandbox"
|
|
495
|
+
}), {
|
|
496
|
+
...ngDevMode ? { debugName: "connection" } : /* istanbul ignore next */ {},
|
|
497
|
+
equal: jsonEqual
|
|
498
|
+
});
|
|
499
|
+
this.cardConfig = computed(() => {
|
|
500
|
+
const style = this.cardStyle();
|
|
501
|
+
const options = this.cardOptions();
|
|
502
|
+
if (!style && !options) return null;
|
|
503
|
+
return {
|
|
504
|
+
...style ? { style } : {},
|
|
505
|
+
...options ?? {}
|
|
506
|
+
};
|
|
507
|
+
}, {
|
|
508
|
+
...ngDevMode ? { debugName: "cardConfig" } : /* istanbul ignore next */ {},
|
|
509
|
+
equal: structuralEqual
|
|
510
|
+
});
|
|
511
|
+
this.payments = null;
|
|
512
|
+
this.card = null;
|
|
513
|
+
this.ach = null;
|
|
514
|
+
this.generation = 0;
|
|
515
|
+
this.destroyed = false;
|
|
516
|
+
this.announced = false;
|
|
517
|
+
const protection = createPaymentProtection(this, {
|
|
518
|
+
amount: () => this.amount(),
|
|
519
|
+
method: () => this.method(),
|
|
520
|
+
sdk: () => this.loadErrorText() ? "blocked" : this.loading() ? "loading" : "ok",
|
|
521
|
+
offlineMidFlight: false,
|
|
522
|
+
onOutcome: (o) => this.outcome.emit(o),
|
|
523
|
+
onInFlightChange: (v) => this.inFlightChange.emit(v),
|
|
524
|
+
onKeyChange: (k) => this.attemptKeyChange.emit(k),
|
|
525
|
+
onReadinessChange: (r) => this.readinessChange.emit(r)
|
|
526
|
+
});
|
|
527
|
+
this.attempt = protection.attempt;
|
|
528
|
+
this.readiness = protection.readiness;
|
|
529
|
+
effect(() => {
|
|
530
|
+
const method = this.method();
|
|
531
|
+
const mount = method === "card" ? this.mountRef() : null;
|
|
532
|
+
const connection = this.connection();
|
|
533
|
+
const card = this.cardConfig();
|
|
534
|
+
const ach = {
|
|
535
|
+
redirectUri: this.achRedirectUri(),
|
|
536
|
+
transactionId: this.achTransactionId()
|
|
537
|
+
};
|
|
538
|
+
this.resetTick();
|
|
539
|
+
this.styleFromTokens();
|
|
540
|
+
if (method === "card" && !mount) return;
|
|
541
|
+
untracked(() => {
|
|
542
|
+
this.init(mount?.nativeElement ?? null, method, connection, card, ach);
|
|
543
|
+
});
|
|
544
|
+
});
|
|
545
|
+
effect(() => {
|
|
546
|
+
const name = this.accountHolderName();
|
|
547
|
+
untracked(() => this.holder.set(name));
|
|
548
|
+
});
|
|
549
|
+
inject(DestroyRef).onDestroy(() => {
|
|
550
|
+
this.destroyed = true;
|
|
551
|
+
this.generation++;
|
|
552
|
+
this.disposeInstances();
|
|
553
|
+
this.payments = null;
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
async tokenize() {
|
|
557
|
+
if (this.submitting() || this.disabled() || this.pending()) return null;
|
|
558
|
+
if (this.refusedByProtection()) return null;
|
|
559
|
+
const method = this.method();
|
|
560
|
+
const card = this.card;
|
|
561
|
+
const ach = this.ach;
|
|
562
|
+
if (!this.isReady() || (method === "card" ? !card : !ach)) {
|
|
563
|
+
this.fail(squareFailure("not_ready", this.labels.t("squarePayment.msg.notReady"), "tokenize"));
|
|
564
|
+
return null;
|
|
565
|
+
}
|
|
566
|
+
this.attempted.set(true);
|
|
567
|
+
const holder = this.holder().trim();
|
|
568
|
+
if (method === "ach") {
|
|
569
|
+
if (!holder) {
|
|
570
|
+
this.fail(squareFailure("holder_required", this.labels.t("squarePayment.holderRequired"), "validate"));
|
|
571
|
+
this.focusInput("holder");
|
|
572
|
+
return null;
|
|
573
|
+
}
|
|
574
|
+
if (this.requireAchConsent() && !this.mountOnly() && !this.consent()) {
|
|
575
|
+
this.fail(squareFailure("consent_required", this.labels.t("squarePayment.consentRequired"), "validate"));
|
|
576
|
+
this.focusInput("consent");
|
|
577
|
+
return null;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
const generation = this.generation;
|
|
581
|
+
const kind = this.mode();
|
|
582
|
+
const begun = this.attempt.begin();
|
|
583
|
+
if (!begun.ok) return null;
|
|
584
|
+
const attemptKey = begun.key;
|
|
585
|
+
const payableRef = this.attempt.pinnedRef();
|
|
586
|
+
const amount = this.attempt.pinnedAmount();
|
|
587
|
+
let handedToHost = false;
|
|
588
|
+
this.submitting.set(true);
|
|
589
|
+
this.errorText.set("");
|
|
590
|
+
this.announcement.set("");
|
|
591
|
+
try {
|
|
592
|
+
const result = method === "card" ? await card.tokenize() : await ach.tokenize({ accountHolderName: holder });
|
|
593
|
+
if (this.destroyed || generation !== this.generation) return null;
|
|
594
|
+
if (result.status !== "OK" || !result.token) {
|
|
595
|
+
this.fail(failureFromTokenResult(result, method, this.errorOptions()));
|
|
596
|
+
return null;
|
|
597
|
+
}
|
|
598
|
+
let verificationToken = null;
|
|
599
|
+
if (method === "card" && this.shouldVerify(kind, amount)) {
|
|
600
|
+
const verified = await this.verify(result.token, kind, amount);
|
|
601
|
+
if (this.destroyed || generation !== this.generation) return null;
|
|
602
|
+
if ("code" in verified) {
|
|
603
|
+
this.fail(verified);
|
|
604
|
+
return null;
|
|
605
|
+
}
|
|
606
|
+
verificationToken = verified.token;
|
|
607
|
+
}
|
|
608
|
+
const event = {
|
|
609
|
+
token: result.token,
|
|
610
|
+
method,
|
|
611
|
+
kind,
|
|
612
|
+
details: normalizeSquareDetails(result.details),
|
|
613
|
+
verificationToken,
|
|
614
|
+
idempotencyKey: newIdempotencyKey(),
|
|
615
|
+
attemptKey,
|
|
616
|
+
amount,
|
|
617
|
+
payableRef
|
|
618
|
+
};
|
|
619
|
+
this.announcement.set(this.messages().tokenized);
|
|
620
|
+
if (kind === "payment") {
|
|
621
|
+
handedToHost = true;
|
|
622
|
+
this.attempt.markPending("token");
|
|
623
|
+
}
|
|
624
|
+
this.tokenized.emit(event);
|
|
625
|
+
return event;
|
|
626
|
+
} catch (err) {
|
|
627
|
+
if (this.destroyed || generation !== this.generation) return null;
|
|
628
|
+
this.fail({ ...squareFailure("tokenize_failed", this.errorFallback() || this.labels.t(method === "ach" ? "squarePayment.msg.achFailed" : "squarePayment.msg.tokenizeFailed"), "tokenize", messageOfThrown(err, "")) });
|
|
629
|
+
return null;
|
|
630
|
+
} finally {
|
|
631
|
+
this.submitting.set(false);
|
|
632
|
+
if (!handedToHost) this.attempt.release();
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
markUnknown() {
|
|
636
|
+
this.attempt.markUnknown("host");
|
|
637
|
+
}
|
|
638
|
+
markSucceeded() {
|
|
639
|
+
this.attempt.succeed("host");
|
|
640
|
+
}
|
|
641
|
+
markFailed() {
|
|
642
|
+
this.attempt.fail("host");
|
|
643
|
+
}
|
|
644
|
+
markNotCharged() {
|
|
645
|
+
this.attempt.markNotCharged();
|
|
646
|
+
}
|
|
647
|
+
resetPaid() {
|
|
648
|
+
this.attempt.resetPaid();
|
|
649
|
+
}
|
|
650
|
+
reset() {
|
|
651
|
+
this.resetTick.update((n) => n + 1);
|
|
652
|
+
}
|
|
653
|
+
destroyForm() {
|
|
654
|
+
this.generation++;
|
|
655
|
+
this.disposeInstances();
|
|
656
|
+
this.isReady.set(false);
|
|
657
|
+
this.loading.set(false);
|
|
658
|
+
}
|
|
659
|
+
refusedByProtection() {
|
|
660
|
+
if (!this.readiness.passSync()) {
|
|
661
|
+
const reason = this.readiness.reasons()[0] ?? "checking";
|
|
662
|
+
this.outcome.emit({
|
|
663
|
+
kind: "refused",
|
|
664
|
+
attemptKey: this.attempt.key(),
|
|
665
|
+
reason
|
|
666
|
+
});
|
|
667
|
+
this.fail(squareFailure(reason, this.labels.t(refusalLabelKey(reason)), "validate"));
|
|
668
|
+
return true;
|
|
669
|
+
}
|
|
670
|
+
if (this.attempt.inFlight()) return true;
|
|
671
|
+
if (this.attempt.paidLocked() || this.attempt.unknown()) {
|
|
672
|
+
this.attempt.begin();
|
|
673
|
+
return true;
|
|
674
|
+
}
|
|
675
|
+
return false;
|
|
676
|
+
}
|
|
677
|
+
retryLoad() {
|
|
678
|
+
this.reset();
|
|
679
|
+
}
|
|
680
|
+
focusInput(which) {
|
|
681
|
+
if (this.mountOnly()) return;
|
|
682
|
+
const id = which === "holder" ? this.holderTestId() : "square-consent";
|
|
683
|
+
afterNextRender(() => this.host.nativeElement.querySelector(`input[data-testid="${id}"]`)?.focus(), { injector: this.injector });
|
|
684
|
+
}
|
|
685
|
+
errorOptions() {
|
|
686
|
+
return {
|
|
687
|
+
display: this.errorDisplay(),
|
|
688
|
+
overrides: this.errorMessages(),
|
|
689
|
+
...this.errorFallback() ? { fallback: this.errorFallback() } : {}
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
shouldVerify(kind, amount) {
|
|
693
|
+
const forced = this.verifyBuyer();
|
|
694
|
+
if (forced !== null) return forced;
|
|
695
|
+
return kind === "payment" ? amount !== null && !!this.billingContact() : !!this.billingContact();
|
|
696
|
+
}
|
|
697
|
+
async verify(token, kind, amount) {
|
|
698
|
+
const failure = (squareMessage = "") => squareFailure("verification_failed", this.labels.t("squarePayment.msg.verifyFailed"), "verify", squareMessage);
|
|
699
|
+
const verifyBuyer = this.payments?.verifyBuyer?.bind(this.payments);
|
|
700
|
+
if (!verifyBuyer || kind === "payment" && amount === null) return failure();
|
|
701
|
+
const billing = this.billingContact();
|
|
702
|
+
const details = {
|
|
703
|
+
intent: kind === "setup" ? "STORE" : "CHARGE",
|
|
704
|
+
...kind === "payment" ? {
|
|
705
|
+
amount: (Math.round(amount * 100) / 100).toFixed(2),
|
|
706
|
+
currencyCode: this.currency().toUpperCase()
|
|
707
|
+
} : {},
|
|
708
|
+
...billing ? { billingContact: billing } : {},
|
|
709
|
+
customerInitiated: true,
|
|
710
|
+
sellerKeyedIn: false
|
|
711
|
+
};
|
|
712
|
+
try {
|
|
713
|
+
const result = await verifyBuyer(token, details);
|
|
714
|
+
return result?.token ? { token: result.token } : failure();
|
|
715
|
+
} catch (err) {
|
|
716
|
+
return failure(messageOfThrown(err, ""));
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
fail(f) {
|
|
720
|
+
const override = this.errorMessages()?.[f.code];
|
|
721
|
+
if (override) f = {
|
|
722
|
+
...f,
|
|
723
|
+
message: override
|
|
724
|
+
};
|
|
725
|
+
if (this.destroyed) return;
|
|
726
|
+
if (this.showErrors()) this.errorText.set(f.message);
|
|
727
|
+
this.announcement.set("");
|
|
728
|
+
this.failed.emit(f);
|
|
729
|
+
}
|
|
730
|
+
discardLate(pending) {
|
|
731
|
+
pending.then((late) => {
|
|
732
|
+
try {
|
|
733
|
+
Promise.resolve(late.destroy?.()).catch(() => void 0);
|
|
734
|
+
} catch {}
|
|
735
|
+
}, () => void 0);
|
|
736
|
+
}
|
|
737
|
+
disposeInstances() {
|
|
738
|
+
const card = this.card;
|
|
739
|
+
const ach = this.ach;
|
|
740
|
+
this.card = null;
|
|
741
|
+
this.ach = null;
|
|
742
|
+
if (this.announced) {
|
|
743
|
+
this.announced = false;
|
|
744
|
+
if (!this.destroyed) this.squareReady.emit(null);
|
|
745
|
+
}
|
|
746
|
+
for (const instance of [card, ach]) {
|
|
747
|
+
if (!instance?.destroy) continue;
|
|
748
|
+
try {
|
|
749
|
+
Promise.resolve(instance.destroy()).catch(() => void 0);
|
|
750
|
+
} catch {}
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
loadFailed(code, message, squareMessage) {
|
|
754
|
+
this.loading.set(false);
|
|
755
|
+
this.isReady.set(false);
|
|
756
|
+
this.loadErrorText.set(this.loadErrorMessage());
|
|
757
|
+
this.loadError.emit(squareFailure(code, message, "load", squareMessage));
|
|
758
|
+
}
|
|
759
|
+
async init(container, method, connection, cardConfig, ach) {
|
|
760
|
+
const generation = ++this.generation;
|
|
761
|
+
this.disposeInstances();
|
|
762
|
+
this.isReady.set(false);
|
|
763
|
+
this.errorText.set("");
|
|
764
|
+
this.loadErrorText.set("");
|
|
765
|
+
this.announcement.set("");
|
|
766
|
+
if (!this.isBrowser) {
|
|
767
|
+
this.loading.set(false);
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
if (!connection.applicationId || !connection.locationId) {
|
|
771
|
+
this.loadFailed("config_missing", this.labels.t("squarePayment.msg.configMissing"), "");
|
|
772
|
+
return;
|
|
773
|
+
}
|
|
774
|
+
this.loading.set(true);
|
|
775
|
+
try {
|
|
776
|
+
this.payments = null;
|
|
777
|
+
const payments = await withSquareTimeout(this.loader(connection), () => new SquareLoadError("script_failed"));
|
|
778
|
+
if (generation !== this.generation) return;
|
|
779
|
+
this.payments = payments;
|
|
780
|
+
} catch (err) {
|
|
781
|
+
if (generation !== this.generation) return;
|
|
782
|
+
this.loadFailed(err instanceof SquareLoadError ? err.code : "load_error", this.labels.t("squarePayment.msg.loadFailed"), messageOfThrown(err, ""));
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
try {
|
|
786
|
+
const payments = this.payments;
|
|
787
|
+
if (method === "card") {
|
|
788
|
+
const tokenStyle = this.styleFromTokens() && cardConfig?.["style"] === void 0 ? { style: readSquareCardStyle(this.doc, this.host.nativeElement) } : null;
|
|
789
|
+
const options = tokenStyle || cardConfig ? {
|
|
790
|
+
...tokenStyle ?? {},
|
|
791
|
+
...cardConfig ?? {}
|
|
792
|
+
} : null;
|
|
793
|
+
const pendingCard = options ? payments.card(options) : payments.card();
|
|
794
|
+
const card = await withSquareTimeout(pendingCard, () => /* @__PURE__ */ new Error("timeout")).catch((err) => {
|
|
795
|
+
this.discardLate(pendingCard);
|
|
796
|
+
throw err;
|
|
797
|
+
});
|
|
798
|
+
if (generation !== this.generation) {
|
|
799
|
+
try {
|
|
800
|
+
Promise.resolve(card.destroy()).catch(() => void 0);
|
|
801
|
+
} catch {}
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
804
|
+
this.card = card;
|
|
805
|
+
try {
|
|
806
|
+
await withSquareTimeout(card.attach(container), () => /* @__PURE__ */ new Error("timeout"));
|
|
807
|
+
} catch (err) {
|
|
808
|
+
if (generation !== this.generation) return;
|
|
809
|
+
this.disposeInstances();
|
|
810
|
+
this.loadFailed("mount_failed", this.labels.t("squarePayment.msg.cardFormFailed"), messageOfThrown(err, ""));
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
} else {
|
|
814
|
+
const options = {
|
|
815
|
+
...ach.redirectUri ? { redirectURI: ach.redirectUri } : {},
|
|
816
|
+
...ach.transactionId ? { transactionId: ach.transactionId } : {}
|
|
817
|
+
};
|
|
818
|
+
const pendingAch = Object.keys(options).length ? payments.ach(options) : payments.ach();
|
|
819
|
+
const instance = await withSquareTimeout(pendingAch, () => /* @__PURE__ */ new Error("timeout")).catch((err) => {
|
|
820
|
+
this.discardLate(pendingAch);
|
|
821
|
+
throw err;
|
|
822
|
+
});
|
|
823
|
+
if (generation !== this.generation) {
|
|
824
|
+
try {
|
|
825
|
+
Promise.resolve(instance.destroy?.()).catch(() => void 0);
|
|
826
|
+
} catch {}
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
this.ach = instance;
|
|
830
|
+
}
|
|
831
|
+
if (generation !== this.generation) return;
|
|
832
|
+
this.loading.set(false);
|
|
833
|
+
this.isReady.set(true);
|
|
834
|
+
this.announced = true;
|
|
835
|
+
this.squareReady.emit({
|
|
836
|
+
payments,
|
|
837
|
+
card: this.card,
|
|
838
|
+
ach: this.ach
|
|
839
|
+
});
|
|
840
|
+
this.ready.emit();
|
|
841
|
+
} catch (err) {
|
|
842
|
+
if (generation !== this.generation) return;
|
|
843
|
+
this.disposeInstances();
|
|
844
|
+
this.loadFailed("init_failed", this.labels.t(method === "card" ? "squarePayment.msg.cardFormFailed" : "squarePayment.msg.achInitFailed"), messageOfThrown(err, ""));
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
onTab(key) {
|
|
848
|
+
if (this.submitting() || this.disabled() || this.attempt.locked() || key !== "card" && key !== "ach") return;
|
|
849
|
+
this.method.set(key);
|
|
850
|
+
this.errorText.set("");
|
|
851
|
+
}
|
|
852
|
+
static {
|
|
853
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
854
|
+
minVersion: "12.0.0",
|
|
855
|
+
version: "22.2.2",
|
|
856
|
+
ngImport: i0,
|
|
857
|
+
type: SquarePaymentComponent,
|
|
858
|
+
deps: [],
|
|
859
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
static {
|
|
863
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
864
|
+
minVersion: "17.0.0",
|
|
865
|
+
version: "22.2.2",
|
|
866
|
+
type: SquarePaymentComponent,
|
|
867
|
+
isStandalone: true,
|
|
868
|
+
selector: "ui-square-payment",
|
|
869
|
+
inputs: {
|
|
870
|
+
mountOnly: {
|
|
871
|
+
classPropertyName: "mountOnly",
|
|
872
|
+
publicName: "mountOnly",
|
|
873
|
+
isSignal: true,
|
|
874
|
+
isRequired: false,
|
|
875
|
+
transformFunction: null
|
|
876
|
+
},
|
|
877
|
+
mode: {
|
|
878
|
+
classPropertyName: "mode",
|
|
879
|
+
publicName: "mode",
|
|
880
|
+
isSignal: true,
|
|
881
|
+
isRequired: false,
|
|
882
|
+
transformFunction: null
|
|
883
|
+
},
|
|
884
|
+
method: {
|
|
885
|
+
classPropertyName: "method",
|
|
886
|
+
publicName: "method",
|
|
887
|
+
isSignal: true,
|
|
888
|
+
isRequired: false,
|
|
889
|
+
transformFunction: null
|
|
890
|
+
},
|
|
891
|
+
methods: {
|
|
892
|
+
classPropertyName: "methods",
|
|
893
|
+
publicName: "methods",
|
|
894
|
+
isSignal: true,
|
|
895
|
+
isRequired: false,
|
|
896
|
+
transformFunction: null
|
|
897
|
+
},
|
|
898
|
+
applicationId: {
|
|
899
|
+
classPropertyName: "applicationId",
|
|
900
|
+
publicName: "applicationId",
|
|
901
|
+
isSignal: true,
|
|
902
|
+
isRequired: false,
|
|
903
|
+
transformFunction: null
|
|
904
|
+
},
|
|
905
|
+
locationId: {
|
|
906
|
+
classPropertyName: "locationId",
|
|
907
|
+
publicName: "locationId",
|
|
908
|
+
isSignal: true,
|
|
909
|
+
isRequired: false,
|
|
910
|
+
transformFunction: null
|
|
911
|
+
},
|
|
912
|
+
environment: {
|
|
913
|
+
classPropertyName: "environment",
|
|
914
|
+
publicName: "environment",
|
|
915
|
+
isSignal: true,
|
|
916
|
+
isRequired: false,
|
|
917
|
+
transformFunction: null
|
|
918
|
+
},
|
|
919
|
+
amount: {
|
|
920
|
+
classPropertyName: "amount",
|
|
921
|
+
publicName: "amount",
|
|
922
|
+
isSignal: true,
|
|
923
|
+
isRequired: false,
|
|
924
|
+
transformFunction: null
|
|
925
|
+
},
|
|
926
|
+
currency: {
|
|
927
|
+
classPropertyName: "currency",
|
|
928
|
+
publicName: "currency",
|
|
929
|
+
isSignal: true,
|
|
930
|
+
isRequired: false,
|
|
931
|
+
transformFunction: null
|
|
932
|
+
},
|
|
933
|
+
billingContact: {
|
|
934
|
+
classPropertyName: "billingContact",
|
|
935
|
+
publicName: "billingContact",
|
|
936
|
+
isSignal: true,
|
|
937
|
+
isRequired: false,
|
|
938
|
+
transformFunction: null
|
|
939
|
+
},
|
|
940
|
+
verifyBuyer: {
|
|
941
|
+
classPropertyName: "verifyBuyer",
|
|
942
|
+
publicName: "verifyBuyer",
|
|
943
|
+
isSignal: true,
|
|
944
|
+
isRequired: false,
|
|
945
|
+
transformFunction: null
|
|
946
|
+
},
|
|
947
|
+
accountHolderName: {
|
|
948
|
+
classPropertyName: "accountHolderName",
|
|
949
|
+
publicName: "accountHolderName",
|
|
950
|
+
isSignal: true,
|
|
951
|
+
isRequired: false,
|
|
952
|
+
transformFunction: null
|
|
953
|
+
},
|
|
954
|
+
requireAchConsent: {
|
|
955
|
+
classPropertyName: "requireAchConsent",
|
|
956
|
+
publicName: "requireAchConsent",
|
|
957
|
+
isSignal: true,
|
|
958
|
+
isRequired: false,
|
|
959
|
+
transformFunction: null
|
|
960
|
+
},
|
|
961
|
+
achConsentTextInput: {
|
|
962
|
+
classPropertyName: "achConsentTextInput",
|
|
963
|
+
publicName: "achConsentText",
|
|
964
|
+
isSignal: true,
|
|
965
|
+
isRequired: false,
|
|
966
|
+
transformFunction: null
|
|
967
|
+
},
|
|
968
|
+
achRedirectUri: {
|
|
969
|
+
classPropertyName: "achRedirectUri",
|
|
970
|
+
publicName: "achRedirectUri",
|
|
971
|
+
isSignal: true,
|
|
972
|
+
isRequired: false,
|
|
973
|
+
transformFunction: null
|
|
974
|
+
},
|
|
975
|
+
achTransactionId: {
|
|
976
|
+
classPropertyName: "achTransactionId",
|
|
977
|
+
publicName: "achTransactionId",
|
|
978
|
+
isSignal: true,
|
|
979
|
+
isRequired: false,
|
|
980
|
+
transformFunction: null
|
|
981
|
+
},
|
|
982
|
+
cardOptions: {
|
|
983
|
+
classPropertyName: "cardOptions",
|
|
984
|
+
publicName: "cardOptions",
|
|
985
|
+
isSignal: true,
|
|
986
|
+
isRequired: false,
|
|
987
|
+
transformFunction: null
|
|
988
|
+
},
|
|
989
|
+
cardStyle: {
|
|
990
|
+
classPropertyName: "cardStyle",
|
|
991
|
+
publicName: "cardStyle",
|
|
992
|
+
isSignal: true,
|
|
993
|
+
isRequired: false,
|
|
994
|
+
transformFunction: null
|
|
995
|
+
},
|
|
996
|
+
styleFromTokens: {
|
|
997
|
+
classPropertyName: "styleFromTokens",
|
|
998
|
+
publicName: "styleFromTokens",
|
|
999
|
+
isSignal: true,
|
|
1000
|
+
isRequired: false,
|
|
1001
|
+
transformFunction: null
|
|
1002
|
+
},
|
|
1003
|
+
showStatus: {
|
|
1004
|
+
classPropertyName: "showStatus",
|
|
1005
|
+
publicName: "showStatus",
|
|
1006
|
+
isSignal: true,
|
|
1007
|
+
isRequired: false,
|
|
1008
|
+
transformFunction: null
|
|
1009
|
+
},
|
|
1010
|
+
payableRef: {
|
|
1011
|
+
classPropertyName: "payableRef",
|
|
1012
|
+
publicName: "payableRef",
|
|
1013
|
+
isSignal: true,
|
|
1014
|
+
isRequired: false,
|
|
1015
|
+
transformFunction: null
|
|
1016
|
+
},
|
|
1017
|
+
attemptKey: {
|
|
1018
|
+
classPropertyName: "attemptKey",
|
|
1019
|
+
publicName: "attemptKey",
|
|
1020
|
+
isSignal: true,
|
|
1021
|
+
isRequired: false,
|
|
1022
|
+
transformFunction: null
|
|
1023
|
+
},
|
|
1024
|
+
checkStatus: {
|
|
1025
|
+
classPropertyName: "checkStatus",
|
|
1026
|
+
publicName: "checkStatus",
|
|
1027
|
+
isSignal: true,
|
|
1028
|
+
isRequired: false,
|
|
1029
|
+
transformFunction: null
|
|
1030
|
+
},
|
|
1031
|
+
paid: {
|
|
1032
|
+
classPropertyName: "paid",
|
|
1033
|
+
publicName: "paid",
|
|
1034
|
+
isSignal: true,
|
|
1035
|
+
isRequired: false,
|
|
1036
|
+
transformFunction: null
|
|
1037
|
+
},
|
|
1038
|
+
hostPending: {
|
|
1039
|
+
classPropertyName: "hostPending",
|
|
1040
|
+
publicName: "hostPending",
|
|
1041
|
+
isSignal: true,
|
|
1042
|
+
isRequired: false,
|
|
1043
|
+
transformFunction: null
|
|
1044
|
+
},
|
|
1045
|
+
statusPollMs: {
|
|
1046
|
+
classPropertyName: "statusPollMs",
|
|
1047
|
+
publicName: "statusPollMs",
|
|
1048
|
+
isSignal: true,
|
|
1049
|
+
isRequired: false,
|
|
1050
|
+
transformFunction: null
|
|
1051
|
+
},
|
|
1052
|
+
statusPollMaxMs: {
|
|
1053
|
+
classPropertyName: "statusPollMaxMs",
|
|
1054
|
+
publicName: "statusPollMaxMs",
|
|
1055
|
+
isSignal: true,
|
|
1056
|
+
isRequired: false,
|
|
1057
|
+
transformFunction: null
|
|
1058
|
+
},
|
|
1059
|
+
statusCheckTimeoutMs: {
|
|
1060
|
+
classPropertyName: "statusCheckTimeoutMs",
|
|
1061
|
+
publicName: "statusCheckTimeoutMs",
|
|
1062
|
+
isSignal: true,
|
|
1063
|
+
isRequired: false,
|
|
1064
|
+
transformFunction: null
|
|
1065
|
+
},
|
|
1066
|
+
statusFailGraceMs: {
|
|
1067
|
+
classPropertyName: "statusFailGraceMs",
|
|
1068
|
+
publicName: "statusFailGraceMs",
|
|
1069
|
+
isSignal: true,
|
|
1070
|
+
isRequired: false,
|
|
1071
|
+
transformFunction: null
|
|
1072
|
+
},
|
|
1073
|
+
allowStartOver: {
|
|
1074
|
+
classPropertyName: "allowStartOver",
|
|
1075
|
+
publicName: "allowStartOver",
|
|
1076
|
+
isSignal: true,
|
|
1077
|
+
isRequired: false,
|
|
1078
|
+
transformFunction: null
|
|
1079
|
+
},
|
|
1080
|
+
offlineOverride: {
|
|
1081
|
+
classPropertyName: "offlineOverride",
|
|
1082
|
+
publicName: "offlineOverride",
|
|
1083
|
+
isSignal: true,
|
|
1084
|
+
isRequired: false,
|
|
1085
|
+
transformFunction: null
|
|
1086
|
+
},
|
|
1087
|
+
hostSilenceMs: {
|
|
1088
|
+
classPropertyName: "hostSilenceMs",
|
|
1089
|
+
publicName: "hostSilenceMs",
|
|
1090
|
+
isSignal: true,
|
|
1091
|
+
isRequired: false,
|
|
1092
|
+
transformFunction: null
|
|
1093
|
+
},
|
|
1094
|
+
readinessCheck: {
|
|
1095
|
+
classPropertyName: "readinessCheck",
|
|
1096
|
+
publicName: "readinessCheck",
|
|
1097
|
+
isSignal: true,
|
|
1098
|
+
isRequired: false,
|
|
1099
|
+
transformFunction: null
|
|
1100
|
+
},
|
|
1101
|
+
readinessTimeoutMs: {
|
|
1102
|
+
classPropertyName: "readinessTimeoutMs",
|
|
1103
|
+
publicName: "readinessTimeoutMs",
|
|
1104
|
+
isSignal: true,
|
|
1105
|
+
isRequired: false,
|
|
1106
|
+
transformFunction: null
|
|
1107
|
+
},
|
|
1108
|
+
readinessEveryMs: {
|
|
1109
|
+
classPropertyName: "readinessEveryMs",
|
|
1110
|
+
publicName: "readinessEveryMs",
|
|
1111
|
+
isSignal: true,
|
|
1112
|
+
isRequired: false,
|
|
1113
|
+
transformFunction: null
|
|
1114
|
+
},
|
|
1115
|
+
submitLabel: {
|
|
1116
|
+
classPropertyName: "submitLabel",
|
|
1117
|
+
publicName: "submitLabel",
|
|
1118
|
+
isSignal: true,
|
|
1119
|
+
isRequired: false,
|
|
1120
|
+
transformFunction: null
|
|
1121
|
+
},
|
|
1122
|
+
showSubmit: {
|
|
1123
|
+
classPropertyName: "showSubmit",
|
|
1124
|
+
publicName: "showSubmit",
|
|
1125
|
+
isSignal: true,
|
|
1126
|
+
isRequired: false,
|
|
1127
|
+
transformFunction: null
|
|
1128
|
+
},
|
|
1129
|
+
disabled: {
|
|
1130
|
+
classPropertyName: "disabled",
|
|
1131
|
+
publicName: "disabled",
|
|
1132
|
+
isSignal: true,
|
|
1133
|
+
isRequired: false,
|
|
1134
|
+
transformFunction: null
|
|
1135
|
+
},
|
|
1136
|
+
pending: {
|
|
1137
|
+
classPropertyName: "pending",
|
|
1138
|
+
publicName: "pending",
|
|
1139
|
+
isSignal: true,
|
|
1140
|
+
isRequired: false,
|
|
1141
|
+
transformFunction: null
|
|
1142
|
+
},
|
|
1143
|
+
labelInput: {
|
|
1144
|
+
classPropertyName: "labelInput",
|
|
1145
|
+
publicName: "label",
|
|
1146
|
+
isSignal: true,
|
|
1147
|
+
isRequired: false,
|
|
1148
|
+
transformFunction: null
|
|
1149
|
+
},
|
|
1150
|
+
required: {
|
|
1151
|
+
classPropertyName: "required",
|
|
1152
|
+
publicName: "required",
|
|
1153
|
+
isSignal: true,
|
|
1154
|
+
isRequired: false,
|
|
1155
|
+
transformFunction: null
|
|
1156
|
+
},
|
|
1157
|
+
mountId: {
|
|
1158
|
+
classPropertyName: "mountId",
|
|
1159
|
+
publicName: "mountId",
|
|
1160
|
+
isSignal: true,
|
|
1161
|
+
isRequired: false,
|
|
1162
|
+
transformFunction: null
|
|
1163
|
+
},
|
|
1164
|
+
mountClass: {
|
|
1165
|
+
classPropertyName: "mountClass",
|
|
1166
|
+
publicName: "mountClass",
|
|
1167
|
+
isSignal: true,
|
|
1168
|
+
isRequired: false,
|
|
1169
|
+
transformFunction: null
|
|
1170
|
+
},
|
|
1171
|
+
mountTestId: {
|
|
1172
|
+
classPropertyName: "mountTestId",
|
|
1173
|
+
publicName: "mountTestId",
|
|
1174
|
+
isSignal: true,
|
|
1175
|
+
isRequired: false,
|
|
1176
|
+
transformFunction: null
|
|
1177
|
+
},
|
|
1178
|
+
errorTestId: {
|
|
1179
|
+
classPropertyName: "errorTestId",
|
|
1180
|
+
publicName: "errorTestId",
|
|
1181
|
+
isSignal: true,
|
|
1182
|
+
isRequired: false,
|
|
1183
|
+
transformFunction: null
|
|
1184
|
+
},
|
|
1185
|
+
holderTestId: {
|
|
1186
|
+
classPropertyName: "holderTestId",
|
|
1187
|
+
publicName: "holderTestId",
|
|
1188
|
+
isSignal: true,
|
|
1189
|
+
isRequired: false,
|
|
1190
|
+
transformFunction: null
|
|
1191
|
+
},
|
|
1192
|
+
showErrors: {
|
|
1193
|
+
classPropertyName: "showErrors",
|
|
1194
|
+
publicName: "showErrors",
|
|
1195
|
+
isSignal: true,
|
|
1196
|
+
isRequired: false,
|
|
1197
|
+
transformFunction: null
|
|
1198
|
+
},
|
|
1199
|
+
errorDisplay: {
|
|
1200
|
+
classPropertyName: "errorDisplay",
|
|
1201
|
+
publicName: "errorDisplay",
|
|
1202
|
+
isSignal: true,
|
|
1203
|
+
isRequired: false,
|
|
1204
|
+
transformFunction: null
|
|
1205
|
+
},
|
|
1206
|
+
errorMessages: {
|
|
1207
|
+
classPropertyName: "errorMessages",
|
|
1208
|
+
publicName: "errorMessages",
|
|
1209
|
+
isSignal: true,
|
|
1210
|
+
isRequired: false,
|
|
1211
|
+
transformFunction: null
|
|
1212
|
+
},
|
|
1213
|
+
errorFallback: {
|
|
1214
|
+
classPropertyName: "errorFallback",
|
|
1215
|
+
publicName: "errorFallback",
|
|
1216
|
+
isSignal: true,
|
|
1217
|
+
isRequired: false,
|
|
1218
|
+
transformFunction: null
|
|
1219
|
+
},
|
|
1220
|
+
loadErrorMessageInput: {
|
|
1221
|
+
classPropertyName: "loadErrorMessageInput",
|
|
1222
|
+
publicName: "loadErrorMessage",
|
|
1223
|
+
isSignal: true,
|
|
1224
|
+
isRequired: false,
|
|
1225
|
+
transformFunction: null
|
|
1226
|
+
},
|
|
1227
|
+
a11yMessages: {
|
|
1228
|
+
classPropertyName: "a11yMessages",
|
|
1229
|
+
publicName: "a11yMessages",
|
|
1230
|
+
isSignal: true,
|
|
1231
|
+
isRequired: false,
|
|
1232
|
+
transformFunction: null
|
|
1233
|
+
}
|
|
1234
|
+
},
|
|
1235
|
+
outputs: {
|
|
1236
|
+
method: "methodChange",
|
|
1237
|
+
squareReady: "squareReady",
|
|
1238
|
+
ready: "ready",
|
|
1239
|
+
inFlightChange: "inFlightChange",
|
|
1240
|
+
outcome: "outcome",
|
|
1241
|
+
attemptKeyChange: "attemptKeyChange",
|
|
1242
|
+
readinessChange: "readinessChange",
|
|
1243
|
+
tokenized: "tokenized",
|
|
1244
|
+
failed: "failed",
|
|
1245
|
+
loadError: "loadError"
|
|
1246
|
+
},
|
|
1247
|
+
host: { properties: { "attr.aria-busy": "!mountOnly() && (loading() || submitting()) ? \"true\" : null" } },
|
|
1248
|
+
viewQueries: [{
|
|
1249
|
+
propertyName: "mountRef",
|
|
1250
|
+
first: true,
|
|
1251
|
+
predicate: ["mount"],
|
|
1252
|
+
descendants: true,
|
|
1253
|
+
isSignal: true
|
|
1254
|
+
}],
|
|
1255
|
+
ngImport: i0,
|
|
1256
|
+
template: `
|
|
1257
|
+
<div class="sqp">
|
|
1258
|
+
@if (!mountOnly() || a11yMessages()) {
|
|
1259
|
+
<ui-live-region data-testid="square-status" [message]="statusText()" />
|
|
1260
|
+
}
|
|
1261
|
+
@if (!mountOnly() && tabs().length > 1) {
|
|
1262
|
+
<div class="sqp-block"><ui-pill-tabs [ariaLabel]="labels.t('squarePayment.method.group')" [tabs]="tabs()" [activeKey]="method()" (tabChange)="onTab($event)" /></div>
|
|
1263
|
+
}
|
|
1264
|
+
@if (!mountOnly() && showStatus()) {
|
|
1265
|
+
<ui-payment-attempt-status [attempt]="attempt" [readiness]="readiness" [allowStartOver]="allowStartOver()" (retryLoad)="retryLoad()" />
|
|
1266
|
+
}
|
|
1267
|
+
@if (!mountOnly() && (loading() || pending())) {
|
|
1268
|
+
<div class="sqp-skeleton" data-testid="square-skeleton" aria-hidden="true">
|
|
1269
|
+
<ui-skeleton [height]="44" [mb]="10" />
|
|
1270
|
+
<ui-skeleton [height]="44" width="60%" />
|
|
1271
|
+
</div>
|
|
1272
|
+
}
|
|
1273
|
+
@if (!mountOnly() && loadErrorText(); as text) {
|
|
1274
|
+
<div class="sqp-block" data-testid="square-load-error"><ui-alert variant="danger">{{ text }}</ui-alert></div>
|
|
1275
|
+
}
|
|
1276
|
+
@if (!mountOnly() && required()) {
|
|
1277
|
+
<div class="sqp-label" data-testid="square-required-label">{{ label() }}<span class="sqp-required" aria-hidden="true">*</span></div>
|
|
1278
|
+
}
|
|
1279
|
+
@if (method() === 'card') {
|
|
1280
|
+
<div #mount class="sqp-mount" [attr.id]="mountId() || null" [class]="mountClass()" [class.sqp-mount--hidden]="mountHidden()" [class.sqp-mount--locked]="mountLocked()"
|
|
1281
|
+
[attr.aria-hidden]="mountHidden() ? 'true' : null" [attr.aria-disabled]="mountLocked() ? 'true' : null" [attr.inert]="mountHidden() || mountLocked() ? '' : null"
|
|
1282
|
+
[attr.role]="mountOnly() ? null : 'group'" [attr.aria-label]="mountOnly() ? null : label()" [attr.data-testid]="mountTestId()"></div>
|
|
1283
|
+
} @else if (!mountOnly()) {
|
|
1284
|
+
<div class="sqp-ach" data-testid="square-ach">
|
|
1285
|
+
<ui-text data-testid="square-ach-info" size="sm" tone="muted" [text]="labels.t('squarePayment.achInfo')" />
|
|
1286
|
+
<ui-text-input [label]="labels.t('squarePayment.holderLabel')" [placeholder]="labels.t('squarePayment.holderPlaceholder')" [inputTestId]="holderTestId()" autocomplete="name"
|
|
1287
|
+
[required]="true" [maxlength]="255" [error]="holderError()" [showErrors]="attempted()" [disabled]="locked()"
|
|
1288
|
+
[ngModel]="holder()" (ngModelChange)="holder.set($event ?? '')" />
|
|
1289
|
+
@if (requireAchConsent()) {
|
|
1290
|
+
<ui-checkbox testId="square-consent" [label]="achConsent()" [required]="true" [requiredMessage]="labels.t('squarePayment.consentRequired')" [showErrors]="attempted()"
|
|
1291
|
+
[disabled]="locked()" [ngModel]="consent()" (ngModelChange)="consent.set(!!$event)" />
|
|
1292
|
+
}
|
|
1293
|
+
</div>
|
|
1294
|
+
}
|
|
1295
|
+
@if (!mountOnly() && errorText(); as text) {
|
|
1296
|
+
<div class="sqp-block" [id]="errorId" [attr.data-testid]="errorTestId()"><ui-alert variant="danger">{{ text }}</ui-alert></div>
|
|
1297
|
+
}
|
|
1298
|
+
@if (!mountOnly() && showSubmit()) {
|
|
1299
|
+
<div class="sqp-actions">
|
|
1300
|
+
<ui-button variant="primary" type="button" [fullWidth]="true" [loading]="submitting()" [disabled]="submitDisabled()" [ariaDescribedBy]="errorText() ? errorId : undefined"
|
|
1301
|
+
data-testid="square-submit" (click)="tokenize()">{{ effectiveSubmitLabel() }}</ui-button>
|
|
1302
|
+
</div>
|
|
1303
|
+
}
|
|
1304
|
+
</div>
|
|
1305
|
+
`,
|
|
1306
|
+
isInline: true,
|
|
1307
|
+
styles: ["ui-square-payment{display:block;min-width:0}ui-square-payment .sqp{position:relative}ui-square-payment .sqp-block{margin-top:12px}ui-square-payment .sqp-label{font-size:.875rem;font-weight:500;color:var(--ui-text, #1e293b);margin-bottom:6px}ui-square-payment .sqp-required{color:var(--ui-danger, #dc2626);margin-left:2px}ui-square-payment .sqp-mount{min-height:44px;margin-top:12px}ui-square-payment .sqp-ach{display:flex;flex-direction:column;gap:14px;margin-top:12px}ui-square-payment .sqp-actions{margin-top:16px;display:flex;flex-direction:column;align-items:stretch}ui-square-payment .sqp-mount--hidden{position:absolute;top:0;left:0;right:0;opacity:0;pointer-events:none}ui-square-payment .sqp-mount--locked{pointer-events:none;opacity:.6}\n"],
|
|
1308
|
+
dependencies: [
|
|
1309
|
+
{
|
|
1310
|
+
kind: "component",
|
|
1311
|
+
type: AlertComponent,
|
|
1312
|
+
selector: "ui-alert",
|
|
1313
|
+
inputs: [
|
|
1314
|
+
"variant",
|
|
1315
|
+
"title",
|
|
1316
|
+
"dismissible",
|
|
1317
|
+
"dismissAriaLabel",
|
|
1318
|
+
"quiet",
|
|
1319
|
+
"compact",
|
|
1320
|
+
"inline",
|
|
1321
|
+
"fill"
|
|
1322
|
+
],
|
|
1323
|
+
outputs: ["dismissed"]
|
|
1324
|
+
},
|
|
1325
|
+
{
|
|
1326
|
+
kind: "component",
|
|
1327
|
+
type: ButtonComponent,
|
|
1328
|
+
selector: "ui-button",
|
|
1329
|
+
inputs: [
|
|
1330
|
+
"variant",
|
|
1331
|
+
"routerLink",
|
|
1332
|
+
"queryParams",
|
|
1333
|
+
"fragment",
|
|
1334
|
+
"state",
|
|
1335
|
+
"href",
|
|
1336
|
+
"target",
|
|
1337
|
+
"rel",
|
|
1338
|
+
"shortLabel",
|
|
1339
|
+
"shortBelow",
|
|
1340
|
+
"color",
|
|
1341
|
+
"active",
|
|
1342
|
+
"size",
|
|
1343
|
+
"type",
|
|
1344
|
+
"disabled",
|
|
1345
|
+
"loading",
|
|
1346
|
+
"fullWidth",
|
|
1347
|
+
"ariaLabel",
|
|
1348
|
+
"ariaExpanded",
|
|
1349
|
+
"ariaPressed",
|
|
1350
|
+
"ariaDescribedBy",
|
|
1351
|
+
"modal-footer-left",
|
|
1352
|
+
"modal-footer-right"
|
|
1353
|
+
]
|
|
1354
|
+
},
|
|
1355
|
+
{
|
|
1356
|
+
kind: "component",
|
|
1357
|
+
type: CheckboxComponent,
|
|
1358
|
+
selector: "ui-checkbox, ui-checkbox-group",
|
|
1359
|
+
inputs: [
|
|
1360
|
+
"label",
|
|
1361
|
+
"ariaLabel",
|
|
1362
|
+
"testId",
|
|
1363
|
+
"labelTestId",
|
|
1364
|
+
"headingLevel",
|
|
1365
|
+
"indeterminate",
|
|
1366
|
+
"checked",
|
|
1367
|
+
"options",
|
|
1368
|
+
"legend",
|
|
1369
|
+
"orientation",
|
|
1370
|
+
"values",
|
|
1371
|
+
"labelLinks",
|
|
1372
|
+
"description",
|
|
1373
|
+
"indent",
|
|
1374
|
+
"required",
|
|
1375
|
+
"requiredMessage",
|
|
1376
|
+
"hint",
|
|
1377
|
+
"error",
|
|
1378
|
+
"showErrors",
|
|
1379
|
+
"disabled"
|
|
1380
|
+
],
|
|
1381
|
+
outputs: [
|
|
1382
|
+
"checkedChange",
|
|
1383
|
+
"valuesChange",
|
|
1384
|
+
"invalidChange"
|
|
1385
|
+
]
|
|
1386
|
+
},
|
|
1387
|
+
{
|
|
1388
|
+
kind: "ngmodule",
|
|
1389
|
+
type: FormsModule
|
|
1390
|
+
},
|
|
1391
|
+
{
|
|
1392
|
+
kind: "directive",
|
|
1393
|
+
type: i1.NgControlStatus,
|
|
1394
|
+
selector: "[formControlName],[ngModel],[formControl]"
|
|
1395
|
+
},
|
|
1396
|
+
{
|
|
1397
|
+
kind: "directive",
|
|
1398
|
+
type: i1.RequiredValidator,
|
|
1399
|
+
selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]",
|
|
1400
|
+
inputs: ["required"]
|
|
1401
|
+
},
|
|
1402
|
+
{
|
|
1403
|
+
kind: "directive",
|
|
1404
|
+
type: i1.MaxLengthValidator,
|
|
1405
|
+
selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]",
|
|
1406
|
+
inputs: ["maxlength"]
|
|
1407
|
+
},
|
|
1408
|
+
{
|
|
1409
|
+
kind: "directive",
|
|
1410
|
+
type: i1.NgModel,
|
|
1411
|
+
selector: "[ngModel]:not([formControlName]):not([formControl])",
|
|
1412
|
+
inputs: [
|
|
1413
|
+
"name",
|
|
1414
|
+
"disabled",
|
|
1415
|
+
"ngModel",
|
|
1416
|
+
"ngModelOptions"
|
|
1417
|
+
],
|
|
1418
|
+
outputs: ["ngModelChange"],
|
|
1419
|
+
exportAs: ["ngModel"]
|
|
1420
|
+
},
|
|
1421
|
+
{
|
|
1422
|
+
kind: "component",
|
|
1423
|
+
type: LiveRegionComponent,
|
|
1424
|
+
selector: "ui-live-region",
|
|
1425
|
+
inputs: [
|
|
1426
|
+
"message",
|
|
1427
|
+
"politeness",
|
|
1428
|
+
"atomic",
|
|
1429
|
+
"visible"
|
|
1430
|
+
]
|
|
1431
|
+
},
|
|
1432
|
+
{
|
|
1433
|
+
kind: "component",
|
|
1434
|
+
type: PaymentAttemptStatusComponent,
|
|
1435
|
+
selector: "ui-payment-attempt-status",
|
|
1436
|
+
inputs: [
|
|
1437
|
+
"attempt",
|
|
1438
|
+
"showPaid",
|
|
1439
|
+
"allowStartOver",
|
|
1440
|
+
"readiness"
|
|
1441
|
+
],
|
|
1442
|
+
outputs: ["retryLoad"]
|
|
1443
|
+
},
|
|
1444
|
+
{
|
|
1445
|
+
kind: "component",
|
|
1446
|
+
type: PillTabsComponent,
|
|
1447
|
+
selector: "ui-pill-tabs",
|
|
1448
|
+
inputs: [
|
|
1449
|
+
"tabs",
|
|
1450
|
+
"activeKey",
|
|
1451
|
+
"ariaLabel",
|
|
1452
|
+
"name",
|
|
1453
|
+
"noWrap",
|
|
1454
|
+
"orientation",
|
|
1455
|
+
"controlsPanels",
|
|
1456
|
+
"showDescription",
|
|
1457
|
+
"headingLevel"
|
|
1458
|
+
],
|
|
1459
|
+
outputs: ["tabChange"]
|
|
1460
|
+
},
|
|
1461
|
+
{
|
|
1462
|
+
kind: "component",
|
|
1463
|
+
type: SkeletonComponent,
|
|
1464
|
+
selector: "ui-skeleton",
|
|
1465
|
+
inputs: [
|
|
1466
|
+
"height",
|
|
1467
|
+
"width",
|
|
1468
|
+
"radius",
|
|
1469
|
+
"mb",
|
|
1470
|
+
"ariaLabel"
|
|
1471
|
+
]
|
|
1472
|
+
},
|
|
1473
|
+
{
|
|
1474
|
+
kind: "component",
|
|
1475
|
+
type: TextComponent,
|
|
1476
|
+
selector: "ui-text",
|
|
1477
|
+
inputs: [
|
|
1478
|
+
"text",
|
|
1479
|
+
"size",
|
|
1480
|
+
"tone",
|
|
1481
|
+
"color",
|
|
1482
|
+
"strong",
|
|
1483
|
+
"weight"
|
|
1484
|
+
]
|
|
1485
|
+
},
|
|
1486
|
+
{
|
|
1487
|
+
kind: "component",
|
|
1488
|
+
type: TextInputComponent,
|
|
1489
|
+
selector: "ui-text-input",
|
|
1490
|
+
inputs: [
|
|
1491
|
+
"label",
|
|
1492
|
+
"ariaLabel",
|
|
1493
|
+
"inputTestId",
|
|
1494
|
+
"inputName",
|
|
1495
|
+
"placeholder",
|
|
1496
|
+
"prefix",
|
|
1497
|
+
"leadingIcon",
|
|
1498
|
+
"revealable",
|
|
1499
|
+
"passwordRequirements",
|
|
1500
|
+
"passwordRules",
|
|
1501
|
+
"type",
|
|
1502
|
+
"maxlength",
|
|
1503
|
+
"required",
|
|
1504
|
+
"autocomplete",
|
|
1505
|
+
"inputmode",
|
|
1506
|
+
"readonly",
|
|
1507
|
+
"hint",
|
|
1508
|
+
"ariaDescribedBy",
|
|
1509
|
+
"error",
|
|
1510
|
+
"phoneFormat",
|
|
1511
|
+
"min",
|
|
1512
|
+
"max",
|
|
1513
|
+
"maxDecimals",
|
|
1514
|
+
"step",
|
|
1515
|
+
"valueType",
|
|
1516
|
+
"formatter",
|
|
1517
|
+
"integer",
|
|
1518
|
+
"showErrors",
|
|
1519
|
+
"disabled"
|
|
1520
|
+
],
|
|
1521
|
+
outputs: [
|
|
1522
|
+
"valueChange",
|
|
1523
|
+
"focused",
|
|
1524
|
+
"blurred",
|
|
1525
|
+
"invalidChange"
|
|
1526
|
+
]
|
|
1527
|
+
}
|
|
1528
|
+
],
|
|
1529
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
1530
|
+
encapsulation: i0.ViewEncapsulation.None
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1533
|
+
};
|
|
1534
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1535
|
+
minVersion: "12.0.0",
|
|
1536
|
+
version: "22.2.2",
|
|
1537
|
+
ngImport: i0,
|
|
1538
|
+
type: SquarePaymentComponent,
|
|
1539
|
+
decorators: [{
|
|
1540
|
+
type: Component,
|
|
1541
|
+
args: [{
|
|
1542
|
+
selector: "ui-square-payment",
|
|
1543
|
+
standalone: true,
|
|
1544
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1545
|
+
encapsulation: ViewEncapsulation.None,
|
|
1546
|
+
imports: [
|
|
1547
|
+
AlertComponent,
|
|
1548
|
+
ButtonComponent,
|
|
1549
|
+
CheckboxComponent,
|
|
1550
|
+
FormsModule,
|
|
1551
|
+
LiveRegionComponent,
|
|
1552
|
+
PaymentAttemptStatusComponent,
|
|
1553
|
+
PillTabsComponent,
|
|
1554
|
+
SkeletonComponent,
|
|
1555
|
+
TextComponent,
|
|
1556
|
+
TextInputComponent
|
|
1557
|
+
],
|
|
1558
|
+
host: { "[attr.aria-busy]": "!mountOnly() && (loading() || submitting()) ? \"true\" : null" },
|
|
1559
|
+
template: `
|
|
1560
|
+
<div class="sqp">
|
|
1561
|
+
@if (!mountOnly() || a11yMessages()) {
|
|
1562
|
+
<ui-live-region data-testid="square-status" [message]="statusText()" />
|
|
1563
|
+
}
|
|
1564
|
+
@if (!mountOnly() && tabs().length > 1) {
|
|
1565
|
+
<div class="sqp-block"><ui-pill-tabs [ariaLabel]="labels.t('squarePayment.method.group')" [tabs]="tabs()" [activeKey]="method()" (tabChange)="onTab($event)" /></div>
|
|
1566
|
+
}
|
|
1567
|
+
@if (!mountOnly() && showStatus()) {
|
|
1568
|
+
<ui-payment-attempt-status [attempt]="attempt" [readiness]="readiness" [allowStartOver]="allowStartOver()" (retryLoad)="retryLoad()" />
|
|
1569
|
+
}
|
|
1570
|
+
@if (!mountOnly() && (loading() || pending())) {
|
|
1571
|
+
<div class="sqp-skeleton" data-testid="square-skeleton" aria-hidden="true">
|
|
1572
|
+
<ui-skeleton [height]="44" [mb]="10" />
|
|
1573
|
+
<ui-skeleton [height]="44" width="60%" />
|
|
1574
|
+
</div>
|
|
1575
|
+
}
|
|
1576
|
+
@if (!mountOnly() && loadErrorText(); as text) {
|
|
1577
|
+
<div class="sqp-block" data-testid="square-load-error"><ui-alert variant="danger">{{ text }}</ui-alert></div>
|
|
1578
|
+
}
|
|
1579
|
+
@if (!mountOnly() && required()) {
|
|
1580
|
+
<div class="sqp-label" data-testid="square-required-label">{{ label() }}<span class="sqp-required" aria-hidden="true">*</span></div>
|
|
1581
|
+
}
|
|
1582
|
+
@if (method() === 'card') {
|
|
1583
|
+
<div #mount class="sqp-mount" [attr.id]="mountId() || null" [class]="mountClass()" [class.sqp-mount--hidden]="mountHidden()" [class.sqp-mount--locked]="mountLocked()"
|
|
1584
|
+
[attr.aria-hidden]="mountHidden() ? 'true' : null" [attr.aria-disabled]="mountLocked() ? 'true' : null" [attr.inert]="mountHidden() || mountLocked() ? '' : null"
|
|
1585
|
+
[attr.role]="mountOnly() ? null : 'group'" [attr.aria-label]="mountOnly() ? null : label()" [attr.data-testid]="mountTestId()"></div>
|
|
1586
|
+
} @else if (!mountOnly()) {
|
|
1587
|
+
<div class="sqp-ach" data-testid="square-ach">
|
|
1588
|
+
<ui-text data-testid="square-ach-info" size="sm" tone="muted" [text]="labels.t('squarePayment.achInfo')" />
|
|
1589
|
+
<ui-text-input [label]="labels.t('squarePayment.holderLabel')" [placeholder]="labels.t('squarePayment.holderPlaceholder')" [inputTestId]="holderTestId()" autocomplete="name"
|
|
1590
|
+
[required]="true" [maxlength]="255" [error]="holderError()" [showErrors]="attempted()" [disabled]="locked()"
|
|
1591
|
+
[ngModel]="holder()" (ngModelChange)="holder.set($event ?? '')" />
|
|
1592
|
+
@if (requireAchConsent()) {
|
|
1593
|
+
<ui-checkbox testId="square-consent" [label]="achConsent()" [required]="true" [requiredMessage]="labels.t('squarePayment.consentRequired')" [showErrors]="attempted()"
|
|
1594
|
+
[disabled]="locked()" [ngModel]="consent()" (ngModelChange)="consent.set(!!$event)" />
|
|
1595
|
+
}
|
|
1596
|
+
</div>
|
|
1597
|
+
}
|
|
1598
|
+
@if (!mountOnly() && errorText(); as text) {
|
|
1599
|
+
<div class="sqp-block" [id]="errorId" [attr.data-testid]="errorTestId()"><ui-alert variant="danger">{{ text }}</ui-alert></div>
|
|
1600
|
+
}
|
|
1601
|
+
@if (!mountOnly() && showSubmit()) {
|
|
1602
|
+
<div class="sqp-actions">
|
|
1603
|
+
<ui-button variant="primary" type="button" [fullWidth]="true" [loading]="submitting()" [disabled]="submitDisabled()" [ariaDescribedBy]="errorText() ? errorId : undefined"
|
|
1604
|
+
data-testid="square-submit" (click)="tokenize()">{{ effectiveSubmitLabel() }}</ui-button>
|
|
1605
|
+
</div>
|
|
1606
|
+
}
|
|
1607
|
+
</div>
|
|
1608
|
+
`,
|
|
1609
|
+
styles: ["ui-square-payment{display:block;min-width:0}ui-square-payment .sqp{position:relative}ui-square-payment .sqp-block{margin-top:12px}ui-square-payment .sqp-label{font-size:.875rem;font-weight:500;color:var(--ui-text, #1e293b);margin-bottom:6px}ui-square-payment .sqp-required{color:var(--ui-danger, #dc2626);margin-left:2px}ui-square-payment .sqp-mount{min-height:44px;margin-top:12px}ui-square-payment .sqp-ach{display:flex;flex-direction:column;gap:14px;margin-top:12px}ui-square-payment .sqp-actions{margin-top:16px;display:flex;flex-direction:column;align-items:stretch}ui-square-payment .sqp-mount--hidden{position:absolute;top:0;left:0;right:0;opacity:0;pointer-events:none}ui-square-payment .sqp-mount--locked{pointer-events:none;opacity:.6}\n"]
|
|
1610
|
+
}]
|
|
1611
|
+
}],
|
|
1612
|
+
ctorParameters: () => [],
|
|
1613
|
+
propDecorators: {
|
|
1614
|
+
mountOnly: [{
|
|
1615
|
+
type: i0.Input,
|
|
1616
|
+
args: [{
|
|
1617
|
+
isSignal: true,
|
|
1618
|
+
alias: "mountOnly",
|
|
1619
|
+
required: false
|
|
1620
|
+
}]
|
|
1621
|
+
}],
|
|
1622
|
+
mode: [{
|
|
1623
|
+
type: i0.Input,
|
|
1624
|
+
args: [{
|
|
1625
|
+
isSignal: true,
|
|
1626
|
+
alias: "mode",
|
|
1627
|
+
required: false
|
|
1628
|
+
}]
|
|
1629
|
+
}],
|
|
1630
|
+
method: [{
|
|
1631
|
+
type: i0.Input,
|
|
1632
|
+
args: [{
|
|
1633
|
+
isSignal: true,
|
|
1634
|
+
alias: "method",
|
|
1635
|
+
required: false
|
|
1636
|
+
}]
|
|
1637
|
+
}, {
|
|
1638
|
+
type: i0.Output,
|
|
1639
|
+
args: ["methodChange"]
|
|
1640
|
+
}],
|
|
1641
|
+
methods: [{
|
|
1642
|
+
type: i0.Input,
|
|
1643
|
+
args: [{
|
|
1644
|
+
isSignal: true,
|
|
1645
|
+
alias: "methods",
|
|
1646
|
+
required: false
|
|
1647
|
+
}]
|
|
1648
|
+
}],
|
|
1649
|
+
applicationId: [{
|
|
1650
|
+
type: i0.Input,
|
|
1651
|
+
args: [{
|
|
1652
|
+
isSignal: true,
|
|
1653
|
+
alias: "applicationId",
|
|
1654
|
+
required: false
|
|
1655
|
+
}]
|
|
1656
|
+
}],
|
|
1657
|
+
locationId: [{
|
|
1658
|
+
type: i0.Input,
|
|
1659
|
+
args: [{
|
|
1660
|
+
isSignal: true,
|
|
1661
|
+
alias: "locationId",
|
|
1662
|
+
required: false
|
|
1663
|
+
}]
|
|
1664
|
+
}],
|
|
1665
|
+
environment: [{
|
|
1666
|
+
type: i0.Input,
|
|
1667
|
+
args: [{
|
|
1668
|
+
isSignal: true,
|
|
1669
|
+
alias: "environment",
|
|
1670
|
+
required: false
|
|
1671
|
+
}]
|
|
1672
|
+
}],
|
|
1673
|
+
amount: [{
|
|
1674
|
+
type: i0.Input,
|
|
1675
|
+
args: [{
|
|
1676
|
+
isSignal: true,
|
|
1677
|
+
alias: "amount",
|
|
1678
|
+
required: false
|
|
1679
|
+
}]
|
|
1680
|
+
}],
|
|
1681
|
+
currency: [{
|
|
1682
|
+
type: i0.Input,
|
|
1683
|
+
args: [{
|
|
1684
|
+
isSignal: true,
|
|
1685
|
+
alias: "currency",
|
|
1686
|
+
required: false
|
|
1687
|
+
}]
|
|
1688
|
+
}],
|
|
1689
|
+
billingContact: [{
|
|
1690
|
+
type: i0.Input,
|
|
1691
|
+
args: [{
|
|
1692
|
+
isSignal: true,
|
|
1693
|
+
alias: "billingContact",
|
|
1694
|
+
required: false
|
|
1695
|
+
}]
|
|
1696
|
+
}],
|
|
1697
|
+
verifyBuyer: [{
|
|
1698
|
+
type: i0.Input,
|
|
1699
|
+
args: [{
|
|
1700
|
+
isSignal: true,
|
|
1701
|
+
alias: "verifyBuyer",
|
|
1702
|
+
required: false
|
|
1703
|
+
}]
|
|
1704
|
+
}],
|
|
1705
|
+
accountHolderName: [{
|
|
1706
|
+
type: i0.Input,
|
|
1707
|
+
args: [{
|
|
1708
|
+
isSignal: true,
|
|
1709
|
+
alias: "accountHolderName",
|
|
1710
|
+
required: false
|
|
1711
|
+
}]
|
|
1712
|
+
}],
|
|
1713
|
+
requireAchConsent: [{
|
|
1714
|
+
type: i0.Input,
|
|
1715
|
+
args: [{
|
|
1716
|
+
isSignal: true,
|
|
1717
|
+
alias: "requireAchConsent",
|
|
1718
|
+
required: false
|
|
1719
|
+
}]
|
|
1720
|
+
}],
|
|
1721
|
+
achConsentTextInput: [{
|
|
1722
|
+
type: i0.Input,
|
|
1723
|
+
args: [{
|
|
1724
|
+
isSignal: true,
|
|
1725
|
+
alias: "achConsentText",
|
|
1726
|
+
required: false
|
|
1727
|
+
}]
|
|
1728
|
+
}],
|
|
1729
|
+
achRedirectUri: [{
|
|
1730
|
+
type: i0.Input,
|
|
1731
|
+
args: [{
|
|
1732
|
+
isSignal: true,
|
|
1733
|
+
alias: "achRedirectUri",
|
|
1734
|
+
required: false
|
|
1735
|
+
}]
|
|
1736
|
+
}],
|
|
1737
|
+
achTransactionId: [{
|
|
1738
|
+
type: i0.Input,
|
|
1739
|
+
args: [{
|
|
1740
|
+
isSignal: true,
|
|
1741
|
+
alias: "achTransactionId",
|
|
1742
|
+
required: false
|
|
1743
|
+
}]
|
|
1744
|
+
}],
|
|
1745
|
+
cardOptions: [{
|
|
1746
|
+
type: i0.Input,
|
|
1747
|
+
args: [{
|
|
1748
|
+
isSignal: true,
|
|
1749
|
+
alias: "cardOptions",
|
|
1750
|
+
required: false
|
|
1751
|
+
}]
|
|
1752
|
+
}],
|
|
1753
|
+
cardStyle: [{
|
|
1754
|
+
type: i0.Input,
|
|
1755
|
+
args: [{
|
|
1756
|
+
isSignal: true,
|
|
1757
|
+
alias: "cardStyle",
|
|
1758
|
+
required: false
|
|
1759
|
+
}]
|
|
1760
|
+
}],
|
|
1761
|
+
styleFromTokens: [{
|
|
1762
|
+
type: i0.Input,
|
|
1763
|
+
args: [{
|
|
1764
|
+
isSignal: true,
|
|
1765
|
+
alias: "styleFromTokens",
|
|
1766
|
+
required: false
|
|
1767
|
+
}]
|
|
1768
|
+
}],
|
|
1769
|
+
showStatus: [{
|
|
1770
|
+
type: i0.Input,
|
|
1771
|
+
args: [{
|
|
1772
|
+
isSignal: true,
|
|
1773
|
+
alias: "showStatus",
|
|
1774
|
+
required: false
|
|
1775
|
+
}]
|
|
1776
|
+
}],
|
|
1777
|
+
payableRef: [{
|
|
1778
|
+
type: i0.Input,
|
|
1779
|
+
args: [{
|
|
1780
|
+
isSignal: true,
|
|
1781
|
+
alias: "payableRef",
|
|
1782
|
+
required: false
|
|
1783
|
+
}]
|
|
1784
|
+
}],
|
|
1785
|
+
attemptKey: [{
|
|
1786
|
+
type: i0.Input,
|
|
1787
|
+
args: [{
|
|
1788
|
+
isSignal: true,
|
|
1789
|
+
alias: "attemptKey",
|
|
1790
|
+
required: false
|
|
1791
|
+
}]
|
|
1792
|
+
}],
|
|
1793
|
+
checkStatus: [{
|
|
1794
|
+
type: i0.Input,
|
|
1795
|
+
args: [{
|
|
1796
|
+
isSignal: true,
|
|
1797
|
+
alias: "checkStatus",
|
|
1798
|
+
required: false
|
|
1799
|
+
}]
|
|
1800
|
+
}],
|
|
1801
|
+
paid: [{
|
|
1802
|
+
type: i0.Input,
|
|
1803
|
+
args: [{
|
|
1804
|
+
isSignal: true,
|
|
1805
|
+
alias: "paid",
|
|
1806
|
+
required: false
|
|
1807
|
+
}]
|
|
1808
|
+
}],
|
|
1809
|
+
hostPending: [{
|
|
1810
|
+
type: i0.Input,
|
|
1811
|
+
args: [{
|
|
1812
|
+
isSignal: true,
|
|
1813
|
+
alias: "hostPending",
|
|
1814
|
+
required: false
|
|
1815
|
+
}]
|
|
1816
|
+
}],
|
|
1817
|
+
statusPollMs: [{
|
|
1818
|
+
type: i0.Input,
|
|
1819
|
+
args: [{
|
|
1820
|
+
isSignal: true,
|
|
1821
|
+
alias: "statusPollMs",
|
|
1822
|
+
required: false
|
|
1823
|
+
}]
|
|
1824
|
+
}],
|
|
1825
|
+
statusPollMaxMs: [{
|
|
1826
|
+
type: i0.Input,
|
|
1827
|
+
args: [{
|
|
1828
|
+
isSignal: true,
|
|
1829
|
+
alias: "statusPollMaxMs",
|
|
1830
|
+
required: false
|
|
1831
|
+
}]
|
|
1832
|
+
}],
|
|
1833
|
+
statusCheckTimeoutMs: [{
|
|
1834
|
+
type: i0.Input,
|
|
1835
|
+
args: [{
|
|
1836
|
+
isSignal: true,
|
|
1837
|
+
alias: "statusCheckTimeoutMs",
|
|
1838
|
+
required: false
|
|
1839
|
+
}]
|
|
1840
|
+
}],
|
|
1841
|
+
statusFailGraceMs: [{
|
|
1842
|
+
type: i0.Input,
|
|
1843
|
+
args: [{
|
|
1844
|
+
isSignal: true,
|
|
1845
|
+
alias: "statusFailGraceMs",
|
|
1846
|
+
required: false
|
|
1847
|
+
}]
|
|
1848
|
+
}],
|
|
1849
|
+
allowStartOver: [{
|
|
1850
|
+
type: i0.Input,
|
|
1851
|
+
args: [{
|
|
1852
|
+
isSignal: true,
|
|
1853
|
+
alias: "allowStartOver",
|
|
1854
|
+
required: false
|
|
1855
|
+
}]
|
|
1856
|
+
}],
|
|
1857
|
+
offlineOverride: [{
|
|
1858
|
+
type: i0.Input,
|
|
1859
|
+
args: [{
|
|
1860
|
+
isSignal: true,
|
|
1861
|
+
alias: "offlineOverride",
|
|
1862
|
+
required: false
|
|
1863
|
+
}]
|
|
1864
|
+
}],
|
|
1865
|
+
hostSilenceMs: [{
|
|
1866
|
+
type: i0.Input,
|
|
1867
|
+
args: [{
|
|
1868
|
+
isSignal: true,
|
|
1869
|
+
alias: "hostSilenceMs",
|
|
1870
|
+
required: false
|
|
1871
|
+
}]
|
|
1872
|
+
}],
|
|
1873
|
+
readinessCheck: [{
|
|
1874
|
+
type: i0.Input,
|
|
1875
|
+
args: [{
|
|
1876
|
+
isSignal: true,
|
|
1877
|
+
alias: "readinessCheck",
|
|
1878
|
+
required: false
|
|
1879
|
+
}]
|
|
1880
|
+
}],
|
|
1881
|
+
readinessTimeoutMs: [{
|
|
1882
|
+
type: i0.Input,
|
|
1883
|
+
args: [{
|
|
1884
|
+
isSignal: true,
|
|
1885
|
+
alias: "readinessTimeoutMs",
|
|
1886
|
+
required: false
|
|
1887
|
+
}]
|
|
1888
|
+
}],
|
|
1889
|
+
readinessEveryMs: [{
|
|
1890
|
+
type: i0.Input,
|
|
1891
|
+
args: [{
|
|
1892
|
+
isSignal: true,
|
|
1893
|
+
alias: "readinessEveryMs",
|
|
1894
|
+
required: false
|
|
1895
|
+
}]
|
|
1896
|
+
}],
|
|
1897
|
+
submitLabel: [{
|
|
1898
|
+
type: i0.Input,
|
|
1899
|
+
args: [{
|
|
1900
|
+
isSignal: true,
|
|
1901
|
+
alias: "submitLabel",
|
|
1902
|
+
required: false
|
|
1903
|
+
}]
|
|
1904
|
+
}],
|
|
1905
|
+
showSubmit: [{
|
|
1906
|
+
type: i0.Input,
|
|
1907
|
+
args: [{
|
|
1908
|
+
isSignal: true,
|
|
1909
|
+
alias: "showSubmit",
|
|
1910
|
+
required: false
|
|
1911
|
+
}]
|
|
1912
|
+
}],
|
|
1913
|
+
disabled: [{
|
|
1914
|
+
type: i0.Input,
|
|
1915
|
+
args: [{
|
|
1916
|
+
isSignal: true,
|
|
1917
|
+
alias: "disabled",
|
|
1918
|
+
required: false
|
|
1919
|
+
}]
|
|
1920
|
+
}],
|
|
1921
|
+
pending: [{
|
|
1922
|
+
type: i0.Input,
|
|
1923
|
+
args: [{
|
|
1924
|
+
isSignal: true,
|
|
1925
|
+
alias: "pending",
|
|
1926
|
+
required: false
|
|
1927
|
+
}]
|
|
1928
|
+
}],
|
|
1929
|
+
labelInput: [{
|
|
1930
|
+
type: i0.Input,
|
|
1931
|
+
args: [{
|
|
1932
|
+
isSignal: true,
|
|
1933
|
+
alias: "label",
|
|
1934
|
+
required: false
|
|
1935
|
+
}]
|
|
1936
|
+
}],
|
|
1937
|
+
required: [{
|
|
1938
|
+
type: i0.Input,
|
|
1939
|
+
args: [{
|
|
1940
|
+
isSignal: true,
|
|
1941
|
+
alias: "required",
|
|
1942
|
+
required: false
|
|
1943
|
+
}]
|
|
1944
|
+
}],
|
|
1945
|
+
mountId: [{
|
|
1946
|
+
type: i0.Input,
|
|
1947
|
+
args: [{
|
|
1948
|
+
isSignal: true,
|
|
1949
|
+
alias: "mountId",
|
|
1950
|
+
required: false
|
|
1951
|
+
}]
|
|
1952
|
+
}],
|
|
1953
|
+
mountClass: [{
|
|
1954
|
+
type: i0.Input,
|
|
1955
|
+
args: [{
|
|
1956
|
+
isSignal: true,
|
|
1957
|
+
alias: "mountClass",
|
|
1958
|
+
required: false
|
|
1959
|
+
}]
|
|
1960
|
+
}],
|
|
1961
|
+
mountTestId: [{
|
|
1962
|
+
type: i0.Input,
|
|
1963
|
+
args: [{
|
|
1964
|
+
isSignal: true,
|
|
1965
|
+
alias: "mountTestId",
|
|
1966
|
+
required: false
|
|
1967
|
+
}]
|
|
1968
|
+
}],
|
|
1969
|
+
errorTestId: [{
|
|
1970
|
+
type: i0.Input,
|
|
1971
|
+
args: [{
|
|
1972
|
+
isSignal: true,
|
|
1973
|
+
alias: "errorTestId",
|
|
1974
|
+
required: false
|
|
1975
|
+
}]
|
|
1976
|
+
}],
|
|
1977
|
+
holderTestId: [{
|
|
1978
|
+
type: i0.Input,
|
|
1979
|
+
args: [{
|
|
1980
|
+
isSignal: true,
|
|
1981
|
+
alias: "holderTestId",
|
|
1982
|
+
required: false
|
|
1983
|
+
}]
|
|
1984
|
+
}],
|
|
1985
|
+
showErrors: [{
|
|
1986
|
+
type: i0.Input,
|
|
1987
|
+
args: [{
|
|
1988
|
+
isSignal: true,
|
|
1989
|
+
alias: "showErrors",
|
|
1990
|
+
required: false
|
|
1991
|
+
}]
|
|
1992
|
+
}],
|
|
1993
|
+
errorDisplay: [{
|
|
1994
|
+
type: i0.Input,
|
|
1995
|
+
args: [{
|
|
1996
|
+
isSignal: true,
|
|
1997
|
+
alias: "errorDisplay",
|
|
1998
|
+
required: false
|
|
1999
|
+
}]
|
|
2000
|
+
}],
|
|
2001
|
+
errorMessages: [{
|
|
2002
|
+
type: i0.Input,
|
|
2003
|
+
args: [{
|
|
2004
|
+
isSignal: true,
|
|
2005
|
+
alias: "errorMessages",
|
|
2006
|
+
required: false
|
|
2007
|
+
}]
|
|
2008
|
+
}],
|
|
2009
|
+
errorFallback: [{
|
|
2010
|
+
type: i0.Input,
|
|
2011
|
+
args: [{
|
|
2012
|
+
isSignal: true,
|
|
2013
|
+
alias: "errorFallback",
|
|
2014
|
+
required: false
|
|
2015
|
+
}]
|
|
2016
|
+
}],
|
|
2017
|
+
loadErrorMessageInput: [{
|
|
2018
|
+
type: i0.Input,
|
|
2019
|
+
args: [{
|
|
2020
|
+
isSignal: true,
|
|
2021
|
+
alias: "loadErrorMessage",
|
|
2022
|
+
required: false
|
|
2023
|
+
}]
|
|
2024
|
+
}],
|
|
2025
|
+
a11yMessages: [{
|
|
2026
|
+
type: i0.Input,
|
|
2027
|
+
args: [{
|
|
2028
|
+
isSignal: true,
|
|
2029
|
+
alias: "a11yMessages",
|
|
2030
|
+
required: false
|
|
2031
|
+
}]
|
|
2032
|
+
}],
|
|
2033
|
+
squareReady: [{
|
|
2034
|
+
type: i0.Output,
|
|
2035
|
+
args: ["squareReady"]
|
|
2036
|
+
}],
|
|
2037
|
+
ready: [{
|
|
2038
|
+
type: i0.Output,
|
|
2039
|
+
args: ["ready"]
|
|
2040
|
+
}],
|
|
2041
|
+
inFlightChange: [{
|
|
2042
|
+
type: i0.Output,
|
|
2043
|
+
args: ["inFlightChange"]
|
|
2044
|
+
}],
|
|
2045
|
+
outcome: [{
|
|
2046
|
+
type: i0.Output,
|
|
2047
|
+
args: ["outcome"]
|
|
2048
|
+
}],
|
|
2049
|
+
attemptKeyChange: [{
|
|
2050
|
+
type: i0.Output,
|
|
2051
|
+
args: ["attemptKeyChange"]
|
|
2052
|
+
}],
|
|
2053
|
+
readinessChange: [{
|
|
2054
|
+
type: i0.Output,
|
|
2055
|
+
args: ["readinessChange"]
|
|
2056
|
+
}],
|
|
2057
|
+
tokenized: [{
|
|
2058
|
+
type: i0.Output,
|
|
2059
|
+
args: ["tokenized"]
|
|
2060
|
+
}],
|
|
2061
|
+
failed: [{
|
|
2062
|
+
type: i0.Output,
|
|
2063
|
+
args: ["failed"]
|
|
2064
|
+
}],
|
|
2065
|
+
loadError: [{
|
|
2066
|
+
type: i0.Output,
|
|
2067
|
+
args: ["loadError"]
|
|
2068
|
+
}],
|
|
2069
|
+
mountRef: [{
|
|
2070
|
+
type: i0.ViewChild,
|
|
2071
|
+
args: ["mount", { isSignal: true }]
|
|
2072
|
+
}]
|
|
2073
|
+
}
|
|
2074
|
+
});
|
|
2075
|
+
function isSquareUrl(url) {
|
|
2076
|
+
if (!url) return false;
|
|
2077
|
+
try {
|
|
2078
|
+
const u = new URL(url);
|
|
2079
|
+
return u.protocol === "https:" && [
|
|
2080
|
+
"squareup.com",
|
|
2081
|
+
"squareupsandbox.com",
|
|
2082
|
+
"square.com"
|
|
2083
|
+
].some((d) => u.hostname === d || u.hostname.endsWith(`.${d}`));
|
|
2084
|
+
} catch {
|
|
2085
|
+
return false;
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
var SquareConnectFlow = class {
|
|
2089
|
+
constructor(o) {
|
|
2090
|
+
this.o = o;
|
|
2091
|
+
this.tabOpened = false;
|
|
2092
|
+
}
|
|
2093
|
+
get blocked() {
|
|
2094
|
+
return this.o.state.loading() || !!this.o.disabled?.();
|
|
2095
|
+
}
|
|
2096
|
+
startConnect() {
|
|
2097
|
+
const start = this.o.start();
|
|
2098
|
+
if (!start || this.blocked) return;
|
|
2099
|
+
this.o.state.loading.set(true);
|
|
2100
|
+
const tab = this.openBlankTab();
|
|
2101
|
+
start().pipe(takeUntilDestroyed(this.o.destroyRef)).subscribe({
|
|
2102
|
+
next: (result) => {
|
|
2103
|
+
this.o.state.loading.set(false);
|
|
2104
|
+
this.openSquare(tab, result?.authUrl ?? result?.url);
|
|
2105
|
+
},
|
|
2106
|
+
error: (error) => {
|
|
2107
|
+
this.closeTab(tab);
|
|
2108
|
+
this.o.state.loading.set(false);
|
|
2109
|
+
this.o.emit({
|
|
2110
|
+
kind: "failed",
|
|
2111
|
+
action: "start",
|
|
2112
|
+
error
|
|
2113
|
+
});
|
|
2114
|
+
}
|
|
2115
|
+
});
|
|
2116
|
+
}
|
|
2117
|
+
check() {
|
|
2118
|
+
const status = this.o.getStatus();
|
|
2119
|
+
if (!status || this.blocked) return;
|
|
2120
|
+
this.o.state.loading.set(true);
|
|
2121
|
+
status().pipe(takeUntilDestroyed(this.o.destroyRef)).subscribe({
|
|
2122
|
+
next: (s) => {
|
|
2123
|
+
this.o.state.status.set(s);
|
|
2124
|
+
this.o.state.loading.set(false);
|
|
2125
|
+
if (s.connected && s.needsReconnect) this.o.emit({
|
|
2126
|
+
kind: "needs-reconnect",
|
|
2127
|
+
source: "check"
|
|
2128
|
+
});
|
|
2129
|
+
else if (s.connected) this.o.emit({
|
|
2130
|
+
kind: "connected",
|
|
2131
|
+
source: "check"
|
|
2132
|
+
});
|
|
2133
|
+
else this.o.emit({ kind: "not-connected" });
|
|
2134
|
+
},
|
|
2135
|
+
error: (error) => {
|
|
2136
|
+
this.o.state.loading.set(false);
|
|
2137
|
+
this.o.emit({
|
|
2138
|
+
kind: "failed",
|
|
2139
|
+
action: "check",
|
|
2140
|
+
error
|
|
2141
|
+
});
|
|
2142
|
+
}
|
|
2143
|
+
});
|
|
2144
|
+
}
|
|
2145
|
+
disconnect() {
|
|
2146
|
+
const disconnect = this.o.disconnect();
|
|
2147
|
+
if (!disconnect || this.blocked) return;
|
|
2148
|
+
this.o.state.loading.set(true);
|
|
2149
|
+
disconnect().pipe(takeUntilDestroyed(this.o.destroyRef)).subscribe({
|
|
2150
|
+
next: () => {
|
|
2151
|
+
this.o.state.status.set({ connected: false });
|
|
2152
|
+
this.o.state.loading.set(false);
|
|
2153
|
+
this.o.emit({ kind: "disconnected" });
|
|
2154
|
+
},
|
|
2155
|
+
error: (error) => {
|
|
2156
|
+
this.o.state.loading.set(false);
|
|
2157
|
+
this.o.emit({
|
|
2158
|
+
kind: "failed",
|
|
2159
|
+
action: "disconnect",
|
|
2160
|
+
error
|
|
2161
|
+
});
|
|
2162
|
+
}
|
|
2163
|
+
});
|
|
2164
|
+
}
|
|
2165
|
+
readStatusOnReturn() {
|
|
2166
|
+
const status = this.o.getStatus();
|
|
2167
|
+
if (!status) return;
|
|
2168
|
+
status().pipe(takeUntilDestroyed(this.o.destroyRef)).subscribe({
|
|
2169
|
+
next: (s) => {
|
|
2170
|
+
this.o.state.status.set(s);
|
|
2171
|
+
if (s.connected && s.needsReconnect) this.o.emit({
|
|
2172
|
+
kind: "needs-reconnect",
|
|
2173
|
+
source: "return"
|
|
2174
|
+
});
|
|
2175
|
+
else if (s.connected) this.o.emit({
|
|
2176
|
+
kind: "connected",
|
|
2177
|
+
source: "return"
|
|
2178
|
+
});
|
|
2179
|
+
},
|
|
2180
|
+
error: () => {}
|
|
2181
|
+
});
|
|
2182
|
+
}
|
|
2183
|
+
openSquare(tab, url) {
|
|
2184
|
+
if (isSquareUrl(url) && tab && !tab.closed) {
|
|
2185
|
+
tab.location.href = url;
|
|
2186
|
+
this.tabOpened = true;
|
|
2187
|
+
this.o.onOpened?.();
|
|
2188
|
+
} else if (isSquareUrl(url)) this.navigateCurrentTab(url);
|
|
2189
|
+
else {
|
|
2190
|
+
this.closeTab(tab);
|
|
2191
|
+
this.o.emit({ kind: "link-unavailable" });
|
|
2192
|
+
}
|
|
2193
|
+
}
|
|
2194
|
+
openBlankTab() {
|
|
2195
|
+
const tab = window.open("about:blank", "_blank");
|
|
2196
|
+
if (tab) try {
|
|
2197
|
+
tab.opener = null;
|
|
2198
|
+
} catch {}
|
|
2199
|
+
return tab;
|
|
2200
|
+
}
|
|
2201
|
+
navigateCurrentTab(url) {
|
|
2202
|
+
if (this.o.navigate) this.o.navigate(url);
|
|
2203
|
+
else window.location.href = url;
|
|
2204
|
+
}
|
|
2205
|
+
closeTab(tab) {
|
|
2206
|
+
try {
|
|
2207
|
+
tab?.close();
|
|
2208
|
+
} catch {}
|
|
2209
|
+
}
|
|
2210
|
+
};
|
|
2211
|
+
function squareConnectNotice(outcome) {
|
|
2212
|
+
switch (outcome.kind) {
|
|
2213
|
+
case "connected": return {
|
|
2214
|
+
variant: "success",
|
|
2215
|
+
message: uiText("squareConnect.noticeConnected")
|
|
2216
|
+
};
|
|
2217
|
+
case "needs-reconnect": return {
|
|
2218
|
+
variant: "error",
|
|
2219
|
+
message: uiText("squareConnect.noticeReconnect")
|
|
2220
|
+
};
|
|
2221
|
+
case "not-connected": return {
|
|
2222
|
+
variant: "info",
|
|
2223
|
+
message: uiText("squareConnect.noticeNotConnected")
|
|
2224
|
+
};
|
|
2225
|
+
case "disconnected": return {
|
|
2226
|
+
variant: "success",
|
|
2227
|
+
message: uiText("squareConnect.noticeDisconnected")
|
|
2228
|
+
};
|
|
2229
|
+
case "link-unavailable": return {
|
|
2230
|
+
variant: "error",
|
|
2231
|
+
message: uiText("squareConnect.noticeLinkUnavailable")
|
|
2232
|
+
};
|
|
2233
|
+
case "failed": return {
|
|
2234
|
+
variant: "error",
|
|
2235
|
+
message: uiText(outcome.action === "start" ? "squareConnect.failedStart" : outcome.action === "check" ? "squareConnect.failedCheck" : "squareConnect.failedDisconnect")
|
|
2236
|
+
};
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
let nextConnectId = 0;
|
|
2240
|
+
var SquareConnectComponent = class SquareConnectComponent {
|
|
2241
|
+
constructor() {
|
|
2242
|
+
this.confirmMessageId = `sqc-disconnect-msg-${nextConnectId++}`;
|
|
2243
|
+
this.labels = inject(UiLabelsService);
|
|
2244
|
+
this.destroyRef = inject(DestroyRef);
|
|
2245
|
+
this.injector = inject(Injector);
|
|
2246
|
+
this.host = inject(ElementRef);
|
|
2247
|
+
this.startConnect = input(null, ...ngDevMode ? [{ debugName: "startConnect" }] : /* istanbul ignore next */ []);
|
|
2248
|
+
this.getStatus = input(null, ...ngDevMode ? [{ debugName: "getStatus" }] : /* istanbul ignore next */ []);
|
|
2249
|
+
this.disconnect = input(null, ...ngDevMode ? [{ debugName: "disconnect" }] : /* istanbul ignore next */ []);
|
|
2250
|
+
this.status = model(null, ...ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []);
|
|
2251
|
+
this.titleInput = input(null, {
|
|
2252
|
+
...ngDevMode ? { debugName: "titleInput" } : /* istanbul ignore next */ {},
|
|
2253
|
+
alias: "title"
|
|
2254
|
+
});
|
|
2255
|
+
this.title = computed(() => this.titleInput() ?? this.labels.t("squareConnect.title"), ...ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []);
|
|
2256
|
+
this.bare = input(false, ...ngDevMode ? [{ debugName: "bare" }] : /* istanbul ignore next */ []);
|
|
2257
|
+
this.startTitleInput = input(null, {
|
|
2258
|
+
...ngDevMode ? { debugName: "startTitleInput" } : /* istanbul ignore next */ {},
|
|
2259
|
+
alias: "startTitle"
|
|
2260
|
+
});
|
|
2261
|
+
this.startTitle = computed(() => this.startTitleInput() ?? this.labels.t("squareConnect.startTitle"), ...ngDevMode ? [{ debugName: "startTitle" }] : /* istanbul ignore next */ []);
|
|
2262
|
+
this.startTextInput = input(null, {
|
|
2263
|
+
...ngDevMode ? { debugName: "startTextInput" } : /* istanbul ignore next */ {},
|
|
2264
|
+
alias: "startText"
|
|
2265
|
+
});
|
|
2266
|
+
this.startText = computed(() => this.startTextInput() ?? this.labels.t("squareConnect.startText"), ...ngDevMode ? [{ debugName: "startText" }] : /* istanbul ignore next */ []);
|
|
2267
|
+
this.startLabelInput = input(null, {
|
|
2268
|
+
...ngDevMode ? { debugName: "startLabelInput" } : /* istanbul ignore next */ {},
|
|
2269
|
+
alias: "startLabel"
|
|
2270
|
+
});
|
|
2271
|
+
this.startLabel = computed(() => this.startLabelInput() ?? this.labels.t("squareConnect.startLabel"), ...ngDevMode ? [{ debugName: "startLabel" }] : /* istanbul ignore next */ []);
|
|
2272
|
+
this.disabled = input(false, ...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
|
|
2273
|
+
this.confirmDisconnect = input(true, ...ngDevMode ? [{ debugName: "confirmDisconnect" }] : /* istanbul ignore next */ []);
|
|
2274
|
+
this.refreshOnReturn = input(false, ...ngDevMode ? [{ debugName: "refreshOnReturn" }] : /* istanbul ignore next */ []);
|
|
2275
|
+
this.navigateTab = input(null, ...ngDevMode ? [{ debugName: "navigateTab" }] : /* istanbul ignore next */ []);
|
|
2276
|
+
this.outcome = output();
|
|
2277
|
+
this.loading = model(false, ...ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []);
|
|
2278
|
+
this.awaiting = signal(false, ...ngDevMode ? [{ debugName: "awaiting" }] : /* istanbul ignore next */ []);
|
|
2279
|
+
this.confirming = signal(false, ...ngDevMode ? [{ debugName: "confirming" }] : /* istanbul ignore next */ []);
|
|
2280
|
+
this.state = computed(() => {
|
|
2281
|
+
const s = this.status();
|
|
2282
|
+
return !s?.connected ? "none" : s.needsReconnect ? "reconnect" : "connected";
|
|
2283
|
+
}, ...ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []);
|
|
2284
|
+
this.merchant = computed(() => this.status()?.merchantName || this.status()?.merchantId || "", ...ngDevMode ? [{ debugName: "merchant" }] : /* istanbul ignore next */ []);
|
|
2285
|
+
this.location = computed(() => this.status()?.locationName || this.status()?.locationId || "", ...ngDevMode ? [{ debugName: "location" }] : /* istanbul ignore next */ []);
|
|
2286
|
+
this.connectedOn = computed(() => this.labels.formatDate(this.status()?.connectedAt ?? null, "mediumDate"), ...ngDevMode ? [{ debugName: "connectedOn" }] : /* istanbul ignore next */ []);
|
|
2287
|
+
this.liveText = computed(() => {
|
|
2288
|
+
const text = this.labels.t({
|
|
2289
|
+
none: "squareConnect.live.none",
|
|
2290
|
+
connected: "squareConnect.live.connected",
|
|
2291
|
+
reconnect: "squareConnect.live.reconnect"
|
|
2292
|
+
}[this.state()]);
|
|
2293
|
+
return this.loading() ? this.labels.t("squareConnect.live.loading", { text }) : text;
|
|
2294
|
+
}, ...ngDevMode ? [{ debugName: "liveText" }] : /* istanbul ignore next */ []);
|
|
2295
|
+
this.acted = false;
|
|
2296
|
+
this.lastState = this.state();
|
|
2297
|
+
this.flow = new SquareConnectFlow({
|
|
2298
|
+
start: () => this.startConnect(),
|
|
2299
|
+
getStatus: () => this.getStatus(),
|
|
2300
|
+
disconnect: () => this.disconnect(),
|
|
2301
|
+
state: {
|
|
2302
|
+
status: this.status,
|
|
2303
|
+
loading: this.loading
|
|
2304
|
+
},
|
|
2305
|
+
emit: (outcome) => this.outcome.emit(outcome),
|
|
2306
|
+
disabled: () => this.disabled(),
|
|
2307
|
+
navigate: (url) => this.navigateCurrentTab(url),
|
|
2308
|
+
onOpened: () => this.awaiting.set(true),
|
|
2309
|
+
destroyRef: this.destroyRef
|
|
2310
|
+
});
|
|
2311
|
+
effect(() => {
|
|
2312
|
+
const state = this.state();
|
|
2313
|
+
if (this.loading()) return;
|
|
2314
|
+
const changed = state !== this.lastState;
|
|
2315
|
+
this.lastState = state;
|
|
2316
|
+
const focusIt = changed && this.acted;
|
|
2317
|
+
this.acted = false;
|
|
2318
|
+
if (state === "connected") this.awaiting.set(false);
|
|
2319
|
+
if (focusIt) afterNextRender(() => this.host.nativeElement.querySelector(".sqc-state")?.focus(), { injector: this.injector });
|
|
2320
|
+
});
|
|
2321
|
+
if (typeof document !== "undefined") {
|
|
2322
|
+
const onVisible = () => {
|
|
2323
|
+
if (document.visibilityState !== "visible" || !this.flow.tabOpened || !this.refreshOnReturn() || this.loading()) return;
|
|
2324
|
+
this.flow.tabOpened = false;
|
|
2325
|
+
this.flow.readStatusOnReturn();
|
|
2326
|
+
};
|
|
2327
|
+
document.addEventListener("visibilitychange", onVisible);
|
|
2328
|
+
this.destroyRef.onDestroy(() => document.removeEventListener("visibilitychange", onVisible));
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
start() {
|
|
2332
|
+
const run = this.canRun(this.startConnect());
|
|
2333
|
+
this.flow.startConnect();
|
|
2334
|
+
this.acted ||= run;
|
|
2335
|
+
}
|
|
2336
|
+
check() {
|
|
2337
|
+
const run = this.canRun(this.getStatus());
|
|
2338
|
+
this.flow.check();
|
|
2339
|
+
this.acted ||= run;
|
|
2340
|
+
}
|
|
2341
|
+
askDisconnect() {
|
|
2342
|
+
if (this.disabled() || this.loading() || !this.disconnect()) return;
|
|
2343
|
+
if (this.confirmDisconnect()) this.confirming.set(true);
|
|
2344
|
+
else this.doDisconnect();
|
|
2345
|
+
}
|
|
2346
|
+
cancelDisconnect() {
|
|
2347
|
+
if (!this.loading()) this.confirming.set(false);
|
|
2348
|
+
}
|
|
2349
|
+
doDisconnect() {
|
|
2350
|
+
const run = this.canRun(this.disconnect());
|
|
2351
|
+
this.flow.disconnect();
|
|
2352
|
+
this.acted ||= run;
|
|
2353
|
+
this.confirming.set(false);
|
|
2354
|
+
}
|
|
2355
|
+
canRun(call) {
|
|
2356
|
+
return !!call && !this.loading() && !this.disabled();
|
|
2357
|
+
}
|
|
2358
|
+
navigateCurrentTab(url) {
|
|
2359
|
+
const navigate = this.navigateTab();
|
|
2360
|
+
if (navigate) navigate(url);
|
|
2361
|
+
else window.location.href = url;
|
|
2362
|
+
}
|
|
2363
|
+
static {
|
|
2364
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
2365
|
+
minVersion: "12.0.0",
|
|
2366
|
+
version: "22.2.2",
|
|
2367
|
+
ngImport: i0,
|
|
2368
|
+
type: SquareConnectComponent,
|
|
2369
|
+
deps: [],
|
|
2370
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
2371
|
+
});
|
|
2372
|
+
}
|
|
2373
|
+
static {
|
|
2374
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
2375
|
+
minVersion: "17.0.0",
|
|
2376
|
+
version: "22.2.2",
|
|
2377
|
+
type: SquareConnectComponent,
|
|
2378
|
+
isStandalone: true,
|
|
2379
|
+
selector: "ui-square-connect",
|
|
2380
|
+
inputs: {
|
|
2381
|
+
startConnect: {
|
|
2382
|
+
classPropertyName: "startConnect",
|
|
2383
|
+
publicName: "startConnect",
|
|
2384
|
+
isSignal: true,
|
|
2385
|
+
isRequired: false,
|
|
2386
|
+
transformFunction: null
|
|
2387
|
+
},
|
|
2388
|
+
getStatus: {
|
|
2389
|
+
classPropertyName: "getStatus",
|
|
2390
|
+
publicName: "getStatus",
|
|
2391
|
+
isSignal: true,
|
|
2392
|
+
isRequired: false,
|
|
2393
|
+
transformFunction: null
|
|
2394
|
+
},
|
|
2395
|
+
disconnect: {
|
|
2396
|
+
classPropertyName: "disconnect",
|
|
2397
|
+
publicName: "disconnect",
|
|
2398
|
+
isSignal: true,
|
|
2399
|
+
isRequired: false,
|
|
2400
|
+
transformFunction: null
|
|
2401
|
+
},
|
|
2402
|
+
status: {
|
|
2403
|
+
classPropertyName: "status",
|
|
2404
|
+
publicName: "status",
|
|
2405
|
+
isSignal: true,
|
|
2406
|
+
isRequired: false,
|
|
2407
|
+
transformFunction: null
|
|
2408
|
+
},
|
|
2409
|
+
titleInput: {
|
|
2410
|
+
classPropertyName: "titleInput",
|
|
2411
|
+
publicName: "title",
|
|
2412
|
+
isSignal: true,
|
|
2413
|
+
isRequired: false,
|
|
2414
|
+
transformFunction: null
|
|
2415
|
+
},
|
|
2416
|
+
bare: {
|
|
2417
|
+
classPropertyName: "bare",
|
|
2418
|
+
publicName: "bare",
|
|
2419
|
+
isSignal: true,
|
|
2420
|
+
isRequired: false,
|
|
2421
|
+
transformFunction: null
|
|
2422
|
+
},
|
|
2423
|
+
startTitleInput: {
|
|
2424
|
+
classPropertyName: "startTitleInput",
|
|
2425
|
+
publicName: "startTitle",
|
|
2426
|
+
isSignal: true,
|
|
2427
|
+
isRequired: false,
|
|
2428
|
+
transformFunction: null
|
|
2429
|
+
},
|
|
2430
|
+
startTextInput: {
|
|
2431
|
+
classPropertyName: "startTextInput",
|
|
2432
|
+
publicName: "startText",
|
|
2433
|
+
isSignal: true,
|
|
2434
|
+
isRequired: false,
|
|
2435
|
+
transformFunction: null
|
|
2436
|
+
},
|
|
2437
|
+
startLabelInput: {
|
|
2438
|
+
classPropertyName: "startLabelInput",
|
|
2439
|
+
publicName: "startLabel",
|
|
2440
|
+
isSignal: true,
|
|
2441
|
+
isRequired: false,
|
|
2442
|
+
transformFunction: null
|
|
2443
|
+
},
|
|
2444
|
+
disabled: {
|
|
2445
|
+
classPropertyName: "disabled",
|
|
2446
|
+
publicName: "disabled",
|
|
2447
|
+
isSignal: true,
|
|
2448
|
+
isRequired: false,
|
|
2449
|
+
transformFunction: null
|
|
2450
|
+
},
|
|
2451
|
+
confirmDisconnect: {
|
|
2452
|
+
classPropertyName: "confirmDisconnect",
|
|
2453
|
+
publicName: "confirmDisconnect",
|
|
2454
|
+
isSignal: true,
|
|
2455
|
+
isRequired: false,
|
|
2456
|
+
transformFunction: null
|
|
2457
|
+
},
|
|
2458
|
+
refreshOnReturn: {
|
|
2459
|
+
classPropertyName: "refreshOnReturn",
|
|
2460
|
+
publicName: "refreshOnReturn",
|
|
2461
|
+
isSignal: true,
|
|
2462
|
+
isRequired: false,
|
|
2463
|
+
transformFunction: null
|
|
2464
|
+
},
|
|
2465
|
+
navigateTab: {
|
|
2466
|
+
classPropertyName: "navigateTab",
|
|
2467
|
+
publicName: "navigateTab",
|
|
2468
|
+
isSignal: true,
|
|
2469
|
+
isRequired: false,
|
|
2470
|
+
transformFunction: null
|
|
2471
|
+
},
|
|
2472
|
+
loading: {
|
|
2473
|
+
classPropertyName: "loading",
|
|
2474
|
+
publicName: "loading",
|
|
2475
|
+
isSignal: true,
|
|
2476
|
+
isRequired: false,
|
|
2477
|
+
transformFunction: null
|
|
2478
|
+
}
|
|
2479
|
+
},
|
|
2480
|
+
outputs: {
|
|
2481
|
+
status: "statusChange",
|
|
2482
|
+
outcome: "outcome",
|
|
2483
|
+
loading: "loadingChange"
|
|
2484
|
+
},
|
|
2485
|
+
ngImport: i0,
|
|
2486
|
+
template: `
|
|
2487
|
+
<!-- Persistent live region: present before the state changes, so every new state is announced (and "Loading" while a request runs). -->
|
|
2488
|
+
<ui-live-region data-testid="square-connect-live" [message]="liveText()" />
|
|
2489
|
+
@if (bare()) {
|
|
2490
|
+
<ng-container *ngTemplateOutlet="body" />
|
|
2491
|
+
} @else {
|
|
2492
|
+
<ui-detail-card [collapsible]="false" [title]="title()" [headingLevel]="3" data-testid="square-connect-card">
|
|
2493
|
+
<ng-container *ngTemplateOutlet="body" />
|
|
2494
|
+
</ui-detail-card>
|
|
2495
|
+
}
|
|
2496
|
+
|
|
2497
|
+
<ng-template #body>
|
|
2498
|
+
@if (state() === 'none') {
|
|
2499
|
+
<ui-stack gap="sm" class="sqc-state" tabindex="-1" data-testid="square-connect-status-none" [attr.aria-busy]="loading() ? 'true' : null">
|
|
2500
|
+
<ui-text size="lg" weight="semibold" [text]="startTitle()" />
|
|
2501
|
+
<ui-text size="sm" [text]="startText()" />
|
|
2502
|
+
<ui-stack direction="horizontal">
|
|
2503
|
+
<ui-button variant="primary" size="sm" data-testid="square-connect-start-button" [disabled]="disabled()" (click)="start()">@if (loading()) {<span aria-hidden="true">{{ labels.t('common.loadingellipsis') }}</span><span class="sqc-sr">{{ labels.t('squareConnect.opensInNewTabBusy', { label: startLabel() }) }}</span>} @else { {{ startLabel() }}<span class="sqc-sr">{{ labels.t('squareConnect.opensInNewTabSr') }}</span>}</ui-button>
|
|
2504
|
+
@if (awaiting()) {
|
|
2505
|
+
<ui-button variant="secondary" size="sm" data-testid="square-connect-check-status-button" [disabled]="disabled() || loading()" (click)="check()">{{ labels.t(loading() ? 'squareConnect.checking' : 'squareConnect.checkStatus') }}</ui-button>
|
|
2506
|
+
}
|
|
2507
|
+
</ui-stack>
|
|
2508
|
+
</ui-stack>
|
|
2509
|
+
} @else if (state() === 'reconnect') {
|
|
2510
|
+
<ui-stack gap="sm" class="sqc-state" tabindex="-1" data-testid="square-connect-status-reconnect" [attr.aria-busy]="loading() ? 'true' : null">
|
|
2511
|
+
<span class="sqc-badge"><ui-badge [label]="labels.t('squareConnect.needsReconnect')" variant="red" data-testid="square-connect-reconnect-badge" /></span>
|
|
2512
|
+
<ui-text size="sm" [text]="labels.t('squareConnect.reconnectText')" />
|
|
2513
|
+
<ui-stack direction="horizontal">
|
|
2514
|
+
<ui-button variant="primary" size="sm" data-testid="square-connect-reconnect-button" [disabled]="disabled()" (click)="start()">@if (loading()) {<span aria-hidden="true">{{ labels.t('common.loadingellipsis') }}</span><span class="sqc-sr">{{ labels.t('squareConnect.opensInNewTabBusy', { label: labels.t('squareConnect.reconnect') }) }}</span>} @else { {{ labels.t('squareConnect.reconnect') }}<span class="sqc-sr">{{ labels.t('squareConnect.opensInNewTabSr') }}</span>}</ui-button>
|
|
2515
|
+
<ui-button variant="secondary" size="sm" data-testid="square-connect-disconnect-button" [disabled]="disabled() || loading()" (click)="askDisconnect()">{{ labels.t('squareConnect.disconnect') }}</ui-button>
|
|
2516
|
+
</ui-stack>
|
|
2517
|
+
</ui-stack>
|
|
2518
|
+
} @else {
|
|
2519
|
+
<ui-stack gap="sm" class="sqc-state" tabindex="-1" data-testid="square-connect-status-connected" [attr.aria-busy]="loading() ? 'true' : null">
|
|
2520
|
+
<ui-text size="lg" weight="semibold" [text]="labels.t('squareConnect.connected')" />
|
|
2521
|
+
@if (merchant(); as merchant) { <ui-text size="sm" tone="muted" data-testid="square-connect-merchant" [text]="labels.t('squareConnect.merchantLine', { merchant })" /> }
|
|
2522
|
+
@if (location(); as location) { <ui-text size="sm" tone="muted" data-testid="square-connect-location" [text]="labels.t('squareConnect.locationLine', { location })" /> }
|
|
2523
|
+
@if (connectedOn(); as date) { <ui-text size="sm" tone="muted" data-testid="square-connect-date" [text]="labels.t('squareConnect.connectedOn', { date })" /> }
|
|
2524
|
+
<ui-stack direction="horizontal">
|
|
2525
|
+
<ui-button variant="secondary" size="sm" data-testid="square-connect-check-status-button" [disabled]="disabled() || loading()" (click)="check()">{{ labels.t(loading() ? 'squareConnect.checking' : 'squareConnect.checkStatus') }}</ui-button>
|
|
2526
|
+
<ui-button variant="secondary" size="sm" data-testid="square-connect-disconnect-button" [disabled]="disabled() || loading()" (click)="askDisconnect()">{{ labels.t('squareConnect.disconnect') }}</ui-button>
|
|
2527
|
+
</ui-stack>
|
|
2528
|
+
</ui-stack>
|
|
2529
|
+
}
|
|
2530
|
+
</ng-template>
|
|
2531
|
+
|
|
2532
|
+
<ui-modal [open]="confirming()" [title]="labels.t('squareConnect.disconnectTitle')" maxWidth="440px" [describedBy]="confirmMessageId" [busy]="loading()" dialogTestId="square-connect-confirm" (close)="cancelDisconnect()">
|
|
2533
|
+
<p [id]="confirmMessageId" class="sqc-confirm" data-testid="square-connect-confirm-message">{{ labels.t('squareConnect.disconnectMessage') }}</p>
|
|
2534
|
+
<ui-button modal-footer-left variant="secondary" size="sm" data-testid="square-connect-confirm-cancel" [disabled]="loading()" (click)="cancelDisconnect()">{{ labels.t('common.cancel') }}</ui-button>
|
|
2535
|
+
<ui-button modal-footer-right variant="danger" size="sm" data-testid="square-connect-confirm-accept" [loading]="loading()" (click)="doDisconnect()">{{ labels.t('squareConnect.disconnect') }}</ui-button>
|
|
2536
|
+
</ui-modal>
|
|
2537
|
+
`,
|
|
2538
|
+
isInline: true,
|
|
2539
|
+
styles: ["ui-square-connect{display:block;min-width:0}ui-square-connect .sqc-badge{display:flex}ui-square-connect .sqc-confirm{margin:0;font-size:.9375rem;line-height:1.5}ui-square-connect .sqc-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}\n"],
|
|
2540
|
+
dependencies: [
|
|
2541
|
+
{
|
|
2542
|
+
kind: "directive",
|
|
2543
|
+
type: NgTemplateOutlet,
|
|
2544
|
+
selector: "[ngTemplateOutlet]",
|
|
2545
|
+
inputs: [
|
|
2546
|
+
"ngTemplateOutletContext",
|
|
2547
|
+
"ngTemplateOutlet",
|
|
2548
|
+
"ngTemplateOutletInjector"
|
|
2549
|
+
]
|
|
2550
|
+
},
|
|
2551
|
+
{
|
|
2552
|
+
kind: "component",
|
|
2553
|
+
type: BadgeComponent,
|
|
2554
|
+
selector: "ui-badge",
|
|
2555
|
+
inputs: [
|
|
2556
|
+
"label",
|
|
2557
|
+
"variant",
|
|
2558
|
+
"color"
|
|
2559
|
+
]
|
|
2560
|
+
},
|
|
2561
|
+
{
|
|
2562
|
+
kind: "component",
|
|
2563
|
+
type: ButtonComponent,
|
|
2564
|
+
selector: "ui-button",
|
|
2565
|
+
inputs: [
|
|
2566
|
+
"variant",
|
|
2567
|
+
"routerLink",
|
|
2568
|
+
"queryParams",
|
|
2569
|
+
"fragment",
|
|
2570
|
+
"state",
|
|
2571
|
+
"href",
|
|
2572
|
+
"target",
|
|
2573
|
+
"rel",
|
|
2574
|
+
"shortLabel",
|
|
2575
|
+
"shortBelow",
|
|
2576
|
+
"color",
|
|
2577
|
+
"active",
|
|
2578
|
+
"size",
|
|
2579
|
+
"type",
|
|
2580
|
+
"disabled",
|
|
2581
|
+
"loading",
|
|
2582
|
+
"fullWidth",
|
|
2583
|
+
"ariaLabel",
|
|
2584
|
+
"ariaExpanded",
|
|
2585
|
+
"ariaPressed",
|
|
2586
|
+
"ariaDescribedBy",
|
|
2587
|
+
"modal-footer-left",
|
|
2588
|
+
"modal-footer-right"
|
|
2589
|
+
]
|
|
2590
|
+
},
|
|
2591
|
+
{
|
|
2592
|
+
kind: "component",
|
|
2593
|
+
type: DetailCardComponent,
|
|
2594
|
+
selector: "ui-detail-card",
|
|
2595
|
+
inputs: [
|
|
2596
|
+
"title",
|
|
2597
|
+
"uppercaseTitle",
|
|
2598
|
+
"headingLevel",
|
|
2599
|
+
"titleId",
|
|
2600
|
+
"ariaLabel",
|
|
2601
|
+
"subtitle",
|
|
2602
|
+
"background",
|
|
2603
|
+
"headerBackground",
|
|
2604
|
+
"footerBackground",
|
|
2605
|
+
"footerAlign",
|
|
2606
|
+
"textColor",
|
|
2607
|
+
"showHeader",
|
|
2608
|
+
"collapsible",
|
|
2609
|
+
"expanded",
|
|
2610
|
+
"showEdit",
|
|
2611
|
+
"editLabel",
|
|
2612
|
+
"editTestId",
|
|
2613
|
+
"editIcon",
|
|
2614
|
+
"editAriaLabel",
|
|
2615
|
+
"fill",
|
|
2616
|
+
"noPadding",
|
|
2617
|
+
"maxBodyHeight",
|
|
2618
|
+
"selectable",
|
|
2619
|
+
"selected",
|
|
2620
|
+
"selectedColor",
|
|
2621
|
+
"selectedBackground"
|
|
2622
|
+
],
|
|
2623
|
+
outputs: [
|
|
2624
|
+
"expandedChange",
|
|
2625
|
+
"editClick",
|
|
2626
|
+
"selectedChange"
|
|
2627
|
+
]
|
|
2628
|
+
},
|
|
2629
|
+
{
|
|
2630
|
+
kind: "component",
|
|
2631
|
+
type: ModalComponent,
|
|
2632
|
+
selector: "ui-modal",
|
|
2633
|
+
inputs: [
|
|
2634
|
+
"open",
|
|
2635
|
+
"title",
|
|
2636
|
+
"description",
|
|
2637
|
+
"describedBy",
|
|
2638
|
+
"maxWidth",
|
|
2639
|
+
"bodyOverflow",
|
|
2640
|
+
"dialogTestId",
|
|
2641
|
+
"hideClose",
|
|
2642
|
+
"closable",
|
|
2643
|
+
"layout",
|
|
2644
|
+
"closeOnBackdrop",
|
|
2645
|
+
"closeOnEscape",
|
|
2646
|
+
"busy",
|
|
2647
|
+
"returnFocusTo"
|
|
2648
|
+
],
|
|
2649
|
+
outputs: ["close"]
|
|
2650
|
+
},
|
|
2651
|
+
{
|
|
2652
|
+
kind: "component",
|
|
2653
|
+
type: LiveRegionComponent,
|
|
2654
|
+
selector: "ui-live-region",
|
|
2655
|
+
inputs: [
|
|
2656
|
+
"message",
|
|
2657
|
+
"politeness",
|
|
2658
|
+
"atomic",
|
|
2659
|
+
"visible"
|
|
2660
|
+
]
|
|
2661
|
+
},
|
|
2662
|
+
{
|
|
2663
|
+
kind: "component",
|
|
2664
|
+
type: StackComponent,
|
|
2665
|
+
selector: "ui-stack",
|
|
2666
|
+
inputs: [
|
|
2667
|
+
"gap",
|
|
2668
|
+
"direction",
|
|
2669
|
+
"align",
|
|
2670
|
+
"justify",
|
|
2671
|
+
"wrap",
|
|
2672
|
+
"minHeight",
|
|
2673
|
+
"width",
|
|
2674
|
+
"maxWidth",
|
|
2675
|
+
"padding",
|
|
2676
|
+
"centered"
|
|
2677
|
+
]
|
|
2678
|
+
},
|
|
2679
|
+
{
|
|
2680
|
+
kind: "component",
|
|
2681
|
+
type: TextComponent,
|
|
2682
|
+
selector: "ui-text",
|
|
2683
|
+
inputs: [
|
|
2684
|
+
"text",
|
|
2685
|
+
"size",
|
|
2686
|
+
"tone",
|
|
2687
|
+
"color",
|
|
2688
|
+
"strong",
|
|
2689
|
+
"weight"
|
|
2690
|
+
]
|
|
2691
|
+
}
|
|
2692
|
+
],
|
|
2693
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
2694
|
+
encapsulation: i0.ViewEncapsulation.None
|
|
2695
|
+
});
|
|
2696
|
+
}
|
|
2697
|
+
};
|
|
2698
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
2699
|
+
minVersion: "12.0.0",
|
|
2700
|
+
version: "22.2.2",
|
|
2701
|
+
ngImport: i0,
|
|
2702
|
+
type: SquareConnectComponent,
|
|
2703
|
+
decorators: [{
|
|
2704
|
+
type: Component,
|
|
2705
|
+
args: [{
|
|
2706
|
+
selector: "ui-square-connect",
|
|
2707
|
+
standalone: true,
|
|
2708
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2709
|
+
imports: [
|
|
2710
|
+
NgTemplateOutlet,
|
|
2711
|
+
BadgeComponent,
|
|
2712
|
+
ButtonComponent,
|
|
2713
|
+
DetailCardComponent,
|
|
2714
|
+
ModalComponent,
|
|
2715
|
+
LiveRegionComponent,
|
|
2716
|
+
StackComponent,
|
|
2717
|
+
TextComponent
|
|
2718
|
+
],
|
|
2719
|
+
template: `
|
|
2720
|
+
<!-- Persistent live region: present before the state changes, so every new state is announced (and "Loading" while a request runs). -->
|
|
2721
|
+
<ui-live-region data-testid="square-connect-live" [message]="liveText()" />
|
|
2722
|
+
@if (bare()) {
|
|
2723
|
+
<ng-container *ngTemplateOutlet="body" />
|
|
2724
|
+
} @else {
|
|
2725
|
+
<ui-detail-card [collapsible]="false" [title]="title()" [headingLevel]="3" data-testid="square-connect-card">
|
|
2726
|
+
<ng-container *ngTemplateOutlet="body" />
|
|
2727
|
+
</ui-detail-card>
|
|
2728
|
+
}
|
|
2729
|
+
|
|
2730
|
+
<ng-template #body>
|
|
2731
|
+
@if (state() === 'none') {
|
|
2732
|
+
<ui-stack gap="sm" class="sqc-state" tabindex="-1" data-testid="square-connect-status-none" [attr.aria-busy]="loading() ? 'true' : null">
|
|
2733
|
+
<ui-text size="lg" weight="semibold" [text]="startTitle()" />
|
|
2734
|
+
<ui-text size="sm" [text]="startText()" />
|
|
2735
|
+
<ui-stack direction="horizontal">
|
|
2736
|
+
<ui-button variant="primary" size="sm" data-testid="square-connect-start-button" [disabled]="disabled()" (click)="start()">@if (loading()) {<span aria-hidden="true">{{ labels.t('common.loadingellipsis') }}</span><span class="sqc-sr">{{ labels.t('squareConnect.opensInNewTabBusy', { label: startLabel() }) }}</span>} @else { {{ startLabel() }}<span class="sqc-sr">{{ labels.t('squareConnect.opensInNewTabSr') }}</span>}</ui-button>
|
|
2737
|
+
@if (awaiting()) {
|
|
2738
|
+
<ui-button variant="secondary" size="sm" data-testid="square-connect-check-status-button" [disabled]="disabled() || loading()" (click)="check()">{{ labels.t(loading() ? 'squareConnect.checking' : 'squareConnect.checkStatus') }}</ui-button>
|
|
2739
|
+
}
|
|
2740
|
+
</ui-stack>
|
|
2741
|
+
</ui-stack>
|
|
2742
|
+
} @else if (state() === 'reconnect') {
|
|
2743
|
+
<ui-stack gap="sm" class="sqc-state" tabindex="-1" data-testid="square-connect-status-reconnect" [attr.aria-busy]="loading() ? 'true' : null">
|
|
2744
|
+
<span class="sqc-badge"><ui-badge [label]="labels.t('squareConnect.needsReconnect')" variant="red" data-testid="square-connect-reconnect-badge" /></span>
|
|
2745
|
+
<ui-text size="sm" [text]="labels.t('squareConnect.reconnectText')" />
|
|
2746
|
+
<ui-stack direction="horizontal">
|
|
2747
|
+
<ui-button variant="primary" size="sm" data-testid="square-connect-reconnect-button" [disabled]="disabled()" (click)="start()">@if (loading()) {<span aria-hidden="true">{{ labels.t('common.loadingellipsis') }}</span><span class="sqc-sr">{{ labels.t('squareConnect.opensInNewTabBusy', { label: labels.t('squareConnect.reconnect') }) }}</span>} @else { {{ labels.t('squareConnect.reconnect') }}<span class="sqc-sr">{{ labels.t('squareConnect.opensInNewTabSr') }}</span>}</ui-button>
|
|
2748
|
+
<ui-button variant="secondary" size="sm" data-testid="square-connect-disconnect-button" [disabled]="disabled() || loading()" (click)="askDisconnect()">{{ labels.t('squareConnect.disconnect') }}</ui-button>
|
|
2749
|
+
</ui-stack>
|
|
2750
|
+
</ui-stack>
|
|
2751
|
+
} @else {
|
|
2752
|
+
<ui-stack gap="sm" class="sqc-state" tabindex="-1" data-testid="square-connect-status-connected" [attr.aria-busy]="loading() ? 'true' : null">
|
|
2753
|
+
<ui-text size="lg" weight="semibold" [text]="labels.t('squareConnect.connected')" />
|
|
2754
|
+
@if (merchant(); as merchant) { <ui-text size="sm" tone="muted" data-testid="square-connect-merchant" [text]="labels.t('squareConnect.merchantLine', { merchant })" /> }
|
|
2755
|
+
@if (location(); as location) { <ui-text size="sm" tone="muted" data-testid="square-connect-location" [text]="labels.t('squareConnect.locationLine', { location })" /> }
|
|
2756
|
+
@if (connectedOn(); as date) { <ui-text size="sm" tone="muted" data-testid="square-connect-date" [text]="labels.t('squareConnect.connectedOn', { date })" /> }
|
|
2757
|
+
<ui-stack direction="horizontal">
|
|
2758
|
+
<ui-button variant="secondary" size="sm" data-testid="square-connect-check-status-button" [disabled]="disabled() || loading()" (click)="check()">{{ labels.t(loading() ? 'squareConnect.checking' : 'squareConnect.checkStatus') }}</ui-button>
|
|
2759
|
+
<ui-button variant="secondary" size="sm" data-testid="square-connect-disconnect-button" [disabled]="disabled() || loading()" (click)="askDisconnect()">{{ labels.t('squareConnect.disconnect') }}</ui-button>
|
|
2760
|
+
</ui-stack>
|
|
2761
|
+
</ui-stack>
|
|
2762
|
+
}
|
|
2763
|
+
</ng-template>
|
|
2764
|
+
|
|
2765
|
+
<ui-modal [open]="confirming()" [title]="labels.t('squareConnect.disconnectTitle')" maxWidth="440px" [describedBy]="confirmMessageId" [busy]="loading()" dialogTestId="square-connect-confirm" (close)="cancelDisconnect()">
|
|
2766
|
+
<p [id]="confirmMessageId" class="sqc-confirm" data-testid="square-connect-confirm-message">{{ labels.t('squareConnect.disconnectMessage') }}</p>
|
|
2767
|
+
<ui-button modal-footer-left variant="secondary" size="sm" data-testid="square-connect-confirm-cancel" [disabled]="loading()" (click)="cancelDisconnect()">{{ labels.t('common.cancel') }}</ui-button>
|
|
2768
|
+
<ui-button modal-footer-right variant="danger" size="sm" data-testid="square-connect-confirm-accept" [loading]="loading()" (click)="doDisconnect()">{{ labels.t('squareConnect.disconnect') }}</ui-button>
|
|
2769
|
+
</ui-modal>
|
|
2770
|
+
`,
|
|
2771
|
+
encapsulation: ViewEncapsulation.None,
|
|
2772
|
+
styles: ["ui-square-connect{display:block;min-width:0}ui-square-connect .sqc-badge{display:flex}ui-square-connect .sqc-confirm{margin:0;font-size:.9375rem;line-height:1.5}ui-square-connect .sqc-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}\n"]
|
|
2773
|
+
}]
|
|
2774
|
+
}],
|
|
2775
|
+
ctorParameters: () => [],
|
|
2776
|
+
propDecorators: {
|
|
2777
|
+
startConnect: [{
|
|
2778
|
+
type: i0.Input,
|
|
2779
|
+
args: [{
|
|
2780
|
+
isSignal: true,
|
|
2781
|
+
alias: "startConnect",
|
|
2782
|
+
required: false
|
|
2783
|
+
}]
|
|
2784
|
+
}],
|
|
2785
|
+
getStatus: [{
|
|
2786
|
+
type: i0.Input,
|
|
2787
|
+
args: [{
|
|
2788
|
+
isSignal: true,
|
|
2789
|
+
alias: "getStatus",
|
|
2790
|
+
required: false
|
|
2791
|
+
}]
|
|
2792
|
+
}],
|
|
2793
|
+
disconnect: [{
|
|
2794
|
+
type: i0.Input,
|
|
2795
|
+
args: [{
|
|
2796
|
+
isSignal: true,
|
|
2797
|
+
alias: "disconnect",
|
|
2798
|
+
required: false
|
|
2799
|
+
}]
|
|
2800
|
+
}],
|
|
2801
|
+
status: [{
|
|
2802
|
+
type: i0.Input,
|
|
2803
|
+
args: [{
|
|
2804
|
+
isSignal: true,
|
|
2805
|
+
alias: "status",
|
|
2806
|
+
required: false
|
|
2807
|
+
}]
|
|
2808
|
+
}, {
|
|
2809
|
+
type: i0.Output,
|
|
2810
|
+
args: ["statusChange"]
|
|
2811
|
+
}],
|
|
2812
|
+
titleInput: [{
|
|
2813
|
+
type: i0.Input,
|
|
2814
|
+
args: [{
|
|
2815
|
+
isSignal: true,
|
|
2816
|
+
alias: "title",
|
|
2817
|
+
required: false
|
|
2818
|
+
}]
|
|
2819
|
+
}],
|
|
2820
|
+
bare: [{
|
|
2821
|
+
type: i0.Input,
|
|
2822
|
+
args: [{
|
|
2823
|
+
isSignal: true,
|
|
2824
|
+
alias: "bare",
|
|
2825
|
+
required: false
|
|
2826
|
+
}]
|
|
2827
|
+
}],
|
|
2828
|
+
startTitleInput: [{
|
|
2829
|
+
type: i0.Input,
|
|
2830
|
+
args: [{
|
|
2831
|
+
isSignal: true,
|
|
2832
|
+
alias: "startTitle",
|
|
2833
|
+
required: false
|
|
2834
|
+
}]
|
|
2835
|
+
}],
|
|
2836
|
+
startTextInput: [{
|
|
2837
|
+
type: i0.Input,
|
|
2838
|
+
args: [{
|
|
2839
|
+
isSignal: true,
|
|
2840
|
+
alias: "startText",
|
|
2841
|
+
required: false
|
|
2842
|
+
}]
|
|
2843
|
+
}],
|
|
2844
|
+
startLabelInput: [{
|
|
2845
|
+
type: i0.Input,
|
|
2846
|
+
args: [{
|
|
2847
|
+
isSignal: true,
|
|
2848
|
+
alias: "startLabel",
|
|
2849
|
+
required: false
|
|
2850
|
+
}]
|
|
2851
|
+
}],
|
|
2852
|
+
disabled: [{
|
|
2853
|
+
type: i0.Input,
|
|
2854
|
+
args: [{
|
|
2855
|
+
isSignal: true,
|
|
2856
|
+
alias: "disabled",
|
|
2857
|
+
required: false
|
|
2858
|
+
}]
|
|
2859
|
+
}],
|
|
2860
|
+
confirmDisconnect: [{
|
|
2861
|
+
type: i0.Input,
|
|
2862
|
+
args: [{
|
|
2863
|
+
isSignal: true,
|
|
2864
|
+
alias: "confirmDisconnect",
|
|
2865
|
+
required: false
|
|
2866
|
+
}]
|
|
2867
|
+
}],
|
|
2868
|
+
refreshOnReturn: [{
|
|
2869
|
+
type: i0.Input,
|
|
2870
|
+
args: [{
|
|
2871
|
+
isSignal: true,
|
|
2872
|
+
alias: "refreshOnReturn",
|
|
2873
|
+
required: false
|
|
2874
|
+
}]
|
|
2875
|
+
}],
|
|
2876
|
+
navigateTab: [{
|
|
2877
|
+
type: i0.Input,
|
|
2878
|
+
args: [{
|
|
2879
|
+
isSignal: true,
|
|
2880
|
+
alias: "navigateTab",
|
|
2881
|
+
required: false
|
|
2882
|
+
}]
|
|
2883
|
+
}],
|
|
2884
|
+
outcome: [{
|
|
2885
|
+
type: i0.Output,
|
|
2886
|
+
args: ["outcome"]
|
|
2887
|
+
}],
|
|
2888
|
+
loading: [{
|
|
2889
|
+
type: i0.Input,
|
|
2890
|
+
args: [{
|
|
2891
|
+
isSignal: true,
|
|
2892
|
+
alias: "loading",
|
|
2893
|
+
required: false
|
|
2894
|
+
}]
|
|
2895
|
+
}, {
|
|
2896
|
+
type: i0.Output,
|
|
2897
|
+
args: ["loadingChange"]
|
|
2898
|
+
}]
|
|
2899
|
+
}
|
|
2900
|
+
});
|
|
2901
|
+
const PAID = /* @__PURE__ */ new Set(["COMPLETED", "PAID"]);
|
|
2902
|
+
const FAILED = /* @__PURE__ */ new Set([
|
|
2903
|
+
"FAILED",
|
|
2904
|
+
"CANCELED",
|
|
2905
|
+
"CANCELLED"
|
|
2906
|
+
]);
|
|
2907
|
+
function squareOutcomeOf(status, method = "card") {
|
|
2908
|
+
const value = (status ?? "").trim().toUpperCase();
|
|
2909
|
+
if (!value) return method === "ach" ? "processing" : "paid";
|
|
2910
|
+
if (PAID.has(value)) return "paid";
|
|
2911
|
+
if (FAILED.has(value)) return "failed";
|
|
2912
|
+
return "processing";
|
|
2913
|
+
}
|
|
2914
|
+
const SQUARE_PAYMENT_METHOD_VALUES = ["CARD", "ACH"];
|
|
2915
|
+
const squareMethodLabel = (value) => value === "CARD" ? uiText("squarePaymentMethod.methodCard") : value === "ACH" ? uiText("squarePaymentMethod.methodAch") : value;
|
|
2916
|
+
const squareMethodOf = (method) => method === "ACH" ? "ach" : "card";
|
|
2917
|
+
const SQUARE_METHOD_TEXTS = {
|
|
2918
|
+
get amountNeeded() {
|
|
2919
|
+
return uiText("squarePaymentMethod.amountNeeded");
|
|
2920
|
+
},
|
|
2921
|
+
get notCompleted() {
|
|
2922
|
+
return uiText("squarePaymentMethod.notCompleted");
|
|
2923
|
+
},
|
|
2924
|
+
get achTitle() {
|
|
2925
|
+
return uiText("squarePaymentMethod.achTitle");
|
|
2926
|
+
},
|
|
2927
|
+
achMessage: (amount) => uiText("squarePaymentMethod.achMessage", { amount }),
|
|
2928
|
+
get pendingTitle() {
|
|
2929
|
+
return uiText("squarePaymentMethod.pendingTitle");
|
|
2930
|
+
},
|
|
2931
|
+
pendingMessage: (amount) => uiText("squarePaymentMethod.pendingMessage", { amount }),
|
|
2932
|
+
get receiptNote() {
|
|
2933
|
+
return uiText("squarePaymentMethod.receiptNote");
|
|
2934
|
+
}
|
|
2935
|
+
};
|
|
2936
|
+
var PaymentSquareBodyComponent = class PaymentSquareBodyComponent {
|
|
2937
|
+
constructor() {
|
|
2938
|
+
this.labels = inject(UiLabelsService);
|
|
2939
|
+
this.injector = inject(Injector);
|
|
2940
|
+
this.host = inject(ElementRef);
|
|
2941
|
+
this.ctx = input.required(...ngDevMode ? [{ debugName: "ctx" }] : /* istanbul ignore next */ []);
|
|
2942
|
+
this.config = input.required(...ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []);
|
|
2943
|
+
this.payment = viewChild(SquarePaymentComponent, ...ngDevMode ? [{ debugName: "payment" }] : /* istanbul ignore next */ []);
|
|
2944
|
+
this.texts = SQUARE_METHOD_TEXTS;
|
|
2945
|
+
this.ready = signal(false, ...ngDevMode ? [{ debugName: "ready" }] : /* istanbul ignore next */ []);
|
|
2946
|
+
this.processing = signal(false, ...ngDevMode ? [{ debugName: "processing" }] : /* istanbul ignore next */ []);
|
|
2947
|
+
this.done = signal(false, ...ngDevMode ? [{ debugName: "done" }] : /* istanbul ignore next */ []);
|
|
2948
|
+
this.error = signal("", ...ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []);
|
|
2949
|
+
this.estimate = signal(null, ...ngDevMode ? [{ debugName: "estimate" }] : /* istanbul ignore next */ []);
|
|
2950
|
+
this.estimating = signal(false, ...ngDevMode ? [{ debugName: "estimating" }] : /* istanbul ignore next */ []);
|
|
2951
|
+
this.estimateError = signal("", ...ngDevMode ? [{ debugName: "estimateError" }] : /* istanbul ignore next */ []);
|
|
2952
|
+
this.estimateTick = signal(0, ...ngDevMode ? [{ debugName: "estimateTick" }] : /* istanbul ignore next */ []);
|
|
2953
|
+
this.resultFees = signal(null, ...ngDevMode ? [{ debugName: "resultFees" }] : /* istanbul ignore next */ []);
|
|
2954
|
+
this.confirmation = signal(null, ...ngDevMode ? [{ debugName: "confirmation" }] : /* istanbul ignore next */ []);
|
|
2955
|
+
this.lastAmount = signal(null, ...ngDevMode ? [{ debugName: "lastAmount" }] : /* istanbul ignore next */ []);
|
|
2956
|
+
this.payAmount = null;
|
|
2957
|
+
this.payMethod = null;
|
|
2958
|
+
this.doneAmount = null;
|
|
2959
|
+
this.doneMethod = null;
|
|
2960
|
+
this.estimateRun = 0;
|
|
2961
|
+
this.amountValue = computed(() => this.ctx().amount, ...ngDevMode ? [{ debugName: "amountValue" }] : /* istanbul ignore next */ []);
|
|
2962
|
+
this.methodValue = computed(() => this.ctx().method, ...ngDevMode ? [{ debugName: "methodValue" }] : /* istanbul ignore next */ []);
|
|
2963
|
+
this.squareMethod = computed(() => squareMethodOf(this.ctx().method), ...ngDevMode ? [{ debugName: "squareMethod" }] : /* istanbul ignore next */ []);
|
|
2964
|
+
this.total = computed(() => this.resultFees()?.totalAmount ?? this.estimate()?.totalAmount ?? this.lastAmount() ?? 0, ...ngDevMode ? [{ debugName: "total" }] : /* istanbul ignore next */ []);
|
|
2965
|
+
this.chargedAmount = computed(() => this.estimate()?.totalAmount ?? this.resultFees()?.totalAmount ?? this.lastAmount(), ...ngDevMode ? [{ debugName: "chargedAmount" }] : /* istanbul ignore next */ []);
|
|
2966
|
+
this.receiptNote = computed(() => this.config().receiptNote(), ...ngDevMode ? [{ debugName: "receiptNote" }] : /* istanbul ignore next */ []);
|
|
2967
|
+
this.feeRows = computed(() => {
|
|
2968
|
+
const fees = this.resultFees() ?? this.estimate();
|
|
2969
|
+
const amount = this.lastAmount();
|
|
2970
|
+
if (!fees || amount == null || fees.processingFee === void 0 && fees.platformFee === void 0) return [];
|
|
2971
|
+
const money = (n) => formatCurrency(n, { currency: this.ctx().currency });
|
|
2972
|
+
const rows = [{
|
|
2973
|
+
key: "amount",
|
|
2974
|
+
label: this.labels.t("squarePaymentMethod.paymentAmount"),
|
|
2975
|
+
value: money(amount)
|
|
2976
|
+
}];
|
|
2977
|
+
if (fees.processingFee !== void 0) rows.push({
|
|
2978
|
+
key: "processing",
|
|
2979
|
+
label: `${this.labels.t("squarePaymentMethod.processingFee")}${fees.processingFeeLabel ? ` (${fees.processingFeeLabel})` : ""}`,
|
|
2980
|
+
value: money(fees.processingFee)
|
|
2981
|
+
});
|
|
2982
|
+
if (fees.platformFee !== void 0) rows.push({
|
|
2983
|
+
key: "platform",
|
|
2984
|
+
label: `${this.labels.t("squarePaymentMethod.platformFee")}${fees.platformFeeLabel ? ` (${fees.platformFeeLabel})` : ""}`,
|
|
2985
|
+
value: money(fees.platformFee)
|
|
2986
|
+
});
|
|
2987
|
+
return rows;
|
|
2988
|
+
}, ...ngDevMode ? [{ debugName: "feeRows" }] : /* istanbul ignore next */ []);
|
|
2989
|
+
this.totalCard = computed(() => {
|
|
2990
|
+
const fees = this.resultFees() ?? this.estimate();
|
|
2991
|
+
if (!fees || this.lastAmount() == null || fees.totalAmount === void 0) return null;
|
|
2992
|
+
return {
|
|
2993
|
+
value: formatCurrency(fees.totalAmount, { currency: this.ctx().currency }),
|
|
2994
|
+
subtitle: this.labels.t("squarePaymentMethod.amountPlusFees")
|
|
2995
|
+
};
|
|
2996
|
+
}, ...ngDevMode ? [{ debugName: "totalCard" }] : /* istanbul ignore next */ []);
|
|
2997
|
+
this.gone = false;
|
|
2998
|
+
const configured = (read) => computed(() => read(this.config()));
|
|
2999
|
+
const inputs = {
|
|
3000
|
+
payableRef: configured((c) => c.payableRef()),
|
|
3001
|
+
attemptKey: configured((c) => c.attemptKey()),
|
|
3002
|
+
checkStatus: configured((c) => c.checkStatus()),
|
|
3003
|
+
paid: configured((c) => c.paid()),
|
|
3004
|
+
hostPending: configured((c) => c.hostPending()),
|
|
3005
|
+
statusPollMs: configured((c) => c.statusPollMs()),
|
|
3006
|
+
statusPollMaxMs: configured((c) => c.statusPollMaxMs()),
|
|
3007
|
+
statusCheckTimeoutMs: configured((c) => c.statusCheckTimeoutMs()),
|
|
3008
|
+
statusFailGraceMs: configured((c) => c.statusFailGraceMs()),
|
|
3009
|
+
authTimeoutMs: configured((c) => c.authTimeoutMs()),
|
|
3010
|
+
readinessCheck: configured((c) => c.readinessCheck()),
|
|
3011
|
+
readinessTimeoutMs: configured((c) => c.readinessTimeoutMs()),
|
|
3012
|
+
readinessEveryMs: configured((c) => c.readinessEveryMs()),
|
|
3013
|
+
offlineOverride: configured((c) => c.offlineOverride())
|
|
3014
|
+
};
|
|
3015
|
+
const protection = createPaymentProtection(inputs, {
|
|
3016
|
+
amount: () => this.ctx().amount,
|
|
3017
|
+
method: () => this.ctx().method,
|
|
3018
|
+
sdk: () => this.payment()?.loadErrorText() ? "blocked" : "ok",
|
|
3019
|
+
onOutcome: (o) => this.onAttemptOutcome(o)
|
|
3020
|
+
});
|
|
3021
|
+
this.attempt = protection.attempt;
|
|
3022
|
+
this.readiness = protection.readiness;
|
|
3023
|
+
inject(DestroyRef).onDestroy(() => {
|
|
3024
|
+
this.gone = true;
|
|
3025
|
+
});
|
|
3026
|
+
const controls = {
|
|
3027
|
+
markUnknown: () => this.attempt.markUnknown("host"),
|
|
3028
|
+
markSucceeded: () => this.attempt.succeed("host"),
|
|
3029
|
+
markFailed: () => this.attempt.fail("host"),
|
|
3030
|
+
resetPaid: () => {
|
|
3031
|
+
this.attempt.resetPaid();
|
|
3032
|
+
this.done.set(false);
|
|
3033
|
+
this.confirmation.set(null);
|
|
3034
|
+
this.error.set("");
|
|
3035
|
+
this.ctx().setExclusive(false);
|
|
3036
|
+
},
|
|
3037
|
+
markNotCharged: () => {
|
|
3038
|
+
this.attempt.markNotCharged();
|
|
3039
|
+
this.payment()?.markNotCharged();
|
|
3040
|
+
this.processing.set(false);
|
|
3041
|
+
this.ctx().setBusy(false);
|
|
3042
|
+
}
|
|
3043
|
+
};
|
|
3044
|
+
effect(() => {
|
|
3045
|
+
const config = this.config();
|
|
3046
|
+
untracked(() => config.attachControls(controls));
|
|
3047
|
+
});
|
|
3048
|
+
inject(DestroyRef).onDestroy(() => this.config().detachControls(controls));
|
|
3049
|
+
effect(() => {
|
|
3050
|
+
const amount = this.amountValue();
|
|
3051
|
+
if (amount != null) untracked(() => this.lastAmount.set(amount));
|
|
3052
|
+
});
|
|
3053
|
+
effect(() => {
|
|
3054
|
+
const ctx = this.ctx();
|
|
3055
|
+
const processing = this.processing();
|
|
3056
|
+
const notice = this.confirmation();
|
|
3057
|
+
const ready = this.ready();
|
|
3058
|
+
const estimating = this.estimating();
|
|
3059
|
+
const done = this.done();
|
|
3060
|
+
const estimateFailed = !!this.estimateError();
|
|
3061
|
+
const unknown = this.attempt.unknown();
|
|
3062
|
+
const paidLocked = this.attempt.paidLocked();
|
|
3063
|
+
const gateReady = this.readiness.ready();
|
|
3064
|
+
const label = notice ? this.labels.t("common.done") : ctx.amount != null ? `${this.labels.t("squarePaymentMethod.pay")} ${formatCurrency(this.total(), { currency: ctx.currency })}` : this.labels.t("squarePaymentMethod.pay");
|
|
3065
|
+
untracked(() => ctx.setPrimary({
|
|
3066
|
+
label,
|
|
3067
|
+
loading: processing && !notice,
|
|
3068
|
+
disabled: notice ? done : !ready || processing || estimating || estimateFailed || ctx.amount == null || done || unknown || paidLocked || !gateReady,
|
|
3069
|
+
onClick: () => notice ? this.finish() : void this.pay()
|
|
3070
|
+
}));
|
|
3071
|
+
});
|
|
3072
|
+
effect((onCleanup) => {
|
|
3073
|
+
const estimate = this.config().estimateFees();
|
|
3074
|
+
const amount = this.amountValue();
|
|
3075
|
+
const method = this.methodValue();
|
|
3076
|
+
this.estimateTick();
|
|
3077
|
+
const run = ++this.estimateRun;
|
|
3078
|
+
untracked(() => {
|
|
3079
|
+
this.estimate.set(null);
|
|
3080
|
+
this.resultFees.set(null);
|
|
3081
|
+
this.estimateError.set("");
|
|
3082
|
+
});
|
|
3083
|
+
if (!estimate || amount == null) {
|
|
3084
|
+
untracked(() => this.estimating.set(false));
|
|
3085
|
+
return;
|
|
3086
|
+
}
|
|
3087
|
+
untracked(() => this.estimating.set(true));
|
|
3088
|
+
let hung = null;
|
|
3089
|
+
const failure = this.labels.t("squarePaymentMethod.feesFailed");
|
|
3090
|
+
const timer = setTimeout(async () => {
|
|
3091
|
+
hung = setTimeout(() => {
|
|
3092
|
+
if (run !== this.estimateRun) return;
|
|
3093
|
+
this.estimating.set(false);
|
|
3094
|
+
if (this.feesMustBeKnown()) this.estimateError.set(failure);
|
|
3095
|
+
}, Math.max(1, this.config().estimateTimeoutMs()));
|
|
3096
|
+
let fees = null;
|
|
3097
|
+
try {
|
|
3098
|
+
fees = await callHost(() => estimate({
|
|
3099
|
+
amount,
|
|
3100
|
+
paymentMethod: method,
|
|
3101
|
+
method: squareMethodOf(method),
|
|
3102
|
+
funding: null
|
|
3103
|
+
})) ?? null;
|
|
3104
|
+
} catch {
|
|
3105
|
+
fees = null;
|
|
3106
|
+
}
|
|
3107
|
+
if (hung) {
|
|
3108
|
+
clearTimeout(hung);
|
|
3109
|
+
hung = null;
|
|
3110
|
+
}
|
|
3111
|
+
if (run !== this.estimateRun) return;
|
|
3112
|
+
this.estimating.set(false);
|
|
3113
|
+
if (fees) {
|
|
3114
|
+
this.estimate.set(fees);
|
|
3115
|
+
this.estimateError.set("");
|
|
3116
|
+
} else {
|
|
3117
|
+
this.estimate.set(null);
|
|
3118
|
+
this.estimateError.set(this.feesMustBeKnown() ? failure : "");
|
|
3119
|
+
}
|
|
3120
|
+
}, 300);
|
|
3121
|
+
onCleanup(() => {
|
|
3122
|
+
clearTimeout(timer);
|
|
3123
|
+
if (hung) clearTimeout(hung);
|
|
3124
|
+
});
|
|
3125
|
+
});
|
|
3126
|
+
effect(() => {
|
|
3127
|
+
this.methodValue();
|
|
3128
|
+
const config = this.config();
|
|
3129
|
+
config.applicationId();
|
|
3130
|
+
config.locationId();
|
|
3131
|
+
config.environment();
|
|
3132
|
+
untracked(() => {
|
|
3133
|
+
this.ready.set(false);
|
|
3134
|
+
this.error.set("");
|
|
3135
|
+
});
|
|
3136
|
+
});
|
|
3137
|
+
effect(() => {
|
|
3138
|
+
const ctx = this.ctx();
|
|
3139
|
+
untracked(() => ctx.onCancel(() => {
|
|
3140
|
+
if (this.confirmation()) this.finish();
|
|
3141
|
+
}));
|
|
3142
|
+
});
|
|
3143
|
+
inject(DestroyRef).onDestroy(() => {
|
|
3144
|
+
this.estimateRun++;
|
|
3145
|
+
});
|
|
3146
|
+
}
|
|
3147
|
+
feesMustBeKnown() {
|
|
3148
|
+
return this.config().feesRequired() || !!this.config().billingContact();
|
|
3149
|
+
}
|
|
3150
|
+
retryEstimate() {
|
|
3151
|
+
this.estimateTick.update((n) => n + 1);
|
|
3152
|
+
}
|
|
3153
|
+
onReady() {
|
|
3154
|
+
this.ready.set(true);
|
|
3155
|
+
this.ctx().announce(this.labels.t("squarePaymentMethod.announceReady"));
|
|
3156
|
+
}
|
|
3157
|
+
onFailed(failure) {
|
|
3158
|
+
const message = failure.stage === "verify" ? `${failure.message} ${this.labels.t("paymentAttempt.verifyRetry", { amount: formatCurrency(this.total(), { currency: this.ctx().currency }) })}` : failure.message;
|
|
3159
|
+
failure = {
|
|
3160
|
+
...failure,
|
|
3161
|
+
message
|
|
3162
|
+
};
|
|
3163
|
+
this.error.set(failure.message);
|
|
3164
|
+
this.processing.set(false);
|
|
3165
|
+
this.ctx().report("failed", { message: failure.message });
|
|
3166
|
+
}
|
|
3167
|
+
async pay() {
|
|
3168
|
+
const ctx = this.ctx();
|
|
3169
|
+
const payment = this.payment();
|
|
3170
|
+
if (this.processing() || this.estimating() || this.done() || !payment) return;
|
|
3171
|
+
if (this.refused(ctx)) return;
|
|
3172
|
+
if (!ctx.validate() || ctx.amount == null) return;
|
|
3173
|
+
this.payAmount = ctx.amount;
|
|
3174
|
+
this.payMethod = ctx.method;
|
|
3175
|
+
const attemptAmount = ctx.amount;
|
|
3176
|
+
const attemptMethod = ctx.method;
|
|
3177
|
+
const create = this.config().createPayment();
|
|
3178
|
+
if (!create) {
|
|
3179
|
+
this.onFailed({
|
|
3180
|
+
code: "not_configured",
|
|
3181
|
+
message: this.labels.t("squarePaymentMethod.unavailable"),
|
|
3182
|
+
squareMessage: "",
|
|
3183
|
+
stage: "tokenize"
|
|
3184
|
+
});
|
|
3185
|
+
return;
|
|
3186
|
+
}
|
|
3187
|
+
this.error.set("");
|
|
3188
|
+
this.processing.set(true);
|
|
3189
|
+
ctx.setBusy(true);
|
|
3190
|
+
ctx.announce(this.labels.t("squarePaymentMethod.announceProcessing"));
|
|
3191
|
+
let finished = false;
|
|
3192
|
+
const run = await this.attempt.run(async (key) => {
|
|
3193
|
+
const live = () => this.attempt.isLive(key);
|
|
3194
|
+
try {
|
|
3195
|
+
if (squareMethodOf(attemptMethod) === "ach") this.attempt.markPending("bank_window");
|
|
3196
|
+
const event = await payment.tokenize();
|
|
3197
|
+
if (!event) return { kind: "released" };
|
|
3198
|
+
if (this.gone) return {
|
|
3199
|
+
kind: "released",
|
|
3200
|
+
reason: "destroyed"
|
|
3201
|
+
};
|
|
3202
|
+
const request = {
|
|
3203
|
+
amount: attemptAmount,
|
|
3204
|
+
paymentMethod: attemptMethod,
|
|
3205
|
+
method: event.method,
|
|
3206
|
+
receivedDate: ctx.receivedDate,
|
|
3207
|
+
notes: ctx.note || null,
|
|
3208
|
+
...ctx.allocation,
|
|
3209
|
+
token: event.token,
|
|
3210
|
+
details: event.details,
|
|
3211
|
+
funding: event.details.cardType,
|
|
3212
|
+
verificationToken: event.verificationToken,
|
|
3213
|
+
idempotencyKey: event.idempotencyKey,
|
|
3214
|
+
attemptKey: key,
|
|
3215
|
+
payableRef: this.attempt.pinnedRef()
|
|
3216
|
+
};
|
|
3217
|
+
let result;
|
|
3218
|
+
try {
|
|
3219
|
+
result = await callHost(() => create(request));
|
|
3220
|
+
} catch (err) {
|
|
3221
|
+
const kind = classifyHostError(err);
|
|
3222
|
+
if (kind === "unknown") return {
|
|
3223
|
+
kind: "unknown",
|
|
3224
|
+
reason: "host_error"
|
|
3225
|
+
};
|
|
3226
|
+
const message = hostErrorMessage(err, this.labels.t("squarePaymentMethod.paymentFailed"));
|
|
3227
|
+
if (kind === "not_sent") {
|
|
3228
|
+
if (live()) {
|
|
3229
|
+
this.error.set(message);
|
|
3230
|
+
ctx.report("refused", { message });
|
|
3231
|
+
}
|
|
3232
|
+
return {
|
|
3233
|
+
kind: "released",
|
|
3234
|
+
reason: "not_sent"
|
|
3235
|
+
};
|
|
3236
|
+
}
|
|
3237
|
+
if (live()) {
|
|
3238
|
+
this.error.set(message);
|
|
3239
|
+
ctx.report("failed", { message });
|
|
3240
|
+
}
|
|
3241
|
+
return {
|
|
3242
|
+
kind: "failure",
|
|
3243
|
+
reason: "host_refused"
|
|
3244
|
+
};
|
|
3245
|
+
}
|
|
3246
|
+
if (wasQueuedOffline(result)) {
|
|
3247
|
+
warnQueuedPayment();
|
|
3248
|
+
const message = this.labels.t("paymentAttempt.queuedOffline");
|
|
3249
|
+
if (live()) {
|
|
3250
|
+
this.error.set(message);
|
|
3251
|
+
ctx.report("refused", { message });
|
|
3252
|
+
}
|
|
3253
|
+
return {
|
|
3254
|
+
kind: "released",
|
|
3255
|
+
reason: "not_sent"
|
|
3256
|
+
};
|
|
3257
|
+
}
|
|
3258
|
+
if (this.gone) return {
|
|
3259
|
+
kind: squareOutcomeOf(result?.status, squareMethodOf(attemptMethod)) === "failed" ? "failure" : "success",
|
|
3260
|
+
value: result ?? null,
|
|
3261
|
+
reason: "created"
|
|
3262
|
+
};
|
|
3263
|
+
finished = this.afterCreate(result ?? null, ctx, live(), attemptAmount, attemptMethod);
|
|
3264
|
+
return {
|
|
3265
|
+
kind: squareOutcomeOf(result?.status, squareMethodOf(attemptMethod)) === "failed" ? "failure" : "success",
|
|
3266
|
+
value: result ?? null,
|
|
3267
|
+
reason: "created"
|
|
3268
|
+
};
|
|
3269
|
+
} finally {
|
|
3270
|
+
if (live()) payment.markNotCharged();
|
|
3271
|
+
}
|
|
3272
|
+
}, { timeoutMs: this.config().paymentTimeoutMs() });
|
|
3273
|
+
this.processing.set(false);
|
|
3274
|
+
if ("refused" in run && run.refused) {
|
|
3275
|
+
ctx.setBusy(false);
|
|
3276
|
+
return;
|
|
3277
|
+
}
|
|
3278
|
+
if (run.kind === "unknown") return;
|
|
3279
|
+
if (!finished) ctx.setBusy(false);
|
|
3280
|
+
}
|
|
3281
|
+
refused(ctx) {
|
|
3282
|
+
if (!this.readiness.passSync()) {
|
|
3283
|
+
const reason = this.readiness.reasons()[0] ?? "checking";
|
|
3284
|
+
const message = this.labels.t(refusalLabelKey(reason));
|
|
3285
|
+
this.error.set(message);
|
|
3286
|
+
ctx.report("refused", { message });
|
|
3287
|
+
ctx.announce(message);
|
|
3288
|
+
return true;
|
|
3289
|
+
}
|
|
3290
|
+
if (this.attempt.paidLocked() || this.attempt.unknown()) {
|
|
3291
|
+
this.attempt.begin();
|
|
3292
|
+
return true;
|
|
3293
|
+
}
|
|
3294
|
+
return false;
|
|
3295
|
+
}
|
|
3296
|
+
onAttemptOutcome(outcome) {
|
|
3297
|
+
const ctx = this.ctx();
|
|
3298
|
+
if (outcome.kind === "unknown" && outcome.reason === "duplicate_suspected") {
|
|
3299
|
+
const message = this.labels.t("paymentAttempt.duplicate");
|
|
3300
|
+
this.error.set(message);
|
|
3301
|
+
ctx.report("duplicate_suspected", {
|
|
3302
|
+
message,
|
|
3303
|
+
attemptKey: outcome.attemptKey
|
|
3304
|
+
});
|
|
3305
|
+
ctx.announce(message);
|
|
3306
|
+
} else if (outcome.kind === "unknown") {
|
|
3307
|
+
this.payAmount = this.attempt.pinnedAmount() ?? this.payAmount;
|
|
3308
|
+
this.payMethod = this.attempt.pinnedMethod() ?? this.payMethod;
|
|
3309
|
+
const message = this.labels.t(outcome.reason === "offline" ? "paymentAttempt.offlineInFlight" : outcome.reason === "timeout" ? "paymentAttempt.timeout" : "paymentAttempt.checking");
|
|
3310
|
+
ctx.report("unknown", { message });
|
|
3311
|
+
ctx.announce(message);
|
|
3312
|
+
} else if (outcome.kind === "refused") ctx.report("refused", { message: this.labels.t(refusalLabelKey(outcome.reason ?? "")) });
|
|
3313
|
+
else if (outcome.kind === "succeeded" && outcome.reason === "other_tab") ctx.report("paid_elsewhere", {
|
|
3314
|
+
message: this.labels.t("paymentAttempt.paid"),
|
|
3315
|
+
attemptKey: outcome.attemptKey,
|
|
3316
|
+
...outcome.method !== void 0 ? { paid: {
|
|
3317
|
+
amount: outcome.amount ?? null,
|
|
3318
|
+
method: outcome.method
|
|
3319
|
+
} } : {}
|
|
3320
|
+
});
|
|
3321
|
+
else if (outcome.kind === "succeeded" && (outcome.reason === "status_check" || outcome.reason === "host") && !this.done()) {
|
|
3322
|
+
const paid = {
|
|
3323
|
+
type: "stripe",
|
|
3324
|
+
paymentMethod: outcome.method ?? this.payMethod ?? ctx.method,
|
|
3325
|
+
amount: outcome.amount ?? this.payAmount ?? ctx.amount ?? this.lastAmount() ?? 0,
|
|
3326
|
+
processor: "square"
|
|
3327
|
+
};
|
|
3328
|
+
this.doneAmount = paid.amount;
|
|
3329
|
+
this.doneMethod = paid.paymentMethod;
|
|
3330
|
+
ctx.report("paid", { result: paid });
|
|
3331
|
+
ctx.announce(this.labels.t("paymentAttempt.succeededAfterCheck"));
|
|
3332
|
+
this.done.set(true);
|
|
3333
|
+
ctx.setBusy(false);
|
|
3334
|
+
ctx.complete(paid);
|
|
3335
|
+
} else if (outcome.kind === "failed") {
|
|
3336
|
+
if (outcome.reason === "status_check" || outcome.reason === "host") {
|
|
3337
|
+
const message = this.labels.t("paymentAttempt.failedAfterCheck");
|
|
3338
|
+
this.error.set(message);
|
|
3339
|
+
ctx.report("failed", { message });
|
|
3340
|
+
}
|
|
3341
|
+
this.payment()?.markNotCharged();
|
|
3342
|
+
ctx.setBusy(false);
|
|
3343
|
+
}
|
|
3344
|
+
}
|
|
3345
|
+
afterCreate(result, ctx, live, amount, method) {
|
|
3346
|
+
if (this.done() || this.confirmation()) return true;
|
|
3347
|
+
const money = formatCurrency(amount, { currency: ctx.currency });
|
|
3348
|
+
const outcome = squareOutcomeOf(result?.status, squareMethodOf(method));
|
|
3349
|
+
if (outcome === "failed") {
|
|
3350
|
+
if (live) {
|
|
3351
|
+
const message = result?.failureMessage || this.texts.notCompleted;
|
|
3352
|
+
this.error.set(message);
|
|
3353
|
+
ctx.report("failed", { message });
|
|
3354
|
+
}
|
|
3355
|
+
return false;
|
|
3356
|
+
}
|
|
3357
|
+
if (live && result && (result.processingFee !== void 0 || result.platformFee !== void 0 || result.totalAmount !== void 0)) this.resultFees.set({
|
|
3358
|
+
processingFee: result.processingFee,
|
|
3359
|
+
platformFee: result.platformFee,
|
|
3360
|
+
totalAmount: result.totalAmount,
|
|
3361
|
+
processingFeeLabel: result.processingFeeLabel,
|
|
3362
|
+
platformFeeLabel: result.platformFeeLabel
|
|
3363
|
+
});
|
|
3364
|
+
const paid = {
|
|
3365
|
+
type: "stripe",
|
|
3366
|
+
paymentMethod: method,
|
|
3367
|
+
amount,
|
|
3368
|
+
processor: "square"
|
|
3369
|
+
};
|
|
3370
|
+
this.doneAmount = amount;
|
|
3371
|
+
this.doneMethod = method;
|
|
3372
|
+
if (outcome === "paid") {
|
|
3373
|
+
ctx.report("paid", { result: paid });
|
|
3374
|
+
this.done.set(true);
|
|
3375
|
+
ctx.complete(paid);
|
|
3376
|
+
return true;
|
|
3377
|
+
}
|
|
3378
|
+
ctx.report("processing", { result: paid });
|
|
3379
|
+
this.confirmation.set(squareMethodOf(method) === "ach" ? {
|
|
3380
|
+
title: this.texts.achTitle,
|
|
3381
|
+
message: this.texts.achMessage(money)
|
|
3382
|
+
} : {
|
|
3383
|
+
title: this.texts.pendingTitle,
|
|
3384
|
+
message: this.texts.pendingMessage(money)
|
|
3385
|
+
});
|
|
3386
|
+
ctx.setExclusive(true);
|
|
3387
|
+
ctx.setBusy(false);
|
|
3388
|
+
afterNextRender(() => this.host.nativeElement.querySelector(".psq-notice")?.focus(), { injector: this.injector });
|
|
3389
|
+
return true;
|
|
3390
|
+
}
|
|
3391
|
+
finish() {
|
|
3392
|
+
const ctx = this.ctx();
|
|
3393
|
+
if (this.done()) return;
|
|
3394
|
+
this.done.set(true);
|
|
3395
|
+
ctx.complete({
|
|
3396
|
+
type: "stripe",
|
|
3397
|
+
paymentMethod: this.doneMethod ?? this.payMethod ?? ctx.method,
|
|
3398
|
+
amount: this.doneAmount ?? this.payAmount ?? ctx.amount ?? this.lastAmount() ?? 0,
|
|
3399
|
+
processor: "square"
|
|
3400
|
+
});
|
|
3401
|
+
}
|
|
3402
|
+
static {
|
|
3403
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
3404
|
+
minVersion: "12.0.0",
|
|
3405
|
+
version: "22.2.2",
|
|
3406
|
+
ngImport: i0,
|
|
3407
|
+
type: PaymentSquareBodyComponent,
|
|
3408
|
+
deps: [],
|
|
3409
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
3410
|
+
});
|
|
3411
|
+
}
|
|
3412
|
+
static {
|
|
3413
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
3414
|
+
minVersion: "17.0.0",
|
|
3415
|
+
version: "22.2.2",
|
|
3416
|
+
type: PaymentSquareBodyComponent,
|
|
3417
|
+
isStandalone: true,
|
|
3418
|
+
selector: "ui-payment-square-body",
|
|
3419
|
+
inputs: {
|
|
3420
|
+
ctx: {
|
|
3421
|
+
classPropertyName: "ctx",
|
|
3422
|
+
publicName: "ctx",
|
|
3423
|
+
isSignal: true,
|
|
3424
|
+
isRequired: true,
|
|
3425
|
+
transformFunction: null
|
|
3426
|
+
},
|
|
3427
|
+
config: {
|
|
3428
|
+
classPropertyName: "config",
|
|
3429
|
+
publicName: "config",
|
|
3430
|
+
isSignal: true,
|
|
3431
|
+
isRequired: true,
|
|
3432
|
+
transformFunction: null
|
|
3433
|
+
}
|
|
3434
|
+
},
|
|
3435
|
+
viewQueries: [{
|
|
3436
|
+
propertyName: "payment",
|
|
3437
|
+
first: true,
|
|
3438
|
+
predicate: SquarePaymentComponent,
|
|
3439
|
+
descendants: true,
|
|
3440
|
+
isSignal: true
|
|
3441
|
+
}],
|
|
3442
|
+
ngImport: i0,
|
|
3443
|
+
template: `
|
|
3444
|
+
<div class="psq">
|
|
3445
|
+
@if (confirmation(); as notice) {
|
|
3446
|
+
<ui-alert variant="success" [title]="notice.title" tabindex="-1" class="psq-notice" data-testid="square-method-confirmation">
|
|
3447
|
+
<p>{{ notice.message }}</p>
|
|
3448
|
+
<p>{{ receiptNote() }}</p>
|
|
3449
|
+
</ui-alert>
|
|
3450
|
+
} @else {
|
|
3451
|
+
<ui-payment-attempt-status [attempt]="attempt" [readiness]="readiness" [allowStartOver]="config().allowStartOver()" [showPaid]="!confirmation() && !done()" (retryLoad)="payment()?.reset()" />
|
|
3452
|
+
@if (ctx().amount == null) {
|
|
3453
|
+
<ui-hint data-testid="square-method-amount-needed">{{ texts.amountNeeded }}</ui-hint>
|
|
3454
|
+
}
|
|
3455
|
+
@if (estimateError()) {
|
|
3456
|
+
<div class="psq-error">
|
|
3457
|
+
<ui-alert variant="warning" data-testid="square-method-estimate-error">{{ estimateError() }}
|
|
3458
|
+
<ui-button variant="secondary" size="sm" data-testid="square-method-estimate-retry" (click)="retryEstimate()">{{ labels.t('common.tryAgain') }}</ui-button>
|
|
3459
|
+
</ui-alert>
|
|
3460
|
+
</div>
|
|
3461
|
+
}
|
|
3462
|
+
@if (lastAmount() != null) {
|
|
3463
|
+
<ui-square-payment #payment mode="payment" [method]="squareMethod()" [applicationId]="config().applicationId()" [locationId]="config().locationId()" [environment]="config().environment()"
|
|
3464
|
+
[amount]="chargedAmount()" [currency]="ctx().currency" [billingContact]="config().billingContact()" [accountHolderName]="config().accountHolderName()"
|
|
3465
|
+
[requireAchConsent]="config().requireAchConsent()" [cardStyle]="config().cardStyle()" [styleFromTokens]="true" [showSubmit]="false" [showErrors]="false"
|
|
3466
|
+
[showStatus]="false" [offlineOverride]="config().offlineOverride()" [disabled]="processing() || done() || attempt.unknown() || attempt.paidLocked()" [label]="labels.t('squarePaymentMethod.paymentDetails')" (ready)="onReady()" (failed)="onFailed($event)" (loadError)="onFailed($event)" />
|
|
3467
|
+
@if (totalCard(); as card) {
|
|
3468
|
+
<ui-kpi-card class="psq-total" data-testid="square-method-total" [label]="labels.t('squarePaymentMethod.totalCharged')" [value]="card.value" [subtitle]="card.subtitle" icon="dollar" color="blue" valueColor="blue" />
|
|
3469
|
+
}
|
|
3470
|
+
@if (feeRows().length) {
|
|
3471
|
+
<dl class="psq-fees" data-testid="square-method-fees" [attr.aria-label]="labels.t('squarePaymentMethod.paymentTotal')">
|
|
3472
|
+
@for (row of feeRows(); track row.key) {
|
|
3473
|
+
<div class="psq-fee" [attr.data-testid]="'square-fee-' + row.key"><dt>{{ row.label }}</dt><dd>{{ row.value }}</dd></div>
|
|
3474
|
+
}
|
|
3475
|
+
</dl>
|
|
3476
|
+
}
|
|
3477
|
+
@if (error()) { <div class="psq-error"><ui-alert variant="danger" data-testid="square-method-error">{{ error() }}</ui-alert></div> }
|
|
3478
|
+
}
|
|
3479
|
+
}
|
|
3480
|
+
</div>
|
|
3481
|
+
`,
|
|
3482
|
+
isInline: true,
|
|
3483
|
+
styles: ["ui-payment-square-body{display:block;min-width:0}ui-payment-square-body .psq-error{margin-top:12px}ui-payment-square-body .psq-total{display:block;margin-top:16px}ui-payment-square-body .psq-fees{margin:16px 0 0;padding:14px 16px;border:1px solid var(--ui-psp-border, #e2e8f0);border-radius:10px;font-size:.8125rem}ui-payment-square-body .psq-fee{display:flex;justify-content:space-between;gap:12px;padding:4px 0;color:var(--ui-psp-muted, #475569)}ui-payment-square-body .psq-fee dt,ui-payment-square-body .psq-fee dd{margin:0}ui-payment-square-body .psq-notice:focus{outline:none}ui-payment-square-body .psq-notice p{margin:0 0 6px}\n"],
|
|
3484
|
+
dependencies: [
|
|
3485
|
+
{
|
|
3486
|
+
kind: "component",
|
|
3487
|
+
type: AlertComponent,
|
|
3488
|
+
selector: "ui-alert",
|
|
3489
|
+
inputs: [
|
|
3490
|
+
"variant",
|
|
3491
|
+
"title",
|
|
3492
|
+
"dismissible",
|
|
3493
|
+
"dismissAriaLabel",
|
|
3494
|
+
"quiet",
|
|
3495
|
+
"compact",
|
|
3496
|
+
"inline",
|
|
3497
|
+
"fill"
|
|
3498
|
+
],
|
|
3499
|
+
outputs: ["dismissed"]
|
|
3500
|
+
},
|
|
3501
|
+
{
|
|
3502
|
+
kind: "component",
|
|
3503
|
+
type: ButtonComponent,
|
|
3504
|
+
selector: "ui-button",
|
|
3505
|
+
inputs: [
|
|
3506
|
+
"variant",
|
|
3507
|
+
"routerLink",
|
|
3508
|
+
"queryParams",
|
|
3509
|
+
"fragment",
|
|
3510
|
+
"state",
|
|
3511
|
+
"href",
|
|
3512
|
+
"target",
|
|
3513
|
+
"rel",
|
|
3514
|
+
"shortLabel",
|
|
3515
|
+
"shortBelow",
|
|
3516
|
+
"color",
|
|
3517
|
+
"active",
|
|
3518
|
+
"size",
|
|
3519
|
+
"type",
|
|
3520
|
+
"disabled",
|
|
3521
|
+
"loading",
|
|
3522
|
+
"fullWidth",
|
|
3523
|
+
"ariaLabel",
|
|
3524
|
+
"ariaExpanded",
|
|
3525
|
+
"ariaPressed",
|
|
3526
|
+
"ariaDescribedBy",
|
|
3527
|
+
"modal-footer-left",
|
|
3528
|
+
"modal-footer-right"
|
|
3529
|
+
]
|
|
3530
|
+
},
|
|
3531
|
+
{
|
|
3532
|
+
kind: "component",
|
|
3533
|
+
type: HintComponent,
|
|
3534
|
+
selector: "ui-hint"
|
|
3535
|
+
},
|
|
3536
|
+
{
|
|
3537
|
+
kind: "component",
|
|
3538
|
+
type: KpiCardComponent,
|
|
3539
|
+
selector: "ui-kpi-card",
|
|
3540
|
+
inputs: [
|
|
3541
|
+
"label",
|
|
3542
|
+
"value",
|
|
3543
|
+
"subtitle",
|
|
3544
|
+
"icon",
|
|
3545
|
+
"color",
|
|
3546
|
+
"highlight",
|
|
3547
|
+
"clickable",
|
|
3548
|
+
"valueColor",
|
|
3549
|
+
"loading",
|
|
3550
|
+
"loadingLabel",
|
|
3551
|
+
"background",
|
|
3552
|
+
"progress",
|
|
3553
|
+
"progressMax",
|
|
3554
|
+
"progressSize",
|
|
3555
|
+
"progressStrokeWidth",
|
|
3556
|
+
"progressVariant",
|
|
3557
|
+
"progressAriaLabel",
|
|
3558
|
+
"progressValueText"
|
|
3559
|
+
]
|
|
3560
|
+
},
|
|
3561
|
+
{
|
|
3562
|
+
kind: "component",
|
|
3563
|
+
type: PaymentAttemptStatusComponent,
|
|
3564
|
+
selector: "ui-payment-attempt-status",
|
|
3565
|
+
inputs: [
|
|
3566
|
+
"attempt",
|
|
3567
|
+
"showPaid",
|
|
3568
|
+
"allowStartOver",
|
|
3569
|
+
"readiness"
|
|
3570
|
+
],
|
|
3571
|
+
outputs: ["retryLoad"]
|
|
3572
|
+
},
|
|
3573
|
+
{
|
|
3574
|
+
kind: "component",
|
|
3575
|
+
type: SquarePaymentComponent,
|
|
3576
|
+
selector: "ui-square-payment",
|
|
3577
|
+
inputs: [
|
|
3578
|
+
"mountOnly",
|
|
3579
|
+
"mode",
|
|
3580
|
+
"method",
|
|
3581
|
+
"methods",
|
|
3582
|
+
"applicationId",
|
|
3583
|
+
"locationId",
|
|
3584
|
+
"environment",
|
|
3585
|
+
"amount",
|
|
3586
|
+
"currency",
|
|
3587
|
+
"billingContact",
|
|
3588
|
+
"verifyBuyer",
|
|
3589
|
+
"accountHolderName",
|
|
3590
|
+
"requireAchConsent",
|
|
3591
|
+
"achConsentText",
|
|
3592
|
+
"achRedirectUri",
|
|
3593
|
+
"achTransactionId",
|
|
3594
|
+
"cardOptions",
|
|
3595
|
+
"cardStyle",
|
|
3596
|
+
"styleFromTokens",
|
|
3597
|
+
"showStatus",
|
|
3598
|
+
"payableRef",
|
|
3599
|
+
"attemptKey",
|
|
3600
|
+
"checkStatus",
|
|
3601
|
+
"paid",
|
|
3602
|
+
"hostPending",
|
|
3603
|
+
"statusPollMs",
|
|
3604
|
+
"statusPollMaxMs",
|
|
3605
|
+
"statusCheckTimeoutMs",
|
|
3606
|
+
"statusFailGraceMs",
|
|
3607
|
+
"allowStartOver",
|
|
3608
|
+
"offlineOverride",
|
|
3609
|
+
"hostSilenceMs",
|
|
3610
|
+
"readinessCheck",
|
|
3611
|
+
"readinessTimeoutMs",
|
|
3612
|
+
"readinessEveryMs",
|
|
3613
|
+
"submitLabel",
|
|
3614
|
+
"showSubmit",
|
|
3615
|
+
"disabled",
|
|
3616
|
+
"pending",
|
|
3617
|
+
"label",
|
|
3618
|
+
"required",
|
|
3619
|
+
"mountId",
|
|
3620
|
+
"mountClass",
|
|
3621
|
+
"mountTestId",
|
|
3622
|
+
"errorTestId",
|
|
3623
|
+
"holderTestId",
|
|
3624
|
+
"showErrors",
|
|
3625
|
+
"errorDisplay",
|
|
3626
|
+
"errorMessages",
|
|
3627
|
+
"errorFallback",
|
|
3628
|
+
"loadErrorMessage",
|
|
3629
|
+
"a11yMessages"
|
|
3630
|
+
],
|
|
3631
|
+
outputs: [
|
|
3632
|
+
"methodChange",
|
|
3633
|
+
"squareReady",
|
|
3634
|
+
"ready",
|
|
3635
|
+
"inFlightChange",
|
|
3636
|
+
"outcome",
|
|
3637
|
+
"attemptKeyChange",
|
|
3638
|
+
"readinessChange",
|
|
3639
|
+
"tokenized",
|
|
3640
|
+
"failed",
|
|
3641
|
+
"loadError"
|
|
3642
|
+
]
|
|
3643
|
+
}
|
|
3644
|
+
],
|
|
3645
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
3646
|
+
encapsulation: i0.ViewEncapsulation.None
|
|
3647
|
+
});
|
|
3648
|
+
}
|
|
3649
|
+
};
|
|
3650
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
3651
|
+
minVersion: "12.0.0",
|
|
3652
|
+
version: "22.2.2",
|
|
3653
|
+
ngImport: i0,
|
|
3654
|
+
type: PaymentSquareBodyComponent,
|
|
3655
|
+
decorators: [{
|
|
3656
|
+
type: Component,
|
|
3657
|
+
args: [{
|
|
3658
|
+
selector: "ui-payment-square-body",
|
|
3659
|
+
standalone: true,
|
|
3660
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
3661
|
+
encapsulation: ViewEncapsulation.None,
|
|
3662
|
+
imports: [
|
|
3663
|
+
AlertComponent,
|
|
3664
|
+
ButtonComponent,
|
|
3665
|
+
HintComponent,
|
|
3666
|
+
KpiCardComponent,
|
|
3667
|
+
PaymentAttemptStatusComponent,
|
|
3668
|
+
SquarePaymentComponent
|
|
3669
|
+
],
|
|
3670
|
+
template: `
|
|
3671
|
+
<div class="psq">
|
|
3672
|
+
@if (confirmation(); as notice) {
|
|
3673
|
+
<ui-alert variant="success" [title]="notice.title" tabindex="-1" class="psq-notice" data-testid="square-method-confirmation">
|
|
3674
|
+
<p>{{ notice.message }}</p>
|
|
3675
|
+
<p>{{ receiptNote() }}</p>
|
|
3676
|
+
</ui-alert>
|
|
3677
|
+
} @else {
|
|
3678
|
+
<ui-payment-attempt-status [attempt]="attempt" [readiness]="readiness" [allowStartOver]="config().allowStartOver()" [showPaid]="!confirmation() && !done()" (retryLoad)="payment()?.reset()" />
|
|
3679
|
+
@if (ctx().amount == null) {
|
|
3680
|
+
<ui-hint data-testid="square-method-amount-needed">{{ texts.amountNeeded }}</ui-hint>
|
|
3681
|
+
}
|
|
3682
|
+
@if (estimateError()) {
|
|
3683
|
+
<div class="psq-error">
|
|
3684
|
+
<ui-alert variant="warning" data-testid="square-method-estimate-error">{{ estimateError() }}
|
|
3685
|
+
<ui-button variant="secondary" size="sm" data-testid="square-method-estimate-retry" (click)="retryEstimate()">{{ labels.t('common.tryAgain') }}</ui-button>
|
|
3686
|
+
</ui-alert>
|
|
3687
|
+
</div>
|
|
3688
|
+
}
|
|
3689
|
+
@if (lastAmount() != null) {
|
|
3690
|
+
<ui-square-payment #payment mode="payment" [method]="squareMethod()" [applicationId]="config().applicationId()" [locationId]="config().locationId()" [environment]="config().environment()"
|
|
3691
|
+
[amount]="chargedAmount()" [currency]="ctx().currency" [billingContact]="config().billingContact()" [accountHolderName]="config().accountHolderName()"
|
|
3692
|
+
[requireAchConsent]="config().requireAchConsent()" [cardStyle]="config().cardStyle()" [styleFromTokens]="true" [showSubmit]="false" [showErrors]="false"
|
|
3693
|
+
[showStatus]="false" [offlineOverride]="config().offlineOverride()" [disabled]="processing() || done() || attempt.unknown() || attempt.paidLocked()" [label]="labels.t('squarePaymentMethod.paymentDetails')" (ready)="onReady()" (failed)="onFailed($event)" (loadError)="onFailed($event)" />
|
|
3694
|
+
@if (totalCard(); as card) {
|
|
3695
|
+
<ui-kpi-card class="psq-total" data-testid="square-method-total" [label]="labels.t('squarePaymentMethod.totalCharged')" [value]="card.value" [subtitle]="card.subtitle" icon="dollar" color="blue" valueColor="blue" />
|
|
3696
|
+
}
|
|
3697
|
+
@if (feeRows().length) {
|
|
3698
|
+
<dl class="psq-fees" data-testid="square-method-fees" [attr.aria-label]="labels.t('squarePaymentMethod.paymentTotal')">
|
|
3699
|
+
@for (row of feeRows(); track row.key) {
|
|
3700
|
+
<div class="psq-fee" [attr.data-testid]="'square-fee-' + row.key"><dt>{{ row.label }}</dt><dd>{{ row.value }}</dd></div>
|
|
3701
|
+
}
|
|
3702
|
+
</dl>
|
|
3703
|
+
}
|
|
3704
|
+
@if (error()) { <div class="psq-error"><ui-alert variant="danger" data-testid="square-method-error">{{ error() }}</ui-alert></div> }
|
|
3705
|
+
}
|
|
3706
|
+
}
|
|
3707
|
+
</div>
|
|
3708
|
+
`,
|
|
3709
|
+
styles: ["ui-payment-square-body{display:block;min-width:0}ui-payment-square-body .psq-error{margin-top:12px}ui-payment-square-body .psq-total{display:block;margin-top:16px}ui-payment-square-body .psq-fees{margin:16px 0 0;padding:14px 16px;border:1px solid var(--ui-psp-border, #e2e8f0);border-radius:10px;font-size:.8125rem}ui-payment-square-body .psq-fee{display:flex;justify-content:space-between;gap:12px;padding:4px 0;color:var(--ui-psp-muted, #475569)}ui-payment-square-body .psq-fee dt,ui-payment-square-body .psq-fee dd{margin:0}ui-payment-square-body .psq-notice:focus{outline:none}ui-payment-square-body .psq-notice p{margin:0 0 6px}\n"]
|
|
3710
|
+
}]
|
|
3711
|
+
}],
|
|
3712
|
+
ctorParameters: () => [],
|
|
3713
|
+
propDecorators: {
|
|
3714
|
+
ctx: [{
|
|
3715
|
+
type: i0.Input,
|
|
3716
|
+
args: [{
|
|
3717
|
+
isSignal: true,
|
|
3718
|
+
alias: "ctx",
|
|
3719
|
+
required: true
|
|
3720
|
+
}]
|
|
3721
|
+
}],
|
|
3722
|
+
config: [{
|
|
3723
|
+
type: i0.Input,
|
|
3724
|
+
args: [{
|
|
3725
|
+
isSignal: true,
|
|
3726
|
+
alias: "config",
|
|
3727
|
+
required: true
|
|
3728
|
+
}]
|
|
3729
|
+
}],
|
|
3730
|
+
payment: [{
|
|
3731
|
+
type: i0.ViewChild,
|
|
3732
|
+
args: [i0.forwardRef(() => SquarePaymentComponent), { isSignal: true }]
|
|
3733
|
+
}]
|
|
3734
|
+
}
|
|
3735
|
+
});
|
|
3736
|
+
var SquarePaymentMethodComponent = class SquarePaymentMethodComponent extends PaymentMethodPlugin {
|
|
3737
|
+
constructor() {
|
|
3738
|
+
super(...arguments);
|
|
3739
|
+
this.self = this;
|
|
3740
|
+
this.createPayment = input(null, ...ngDevMode ? [{ debugName: "createPayment" }] : /* istanbul ignore next */ []);
|
|
3741
|
+
this.estimateFees = input(null, ...ngDevMode ? [{ debugName: "estimateFees" }] : /* istanbul ignore next */ []);
|
|
3742
|
+
this.applicationId = input(null, ...ngDevMode ? [{ debugName: "applicationId" }] : /* istanbul ignore next */ []);
|
|
3743
|
+
this.locationId = input(null, ...ngDevMode ? [{ debugName: "locationId" }] : /* istanbul ignore next */ []);
|
|
3744
|
+
this.environment = input(null, ...ngDevMode ? [{ debugName: "environment" }] : /* istanbul ignore next */ []);
|
|
3745
|
+
this.billingContact = input(null, ...ngDevMode ? [{ debugName: "billingContact" }] : /* istanbul ignore next */ []);
|
|
3746
|
+
this.accountHolderName = input("", ...ngDevMode ? [{ debugName: "accountHolderName" }] : /* istanbul ignore next */ []);
|
|
3747
|
+
this.requireAchConsent = input(true, ...ngDevMode ? [{ debugName: "requireAchConsent" }] : /* istanbul ignore next */ []);
|
|
3748
|
+
this.cardStyle = input(null, ...ngDevMode ? [{ debugName: "cardStyle" }] : /* istanbul ignore next */ []);
|
|
3749
|
+
this.methodListInput = input(null, {
|
|
3750
|
+
...ngDevMode ? { debugName: "methodListInput" } : /* istanbul ignore next */ {},
|
|
3751
|
+
alias: "methodList"
|
|
3752
|
+
});
|
|
3753
|
+
this.methodList = computed(() => this.methodListInput() ?? SQUARE_PAYMENT_METHOD_VALUES.map((value) => ({
|
|
3754
|
+
value,
|
|
3755
|
+
label: squareMethodLabel(value)
|
|
3756
|
+
})), ...ngDevMode ? [{ debugName: "methodList" }] : /* istanbul ignore next */ []);
|
|
3757
|
+
this.estimateTimeoutMs = input(1e4, ...ngDevMode ? [{ debugName: "estimateTimeoutMs" }] : /* istanbul ignore next */ []);
|
|
3758
|
+
this.payableRef = input(null, ...ngDevMode ? [{ debugName: "payableRef" }] : /* istanbul ignore next */ []);
|
|
3759
|
+
this.attemptKey = input(null, ...ngDevMode ? [{ debugName: "attemptKey" }] : /* istanbul ignore next */ []);
|
|
3760
|
+
this.checkStatus = input(null, ...ngDevMode ? [{ debugName: "checkStatus" }] : /* istanbul ignore next */ []);
|
|
3761
|
+
this.paid = input(false, ...ngDevMode ? [{ debugName: "paid" }] : /* istanbul ignore next */ []);
|
|
3762
|
+
this.hostPending = input(false, ...ngDevMode ? [{ debugName: "hostPending" }] : /* istanbul ignore next */ []);
|
|
3763
|
+
this.statusPollMs = input(PAYMENT_STATUS_POLL_MS, ...ngDevMode ? [{ debugName: "statusPollMs" }] : /* istanbul ignore next */ []);
|
|
3764
|
+
this.statusPollMaxMs = input(PAYMENT_STATUS_POLL_MAX_MS, ...ngDevMode ? [{ debugName: "statusPollMaxMs" }] : /* istanbul ignore next */ []);
|
|
3765
|
+
this.statusCheckTimeoutMs = input(PAYMENT_STATUS_CHECK_TIMEOUT_MS, ...ngDevMode ? [{ debugName: "statusCheckTimeoutMs" }] : /* istanbul ignore next */ []);
|
|
3766
|
+
this.statusFailGraceMs = input(PAYMENT_STATUS_FAIL_GRACE_MS, ...ngDevMode ? [{ debugName: "statusFailGraceMs" }] : /* istanbul ignore next */ []);
|
|
3767
|
+
this.allowStartOver = input(false, ...ngDevMode ? [{ debugName: "allowStartOver" }] : /* istanbul ignore next */ []);
|
|
3768
|
+
this.offlineOverride = input(false, ...ngDevMode ? [{ debugName: "offlineOverride" }] : /* istanbul ignore next */ []);
|
|
3769
|
+
this.authTimeoutMs = input(PAYMENT_AUTH_TIMEOUT_MS, ...ngDevMode ? [{ debugName: "authTimeoutMs" }] : /* istanbul ignore next */ []);
|
|
3770
|
+
this.paymentTimeoutMs = input(PAYMENT_REQUEST_TIMEOUT_MS, ...ngDevMode ? [{ debugName: "paymentTimeoutMs" }] : /* istanbul ignore next */ []);
|
|
3771
|
+
this.readinessCheck = input(null, ...ngDevMode ? [{ debugName: "readinessCheck" }] : /* istanbul ignore next */ []);
|
|
3772
|
+
this.readinessTimeoutMs = input(PAYMENT_READINESS_TIMEOUT_MS, ...ngDevMode ? [{ debugName: "readinessTimeoutMs" }] : /* istanbul ignore next */ []);
|
|
3773
|
+
this.readinessEveryMs = input(PAYMENT_READINESS_EVERY_MS, ...ngDevMode ? [{ debugName: "readinessEveryMs" }] : /* istanbul ignore next */ []);
|
|
3774
|
+
this.feesRequired = input(false, ...ngDevMode ? [{ debugName: "feesRequired" }] : /* istanbul ignore next */ []);
|
|
3775
|
+
this.receiptNoteInput = input(null, {
|
|
3776
|
+
...ngDevMode ? { debugName: "receiptNoteInput" } : /* istanbul ignore next */ {},
|
|
3777
|
+
alias: "receiptNote"
|
|
3778
|
+
});
|
|
3779
|
+
this.receiptNote = computed(() => this.receiptNoteInput() ?? SQUARE_METHOD_TEXTS.receiptNote, ...ngDevMode ? [{ debugName: "receiptNote" }] : /* istanbul ignore next */ []);
|
|
3780
|
+
this.body = viewChild("body", ...ngDevMode ? [{ debugName: "body" }] : /* istanbul ignore next */ []);
|
|
3781
|
+
this.controls = signal(null, ...ngDevMode ? [{ debugName: "controls" }] : /* istanbul ignore next */ []);
|
|
3782
|
+
this.methods = this.methodList;
|
|
3783
|
+
this.template = this.body;
|
|
3784
|
+
}
|
|
3785
|
+
attachControls(controls) {
|
|
3786
|
+
this.controls.set(controls);
|
|
3787
|
+
}
|
|
3788
|
+
detachControls(controls) {
|
|
3789
|
+
if (this.controls() === controls) this.controls.set(null);
|
|
3790
|
+
}
|
|
3791
|
+
markUnknown() {
|
|
3792
|
+
this.controls()?.markUnknown();
|
|
3793
|
+
}
|
|
3794
|
+
markSucceeded() {
|
|
3795
|
+
this.controls()?.markSucceeded();
|
|
3796
|
+
}
|
|
3797
|
+
markFailed() {
|
|
3798
|
+
this.controls()?.markFailed();
|
|
3799
|
+
}
|
|
3800
|
+
markNotCharged() {
|
|
3801
|
+
this.controls()?.markNotCharged();
|
|
3802
|
+
}
|
|
3803
|
+
resetPaid() {
|
|
3804
|
+
this.controls()?.resetPaid();
|
|
3805
|
+
}
|
|
3806
|
+
static {
|
|
3807
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
3808
|
+
minVersion: "12.0.0",
|
|
3809
|
+
version: "22.2.2",
|
|
3810
|
+
ngImport: i0,
|
|
3811
|
+
type: SquarePaymentMethodComponent,
|
|
3812
|
+
deps: null,
|
|
3813
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
3814
|
+
});
|
|
3815
|
+
}
|
|
3816
|
+
static {
|
|
3817
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
3818
|
+
minVersion: "17.2.0",
|
|
3819
|
+
version: "22.2.2",
|
|
3820
|
+
type: SquarePaymentMethodComponent,
|
|
3821
|
+
isStandalone: true,
|
|
3822
|
+
selector: "ui-square-payment-method",
|
|
3823
|
+
inputs: {
|
|
3824
|
+
createPayment: {
|
|
3825
|
+
classPropertyName: "createPayment",
|
|
3826
|
+
publicName: "createPayment",
|
|
3827
|
+
isSignal: true,
|
|
3828
|
+
isRequired: false,
|
|
3829
|
+
transformFunction: null
|
|
3830
|
+
},
|
|
3831
|
+
estimateFees: {
|
|
3832
|
+
classPropertyName: "estimateFees",
|
|
3833
|
+
publicName: "estimateFees",
|
|
3834
|
+
isSignal: true,
|
|
3835
|
+
isRequired: false,
|
|
3836
|
+
transformFunction: null
|
|
3837
|
+
},
|
|
3838
|
+
applicationId: {
|
|
3839
|
+
classPropertyName: "applicationId",
|
|
3840
|
+
publicName: "applicationId",
|
|
3841
|
+
isSignal: true,
|
|
3842
|
+
isRequired: false,
|
|
3843
|
+
transformFunction: null
|
|
3844
|
+
},
|
|
3845
|
+
locationId: {
|
|
3846
|
+
classPropertyName: "locationId",
|
|
3847
|
+
publicName: "locationId",
|
|
3848
|
+
isSignal: true,
|
|
3849
|
+
isRequired: false,
|
|
3850
|
+
transformFunction: null
|
|
3851
|
+
},
|
|
3852
|
+
environment: {
|
|
3853
|
+
classPropertyName: "environment",
|
|
3854
|
+
publicName: "environment",
|
|
3855
|
+
isSignal: true,
|
|
3856
|
+
isRequired: false,
|
|
3857
|
+
transformFunction: null
|
|
3858
|
+
},
|
|
3859
|
+
billingContact: {
|
|
3860
|
+
classPropertyName: "billingContact",
|
|
3861
|
+
publicName: "billingContact",
|
|
3862
|
+
isSignal: true,
|
|
3863
|
+
isRequired: false,
|
|
3864
|
+
transformFunction: null
|
|
3865
|
+
},
|
|
3866
|
+
accountHolderName: {
|
|
3867
|
+
classPropertyName: "accountHolderName",
|
|
3868
|
+
publicName: "accountHolderName",
|
|
3869
|
+
isSignal: true,
|
|
3870
|
+
isRequired: false,
|
|
3871
|
+
transformFunction: null
|
|
3872
|
+
},
|
|
3873
|
+
requireAchConsent: {
|
|
3874
|
+
classPropertyName: "requireAchConsent",
|
|
3875
|
+
publicName: "requireAchConsent",
|
|
3876
|
+
isSignal: true,
|
|
3877
|
+
isRequired: false,
|
|
3878
|
+
transformFunction: null
|
|
3879
|
+
},
|
|
3880
|
+
cardStyle: {
|
|
3881
|
+
classPropertyName: "cardStyle",
|
|
3882
|
+
publicName: "cardStyle",
|
|
3883
|
+
isSignal: true,
|
|
3884
|
+
isRequired: false,
|
|
3885
|
+
transformFunction: null
|
|
3886
|
+
},
|
|
3887
|
+
methodListInput: {
|
|
3888
|
+
classPropertyName: "methodListInput",
|
|
3889
|
+
publicName: "methodList",
|
|
3890
|
+
isSignal: true,
|
|
3891
|
+
isRequired: false,
|
|
3892
|
+
transformFunction: null
|
|
3893
|
+
},
|
|
3894
|
+
estimateTimeoutMs: {
|
|
3895
|
+
classPropertyName: "estimateTimeoutMs",
|
|
3896
|
+
publicName: "estimateTimeoutMs",
|
|
3897
|
+
isSignal: true,
|
|
3898
|
+
isRequired: false,
|
|
3899
|
+
transformFunction: null
|
|
3900
|
+
},
|
|
3901
|
+
payableRef: {
|
|
3902
|
+
classPropertyName: "payableRef",
|
|
3903
|
+
publicName: "payableRef",
|
|
3904
|
+
isSignal: true,
|
|
3905
|
+
isRequired: false,
|
|
3906
|
+
transformFunction: null
|
|
3907
|
+
},
|
|
3908
|
+
attemptKey: {
|
|
3909
|
+
classPropertyName: "attemptKey",
|
|
3910
|
+
publicName: "attemptKey",
|
|
3911
|
+
isSignal: true,
|
|
3912
|
+
isRequired: false,
|
|
3913
|
+
transformFunction: null
|
|
3914
|
+
},
|
|
3915
|
+
checkStatus: {
|
|
3916
|
+
classPropertyName: "checkStatus",
|
|
3917
|
+
publicName: "checkStatus",
|
|
3918
|
+
isSignal: true,
|
|
3919
|
+
isRequired: false,
|
|
3920
|
+
transformFunction: null
|
|
3921
|
+
},
|
|
3922
|
+
paid: {
|
|
3923
|
+
classPropertyName: "paid",
|
|
3924
|
+
publicName: "paid",
|
|
3925
|
+
isSignal: true,
|
|
3926
|
+
isRequired: false,
|
|
3927
|
+
transformFunction: null
|
|
3928
|
+
},
|
|
3929
|
+
hostPending: {
|
|
3930
|
+
classPropertyName: "hostPending",
|
|
3931
|
+
publicName: "hostPending",
|
|
3932
|
+
isSignal: true,
|
|
3933
|
+
isRequired: false,
|
|
3934
|
+
transformFunction: null
|
|
3935
|
+
},
|
|
3936
|
+
statusPollMs: {
|
|
3937
|
+
classPropertyName: "statusPollMs",
|
|
3938
|
+
publicName: "statusPollMs",
|
|
3939
|
+
isSignal: true,
|
|
3940
|
+
isRequired: false,
|
|
3941
|
+
transformFunction: null
|
|
3942
|
+
},
|
|
3943
|
+
statusPollMaxMs: {
|
|
3944
|
+
classPropertyName: "statusPollMaxMs",
|
|
3945
|
+
publicName: "statusPollMaxMs",
|
|
3946
|
+
isSignal: true,
|
|
3947
|
+
isRequired: false,
|
|
3948
|
+
transformFunction: null
|
|
3949
|
+
},
|
|
3950
|
+
statusCheckTimeoutMs: {
|
|
3951
|
+
classPropertyName: "statusCheckTimeoutMs",
|
|
3952
|
+
publicName: "statusCheckTimeoutMs",
|
|
3953
|
+
isSignal: true,
|
|
3954
|
+
isRequired: false,
|
|
3955
|
+
transformFunction: null
|
|
3956
|
+
},
|
|
3957
|
+
statusFailGraceMs: {
|
|
3958
|
+
classPropertyName: "statusFailGraceMs",
|
|
3959
|
+
publicName: "statusFailGraceMs",
|
|
3960
|
+
isSignal: true,
|
|
3961
|
+
isRequired: false,
|
|
3962
|
+
transformFunction: null
|
|
3963
|
+
},
|
|
3964
|
+
allowStartOver: {
|
|
3965
|
+
classPropertyName: "allowStartOver",
|
|
3966
|
+
publicName: "allowStartOver",
|
|
3967
|
+
isSignal: true,
|
|
3968
|
+
isRequired: false,
|
|
3969
|
+
transformFunction: null
|
|
3970
|
+
},
|
|
3971
|
+
offlineOverride: {
|
|
3972
|
+
classPropertyName: "offlineOverride",
|
|
3973
|
+
publicName: "offlineOverride",
|
|
3974
|
+
isSignal: true,
|
|
3975
|
+
isRequired: false,
|
|
3976
|
+
transformFunction: null
|
|
3977
|
+
},
|
|
3978
|
+
authTimeoutMs: {
|
|
3979
|
+
classPropertyName: "authTimeoutMs",
|
|
3980
|
+
publicName: "authTimeoutMs",
|
|
3981
|
+
isSignal: true,
|
|
3982
|
+
isRequired: false,
|
|
3983
|
+
transformFunction: null
|
|
3984
|
+
},
|
|
3985
|
+
paymentTimeoutMs: {
|
|
3986
|
+
classPropertyName: "paymentTimeoutMs",
|
|
3987
|
+
publicName: "paymentTimeoutMs",
|
|
3988
|
+
isSignal: true,
|
|
3989
|
+
isRequired: false,
|
|
3990
|
+
transformFunction: null
|
|
3991
|
+
},
|
|
3992
|
+
readinessCheck: {
|
|
3993
|
+
classPropertyName: "readinessCheck",
|
|
3994
|
+
publicName: "readinessCheck",
|
|
3995
|
+
isSignal: true,
|
|
3996
|
+
isRequired: false,
|
|
3997
|
+
transformFunction: null
|
|
3998
|
+
},
|
|
3999
|
+
readinessTimeoutMs: {
|
|
4000
|
+
classPropertyName: "readinessTimeoutMs",
|
|
4001
|
+
publicName: "readinessTimeoutMs",
|
|
4002
|
+
isSignal: true,
|
|
4003
|
+
isRequired: false,
|
|
4004
|
+
transformFunction: null
|
|
4005
|
+
},
|
|
4006
|
+
readinessEveryMs: {
|
|
4007
|
+
classPropertyName: "readinessEveryMs",
|
|
4008
|
+
publicName: "readinessEveryMs",
|
|
4009
|
+
isSignal: true,
|
|
4010
|
+
isRequired: false,
|
|
4011
|
+
transformFunction: null
|
|
4012
|
+
},
|
|
4013
|
+
feesRequired: {
|
|
4014
|
+
classPropertyName: "feesRequired",
|
|
4015
|
+
publicName: "feesRequired",
|
|
4016
|
+
isSignal: true,
|
|
4017
|
+
isRequired: false,
|
|
4018
|
+
transformFunction: null
|
|
4019
|
+
},
|
|
4020
|
+
receiptNoteInput: {
|
|
4021
|
+
classPropertyName: "receiptNoteInput",
|
|
4022
|
+
publicName: "receiptNote",
|
|
4023
|
+
isSignal: true,
|
|
4024
|
+
isRequired: false,
|
|
4025
|
+
transformFunction: null
|
|
4026
|
+
}
|
|
4027
|
+
},
|
|
4028
|
+
host: { styleAttribute: "display: none" },
|
|
4029
|
+
providers: [{
|
|
4030
|
+
provide: PAYMENT_METHOD_PLUGIN,
|
|
4031
|
+
useExisting: forwardRef(() => SquarePaymentMethodComponent)
|
|
4032
|
+
}],
|
|
4033
|
+
viewQueries: [{
|
|
4034
|
+
propertyName: "body",
|
|
4035
|
+
first: true,
|
|
4036
|
+
predicate: ["body"],
|
|
4037
|
+
descendants: true,
|
|
4038
|
+
isSignal: true
|
|
4039
|
+
}],
|
|
4040
|
+
usesInheritance: true,
|
|
4041
|
+
ngImport: i0,
|
|
4042
|
+
template: `<ng-template #body let-ctx><ui-payment-square-body [ctx]="ctx" [config]="self" /></ng-template>`,
|
|
4043
|
+
isInline: true,
|
|
4044
|
+
dependencies: [{
|
|
4045
|
+
kind: "component",
|
|
4046
|
+
type: PaymentSquareBodyComponent,
|
|
4047
|
+
selector: "ui-payment-square-body",
|
|
4048
|
+
inputs: ["ctx", "config"]
|
|
4049
|
+
}],
|
|
4050
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
4051
|
+
});
|
|
4052
|
+
}
|
|
4053
|
+
};
|
|
4054
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
4055
|
+
minVersion: "12.0.0",
|
|
4056
|
+
version: "22.2.2",
|
|
4057
|
+
ngImport: i0,
|
|
4058
|
+
type: SquarePaymentMethodComponent,
|
|
4059
|
+
decorators: [{
|
|
4060
|
+
type: Component,
|
|
4061
|
+
args: [{
|
|
4062
|
+
selector: "ui-square-payment-method",
|
|
4063
|
+
standalone: true,
|
|
4064
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
4065
|
+
imports: [PaymentSquareBodyComponent],
|
|
4066
|
+
providers: [{
|
|
4067
|
+
provide: PAYMENT_METHOD_PLUGIN,
|
|
4068
|
+
useExisting: forwardRef(() => SquarePaymentMethodComponent)
|
|
4069
|
+
}],
|
|
4070
|
+
host: { style: "display: none" },
|
|
4071
|
+
template: `<ng-template #body let-ctx><ui-payment-square-body [ctx]="ctx" [config]="self" /></ng-template>`
|
|
4072
|
+
}]
|
|
4073
|
+
}],
|
|
4074
|
+
propDecorators: {
|
|
4075
|
+
createPayment: [{
|
|
4076
|
+
type: i0.Input,
|
|
4077
|
+
args: [{
|
|
4078
|
+
isSignal: true,
|
|
4079
|
+
alias: "createPayment",
|
|
4080
|
+
required: false
|
|
4081
|
+
}]
|
|
4082
|
+
}],
|
|
4083
|
+
estimateFees: [{
|
|
4084
|
+
type: i0.Input,
|
|
4085
|
+
args: [{
|
|
4086
|
+
isSignal: true,
|
|
4087
|
+
alias: "estimateFees",
|
|
4088
|
+
required: false
|
|
4089
|
+
}]
|
|
4090
|
+
}],
|
|
4091
|
+
applicationId: [{
|
|
4092
|
+
type: i0.Input,
|
|
4093
|
+
args: [{
|
|
4094
|
+
isSignal: true,
|
|
4095
|
+
alias: "applicationId",
|
|
4096
|
+
required: false
|
|
4097
|
+
}]
|
|
4098
|
+
}],
|
|
4099
|
+
locationId: [{
|
|
4100
|
+
type: i0.Input,
|
|
4101
|
+
args: [{
|
|
4102
|
+
isSignal: true,
|
|
4103
|
+
alias: "locationId",
|
|
4104
|
+
required: false
|
|
4105
|
+
}]
|
|
4106
|
+
}],
|
|
4107
|
+
environment: [{
|
|
4108
|
+
type: i0.Input,
|
|
4109
|
+
args: [{
|
|
4110
|
+
isSignal: true,
|
|
4111
|
+
alias: "environment",
|
|
4112
|
+
required: false
|
|
4113
|
+
}]
|
|
4114
|
+
}],
|
|
4115
|
+
billingContact: [{
|
|
4116
|
+
type: i0.Input,
|
|
4117
|
+
args: [{
|
|
4118
|
+
isSignal: true,
|
|
4119
|
+
alias: "billingContact",
|
|
4120
|
+
required: false
|
|
4121
|
+
}]
|
|
4122
|
+
}],
|
|
4123
|
+
accountHolderName: [{
|
|
4124
|
+
type: i0.Input,
|
|
4125
|
+
args: [{
|
|
4126
|
+
isSignal: true,
|
|
4127
|
+
alias: "accountHolderName",
|
|
4128
|
+
required: false
|
|
4129
|
+
}]
|
|
4130
|
+
}],
|
|
4131
|
+
requireAchConsent: [{
|
|
4132
|
+
type: i0.Input,
|
|
4133
|
+
args: [{
|
|
4134
|
+
isSignal: true,
|
|
4135
|
+
alias: "requireAchConsent",
|
|
4136
|
+
required: false
|
|
4137
|
+
}]
|
|
4138
|
+
}],
|
|
4139
|
+
cardStyle: [{
|
|
4140
|
+
type: i0.Input,
|
|
4141
|
+
args: [{
|
|
4142
|
+
isSignal: true,
|
|
4143
|
+
alias: "cardStyle",
|
|
4144
|
+
required: false
|
|
4145
|
+
}]
|
|
4146
|
+
}],
|
|
4147
|
+
methodListInput: [{
|
|
4148
|
+
type: i0.Input,
|
|
4149
|
+
args: [{
|
|
4150
|
+
isSignal: true,
|
|
4151
|
+
alias: "methodList",
|
|
4152
|
+
required: false
|
|
4153
|
+
}]
|
|
4154
|
+
}],
|
|
4155
|
+
estimateTimeoutMs: [{
|
|
4156
|
+
type: i0.Input,
|
|
4157
|
+
args: [{
|
|
4158
|
+
isSignal: true,
|
|
4159
|
+
alias: "estimateTimeoutMs",
|
|
4160
|
+
required: false
|
|
4161
|
+
}]
|
|
4162
|
+
}],
|
|
4163
|
+
payableRef: [{
|
|
4164
|
+
type: i0.Input,
|
|
4165
|
+
args: [{
|
|
4166
|
+
isSignal: true,
|
|
4167
|
+
alias: "payableRef",
|
|
4168
|
+
required: false
|
|
4169
|
+
}]
|
|
4170
|
+
}],
|
|
4171
|
+
attemptKey: [{
|
|
4172
|
+
type: i0.Input,
|
|
4173
|
+
args: [{
|
|
4174
|
+
isSignal: true,
|
|
4175
|
+
alias: "attemptKey",
|
|
4176
|
+
required: false
|
|
4177
|
+
}]
|
|
4178
|
+
}],
|
|
4179
|
+
checkStatus: [{
|
|
4180
|
+
type: i0.Input,
|
|
4181
|
+
args: [{
|
|
4182
|
+
isSignal: true,
|
|
4183
|
+
alias: "checkStatus",
|
|
4184
|
+
required: false
|
|
4185
|
+
}]
|
|
4186
|
+
}],
|
|
4187
|
+
paid: [{
|
|
4188
|
+
type: i0.Input,
|
|
4189
|
+
args: [{
|
|
4190
|
+
isSignal: true,
|
|
4191
|
+
alias: "paid",
|
|
4192
|
+
required: false
|
|
4193
|
+
}]
|
|
4194
|
+
}],
|
|
4195
|
+
hostPending: [{
|
|
4196
|
+
type: i0.Input,
|
|
4197
|
+
args: [{
|
|
4198
|
+
isSignal: true,
|
|
4199
|
+
alias: "hostPending",
|
|
4200
|
+
required: false
|
|
4201
|
+
}]
|
|
4202
|
+
}],
|
|
4203
|
+
statusPollMs: [{
|
|
4204
|
+
type: i0.Input,
|
|
4205
|
+
args: [{
|
|
4206
|
+
isSignal: true,
|
|
4207
|
+
alias: "statusPollMs",
|
|
4208
|
+
required: false
|
|
4209
|
+
}]
|
|
4210
|
+
}],
|
|
4211
|
+
statusPollMaxMs: [{
|
|
4212
|
+
type: i0.Input,
|
|
4213
|
+
args: [{
|
|
4214
|
+
isSignal: true,
|
|
4215
|
+
alias: "statusPollMaxMs",
|
|
4216
|
+
required: false
|
|
4217
|
+
}]
|
|
4218
|
+
}],
|
|
4219
|
+
statusCheckTimeoutMs: [{
|
|
4220
|
+
type: i0.Input,
|
|
4221
|
+
args: [{
|
|
4222
|
+
isSignal: true,
|
|
4223
|
+
alias: "statusCheckTimeoutMs",
|
|
4224
|
+
required: false
|
|
4225
|
+
}]
|
|
4226
|
+
}],
|
|
4227
|
+
statusFailGraceMs: [{
|
|
4228
|
+
type: i0.Input,
|
|
4229
|
+
args: [{
|
|
4230
|
+
isSignal: true,
|
|
4231
|
+
alias: "statusFailGraceMs",
|
|
4232
|
+
required: false
|
|
4233
|
+
}]
|
|
4234
|
+
}],
|
|
4235
|
+
allowStartOver: [{
|
|
4236
|
+
type: i0.Input,
|
|
4237
|
+
args: [{
|
|
4238
|
+
isSignal: true,
|
|
4239
|
+
alias: "allowStartOver",
|
|
4240
|
+
required: false
|
|
4241
|
+
}]
|
|
4242
|
+
}],
|
|
4243
|
+
offlineOverride: [{
|
|
4244
|
+
type: i0.Input,
|
|
4245
|
+
args: [{
|
|
4246
|
+
isSignal: true,
|
|
4247
|
+
alias: "offlineOverride",
|
|
4248
|
+
required: false
|
|
4249
|
+
}]
|
|
4250
|
+
}],
|
|
4251
|
+
authTimeoutMs: [{
|
|
4252
|
+
type: i0.Input,
|
|
4253
|
+
args: [{
|
|
4254
|
+
isSignal: true,
|
|
4255
|
+
alias: "authTimeoutMs",
|
|
4256
|
+
required: false
|
|
4257
|
+
}]
|
|
4258
|
+
}],
|
|
4259
|
+
paymentTimeoutMs: [{
|
|
4260
|
+
type: i0.Input,
|
|
4261
|
+
args: [{
|
|
4262
|
+
isSignal: true,
|
|
4263
|
+
alias: "paymentTimeoutMs",
|
|
4264
|
+
required: false
|
|
4265
|
+
}]
|
|
4266
|
+
}],
|
|
4267
|
+
readinessCheck: [{
|
|
4268
|
+
type: i0.Input,
|
|
4269
|
+
args: [{
|
|
4270
|
+
isSignal: true,
|
|
4271
|
+
alias: "readinessCheck",
|
|
4272
|
+
required: false
|
|
4273
|
+
}]
|
|
4274
|
+
}],
|
|
4275
|
+
readinessTimeoutMs: [{
|
|
4276
|
+
type: i0.Input,
|
|
4277
|
+
args: [{
|
|
4278
|
+
isSignal: true,
|
|
4279
|
+
alias: "readinessTimeoutMs",
|
|
4280
|
+
required: false
|
|
4281
|
+
}]
|
|
4282
|
+
}],
|
|
4283
|
+
readinessEveryMs: [{
|
|
4284
|
+
type: i0.Input,
|
|
4285
|
+
args: [{
|
|
4286
|
+
isSignal: true,
|
|
4287
|
+
alias: "readinessEveryMs",
|
|
4288
|
+
required: false
|
|
4289
|
+
}]
|
|
4290
|
+
}],
|
|
4291
|
+
feesRequired: [{
|
|
4292
|
+
type: i0.Input,
|
|
4293
|
+
args: [{
|
|
4294
|
+
isSignal: true,
|
|
4295
|
+
alias: "feesRequired",
|
|
4296
|
+
required: false
|
|
4297
|
+
}]
|
|
4298
|
+
}],
|
|
4299
|
+
receiptNoteInput: [{
|
|
4300
|
+
type: i0.Input,
|
|
4301
|
+
args: [{
|
|
4302
|
+
isSignal: true,
|
|
4303
|
+
alias: "receiptNote",
|
|
4304
|
+
required: false
|
|
4305
|
+
}]
|
|
4306
|
+
}],
|
|
4307
|
+
body: [{
|
|
4308
|
+
type: i0.ViewChild,
|
|
4309
|
+
args: ["body", { isSignal: true }]
|
|
4310
|
+
}]
|
|
4311
|
+
}
|
|
4312
|
+
});
|
|
4313
|
+
export { SQUARE_A11Y_MESSAGES, SQUARE_FIELD_ERROR_KEYS, SQUARE_LOADER, SQUARE_METHOD_TEXTS, SQUARE_PAYMENT_DEFAULTS, SQUARE_PAYMENT_ERROR_KEYS, SQUARE_PAYMENT_METHOD_VALUES, SQUARE_SANDBOX_SDK_URL, SQUARE_SDK_URL, SQUARE_TYPE_ERROR_KEYS, SquareConnectComponent, SquareConnectFlow, SquareLoadError, SquarePaymentComponent, SquarePaymentMethodComponent, defaultSquareLoader, failureFromTokenResult, getSquareErrorMessage, getSquarePaymentErrorMessage, isSquareUrl, newIdempotencyKey, normalizeSquareDetails, provideSquarePayment, readSquareCardStyle, squareConnectNotice, squareMethodLabel, squareOutcomeOf, squareSdkUrl };
|
|
4314
|
+
|
|
4315
|
+
//# sourceMappingURL=forgeroute-ui-square.mjs.map
|