@forgeroute/ui 0.4.3 → 0.4.4
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.
|
@@ -0,0 +1,2762 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, Injectable, InjectionToken, PLATFORM_ID, computed, effect, inject, input, output, signal, untracked, viewChild } from "@angular/core";
|
|
3
|
+
import { DOCUMENT, isPlatformBrowser } from "@angular/common";
|
|
4
|
+
import { AlertComponent, BadgeComponent, ButtonComponent, FormRowComponent, FormSectionComponent, ModalComponent, SkeletonComponent, TextComponent, TextInputComponent } from "@forgeroute/ui";
|
|
5
|
+
import * as i1 from "@angular/forms";
|
|
6
|
+
import { FormsModule } from "@angular/forms";
|
|
7
|
+
const sdkImporter = { load: () => import("@stripe/stripe-js") };
|
|
8
|
+
const defaultStripeLoader = async (publishableKey, options) => {
|
|
9
|
+
const sdk = await sdkImporter.load();
|
|
10
|
+
return options === void 0 ? await sdk.loadStripe(publishableKey) : await sdk.loadStripe(publishableKey, options);
|
|
11
|
+
};
|
|
12
|
+
const STRIPE_LOADER = new InjectionToken("STRIPE_LOADER", {
|
|
13
|
+
providedIn: "root",
|
|
14
|
+
factory: () => defaultStripeLoader
|
|
15
|
+
});
|
|
16
|
+
const STRIPE_PAYMENT_DEFAULTS = new InjectionToken("STRIPE_PAYMENT_DEFAULTS", {
|
|
17
|
+
providedIn: "root",
|
|
18
|
+
factory: () => ({})
|
|
19
|
+
});
|
|
20
|
+
function provideStripePayment(options = {}) {
|
|
21
|
+
const { loader, ...defaults } = options;
|
|
22
|
+
const providers = [{
|
|
23
|
+
provide: STRIPE_PAYMENT_DEFAULTS,
|
|
24
|
+
useValue: defaults
|
|
25
|
+
}];
|
|
26
|
+
if (loader) providers.push({
|
|
27
|
+
provide: STRIPE_LOADER,
|
|
28
|
+
useValue: loader
|
|
29
|
+
});
|
|
30
|
+
return providers;
|
|
31
|
+
}
|
|
32
|
+
function buildLoadOptions(stripeAccount, locale, extra) {
|
|
33
|
+
const options = { ...extra ?? {} };
|
|
34
|
+
if (locale) options.locale = locale;
|
|
35
|
+
if (stripeAccount) options.stripeAccount = stripeAccount;
|
|
36
|
+
return Object.keys(options).length ? options : void 0;
|
|
37
|
+
}
|
|
38
|
+
const STRIPE_ERROR_MESSAGES = {
|
|
39
|
+
stolen_card: "This card has been reported as stolen. Please use a different payment method.",
|
|
40
|
+
lost_card: "This card has been reported as lost. Please use a different payment method.",
|
|
41
|
+
card_declined: "Your card was declined. Please contact your bank or use a different card.",
|
|
42
|
+
generic_decline: "Your card was declined. Please contact your bank or try a different card.",
|
|
43
|
+
insufficient_funds: "Your card has insufficient funds. Please use a different card or add funds to your account.",
|
|
44
|
+
do_not_honor: "Your bank has declined this transaction. Please contact your bank or use a different card.",
|
|
45
|
+
card_not_supported: "This card does not support this type of purchase. Please use a different card.",
|
|
46
|
+
currency_not_supported: "This card does not support the requested currency. Please use a different card.",
|
|
47
|
+
duplicate_transaction: "A duplicate transaction was detected. Please wait a few minutes before trying again.",
|
|
48
|
+
expired_card: "Your card has expired. Please use a different card.",
|
|
49
|
+
incorrect_cvc: "The security code (CVC) is incorrect. Please check and try again.",
|
|
50
|
+
incorrect_number: "The card number is incorrect. Please check and try again.",
|
|
51
|
+
invalid_cvc: "The security code (CVC) is invalid. Please check and try again.",
|
|
52
|
+
invalid_expiry_month: "The expiration month is invalid. Please check and try again.",
|
|
53
|
+
invalid_expiry_year: "The expiration year is invalid. Please check and try again.",
|
|
54
|
+
invalid_number: "The card number is invalid. Please check and try again.",
|
|
55
|
+
processing_error: "An error occurred while processing your card. Please try again.",
|
|
56
|
+
incorrect_zip: "The ZIP/postal code is incorrect. Please check and try again.",
|
|
57
|
+
card_velocity_exceeded: "You have exceeded the balance or credit limit on your card. Please contact your bank.",
|
|
58
|
+
withdrawal_count_limit_exceeded: "You have exceeded the allowed number of transactions. Please try again later or use a different card.",
|
|
59
|
+
authentication_required: "This card requires authentication. Please try again and complete the verification step.",
|
|
60
|
+
fraudulent: "This transaction has been flagged by your bank. Please contact your bank or use a different card.",
|
|
61
|
+
merchant_blacklist: "This card cannot be used for this transaction. Please use a different card.",
|
|
62
|
+
pickup_card: "This card cannot be used. Please contact your bank or use a different card.",
|
|
63
|
+
restricted_card: "This card has restrictions that prevent this transaction. Please contact your bank or use a different card.",
|
|
64
|
+
security_violation: "This card has been flagged for a security violation. Please contact your bank.",
|
|
65
|
+
issuer_not_available: "Your card issuer could not be reached. Please try again later.",
|
|
66
|
+
new_account_information_available: "Your card details have changed. Please update your card information and try again.",
|
|
67
|
+
try_again_later: "Your card issuer is temporarily unable to process this transaction. Please try again later.",
|
|
68
|
+
reenter_transaction: "The transaction could not be processed. Please try again.",
|
|
69
|
+
approve_with_id: "The payment cannot be authorized. Please contact your bank.",
|
|
70
|
+
call_issuer: "Your bank has declined this transaction. Please call your bank for more information.",
|
|
71
|
+
do_not_try_again: "Your bank has permanently declined this card. Please use a different payment method.",
|
|
72
|
+
no_action_taken: "Your bank could not process this transaction. Please contact your bank.",
|
|
73
|
+
not_permitted: "This transaction is not permitted on this card. Please contact your bank or use a different card.",
|
|
74
|
+
revocation_of_all_authorizations: "All authorizations have been revoked for this card. Please contact your bank.",
|
|
75
|
+
revocation_of_authorization: "The authorization for this card has been revoked. Please contact your bank.",
|
|
76
|
+
stop_payment_order: "Your bank has stopped this payment. Please contact your bank.",
|
|
77
|
+
testmode_decline: "This is a test decline. No real charge was attempted.",
|
|
78
|
+
bank_account_declined: "Your bank account could not be used. Please try a different account.",
|
|
79
|
+
debit_not_authorized: "The debit was not authorized. Please contact your bank.",
|
|
80
|
+
payment_intent_unexpected_state: "This payment has already been processed. Please refresh the page and try again.",
|
|
81
|
+
payment_intent_authentication_failure: "Payment authentication failed. Please try again.",
|
|
82
|
+
payment_intent_incompatible_payment_method: "This payment method is not compatible. Please use a different payment method.",
|
|
83
|
+
payment_intent_payment_attempt_failed: "The payment attempt failed. Please try again or use a different payment method.",
|
|
84
|
+
payment_method_unactivated: "This payment method is not activated. Please use a different payment method.",
|
|
85
|
+
payment_method_unexpected_state: "There was an issue with your payment method. Please try again.",
|
|
86
|
+
setup_intent_unexpected_state: "This payment setup has already been completed. Please refresh the page.",
|
|
87
|
+
amount_too_small: "The payment amount is too small to process. Please contact the business.",
|
|
88
|
+
amount_too_large: "The payment amount exceeds the maximum allowed. Please contact the business.",
|
|
89
|
+
balance_insufficient: "Insufficient balance to complete this payment. Please use a different payment method.",
|
|
90
|
+
resource_missing: "The payment session has expired. Please refresh the page and try again."
|
|
91
|
+
};
|
|
92
|
+
const STRIPE_TECHNICAL_ERROR_MESSAGES = {
|
|
93
|
+
api_connection_error: "We could not reach the payment service. Please check your connection and try again.",
|
|
94
|
+
rate_limit_error: "Too many requests. Please wait a moment and try again.",
|
|
95
|
+
api_error: "Something went wrong while processing the payment. Please try again.",
|
|
96
|
+
authentication_error: "Something went wrong while processing the payment. Please try again.",
|
|
97
|
+
invalid_request_error: "Something went wrong while processing the payment. Please try again."
|
|
98
|
+
};
|
|
99
|
+
const STRIPE_DEFAULT_ERROR_MESSAGE = "Payment failed. Please try again.";
|
|
100
|
+
const STRIPE_SESSION_EXPIRED_MESSAGE = "Your payment session has expired. Please refresh the page and try again.";
|
|
101
|
+
function getStripeErrorMessage(error, options = {}) {
|
|
102
|
+
const fallback = options.fallback ?? "Payment failed. Please try again.";
|
|
103
|
+
if (!error) return fallback;
|
|
104
|
+
if (options.display === "stripe") return error.message || fallback;
|
|
105
|
+
const table = {
|
|
106
|
+
...STRIPE_ERROR_MESSAGES,
|
|
107
|
+
...options.overrides ?? {}
|
|
108
|
+
};
|
|
109
|
+
if (error.decline_code && table[error.decline_code]) return table[error.decline_code];
|
|
110
|
+
if (error.code && table[error.code]) return table[error.code];
|
|
111
|
+
const message = error.message;
|
|
112
|
+
if (message) {
|
|
113
|
+
if (message.includes("already succeeded") || message.includes("previously confirmed")) return options.overrides?.["payment_intent_unexpected_state"] ?? "This payment has already been processed. Please refresh the page and try again.";
|
|
114
|
+
if (message.includes("expired")) return STRIPE_SESSION_EXPIRED_MESSAGE;
|
|
115
|
+
}
|
|
116
|
+
const technical = options.display === "table" || !error.type ? void 0 : STRIPE_TECHNICAL_ERROR_MESSAGES[error.type];
|
|
117
|
+
if (technical) return technical;
|
|
118
|
+
return message || fallback;
|
|
119
|
+
}
|
|
120
|
+
const MSG_NOT_INITIALIZED = "Payment system not initialized";
|
|
121
|
+
const MSG_INTENT_FAILED = "Failed to create payment intent";
|
|
122
|
+
const MSG_NOT_COMPLETED = "Payment was not completed";
|
|
123
|
+
const MSG_REQUIRES_PAYMENT_METHOD = "Payment failed. Please try a different payment method.";
|
|
124
|
+
const MSG_NO_PAYMENT_METHOD = "No payment method returned from Stripe";
|
|
125
|
+
const MSG_AUTH_FAILED = "Payment authentication failed";
|
|
126
|
+
const MSG_AUTH_NOT_COMPLETED = "Payment authentication was not completed";
|
|
127
|
+
const MSG_KEY_MISSING = "A Stripe publishable key is required";
|
|
128
|
+
const MSG_LOAD_FAILED = "Failed to load Stripe";
|
|
129
|
+
function paymentMethodIdOf(intent) {
|
|
130
|
+
const pm = intent?.payment_method;
|
|
131
|
+
if (!pm) return null;
|
|
132
|
+
return typeof pm === "string" ? pm : pm.id || null;
|
|
133
|
+
}
|
|
134
|
+
function verificationOf(intent) {
|
|
135
|
+
const action = intent?.next_action;
|
|
136
|
+
if (action?.type !== "verify_with_microdeposits") return null;
|
|
137
|
+
const details = action.verify_with_microdeposits ?? {};
|
|
138
|
+
const arrival = typeof details.arrival_date === "number" ? details.arrival_date : null;
|
|
139
|
+
const type = details.microdeposit_type === "amounts" || details.microdeposit_type === "descriptor_code" ? details.microdeposit_type : null;
|
|
140
|
+
const url = typeof details.hosted_verification_url === "string" && details.hosted_verification_url ? details.hosted_verification_url : null;
|
|
141
|
+
return {
|
|
142
|
+
type,
|
|
143
|
+
arrivalDate: arrival,
|
|
144
|
+
arrivalDateIso: arrival === null ? null : (/* @__PURE__ */ new Date(arrival * 1e3)).toISOString(),
|
|
145
|
+
hostedVerificationUrl: url
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function outcomeOf(intent) {
|
|
149
|
+
switch (intent.status) {
|
|
150
|
+
case "succeeded": return "succeeded";
|
|
151
|
+
case "processing": return "processing";
|
|
152
|
+
case "requires_capture": return "requires_capture";
|
|
153
|
+
case "requires_action": return intent.next_action?.type === "verify_with_microdeposits" ? "requires_verification" : "requires_action";
|
|
154
|
+
case "requires_payment_method": return "requires_payment_method";
|
|
155
|
+
case "canceled": return "canceled";
|
|
156
|
+
default: return "unknown";
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function normalizeIntent(kind, intent) {
|
|
160
|
+
const outcome = outcomeOf(intent);
|
|
161
|
+
return {
|
|
162
|
+
kind,
|
|
163
|
+
status: intent.status,
|
|
164
|
+
outcome,
|
|
165
|
+
intent,
|
|
166
|
+
...kind === "setup" ? { setupIntent: intent } : { paymentIntent: intent },
|
|
167
|
+
intentId: intent.id,
|
|
168
|
+
paymentMethodId: paymentMethodIdOf(intent),
|
|
169
|
+
verification: outcome === "requires_verification" ? verificationOf(intent) : null,
|
|
170
|
+
actionHandled: false
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function failureFromError(error, stage, options = {}) {
|
|
174
|
+
return {
|
|
175
|
+
code: error?.code || error?.type || "unknown_error",
|
|
176
|
+
message: getStripeErrorMessage(error, options),
|
|
177
|
+
stripeMessage: error?.message ?? "",
|
|
178
|
+
...error?.decline_code ? { declineCode: error.decline_code } : {},
|
|
179
|
+
...error?.type ? { type: error.type } : {},
|
|
180
|
+
stage,
|
|
181
|
+
...error ? { error } : {}
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function failure(code, message, stage, stripeMessage = "") {
|
|
185
|
+
return {
|
|
186
|
+
code,
|
|
187
|
+
message,
|
|
188
|
+
stripeMessage,
|
|
189
|
+
stage
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function messageOfThrown(err, fallback) {
|
|
193
|
+
const e = err;
|
|
194
|
+
if (typeof e?.error?.message === "string" && e.error.message) return e.error.message;
|
|
195
|
+
if (typeof e?.message === "string" && e.message) return e.message;
|
|
196
|
+
return fallback;
|
|
197
|
+
}
|
|
198
|
+
function readStripeReturnParams(search) {
|
|
199
|
+
const params = new URLSearchParams(search.startsWith("?") ? search.slice(1) : search);
|
|
200
|
+
const payment = params.get("payment_intent_client_secret");
|
|
201
|
+
const setup = params.get("setup_intent_client_secret");
|
|
202
|
+
const kind = payment ? "payment" : setup ? "setup" : null;
|
|
203
|
+
if (!kind) return null;
|
|
204
|
+
return {
|
|
205
|
+
kind,
|
|
206
|
+
clientSecret: payment ?? setup,
|
|
207
|
+
redirectStatus: params.get("redirect_status")
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
const MSG_VERIFY_FAILED = "Verification failed";
|
|
211
|
+
const MSG_VERIFY_THROWN = "Verification failed. Please check the code and try again.";
|
|
212
|
+
const MSG_RETURN_FAILED = "We could not check the status of this payment. Please contact support before trying again.";
|
|
213
|
+
async function verifyMicrodeposits(stripe, flow, clientSecret, data) {
|
|
214
|
+
const call = flow === "payment" ? stripe.verifyMicrodepositsForPayment : stripe.verifyMicrodepositsForSetup;
|
|
215
|
+
if (typeof call !== "function") return {
|
|
216
|
+
ok: false,
|
|
217
|
+
outcome: null,
|
|
218
|
+
intent: null,
|
|
219
|
+
failure: failure("unsupported", MSG_VERIFY_FAILED, "verify")
|
|
220
|
+
};
|
|
221
|
+
try {
|
|
222
|
+
const result = await call.call(stripe, clientSecret, data);
|
|
223
|
+
if (result.error) return {
|
|
224
|
+
ok: false,
|
|
225
|
+
outcome: null,
|
|
226
|
+
intent: null,
|
|
227
|
+
failure: failureFromError(result.error, "verify", {
|
|
228
|
+
display: "stripe",
|
|
229
|
+
fallback: MSG_VERIFY_FAILED
|
|
230
|
+
})
|
|
231
|
+
};
|
|
232
|
+
const intent = (flow === "payment" ? result.paymentIntent : result.setupIntent) ?? null;
|
|
233
|
+
const event = intent ? normalizeIntent(flow, intent) : null;
|
|
234
|
+
if (event && (event.outcome === "processing" || event.outcome === "succeeded")) return {
|
|
235
|
+
ok: true,
|
|
236
|
+
outcome: event.outcome,
|
|
237
|
+
intent,
|
|
238
|
+
failure: null
|
|
239
|
+
};
|
|
240
|
+
return {
|
|
241
|
+
ok: false,
|
|
242
|
+
outcome: event?.outcome ?? null,
|
|
243
|
+
intent,
|
|
244
|
+
failure: failure("verification_incomplete", MSG_VERIFY_FAILED, "verify")
|
|
245
|
+
};
|
|
246
|
+
} catch (err) {
|
|
247
|
+
return {
|
|
248
|
+
ok: false,
|
|
249
|
+
outcome: null,
|
|
250
|
+
intent: null,
|
|
251
|
+
failure: failure("verification_failed", messageOfThrown(err, MSG_VERIFY_THROWN), "verify", messageOfThrown(err, ""))
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
async function retrieveIntent(stripe, kind, clientSecret) {
|
|
256
|
+
const call = kind === "payment" ? stripe.retrievePaymentIntent : stripe.retrieveSetupIntent;
|
|
257
|
+
if (typeof call !== "function") return {
|
|
258
|
+
event: null,
|
|
259
|
+
failure: failure("unsupported", MSG_RETURN_FAILED, "return")
|
|
260
|
+
};
|
|
261
|
+
try {
|
|
262
|
+
const result = await call.call(stripe, clientSecret);
|
|
263
|
+
if (result.error) return {
|
|
264
|
+
event: null,
|
|
265
|
+
failure: failureFromError(result.error, "return")
|
|
266
|
+
};
|
|
267
|
+
const intent = kind === "payment" ? result.paymentIntent : result.setupIntent;
|
|
268
|
+
if (!intent) return {
|
|
269
|
+
event: null,
|
|
270
|
+
failure: failure("no_intent", MSG_RETURN_FAILED, "return")
|
|
271
|
+
};
|
|
272
|
+
return {
|
|
273
|
+
event: normalizeIntent(kind, intent),
|
|
274
|
+
failure: null
|
|
275
|
+
};
|
|
276
|
+
} catch (err) {
|
|
277
|
+
return {
|
|
278
|
+
event: null,
|
|
279
|
+
failure: failure("return_failed", MSG_RETURN_FAILED, "return", messageOfThrown(err, ""))
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
var StripePaymentService = class StripePaymentService {
|
|
284
|
+
constructor() {
|
|
285
|
+
this.loader = inject(STRIPE_LOADER);
|
|
286
|
+
this.defaults = inject(STRIPE_PAYMENT_DEFAULTS);
|
|
287
|
+
}
|
|
288
|
+
async load(connection = {}) {
|
|
289
|
+
const key = connection.publishableKey || this.defaults.publishableKey;
|
|
290
|
+
if (!key) throw new Error(MSG_KEY_MISSING);
|
|
291
|
+
const stripe = await this.loader(key, buildLoadOptions(connection.stripeAccount, connection.locale ?? this.defaults.locale, connection.options));
|
|
292
|
+
if (!stripe) throw new Error(MSG_LOAD_FAILED);
|
|
293
|
+
return stripe;
|
|
294
|
+
}
|
|
295
|
+
async verifyMicrodepositsForPayment(clientSecret, data, connection = {}) {
|
|
296
|
+
return this.verify("payment", clientSecret, data, connection);
|
|
297
|
+
}
|
|
298
|
+
async verifyMicrodepositsForSetup(clientSecret, data, connection = {}) {
|
|
299
|
+
return this.verify("setup", clientSecret, data, connection);
|
|
300
|
+
}
|
|
301
|
+
async handleReturn(options = {}) {
|
|
302
|
+
const fromUrl = options.clientSecret ? null : readStripeReturnParams(options.search ?? (typeof window === "undefined" ? "" : window.location.search));
|
|
303
|
+
const clientSecret = options.clientSecret ?? fromUrl?.clientSecret;
|
|
304
|
+
if (!clientSecret) return {
|
|
305
|
+
event: null,
|
|
306
|
+
failure: null
|
|
307
|
+
};
|
|
308
|
+
const kind = options.kind ?? fromUrl?.kind ?? "payment";
|
|
309
|
+
let stripe;
|
|
310
|
+
try {
|
|
311
|
+
stripe = await this.load(options);
|
|
312
|
+
} catch (err) {
|
|
313
|
+
return {
|
|
314
|
+
event: null,
|
|
315
|
+
failure: failure("load_error", messageOfThrown(err, MSG_LOAD_FAILED), "load", messageOfThrown(err, ""))
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
return retrieveIntent(stripe, kind, clientSecret);
|
|
319
|
+
}
|
|
320
|
+
async verify(flow, clientSecret, data, connection) {
|
|
321
|
+
let stripe;
|
|
322
|
+
try {
|
|
323
|
+
stripe = await this.load(connection);
|
|
324
|
+
} catch (err) {
|
|
325
|
+
return {
|
|
326
|
+
ok: false,
|
|
327
|
+
outcome: null,
|
|
328
|
+
intent: null,
|
|
329
|
+
failure: failure("load_error", messageOfThrown(err, MSG_LOAD_FAILED), "load", messageOfThrown(err, ""))
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
return verifyMicrodeposits(stripe, flow, clientSecret, data);
|
|
333
|
+
}
|
|
334
|
+
static {
|
|
335
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
336
|
+
minVersion: "12.0.0",
|
|
337
|
+
version: "22.2.2",
|
|
338
|
+
ngImport: i0,
|
|
339
|
+
type: StripePaymentService,
|
|
340
|
+
deps: [],
|
|
341
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
static {
|
|
345
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
346
|
+
minVersion: "12.0.0",
|
|
347
|
+
version: "22.2.2",
|
|
348
|
+
ngImport: i0,
|
|
349
|
+
type: StripePaymentService,
|
|
350
|
+
providedIn: "root"
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
355
|
+
minVersion: "12.0.0",
|
|
356
|
+
version: "22.2.2",
|
|
357
|
+
ngImport: i0,
|
|
358
|
+
type: StripePaymentService,
|
|
359
|
+
decorators: [{
|
|
360
|
+
type: Injectable,
|
|
361
|
+
args: [{ providedIn: "root" }]
|
|
362
|
+
}]
|
|
363
|
+
});
|
|
364
|
+
const TOKENS = [
|
|
365
|
+
["--ui-stripe-color-primary", "colorPrimary"],
|
|
366
|
+
["--ui-stripe-color-background", "colorBackground"],
|
|
367
|
+
["--ui-stripe-color-text", "colorText"],
|
|
368
|
+
["--ui-stripe-color-danger", "colorDanger"],
|
|
369
|
+
["--ui-stripe-font-family", "fontFamily"],
|
|
370
|
+
["--ui-stripe-border-radius", "borderRadius"],
|
|
371
|
+
["--ui-stripe-font-size-base", "fontSizeBase"]
|
|
372
|
+
];
|
|
373
|
+
function isDarkPage(doc) {
|
|
374
|
+
const forced = doc.documentElement.getAttribute("data-theme");
|
|
375
|
+
if (forced === "dark") return true;
|
|
376
|
+
if (forced === "light") return false;
|
|
377
|
+
try {
|
|
378
|
+
return !!doc.defaultView?.matchMedia?.("(prefers-color-scheme: dark)").matches;
|
|
379
|
+
} catch {
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
function readStripeAppearance(doc, element = doc.documentElement) {
|
|
384
|
+
const view = doc.defaultView;
|
|
385
|
+
const variables = {};
|
|
386
|
+
if (view) {
|
|
387
|
+
const style = view.getComputedStyle(element);
|
|
388
|
+
for (const [token, variable] of TOKENS) {
|
|
389
|
+
const value = style.getPropertyValue(token).trim();
|
|
390
|
+
if (value) variables[variable] = value;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
return {
|
|
394
|
+
theme: isDarkPage(doc) ? "night" : "stripe",
|
|
395
|
+
...Object.keys(variables).length ? { variables } : {}
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
const STRIPE_A11Y_MESSAGES = {
|
|
399
|
+
loading: "Loading payment form",
|
|
400
|
+
savingMethod: "Saving payment method",
|
|
401
|
+
processingPayment: "Processing payment",
|
|
402
|
+
methodSaved: "Payment method saved",
|
|
403
|
+
paymentReceived: "Payment received",
|
|
404
|
+
paymentProcessing: "Payment is processing",
|
|
405
|
+
paymentAuthorized: "Payment authorized",
|
|
406
|
+
verificationNeeded: "Bank account added. It needs to be verified with small deposits.",
|
|
407
|
+
actionRequired: "Further action is required to complete the payment"
|
|
408
|
+
};
|
|
409
|
+
const STRIPE_ACH_NOTICE = "Signing in to your bank account lets you pay right away. Entering your routing and account numbers instead requires verification with two small deposits, which typically take a couple of days to arrive in your account.";
|
|
410
|
+
let nextId = 0;
|
|
411
|
+
const jsonEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
412
|
+
var StripePaymentComponent = class StripePaymentComponent {
|
|
413
|
+
constructor() {
|
|
414
|
+
this.loader = inject(STRIPE_LOADER);
|
|
415
|
+
this.defaults = inject(STRIPE_PAYMENT_DEFAULTS);
|
|
416
|
+
this.doc = inject(DOCUMENT);
|
|
417
|
+
this.isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
418
|
+
this.host = inject(ElementRef);
|
|
419
|
+
this.mode = input("payment", ...ngDevMode ? [{ debugName: "mode" }] : /* istanbul ignore next */ []);
|
|
420
|
+
this.publishableKey = input(null, ...ngDevMode ? [{ debugName: "publishableKey" }] : /* istanbul ignore next */ []);
|
|
421
|
+
this.clientSecret = input(null, ...ngDevMode ? [{ debugName: "clientSecret" }] : /* istanbul ignore next */ []);
|
|
422
|
+
this.deferred = input(null, ...ngDevMode ? [{ debugName: "deferred" }] : /* istanbul ignore next */ []);
|
|
423
|
+
this.createIntent = input(null, ...ngDevMode ? [{ debugName: "createIntent" }] : /* istanbul ignore next */ []);
|
|
424
|
+
this.stripeAccount = input(null, ...ngDevMode ? [{ debugName: "stripeAccount" }] : /* istanbul ignore next */ []);
|
|
425
|
+
this.locale = input(null, ...ngDevMode ? [{ debugName: "locale" }] : /* istanbul ignore next */ []);
|
|
426
|
+
this.stripeOptions = input(null, ...ngDevMode ? [{ debugName: "stripeOptions" }] : /* istanbul ignore next */ []);
|
|
427
|
+
this.paymentMethodTypes = input(null, ...ngDevMode ? [{ debugName: "paymentMethodTypes" }] : /* istanbul ignore next */ []);
|
|
428
|
+
this.elementsOptions = input(null, ...ngDevMode ? [{ debugName: "elementsOptions" }] : /* istanbul ignore next */ []);
|
|
429
|
+
this.layout = input("tabs", ...ngDevMode ? [{ debugName: "layout" }] : /* istanbul ignore next */ []);
|
|
430
|
+
this.paymentMethodOrder = input(null, ...ngDevMode ? [{ debugName: "paymentMethodOrder" }] : /* istanbul ignore next */ []);
|
|
431
|
+
this.wallets = input(null, ...ngDevMode ? [{ debugName: "wallets" }] : /* istanbul ignore next */ []);
|
|
432
|
+
this.fields = input(null, ...ngDevMode ? [{ debugName: "fields" }] : /* istanbul ignore next */ []);
|
|
433
|
+
this.defaultValues = input(null, ...ngDevMode ? [{ debugName: "defaultValues" }] : /* istanbul ignore next */ []);
|
|
434
|
+
this.business = input(null, ...ngDevMode ? [{ debugName: "business" }] : /* istanbul ignore next */ []);
|
|
435
|
+
this.terms = input(null, ...ngDevMode ? [{ debugName: "terms" }] : /* istanbul ignore next */ []);
|
|
436
|
+
this.paymentElementOptions = input(null, ...ngDevMode ? [{ debugName: "paymentElementOptions" }] : /* istanbul ignore next */ []);
|
|
437
|
+
this.appearance = input(null, ...ngDevMode ? [{ debugName: "appearance" }] : /* istanbul ignore next */ []);
|
|
438
|
+
this.appearanceFromTokens = input(false, ...ngDevMode ? [{ debugName: "appearanceFromTokens" }] : /* istanbul ignore next */ []);
|
|
439
|
+
this.returnUrl = input(void 0, ...ngDevMode ? [{ debugName: "returnUrl" }] : /* istanbul ignore next */ []);
|
|
440
|
+
this.billingDetails = input(null, ...ngDevMode ? [{ debugName: "billingDetails" }] : /* istanbul ignore next */ []);
|
|
441
|
+
this.confirmParams = input(null, ...ngDevMode ? [{ debugName: "confirmParams" }] : /* istanbul ignore next */ []);
|
|
442
|
+
this.redirect = input("if_required", ...ngDevMode ? [{ debugName: "redirect" }] : /* istanbul ignore next */ []);
|
|
443
|
+
this.submitBeforeConfirm = input(null, ...ngDevMode ? [{ debugName: "submitBeforeConfirm" }] : /* istanbul ignore next */ []);
|
|
444
|
+
this.autoHandleCardAction = input(false, ...ngDevMode ? [{ debugName: "autoHandleCardAction" }] : /* istanbul ignore next */ []);
|
|
445
|
+
this.submitLabel = input("", ...ngDevMode ? [{ debugName: "submitLabel" }] : /* istanbul ignore next */ []);
|
|
446
|
+
this.showSubmit = input(true, ...ngDevMode ? [{ debugName: "showSubmit" }] : /* istanbul ignore next */ []);
|
|
447
|
+
this.disabled = input(false, ...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
|
|
448
|
+
this.pending = input(false, ...ngDevMode ? [{ debugName: "pending" }] : /* istanbul ignore next */ []);
|
|
449
|
+
this.label = input("Payment details", ...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
|
|
450
|
+
this.mountId = input("", ...ngDevMode ? [{ debugName: "mountId" }] : /* istanbul ignore next */ []);
|
|
451
|
+
this.mountClass = input("", ...ngDevMode ? [{ debugName: "mountClass" }] : /* istanbul ignore next */ []);
|
|
452
|
+
this.showAchNotice = input(true, ...ngDevMode ? [{ debugName: "showAchNotice" }] : /* istanbul ignore next */ []);
|
|
453
|
+
this.achNotice = input(STRIPE_ACH_NOTICE, ...ngDevMode ? [{ debugName: "achNotice" }] : /* istanbul ignore next */ []);
|
|
454
|
+
this.achNoticeTestId = input("stripe-ach-notice", ...ngDevMode ? [{ debugName: "achNoticeTestId" }] : /* istanbul ignore next */ []);
|
|
455
|
+
this.initialPaymentMethodType = input("card", ...ngDevMode ? [{ debugName: "initialPaymentMethodType" }] : /* istanbul ignore next */ []);
|
|
456
|
+
this.showErrors = input(true, ...ngDevMode ? [{ debugName: "showErrors" }] : /* istanbul ignore next */ []);
|
|
457
|
+
this.errorDisplay = input("friendly", ...ngDevMode ? [{ debugName: "errorDisplay" }] : /* istanbul ignore next */ []);
|
|
458
|
+
this.errorDisplayByStage = input(null, ...ngDevMode ? [{ debugName: "errorDisplayByStage" }] : /* istanbul ignore next */ []);
|
|
459
|
+
this.errorFallback = input("", ...ngDevMode ? [{ debugName: "errorFallback" }] : /* istanbul ignore next */ []);
|
|
460
|
+
this.errorFallbackByStage = input(null, ...ngDevMode ? [{ debugName: "errorFallbackByStage" }] : /* istanbul ignore next */ []);
|
|
461
|
+
this.errorMessages = input(null, ...ngDevMode ? [{ debugName: "errorMessages" }] : /* istanbul ignore next */ []);
|
|
462
|
+
this.loadErrorMessage = input("Failed to load the payment form. Please try again.", ...ngDevMode ? [{ debugName: "loadErrorMessage" }] : /* istanbul ignore next */ []);
|
|
463
|
+
this.a11yMessages = input(null, ...ngDevMode ? [{ debugName: "a11yMessages" }] : /* istanbul ignore next */ []);
|
|
464
|
+
this.ready = output();
|
|
465
|
+
this.paymentMethodTypeChange = output();
|
|
466
|
+
this.elementChange = output();
|
|
467
|
+
this.confirmed = output();
|
|
468
|
+
this.failed = output();
|
|
469
|
+
this.loadError = output();
|
|
470
|
+
this.loading = signal(false, ...ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []);
|
|
471
|
+
this.isReady = signal(false, ...ngDevMode ? [{ debugName: "isReady" }] : /* istanbul ignore next */ []);
|
|
472
|
+
this.submitting = signal(false, ...ngDevMode ? [{ debugName: "submitting" }] : /* istanbul ignore next */ []);
|
|
473
|
+
this.complete = signal(false, ...ngDevMode ? [{ debugName: "complete" }] : /* istanbul ignore next */ []);
|
|
474
|
+
this.selectedType = signal(null, ...ngDevMode ? [{ debugName: "selectedType" }] : /* istanbul ignore next */ []);
|
|
475
|
+
this.errorText = signal("", ...ngDevMode ? [{ debugName: "errorText" }] : /* istanbul ignore next */ []);
|
|
476
|
+
this.loadErrorText = signal("", ...ngDevMode ? [{ debugName: "loadErrorText" }] : /* istanbul ignore next */ []);
|
|
477
|
+
this.announcement = signal("", ...ngDevMode ? [{ debugName: "announcement" }] : /* istanbul ignore next */ []);
|
|
478
|
+
this.errorId = `ui-stripe-error-${nextId++}`;
|
|
479
|
+
this.mountRef = viewChild("mount", ...ngDevMode ? [{ debugName: "mountRef" }] : /* istanbul ignore next */ []);
|
|
480
|
+
this.mountHidden = computed(() => this.loading() || this.pending() || !!this.loadErrorText(), ...ngDevMode ? [{ debugName: "mountHidden" }] : /* istanbul ignore next */ []);
|
|
481
|
+
this.achNoticeVisible = computed(() => this.showAchNotice() && this.selectedType() === "us_bank_account", ...ngDevMode ? [{ debugName: "achNoticeVisible" }] : /* istanbul ignore next */ []);
|
|
482
|
+
this.effectiveSubmitLabel = computed(() => this.submitLabel() || (this.mode() === "setup" ? "Save payment method" : "Pay"), ...ngDevMode ? [{ debugName: "effectiveSubmitLabel" }] : /* istanbul ignore next */ []);
|
|
483
|
+
this.submitDisabled = computed(() => this.disabled() || this.loading() || this.pending() || !this.isReady() || !!this.loadErrorText(), ...ngDevMode ? [{ debugName: "submitDisabled" }] : /* istanbul ignore next */ []);
|
|
484
|
+
this.messages = computed(() => {
|
|
485
|
+
const given = Object.fromEntries(Object.entries(this.a11yMessages() ?? {}).filter(([, text]) => typeof text === "string"));
|
|
486
|
+
return {
|
|
487
|
+
...STRIPE_A11Y_MESSAGES,
|
|
488
|
+
...given
|
|
489
|
+
};
|
|
490
|
+
}, ...ngDevMode ? [{ debugName: "messages" }] : /* istanbul ignore next */ []);
|
|
491
|
+
this.statusText = computed(() => {
|
|
492
|
+
if (this.loading()) return this.messages().loading;
|
|
493
|
+
if (this.submitting()) return this.mode() === "setup" ? this.messages().savingMethod : this.messages().processingPayment;
|
|
494
|
+
return this.announcement();
|
|
495
|
+
}, ...ngDevMode ? [{ debugName: "statusText" }] : /* istanbul ignore next */ []);
|
|
496
|
+
this.connection = computed(() => {
|
|
497
|
+
return {
|
|
498
|
+
key: this.publishableKey() || this.defaults.publishableKey || "",
|
|
499
|
+
options: buildLoadOptions(this.stripeAccount(), this.locale() ?? this.defaults.locale, this.stripeOptions())
|
|
500
|
+
};
|
|
501
|
+
}, {
|
|
502
|
+
...ngDevMode ? { debugName: "connection" } : /* istanbul ignore next */ {},
|
|
503
|
+
equal: jsonEqual
|
|
504
|
+
});
|
|
505
|
+
this.elementsConfig = computed(() => {
|
|
506
|
+
const secret = this.clientSecret();
|
|
507
|
+
const deferred = this.deferred();
|
|
508
|
+
let options;
|
|
509
|
+
if (secret) options = { clientSecret: secret };
|
|
510
|
+
else if (deferred) options = {
|
|
511
|
+
mode: deferred.mode ?? this.mode(),
|
|
512
|
+
currency: deferred.currency,
|
|
513
|
+
...deferred.setupFutureUsage ? { setup_future_usage: deferred.setupFutureUsage } : {},
|
|
514
|
+
...deferred.captureMethod ? { capture_method: deferred.captureMethod } : {},
|
|
515
|
+
...deferred.onBehalfOf ? { on_behalf_of: deferred.onBehalfOf } : {},
|
|
516
|
+
...this.paymentMethodTypes() ? { payment_method_types: this.paymentMethodTypes() } : {}
|
|
517
|
+
};
|
|
518
|
+
else return null;
|
|
519
|
+
const appearance = this.appearance();
|
|
520
|
+
if (appearance) options["appearance"] = appearance;
|
|
521
|
+
return {
|
|
522
|
+
...options,
|
|
523
|
+
...this.elementsOptions() ?? {}
|
|
524
|
+
};
|
|
525
|
+
}, {
|
|
526
|
+
...ngDevMode ? { debugName: "elementsConfig" } : /* istanbul ignore next */ {},
|
|
527
|
+
equal: jsonEqual
|
|
528
|
+
});
|
|
529
|
+
this.elementConfig = computed(() => {
|
|
530
|
+
const options = {};
|
|
531
|
+
const layout = this.layout();
|
|
532
|
+
if (layout) options["layout"] = layout;
|
|
533
|
+
if (this.paymentMethodOrder()) options["paymentMethodOrder"] = this.paymentMethodOrder();
|
|
534
|
+
if (this.wallets()) options["wallets"] = this.wallets();
|
|
535
|
+
if (this.fields()) options["fields"] = this.fields();
|
|
536
|
+
if (this.business()) options["business"] = this.business();
|
|
537
|
+
if (this.terms()) options["terms"] = this.terms();
|
|
538
|
+
return {
|
|
539
|
+
...options,
|
|
540
|
+
...this.paymentElementOptions() ?? {}
|
|
541
|
+
};
|
|
542
|
+
}, {
|
|
543
|
+
...ngDevMode ? { debugName: "elementConfig" } : /* istanbul ignore next */ {},
|
|
544
|
+
equal: jsonEqual
|
|
545
|
+
});
|
|
546
|
+
this.stripe = null;
|
|
547
|
+
this.stripeSignature = "";
|
|
548
|
+
this.elements = null;
|
|
549
|
+
this.element = null;
|
|
550
|
+
this.generation = 0;
|
|
551
|
+
this.lastType = null;
|
|
552
|
+
this.lastFailure = null;
|
|
553
|
+
this.destroyed = false;
|
|
554
|
+
this.appliedDefaultValues = "";
|
|
555
|
+
this.appliedDisabled = false;
|
|
556
|
+
effect(() => {
|
|
557
|
+
const mount = this.mountRef();
|
|
558
|
+
const connection = this.connection();
|
|
559
|
+
const elements = this.elementsConfig();
|
|
560
|
+
const element = this.elementConfig();
|
|
561
|
+
if (!mount) return;
|
|
562
|
+
untracked(() => {
|
|
563
|
+
this.init(mount.nativeElement, connection, elements, element);
|
|
564
|
+
});
|
|
565
|
+
});
|
|
566
|
+
effect(() => {
|
|
567
|
+
const amount = this.deferred()?.amount;
|
|
568
|
+
untracked(() => {
|
|
569
|
+
if (amount !== void 0 && this.lastAmount !== void 0 && amount !== this.lastAmount && this.elements?.update) this.elements.update({ amount });
|
|
570
|
+
this.lastAmount = amount;
|
|
571
|
+
});
|
|
572
|
+
});
|
|
573
|
+
effect(() => {
|
|
574
|
+
const defaultValues = this.defaultValues();
|
|
575
|
+
untracked(() => this.applyDefaultValues(defaultValues));
|
|
576
|
+
});
|
|
577
|
+
effect(() => {
|
|
578
|
+
const disabled = this.disabled();
|
|
579
|
+
untracked(() => this.applyDisabled(disabled));
|
|
580
|
+
});
|
|
581
|
+
inject(DestroyRef).onDestroy(() => {
|
|
582
|
+
this.destroyed = true;
|
|
583
|
+
this.generation++;
|
|
584
|
+
this.disposeElements();
|
|
585
|
+
this.stripe = null;
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
async confirm(options = {}) {
|
|
589
|
+
if (this.submitting() || this.disabled()) return null;
|
|
590
|
+
const stripe = this.stripe;
|
|
591
|
+
const elements = this.elements;
|
|
592
|
+
if (!stripe || !elements) {
|
|
593
|
+
this.fail(failure("not_initialized", MSG_NOT_INITIALIZED, "submit"));
|
|
594
|
+
return null;
|
|
595
|
+
}
|
|
596
|
+
this.submitting.set(true);
|
|
597
|
+
this.errorText.set("");
|
|
598
|
+
this.announcement.set("");
|
|
599
|
+
let stage = "submit";
|
|
600
|
+
try {
|
|
601
|
+
const mode = this.mode();
|
|
602
|
+
const existing = options.useExistingIntent === true;
|
|
603
|
+
const deferred = !existing && !this.clientSecret() && !!this.deferred();
|
|
604
|
+
if (!existing && (this.submitBeforeConfirm() ?? deferred)) {
|
|
605
|
+
const { error } = await elements.submit();
|
|
606
|
+
if (error) {
|
|
607
|
+
this.fail(failureFromError(error, "submit", this.errorOptions("submit")));
|
|
608
|
+
return null;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
let secret = existing ? options.clientSecret : void 0;
|
|
612
|
+
if (deferred) {
|
|
613
|
+
stage = "intent";
|
|
614
|
+
const create = this.createIntent();
|
|
615
|
+
if (!create) {
|
|
616
|
+
this.fail(failure("no_intent_factory", MSG_INTENT_FAILED, "intent"));
|
|
617
|
+
return null;
|
|
618
|
+
}
|
|
619
|
+
try {
|
|
620
|
+
const created = await create({ mode });
|
|
621
|
+
secret = typeof created === "string" ? created : created?.clientSecret;
|
|
622
|
+
} catch (err) {
|
|
623
|
+
this.fail(failure("intent_creation_failed", messageOfThrown(err, STRIPE_DEFAULT_ERROR_MESSAGE), "intent", messageOfThrown(err, "")));
|
|
624
|
+
return null;
|
|
625
|
+
}
|
|
626
|
+
if (!secret) {
|
|
627
|
+
this.fail(failure("intent_creation_failed", MSG_INTENT_FAILED, "intent"));
|
|
628
|
+
return null;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
stage = "confirm";
|
|
632
|
+
const confirmParams = this.buildConfirmParams();
|
|
633
|
+
const params = {
|
|
634
|
+
elements,
|
|
635
|
+
...secret ? { clientSecret: secret } : {},
|
|
636
|
+
...confirmParams ? { confirmParams } : {},
|
|
637
|
+
redirect: this.redirect()
|
|
638
|
+
};
|
|
639
|
+
const result = mode === "setup" ? await stripe.confirmSetup(params) : await stripe.confirmPayment(params);
|
|
640
|
+
if (result.error) {
|
|
641
|
+
this.fail(failureFromError(result.error, "confirm", this.errorOptions("confirm")));
|
|
642
|
+
return null;
|
|
643
|
+
}
|
|
644
|
+
const intent = mode === "setup" ? result.setupIntent : result.paymentIntent;
|
|
645
|
+
if (!intent) {
|
|
646
|
+
this.fail(failure("not_completed", mode === "setup" ? "Payment method setup was incomplete. Please try again." : MSG_NOT_COMPLETED, "result"));
|
|
647
|
+
return null;
|
|
648
|
+
}
|
|
649
|
+
let event = normalizeIntent(mode, intent);
|
|
650
|
+
if (mode === "setup" && !event.paymentMethodId) {
|
|
651
|
+
this.fail(failure("no_payment_method", MSG_NO_PAYMENT_METHOD, "result"));
|
|
652
|
+
return null;
|
|
653
|
+
}
|
|
654
|
+
if (mode === "payment" && event.outcome === "requires_action" && this.autoHandleCardAction()) {
|
|
655
|
+
stage = "action";
|
|
656
|
+
const handled = await this.runCardAction(stripe, intent.client_secret);
|
|
657
|
+
if (!handled) return null;
|
|
658
|
+
event = handled;
|
|
659
|
+
}
|
|
660
|
+
return this.finish(event);
|
|
661
|
+
} catch (err) {
|
|
662
|
+
this.fail(this.thrownFailure(err, stage));
|
|
663
|
+
return null;
|
|
664
|
+
} finally {
|
|
665
|
+
this.submitting.set(false);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
async handleNextAction(clientSecret) {
|
|
669
|
+
if (this.submitting()) return null;
|
|
670
|
+
const stripe = this.stripe;
|
|
671
|
+
if (!stripe) {
|
|
672
|
+
this.fail(failure("not_initialized", MSG_NOT_INITIALIZED, "action"));
|
|
673
|
+
return null;
|
|
674
|
+
}
|
|
675
|
+
this.submitting.set(true);
|
|
676
|
+
this.errorText.set("");
|
|
677
|
+
try {
|
|
678
|
+
const handled = await this.runCardAction(stripe, clientSecret);
|
|
679
|
+
return handled ? this.finish(handled) : null;
|
|
680
|
+
} catch (err) {
|
|
681
|
+
this.fail(this.thrownFailure(err, "action"));
|
|
682
|
+
return null;
|
|
683
|
+
} finally {
|
|
684
|
+
this.submitting.set(false);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
async fetchUpdates() {
|
|
688
|
+
const elements = this.elements;
|
|
689
|
+
if (!elements?.fetchUpdates) return failure("not_initialized", MSG_NOT_INITIALIZED, "submit");
|
|
690
|
+
try {
|
|
691
|
+
const { error } = await elements.fetchUpdates();
|
|
692
|
+
return error ? failureFromError(error, "confirm", this.errorOptions("confirm")) : null;
|
|
693
|
+
} catch (err) {
|
|
694
|
+
return this.thrownFailure(err, "confirm");
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
updateElements(options) {
|
|
698
|
+
this.elements?.update?.(options);
|
|
699
|
+
}
|
|
700
|
+
updatePaymentElement(options) {
|
|
701
|
+
this.element?.update?.(options);
|
|
702
|
+
}
|
|
703
|
+
destroyElements() {
|
|
704
|
+
this.disposeElements();
|
|
705
|
+
this.isReady.set(false);
|
|
706
|
+
}
|
|
707
|
+
async verifyMicrodepositsForPayment(clientSecret, data) {
|
|
708
|
+
return this.verifyWith("payment", clientSecret, data);
|
|
709
|
+
}
|
|
710
|
+
async verifyMicrodepositsForSetup(clientSecret, data) {
|
|
711
|
+
return this.verifyWith("setup", clientSecret, data);
|
|
712
|
+
}
|
|
713
|
+
async handleReturn(options = {}) {
|
|
714
|
+
const fromUrl = options.clientSecret ? null : readStripeReturnParams(options.search ?? this.doc.defaultView?.location.search ?? "");
|
|
715
|
+
const clientSecret = options.clientSecret ?? fromUrl?.clientSecret;
|
|
716
|
+
if (!clientSecret) return {
|
|
717
|
+
event: null,
|
|
718
|
+
failure: null
|
|
719
|
+
};
|
|
720
|
+
const kind = options.kind ?? fromUrl?.kind ?? this.mode();
|
|
721
|
+
let stripe;
|
|
722
|
+
try {
|
|
723
|
+
stripe = await this.ensureStripe();
|
|
724
|
+
} catch (err) {
|
|
725
|
+
const f = failure("load_error", messageOfThrown(err, MSG_LOAD_FAILED), "load", messageOfThrown(err, ""));
|
|
726
|
+
this.fail(f);
|
|
727
|
+
return {
|
|
728
|
+
event: null,
|
|
729
|
+
failure: f
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
const result = await retrieveIntent(stripe, kind, clientSecret);
|
|
733
|
+
if (result.failure) {
|
|
734
|
+
this.fail(result.failure);
|
|
735
|
+
return result;
|
|
736
|
+
}
|
|
737
|
+
if (result.event && !this.finish(result.event, true)) return {
|
|
738
|
+
event: null,
|
|
739
|
+
failure: this.lastFailure
|
|
740
|
+
};
|
|
741
|
+
return result;
|
|
742
|
+
}
|
|
743
|
+
errorOptions(stage) {
|
|
744
|
+
return {
|
|
745
|
+
display: this.errorDisplayByStage()?.[stage] ?? this.errorDisplay(),
|
|
746
|
+
overrides: this.errorMessages(),
|
|
747
|
+
...this.errorFallbackByStage()?.[stage] || this.errorFallback() ? { fallback: this.errorFallbackByStage()?.[stage] || this.errorFallback() } : {}
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
thrownFailure(err, stage) {
|
|
751
|
+
const e = err;
|
|
752
|
+
const error = {
|
|
753
|
+
...typeof e?.code === "string" ? { code: e.code } : {},
|
|
754
|
+
...typeof e?.type === "string" ? { type: e.type } : {},
|
|
755
|
+
...typeof e?.decline_code === "string" ? { decline_code: e.decline_code } : {},
|
|
756
|
+
...typeof e?.message === "string" && e.message ? { message: e.message } : {}
|
|
757
|
+
};
|
|
758
|
+
const code = stage === "submit" ? "submit_failed" : stage === "action" ? "action_failed" : "confirm_failed";
|
|
759
|
+
const { error: _raw, ...failed } = failureFromError(error, stage, this.errorOptions(stage));
|
|
760
|
+
return {
|
|
761
|
+
...failed,
|
|
762
|
+
code: error.code ?? code,
|
|
763
|
+
...stage === "action" ? { actionHandled: true } : {}
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
buildConfirmParams() {
|
|
767
|
+
const params = {};
|
|
768
|
+
const returnUrl = this.returnUrl();
|
|
769
|
+
if (returnUrl !== null) params["return_url"] = returnUrl ?? this.doc.defaultView?.location.href ?? "";
|
|
770
|
+
const billing = this.billingDetails();
|
|
771
|
+
if (billing) params["payment_method_data"] = { billing_details: billing };
|
|
772
|
+
Object.assign(params, this.confirmParams() ?? {});
|
|
773
|
+
return Object.keys(params).length ? params : null;
|
|
774
|
+
}
|
|
775
|
+
fail(f) {
|
|
776
|
+
const override = this.errorMessages()?.[f.code];
|
|
777
|
+
if (override) f = {
|
|
778
|
+
...f,
|
|
779
|
+
message: override.split("{status}").join(f.status ?? "")
|
|
780
|
+
};
|
|
781
|
+
this.lastFailure = f;
|
|
782
|
+
if (this.destroyed) return;
|
|
783
|
+
if (this.showErrors()) this.errorText.set(f.message);
|
|
784
|
+
this.announcement.set("");
|
|
785
|
+
this.failed.emit(f);
|
|
786
|
+
}
|
|
787
|
+
finish(event, fromReturn = false) {
|
|
788
|
+
const acted = {
|
|
789
|
+
...event.actionHandled ? { actionHandled: true } : {},
|
|
790
|
+
status: event.status
|
|
791
|
+
};
|
|
792
|
+
if (event.outcome === "requires_payment_method") {
|
|
793
|
+
this.fail({
|
|
794
|
+
...failure("requires_payment_method", MSG_REQUIRES_PAYMENT_METHOD, fromReturn ? "return" : "result"),
|
|
795
|
+
...acted
|
|
796
|
+
});
|
|
797
|
+
return null;
|
|
798
|
+
}
|
|
799
|
+
if (event.outcome === "canceled" || event.outcome === "unknown") {
|
|
800
|
+
this.fail({
|
|
801
|
+
...failure("not_completed", MSG_NOT_COMPLETED, fromReturn ? "return" : "result"),
|
|
802
|
+
...acted
|
|
803
|
+
});
|
|
804
|
+
return null;
|
|
805
|
+
}
|
|
806
|
+
if (this.destroyed) return event;
|
|
807
|
+
this.announcement.set(this.announce(event));
|
|
808
|
+
this.confirmed.emit(event);
|
|
809
|
+
return event;
|
|
810
|
+
}
|
|
811
|
+
announce(event) {
|
|
812
|
+
const m = this.messages();
|
|
813
|
+
switch (event.outcome) {
|
|
814
|
+
case "succeeded": return event.kind === "setup" ? m.methodSaved : m.paymentReceived;
|
|
815
|
+
case "processing": return m.paymentProcessing;
|
|
816
|
+
case "requires_capture": return m.paymentAuthorized;
|
|
817
|
+
case "requires_verification": return m.verificationNeeded;
|
|
818
|
+
default: return m.actionRequired;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
async runCardAction(stripe, clientSecret) {
|
|
822
|
+
const acted = { actionHandled: true };
|
|
823
|
+
if (!stripe.handleCardAction || !clientSecret) {
|
|
824
|
+
this.fail({
|
|
825
|
+
...failure("action_unavailable", MSG_AUTH_NOT_COMPLETED, "action"),
|
|
826
|
+
...acted
|
|
827
|
+
});
|
|
828
|
+
return null;
|
|
829
|
+
}
|
|
830
|
+
const { error, paymentIntent } = await stripe.handleCardAction(clientSecret);
|
|
831
|
+
if (error) {
|
|
832
|
+
this.fail({
|
|
833
|
+
...failureFromError(error, "action", {
|
|
834
|
+
...this.errorOptions("action"),
|
|
835
|
+
fallback: MSG_AUTH_FAILED
|
|
836
|
+
}),
|
|
837
|
+
...acted
|
|
838
|
+
});
|
|
839
|
+
return null;
|
|
840
|
+
}
|
|
841
|
+
if (!paymentIntent) {
|
|
842
|
+
this.fail({
|
|
843
|
+
...failure("action_incomplete", MSG_AUTH_NOT_COMPLETED, "action"),
|
|
844
|
+
...acted
|
|
845
|
+
});
|
|
846
|
+
return null;
|
|
847
|
+
}
|
|
848
|
+
const event = {
|
|
849
|
+
...normalizeIntent("payment", paymentIntent),
|
|
850
|
+
...acted
|
|
851
|
+
};
|
|
852
|
+
if (event.outcome === "requires_payment_method") {
|
|
853
|
+
this.fail({
|
|
854
|
+
...failure("authentication_failed", "Payment authentication failed. Please try a different payment method.", "action"),
|
|
855
|
+
...acted,
|
|
856
|
+
status: event.status
|
|
857
|
+
});
|
|
858
|
+
return null;
|
|
859
|
+
}
|
|
860
|
+
return event;
|
|
861
|
+
}
|
|
862
|
+
async ensureStripe() {
|
|
863
|
+
if (this.stripe) return this.stripe;
|
|
864
|
+
const { key, options } = this.connection();
|
|
865
|
+
if (!key) throw new Error(MSG_KEY_MISSING);
|
|
866
|
+
const stripe = await this.loader(key, options);
|
|
867
|
+
if (!stripe) throw new Error(MSG_LOAD_FAILED);
|
|
868
|
+
return stripe;
|
|
869
|
+
}
|
|
870
|
+
async verifyWith(flow, clientSecret, data) {
|
|
871
|
+
let stripe;
|
|
872
|
+
try {
|
|
873
|
+
stripe = await this.ensureStripe();
|
|
874
|
+
} catch (err) {
|
|
875
|
+
return {
|
|
876
|
+
ok: false,
|
|
877
|
+
outcome: null,
|
|
878
|
+
intent: null,
|
|
879
|
+
failure: failure("load_error", messageOfThrown(err, MSG_LOAD_FAILED), "load", messageOfThrown(err, ""))
|
|
880
|
+
};
|
|
881
|
+
}
|
|
882
|
+
return verifyMicrodeposits(stripe, flow, clientSecret, data);
|
|
883
|
+
}
|
|
884
|
+
disposeElements() {
|
|
885
|
+
const element = this.element;
|
|
886
|
+
this.element = null;
|
|
887
|
+
this.elements = null;
|
|
888
|
+
this.lastType = null;
|
|
889
|
+
this.selectedType.set(null);
|
|
890
|
+
this.complete.set(false);
|
|
891
|
+
if (element) try {
|
|
892
|
+
element.destroy();
|
|
893
|
+
} catch {}
|
|
894
|
+
}
|
|
895
|
+
loadFailed(message, stripeMessage) {
|
|
896
|
+
this.loading.set(false);
|
|
897
|
+
this.isReady.set(false);
|
|
898
|
+
this.loadErrorText.set(this.loadErrorMessage());
|
|
899
|
+
this.loadError.emit(failure("load_error", message, "load", stripeMessage));
|
|
900
|
+
}
|
|
901
|
+
async init(container, connection, elementsConfig, elementConfig) {
|
|
902
|
+
const generation = ++this.generation;
|
|
903
|
+
this.disposeElements();
|
|
904
|
+
this.isReady.set(false);
|
|
905
|
+
this.errorText.set("");
|
|
906
|
+
this.loadErrorText.set("");
|
|
907
|
+
this.announcement.set("");
|
|
908
|
+
if (!this.isBrowser || !elementsConfig) {
|
|
909
|
+
this.loading.set(false);
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
912
|
+
if (!connection.key) {
|
|
913
|
+
this.loadFailed(MSG_KEY_MISSING, "");
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
this.loading.set(true);
|
|
917
|
+
try {
|
|
918
|
+
const signature = JSON.stringify(connection);
|
|
919
|
+
if (!this.stripe || this.stripeSignature !== signature) {
|
|
920
|
+
this.stripe = null;
|
|
921
|
+
const stripe = await this.loader(connection.key, connection.options);
|
|
922
|
+
if (generation !== this.generation) return;
|
|
923
|
+
if (!stripe) {
|
|
924
|
+
this.loadFailed(MSG_LOAD_FAILED, "");
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
this.stripe = stripe;
|
|
928
|
+
this.stripeSignature = signature;
|
|
929
|
+
}
|
|
930
|
+
const options = { ...elementsConfig };
|
|
931
|
+
const deferred = this.deferred();
|
|
932
|
+
if (!options["clientSecret"] && deferred?.amount !== void 0 && options["amount"] === void 0) options["amount"] = deferred.amount;
|
|
933
|
+
this.lastAmount = deferred?.amount;
|
|
934
|
+
if (this.appearanceFromTokens() && !options["appearance"]) options["appearance"] = readStripeAppearance(this.doc, this.host.nativeElement);
|
|
935
|
+
const elements = this.stripe.elements(options);
|
|
936
|
+
const elementOptions = { ...elementConfig };
|
|
937
|
+
const defaultValues = this.defaultValues();
|
|
938
|
+
if (defaultValues) elementOptions["defaultValues"] = defaultValues;
|
|
939
|
+
if (this.disabled()) elementOptions["readOnly"] = true;
|
|
940
|
+
this.appliedDefaultValues = JSON.stringify(defaultValues ?? null);
|
|
941
|
+
this.appliedDisabled = this.disabled();
|
|
942
|
+
const element = elements.create("payment", elementOptions);
|
|
943
|
+
this.elements = elements;
|
|
944
|
+
this.element = element;
|
|
945
|
+
element.on("change", (event) => {
|
|
946
|
+
if (generation === this.generation) this.onChange(event);
|
|
947
|
+
});
|
|
948
|
+
element.on("ready", () => {
|
|
949
|
+
if (generation !== this.generation) return;
|
|
950
|
+
this.loading.set(false);
|
|
951
|
+
this.isReady.set(true);
|
|
952
|
+
this.applyDefaultValues(this.defaultValues());
|
|
953
|
+
this.applyDisabled(this.disabled());
|
|
954
|
+
this.ready.emit();
|
|
955
|
+
});
|
|
956
|
+
element.on("loaderror", (event) => {
|
|
957
|
+
if (generation !== this.generation) return;
|
|
958
|
+
const message = event?.error?.message || "Failed to load Stripe";
|
|
959
|
+
this.loadFailed(message, event?.error?.message ?? "");
|
|
960
|
+
});
|
|
961
|
+
element.mount(container);
|
|
962
|
+
} catch (err) {
|
|
963
|
+
if (generation !== this.generation) return;
|
|
964
|
+
this.loadFailed(messageOfThrown(err, MSG_LOAD_FAILED), messageOfThrown(err, ""));
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
applyDefaultValues(defaultValues) {
|
|
968
|
+
const signature = JSON.stringify(defaultValues ?? null);
|
|
969
|
+
if (!this.element?.update || !this.isReady() || signature === this.appliedDefaultValues) return;
|
|
970
|
+
this.appliedDefaultValues = signature;
|
|
971
|
+
this.element.update({ defaultValues: defaultValues ?? {} });
|
|
972
|
+
}
|
|
973
|
+
applyDisabled(disabled) {
|
|
974
|
+
if (!this.element?.update || !this.isReady() || disabled === this.appliedDisabled) return;
|
|
975
|
+
this.appliedDisabled = disabled;
|
|
976
|
+
this.element.update({ readOnly: disabled });
|
|
977
|
+
}
|
|
978
|
+
onChange(event) {
|
|
979
|
+
const type = event?.value?.type ?? null;
|
|
980
|
+
const complete = !!event?.complete;
|
|
981
|
+
this.complete.set(complete);
|
|
982
|
+
if (type) this.selectedType.set(type);
|
|
983
|
+
this.elementChange.emit({
|
|
984
|
+
complete,
|
|
985
|
+
empty: !!event?.empty,
|
|
986
|
+
type,
|
|
987
|
+
errorMessage: event?.error?.message ?? null
|
|
988
|
+
});
|
|
989
|
+
if (type && type !== (this.lastType ?? this.initialPaymentMethodType())) this.paymentMethodTypeChange.emit(type);
|
|
990
|
+
if (type) this.lastType = type;
|
|
991
|
+
}
|
|
992
|
+
static {
|
|
993
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
994
|
+
minVersion: "12.0.0",
|
|
995
|
+
version: "22.2.2",
|
|
996
|
+
ngImport: i0,
|
|
997
|
+
type: StripePaymentComponent,
|
|
998
|
+
deps: [],
|
|
999
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
1000
|
+
});
|
|
1001
|
+
}
|
|
1002
|
+
static {
|
|
1003
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
1004
|
+
minVersion: "17.0.0",
|
|
1005
|
+
version: "22.2.2",
|
|
1006
|
+
type: StripePaymentComponent,
|
|
1007
|
+
isStandalone: true,
|
|
1008
|
+
selector: "ui-stripe-payment",
|
|
1009
|
+
inputs: {
|
|
1010
|
+
mode: {
|
|
1011
|
+
classPropertyName: "mode",
|
|
1012
|
+
publicName: "mode",
|
|
1013
|
+
isSignal: true,
|
|
1014
|
+
isRequired: false,
|
|
1015
|
+
transformFunction: null
|
|
1016
|
+
},
|
|
1017
|
+
publishableKey: {
|
|
1018
|
+
classPropertyName: "publishableKey",
|
|
1019
|
+
publicName: "publishableKey",
|
|
1020
|
+
isSignal: true,
|
|
1021
|
+
isRequired: false,
|
|
1022
|
+
transformFunction: null
|
|
1023
|
+
},
|
|
1024
|
+
clientSecret: {
|
|
1025
|
+
classPropertyName: "clientSecret",
|
|
1026
|
+
publicName: "clientSecret",
|
|
1027
|
+
isSignal: true,
|
|
1028
|
+
isRequired: false,
|
|
1029
|
+
transformFunction: null
|
|
1030
|
+
},
|
|
1031
|
+
deferred: {
|
|
1032
|
+
classPropertyName: "deferred",
|
|
1033
|
+
publicName: "deferred",
|
|
1034
|
+
isSignal: true,
|
|
1035
|
+
isRequired: false,
|
|
1036
|
+
transformFunction: null
|
|
1037
|
+
},
|
|
1038
|
+
createIntent: {
|
|
1039
|
+
classPropertyName: "createIntent",
|
|
1040
|
+
publicName: "createIntent",
|
|
1041
|
+
isSignal: true,
|
|
1042
|
+
isRequired: false,
|
|
1043
|
+
transformFunction: null
|
|
1044
|
+
},
|
|
1045
|
+
stripeAccount: {
|
|
1046
|
+
classPropertyName: "stripeAccount",
|
|
1047
|
+
publicName: "stripeAccount",
|
|
1048
|
+
isSignal: true,
|
|
1049
|
+
isRequired: false,
|
|
1050
|
+
transformFunction: null
|
|
1051
|
+
},
|
|
1052
|
+
locale: {
|
|
1053
|
+
classPropertyName: "locale",
|
|
1054
|
+
publicName: "locale",
|
|
1055
|
+
isSignal: true,
|
|
1056
|
+
isRequired: false,
|
|
1057
|
+
transformFunction: null
|
|
1058
|
+
},
|
|
1059
|
+
stripeOptions: {
|
|
1060
|
+
classPropertyName: "stripeOptions",
|
|
1061
|
+
publicName: "stripeOptions",
|
|
1062
|
+
isSignal: true,
|
|
1063
|
+
isRequired: false,
|
|
1064
|
+
transformFunction: null
|
|
1065
|
+
},
|
|
1066
|
+
paymentMethodTypes: {
|
|
1067
|
+
classPropertyName: "paymentMethodTypes",
|
|
1068
|
+
publicName: "paymentMethodTypes",
|
|
1069
|
+
isSignal: true,
|
|
1070
|
+
isRequired: false,
|
|
1071
|
+
transformFunction: null
|
|
1072
|
+
},
|
|
1073
|
+
elementsOptions: {
|
|
1074
|
+
classPropertyName: "elementsOptions",
|
|
1075
|
+
publicName: "elementsOptions",
|
|
1076
|
+
isSignal: true,
|
|
1077
|
+
isRequired: false,
|
|
1078
|
+
transformFunction: null
|
|
1079
|
+
},
|
|
1080
|
+
layout: {
|
|
1081
|
+
classPropertyName: "layout",
|
|
1082
|
+
publicName: "layout",
|
|
1083
|
+
isSignal: true,
|
|
1084
|
+
isRequired: false,
|
|
1085
|
+
transformFunction: null
|
|
1086
|
+
},
|
|
1087
|
+
paymentMethodOrder: {
|
|
1088
|
+
classPropertyName: "paymentMethodOrder",
|
|
1089
|
+
publicName: "paymentMethodOrder",
|
|
1090
|
+
isSignal: true,
|
|
1091
|
+
isRequired: false,
|
|
1092
|
+
transformFunction: null
|
|
1093
|
+
},
|
|
1094
|
+
wallets: {
|
|
1095
|
+
classPropertyName: "wallets",
|
|
1096
|
+
publicName: "wallets",
|
|
1097
|
+
isSignal: true,
|
|
1098
|
+
isRequired: false,
|
|
1099
|
+
transformFunction: null
|
|
1100
|
+
},
|
|
1101
|
+
fields: {
|
|
1102
|
+
classPropertyName: "fields",
|
|
1103
|
+
publicName: "fields",
|
|
1104
|
+
isSignal: true,
|
|
1105
|
+
isRequired: false,
|
|
1106
|
+
transformFunction: null
|
|
1107
|
+
},
|
|
1108
|
+
defaultValues: {
|
|
1109
|
+
classPropertyName: "defaultValues",
|
|
1110
|
+
publicName: "defaultValues",
|
|
1111
|
+
isSignal: true,
|
|
1112
|
+
isRequired: false,
|
|
1113
|
+
transformFunction: null
|
|
1114
|
+
},
|
|
1115
|
+
business: {
|
|
1116
|
+
classPropertyName: "business",
|
|
1117
|
+
publicName: "business",
|
|
1118
|
+
isSignal: true,
|
|
1119
|
+
isRequired: false,
|
|
1120
|
+
transformFunction: null
|
|
1121
|
+
},
|
|
1122
|
+
terms: {
|
|
1123
|
+
classPropertyName: "terms",
|
|
1124
|
+
publicName: "terms",
|
|
1125
|
+
isSignal: true,
|
|
1126
|
+
isRequired: false,
|
|
1127
|
+
transformFunction: null
|
|
1128
|
+
},
|
|
1129
|
+
paymentElementOptions: {
|
|
1130
|
+
classPropertyName: "paymentElementOptions",
|
|
1131
|
+
publicName: "paymentElementOptions",
|
|
1132
|
+
isSignal: true,
|
|
1133
|
+
isRequired: false,
|
|
1134
|
+
transformFunction: null
|
|
1135
|
+
},
|
|
1136
|
+
appearance: {
|
|
1137
|
+
classPropertyName: "appearance",
|
|
1138
|
+
publicName: "appearance",
|
|
1139
|
+
isSignal: true,
|
|
1140
|
+
isRequired: false,
|
|
1141
|
+
transformFunction: null
|
|
1142
|
+
},
|
|
1143
|
+
appearanceFromTokens: {
|
|
1144
|
+
classPropertyName: "appearanceFromTokens",
|
|
1145
|
+
publicName: "appearanceFromTokens",
|
|
1146
|
+
isSignal: true,
|
|
1147
|
+
isRequired: false,
|
|
1148
|
+
transformFunction: null
|
|
1149
|
+
},
|
|
1150
|
+
returnUrl: {
|
|
1151
|
+
classPropertyName: "returnUrl",
|
|
1152
|
+
publicName: "returnUrl",
|
|
1153
|
+
isSignal: true,
|
|
1154
|
+
isRequired: false,
|
|
1155
|
+
transformFunction: null
|
|
1156
|
+
},
|
|
1157
|
+
billingDetails: {
|
|
1158
|
+
classPropertyName: "billingDetails",
|
|
1159
|
+
publicName: "billingDetails",
|
|
1160
|
+
isSignal: true,
|
|
1161
|
+
isRequired: false,
|
|
1162
|
+
transformFunction: null
|
|
1163
|
+
},
|
|
1164
|
+
confirmParams: {
|
|
1165
|
+
classPropertyName: "confirmParams",
|
|
1166
|
+
publicName: "confirmParams",
|
|
1167
|
+
isSignal: true,
|
|
1168
|
+
isRequired: false,
|
|
1169
|
+
transformFunction: null
|
|
1170
|
+
},
|
|
1171
|
+
redirect: {
|
|
1172
|
+
classPropertyName: "redirect",
|
|
1173
|
+
publicName: "redirect",
|
|
1174
|
+
isSignal: true,
|
|
1175
|
+
isRequired: false,
|
|
1176
|
+
transformFunction: null
|
|
1177
|
+
},
|
|
1178
|
+
submitBeforeConfirm: {
|
|
1179
|
+
classPropertyName: "submitBeforeConfirm",
|
|
1180
|
+
publicName: "submitBeforeConfirm",
|
|
1181
|
+
isSignal: true,
|
|
1182
|
+
isRequired: false,
|
|
1183
|
+
transformFunction: null
|
|
1184
|
+
},
|
|
1185
|
+
autoHandleCardAction: {
|
|
1186
|
+
classPropertyName: "autoHandleCardAction",
|
|
1187
|
+
publicName: "autoHandleCardAction",
|
|
1188
|
+
isSignal: true,
|
|
1189
|
+
isRequired: false,
|
|
1190
|
+
transformFunction: null
|
|
1191
|
+
},
|
|
1192
|
+
submitLabel: {
|
|
1193
|
+
classPropertyName: "submitLabel",
|
|
1194
|
+
publicName: "submitLabel",
|
|
1195
|
+
isSignal: true,
|
|
1196
|
+
isRequired: false,
|
|
1197
|
+
transformFunction: null
|
|
1198
|
+
},
|
|
1199
|
+
showSubmit: {
|
|
1200
|
+
classPropertyName: "showSubmit",
|
|
1201
|
+
publicName: "showSubmit",
|
|
1202
|
+
isSignal: true,
|
|
1203
|
+
isRequired: false,
|
|
1204
|
+
transformFunction: null
|
|
1205
|
+
},
|
|
1206
|
+
disabled: {
|
|
1207
|
+
classPropertyName: "disabled",
|
|
1208
|
+
publicName: "disabled",
|
|
1209
|
+
isSignal: true,
|
|
1210
|
+
isRequired: false,
|
|
1211
|
+
transformFunction: null
|
|
1212
|
+
},
|
|
1213
|
+
pending: {
|
|
1214
|
+
classPropertyName: "pending",
|
|
1215
|
+
publicName: "pending",
|
|
1216
|
+
isSignal: true,
|
|
1217
|
+
isRequired: false,
|
|
1218
|
+
transformFunction: null
|
|
1219
|
+
},
|
|
1220
|
+
label: {
|
|
1221
|
+
classPropertyName: "label",
|
|
1222
|
+
publicName: "label",
|
|
1223
|
+
isSignal: true,
|
|
1224
|
+
isRequired: false,
|
|
1225
|
+
transformFunction: null
|
|
1226
|
+
},
|
|
1227
|
+
mountId: {
|
|
1228
|
+
classPropertyName: "mountId",
|
|
1229
|
+
publicName: "mountId",
|
|
1230
|
+
isSignal: true,
|
|
1231
|
+
isRequired: false,
|
|
1232
|
+
transformFunction: null
|
|
1233
|
+
},
|
|
1234
|
+
mountClass: {
|
|
1235
|
+
classPropertyName: "mountClass",
|
|
1236
|
+
publicName: "mountClass",
|
|
1237
|
+
isSignal: true,
|
|
1238
|
+
isRequired: false,
|
|
1239
|
+
transformFunction: null
|
|
1240
|
+
},
|
|
1241
|
+
showAchNotice: {
|
|
1242
|
+
classPropertyName: "showAchNotice",
|
|
1243
|
+
publicName: "showAchNotice",
|
|
1244
|
+
isSignal: true,
|
|
1245
|
+
isRequired: false,
|
|
1246
|
+
transformFunction: null
|
|
1247
|
+
},
|
|
1248
|
+
achNotice: {
|
|
1249
|
+
classPropertyName: "achNotice",
|
|
1250
|
+
publicName: "achNotice",
|
|
1251
|
+
isSignal: true,
|
|
1252
|
+
isRequired: false,
|
|
1253
|
+
transformFunction: null
|
|
1254
|
+
},
|
|
1255
|
+
achNoticeTestId: {
|
|
1256
|
+
classPropertyName: "achNoticeTestId",
|
|
1257
|
+
publicName: "achNoticeTestId",
|
|
1258
|
+
isSignal: true,
|
|
1259
|
+
isRequired: false,
|
|
1260
|
+
transformFunction: null
|
|
1261
|
+
},
|
|
1262
|
+
initialPaymentMethodType: {
|
|
1263
|
+
classPropertyName: "initialPaymentMethodType",
|
|
1264
|
+
publicName: "initialPaymentMethodType",
|
|
1265
|
+
isSignal: true,
|
|
1266
|
+
isRequired: false,
|
|
1267
|
+
transformFunction: null
|
|
1268
|
+
},
|
|
1269
|
+
showErrors: {
|
|
1270
|
+
classPropertyName: "showErrors",
|
|
1271
|
+
publicName: "showErrors",
|
|
1272
|
+
isSignal: true,
|
|
1273
|
+
isRequired: false,
|
|
1274
|
+
transformFunction: null
|
|
1275
|
+
},
|
|
1276
|
+
errorDisplay: {
|
|
1277
|
+
classPropertyName: "errorDisplay",
|
|
1278
|
+
publicName: "errorDisplay",
|
|
1279
|
+
isSignal: true,
|
|
1280
|
+
isRequired: false,
|
|
1281
|
+
transformFunction: null
|
|
1282
|
+
},
|
|
1283
|
+
errorDisplayByStage: {
|
|
1284
|
+
classPropertyName: "errorDisplayByStage",
|
|
1285
|
+
publicName: "errorDisplayByStage",
|
|
1286
|
+
isSignal: true,
|
|
1287
|
+
isRequired: false,
|
|
1288
|
+
transformFunction: null
|
|
1289
|
+
},
|
|
1290
|
+
errorFallback: {
|
|
1291
|
+
classPropertyName: "errorFallback",
|
|
1292
|
+
publicName: "errorFallback",
|
|
1293
|
+
isSignal: true,
|
|
1294
|
+
isRequired: false,
|
|
1295
|
+
transformFunction: null
|
|
1296
|
+
},
|
|
1297
|
+
errorFallbackByStage: {
|
|
1298
|
+
classPropertyName: "errorFallbackByStage",
|
|
1299
|
+
publicName: "errorFallbackByStage",
|
|
1300
|
+
isSignal: true,
|
|
1301
|
+
isRequired: false,
|
|
1302
|
+
transformFunction: null
|
|
1303
|
+
},
|
|
1304
|
+
errorMessages: {
|
|
1305
|
+
classPropertyName: "errorMessages",
|
|
1306
|
+
publicName: "errorMessages",
|
|
1307
|
+
isSignal: true,
|
|
1308
|
+
isRequired: false,
|
|
1309
|
+
transformFunction: null
|
|
1310
|
+
},
|
|
1311
|
+
loadErrorMessage: {
|
|
1312
|
+
classPropertyName: "loadErrorMessage",
|
|
1313
|
+
publicName: "loadErrorMessage",
|
|
1314
|
+
isSignal: true,
|
|
1315
|
+
isRequired: false,
|
|
1316
|
+
transformFunction: null
|
|
1317
|
+
},
|
|
1318
|
+
a11yMessages: {
|
|
1319
|
+
classPropertyName: "a11yMessages",
|
|
1320
|
+
publicName: "a11yMessages",
|
|
1321
|
+
isSignal: true,
|
|
1322
|
+
isRequired: false,
|
|
1323
|
+
transformFunction: null
|
|
1324
|
+
}
|
|
1325
|
+
},
|
|
1326
|
+
outputs: {
|
|
1327
|
+
ready: "ready",
|
|
1328
|
+
paymentMethodTypeChange: "paymentMethodTypeChange",
|
|
1329
|
+
elementChange: "elementChange",
|
|
1330
|
+
confirmed: "confirmed",
|
|
1331
|
+
failed: "failed",
|
|
1332
|
+
loadError: "loadError"
|
|
1333
|
+
},
|
|
1334
|
+
host: { properties: { "attr.aria-busy": "loading() || submitting() ? \"true\" : null" } },
|
|
1335
|
+
viewQueries: [{
|
|
1336
|
+
propertyName: "mountRef",
|
|
1337
|
+
first: true,
|
|
1338
|
+
predicate: ["mount"],
|
|
1339
|
+
descendants: true,
|
|
1340
|
+
isSignal: true
|
|
1341
|
+
}],
|
|
1342
|
+
ngImport: i0,
|
|
1343
|
+
template: `
|
|
1344
|
+
<div class="sp">
|
|
1345
|
+
<div class="sp-sr" role="status" aria-live="polite" data-testid="stripe-status">{{ statusText() }}</div>
|
|
1346
|
+
@if (loading() || pending()) {
|
|
1347
|
+
<div class="sp-skeleton" data-testid="stripe-skeleton" aria-hidden="true">
|
|
1348
|
+
<ui-skeleton [height]="44" [mb]="10" />
|
|
1349
|
+
<ui-skeleton [height]="44" [mb]="10" />
|
|
1350
|
+
<ui-skeleton [height]="44" width="60%" />
|
|
1351
|
+
</div>
|
|
1352
|
+
}
|
|
1353
|
+
@if (loadErrorText(); as text) {
|
|
1354
|
+
<div class="sp-block" data-testid="stripe-load-error"><ui-alert variant="danger">{{ text }}</ui-alert></div>
|
|
1355
|
+
}
|
|
1356
|
+
<div #mount class="sp-mount" [attr.id]="mountId() || null" [class]="mountClass()" [class.sp-mount--hidden]="mountHidden()" [attr.aria-hidden]="mountHidden() ? 'true' : null" [attr.inert]="mountHidden() ? '' : null"
|
|
1357
|
+
role="group" [attr.aria-label]="label()" data-testid="stripe-mount"></div>
|
|
1358
|
+
@if (achNoticeVisible()) {
|
|
1359
|
+
<div class="sp-block" [attr.data-testid]="achNoticeTestId()"><ui-alert variant="info">{{ achNotice() }}</ui-alert></div>
|
|
1360
|
+
}
|
|
1361
|
+
@if (errorText(); as text) {
|
|
1362
|
+
<div class="sp-block" [id]="errorId" data-testid="stripe-error"><ui-alert variant="danger">{{ text }}</ui-alert></div>
|
|
1363
|
+
}
|
|
1364
|
+
@if (showSubmit()) {
|
|
1365
|
+
<div class="sp-actions">
|
|
1366
|
+
<ui-button variant="primary" type="button" [loading]="submitting()" [disabled]="submitDisabled()" [ariaDescribedBy]="errorText() ? errorId : undefined"
|
|
1367
|
+
data-testid="stripe-submit" (click)="confirm()">{{ effectiveSubmitLabel() }}</ui-button>
|
|
1368
|
+
</div>
|
|
1369
|
+
}
|
|
1370
|
+
</div>
|
|
1371
|
+
`,
|
|
1372
|
+
isInline: true,
|
|
1373
|
+
styles: [":host{display:block;min-width:0}.sp-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.sp-block{margin-top:12px}.sp-actions{margin-top:16px;display:flex;justify-content:flex-end}.sp{position:relative}.sp-mount--hidden{position:absolute;top:0;left:0;right:0;opacity:0;pointer-events:none}@media(max-width:480px){.sp-actions{display:block}.sp-actions ui-button{display:flex}.sp-actions ::ng-deep .btn{width:100%}}\n"],
|
|
1374
|
+
dependencies: [
|
|
1375
|
+
{
|
|
1376
|
+
kind: "component",
|
|
1377
|
+
type: AlertComponent,
|
|
1378
|
+
selector: "ui-alert",
|
|
1379
|
+
inputs: [
|
|
1380
|
+
"variant",
|
|
1381
|
+
"title",
|
|
1382
|
+
"dismissible",
|
|
1383
|
+
"quiet",
|
|
1384
|
+
"compact"
|
|
1385
|
+
],
|
|
1386
|
+
outputs: ["dismissed"]
|
|
1387
|
+
},
|
|
1388
|
+
{
|
|
1389
|
+
kind: "component",
|
|
1390
|
+
type: ButtonComponent,
|
|
1391
|
+
selector: "ui-button",
|
|
1392
|
+
inputs: [
|
|
1393
|
+
"variant",
|
|
1394
|
+
"routerLink",
|
|
1395
|
+
"queryParams",
|
|
1396
|
+
"href",
|
|
1397
|
+
"target",
|
|
1398
|
+
"rel",
|
|
1399
|
+
"color",
|
|
1400
|
+
"active",
|
|
1401
|
+
"size",
|
|
1402
|
+
"type",
|
|
1403
|
+
"disabled",
|
|
1404
|
+
"loading",
|
|
1405
|
+
"fullWidth",
|
|
1406
|
+
"ariaLabel",
|
|
1407
|
+
"ariaExpanded",
|
|
1408
|
+
"ariaPressed",
|
|
1409
|
+
"ariaDescribedBy",
|
|
1410
|
+
"modal-footer-left",
|
|
1411
|
+
"modal-footer-right"
|
|
1412
|
+
]
|
|
1413
|
+
},
|
|
1414
|
+
{
|
|
1415
|
+
kind: "component",
|
|
1416
|
+
type: SkeletonComponent,
|
|
1417
|
+
selector: "ui-skeleton",
|
|
1418
|
+
inputs: [
|
|
1419
|
+
"height",
|
|
1420
|
+
"width",
|
|
1421
|
+
"radius",
|
|
1422
|
+
"mb",
|
|
1423
|
+
"ariaLabel"
|
|
1424
|
+
]
|
|
1425
|
+
}
|
|
1426
|
+
],
|
|
1427
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1430
|
+
};
|
|
1431
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1432
|
+
minVersion: "12.0.0",
|
|
1433
|
+
version: "22.2.2",
|
|
1434
|
+
ngImport: i0,
|
|
1435
|
+
type: StripePaymentComponent,
|
|
1436
|
+
decorators: [{
|
|
1437
|
+
type: Component,
|
|
1438
|
+
args: [{
|
|
1439
|
+
selector: "ui-stripe-payment",
|
|
1440
|
+
standalone: true,
|
|
1441
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1442
|
+
imports: [
|
|
1443
|
+
AlertComponent,
|
|
1444
|
+
ButtonComponent,
|
|
1445
|
+
SkeletonComponent
|
|
1446
|
+
],
|
|
1447
|
+
host: { "[attr.aria-busy]": "loading() || submitting() ? \"true\" : null" },
|
|
1448
|
+
template: `
|
|
1449
|
+
<div class="sp">
|
|
1450
|
+
<div class="sp-sr" role="status" aria-live="polite" data-testid="stripe-status">{{ statusText() }}</div>
|
|
1451
|
+
@if (loading() || pending()) {
|
|
1452
|
+
<div class="sp-skeleton" data-testid="stripe-skeleton" aria-hidden="true">
|
|
1453
|
+
<ui-skeleton [height]="44" [mb]="10" />
|
|
1454
|
+
<ui-skeleton [height]="44" [mb]="10" />
|
|
1455
|
+
<ui-skeleton [height]="44" width="60%" />
|
|
1456
|
+
</div>
|
|
1457
|
+
}
|
|
1458
|
+
@if (loadErrorText(); as text) {
|
|
1459
|
+
<div class="sp-block" data-testid="stripe-load-error"><ui-alert variant="danger">{{ text }}</ui-alert></div>
|
|
1460
|
+
}
|
|
1461
|
+
<div #mount class="sp-mount" [attr.id]="mountId() || null" [class]="mountClass()" [class.sp-mount--hidden]="mountHidden()" [attr.aria-hidden]="mountHidden() ? 'true' : null" [attr.inert]="mountHidden() ? '' : null"
|
|
1462
|
+
role="group" [attr.aria-label]="label()" data-testid="stripe-mount"></div>
|
|
1463
|
+
@if (achNoticeVisible()) {
|
|
1464
|
+
<div class="sp-block" [attr.data-testid]="achNoticeTestId()"><ui-alert variant="info">{{ achNotice() }}</ui-alert></div>
|
|
1465
|
+
}
|
|
1466
|
+
@if (errorText(); as text) {
|
|
1467
|
+
<div class="sp-block" [id]="errorId" data-testid="stripe-error"><ui-alert variant="danger">{{ text }}</ui-alert></div>
|
|
1468
|
+
}
|
|
1469
|
+
@if (showSubmit()) {
|
|
1470
|
+
<div class="sp-actions">
|
|
1471
|
+
<ui-button variant="primary" type="button" [loading]="submitting()" [disabled]="submitDisabled()" [ariaDescribedBy]="errorText() ? errorId : undefined"
|
|
1472
|
+
data-testid="stripe-submit" (click)="confirm()">{{ effectiveSubmitLabel() }}</ui-button>
|
|
1473
|
+
</div>
|
|
1474
|
+
}
|
|
1475
|
+
</div>
|
|
1476
|
+
`,
|
|
1477
|
+
styles: [":host{display:block;min-width:0}.sp-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.sp-block{margin-top:12px}.sp-actions{margin-top:16px;display:flex;justify-content:flex-end}.sp{position:relative}.sp-mount--hidden{position:absolute;top:0;left:0;right:0;opacity:0;pointer-events:none}@media(max-width:480px){.sp-actions{display:block}.sp-actions ui-button{display:flex}.sp-actions ::ng-deep .btn{width:100%}}\n"]
|
|
1478
|
+
}]
|
|
1479
|
+
}],
|
|
1480
|
+
ctorParameters: () => [],
|
|
1481
|
+
propDecorators: {
|
|
1482
|
+
mode: [{
|
|
1483
|
+
type: i0.Input,
|
|
1484
|
+
args: [{
|
|
1485
|
+
isSignal: true,
|
|
1486
|
+
alias: "mode",
|
|
1487
|
+
required: false
|
|
1488
|
+
}]
|
|
1489
|
+
}],
|
|
1490
|
+
publishableKey: [{
|
|
1491
|
+
type: i0.Input,
|
|
1492
|
+
args: [{
|
|
1493
|
+
isSignal: true,
|
|
1494
|
+
alias: "publishableKey",
|
|
1495
|
+
required: false
|
|
1496
|
+
}]
|
|
1497
|
+
}],
|
|
1498
|
+
clientSecret: [{
|
|
1499
|
+
type: i0.Input,
|
|
1500
|
+
args: [{
|
|
1501
|
+
isSignal: true,
|
|
1502
|
+
alias: "clientSecret",
|
|
1503
|
+
required: false
|
|
1504
|
+
}]
|
|
1505
|
+
}],
|
|
1506
|
+
deferred: [{
|
|
1507
|
+
type: i0.Input,
|
|
1508
|
+
args: [{
|
|
1509
|
+
isSignal: true,
|
|
1510
|
+
alias: "deferred",
|
|
1511
|
+
required: false
|
|
1512
|
+
}]
|
|
1513
|
+
}],
|
|
1514
|
+
createIntent: [{
|
|
1515
|
+
type: i0.Input,
|
|
1516
|
+
args: [{
|
|
1517
|
+
isSignal: true,
|
|
1518
|
+
alias: "createIntent",
|
|
1519
|
+
required: false
|
|
1520
|
+
}]
|
|
1521
|
+
}],
|
|
1522
|
+
stripeAccount: [{
|
|
1523
|
+
type: i0.Input,
|
|
1524
|
+
args: [{
|
|
1525
|
+
isSignal: true,
|
|
1526
|
+
alias: "stripeAccount",
|
|
1527
|
+
required: false
|
|
1528
|
+
}]
|
|
1529
|
+
}],
|
|
1530
|
+
locale: [{
|
|
1531
|
+
type: i0.Input,
|
|
1532
|
+
args: [{
|
|
1533
|
+
isSignal: true,
|
|
1534
|
+
alias: "locale",
|
|
1535
|
+
required: false
|
|
1536
|
+
}]
|
|
1537
|
+
}],
|
|
1538
|
+
stripeOptions: [{
|
|
1539
|
+
type: i0.Input,
|
|
1540
|
+
args: [{
|
|
1541
|
+
isSignal: true,
|
|
1542
|
+
alias: "stripeOptions",
|
|
1543
|
+
required: false
|
|
1544
|
+
}]
|
|
1545
|
+
}],
|
|
1546
|
+
paymentMethodTypes: [{
|
|
1547
|
+
type: i0.Input,
|
|
1548
|
+
args: [{
|
|
1549
|
+
isSignal: true,
|
|
1550
|
+
alias: "paymentMethodTypes",
|
|
1551
|
+
required: false
|
|
1552
|
+
}]
|
|
1553
|
+
}],
|
|
1554
|
+
elementsOptions: [{
|
|
1555
|
+
type: i0.Input,
|
|
1556
|
+
args: [{
|
|
1557
|
+
isSignal: true,
|
|
1558
|
+
alias: "elementsOptions",
|
|
1559
|
+
required: false
|
|
1560
|
+
}]
|
|
1561
|
+
}],
|
|
1562
|
+
layout: [{
|
|
1563
|
+
type: i0.Input,
|
|
1564
|
+
args: [{
|
|
1565
|
+
isSignal: true,
|
|
1566
|
+
alias: "layout",
|
|
1567
|
+
required: false
|
|
1568
|
+
}]
|
|
1569
|
+
}],
|
|
1570
|
+
paymentMethodOrder: [{
|
|
1571
|
+
type: i0.Input,
|
|
1572
|
+
args: [{
|
|
1573
|
+
isSignal: true,
|
|
1574
|
+
alias: "paymentMethodOrder",
|
|
1575
|
+
required: false
|
|
1576
|
+
}]
|
|
1577
|
+
}],
|
|
1578
|
+
wallets: [{
|
|
1579
|
+
type: i0.Input,
|
|
1580
|
+
args: [{
|
|
1581
|
+
isSignal: true,
|
|
1582
|
+
alias: "wallets",
|
|
1583
|
+
required: false
|
|
1584
|
+
}]
|
|
1585
|
+
}],
|
|
1586
|
+
fields: [{
|
|
1587
|
+
type: i0.Input,
|
|
1588
|
+
args: [{
|
|
1589
|
+
isSignal: true,
|
|
1590
|
+
alias: "fields",
|
|
1591
|
+
required: false
|
|
1592
|
+
}]
|
|
1593
|
+
}],
|
|
1594
|
+
defaultValues: [{
|
|
1595
|
+
type: i0.Input,
|
|
1596
|
+
args: [{
|
|
1597
|
+
isSignal: true,
|
|
1598
|
+
alias: "defaultValues",
|
|
1599
|
+
required: false
|
|
1600
|
+
}]
|
|
1601
|
+
}],
|
|
1602
|
+
business: [{
|
|
1603
|
+
type: i0.Input,
|
|
1604
|
+
args: [{
|
|
1605
|
+
isSignal: true,
|
|
1606
|
+
alias: "business",
|
|
1607
|
+
required: false
|
|
1608
|
+
}]
|
|
1609
|
+
}],
|
|
1610
|
+
terms: [{
|
|
1611
|
+
type: i0.Input,
|
|
1612
|
+
args: [{
|
|
1613
|
+
isSignal: true,
|
|
1614
|
+
alias: "terms",
|
|
1615
|
+
required: false
|
|
1616
|
+
}]
|
|
1617
|
+
}],
|
|
1618
|
+
paymentElementOptions: [{
|
|
1619
|
+
type: i0.Input,
|
|
1620
|
+
args: [{
|
|
1621
|
+
isSignal: true,
|
|
1622
|
+
alias: "paymentElementOptions",
|
|
1623
|
+
required: false
|
|
1624
|
+
}]
|
|
1625
|
+
}],
|
|
1626
|
+
appearance: [{
|
|
1627
|
+
type: i0.Input,
|
|
1628
|
+
args: [{
|
|
1629
|
+
isSignal: true,
|
|
1630
|
+
alias: "appearance",
|
|
1631
|
+
required: false
|
|
1632
|
+
}]
|
|
1633
|
+
}],
|
|
1634
|
+
appearanceFromTokens: [{
|
|
1635
|
+
type: i0.Input,
|
|
1636
|
+
args: [{
|
|
1637
|
+
isSignal: true,
|
|
1638
|
+
alias: "appearanceFromTokens",
|
|
1639
|
+
required: false
|
|
1640
|
+
}]
|
|
1641
|
+
}],
|
|
1642
|
+
returnUrl: [{
|
|
1643
|
+
type: i0.Input,
|
|
1644
|
+
args: [{
|
|
1645
|
+
isSignal: true,
|
|
1646
|
+
alias: "returnUrl",
|
|
1647
|
+
required: false
|
|
1648
|
+
}]
|
|
1649
|
+
}],
|
|
1650
|
+
billingDetails: [{
|
|
1651
|
+
type: i0.Input,
|
|
1652
|
+
args: [{
|
|
1653
|
+
isSignal: true,
|
|
1654
|
+
alias: "billingDetails",
|
|
1655
|
+
required: false
|
|
1656
|
+
}]
|
|
1657
|
+
}],
|
|
1658
|
+
confirmParams: [{
|
|
1659
|
+
type: i0.Input,
|
|
1660
|
+
args: [{
|
|
1661
|
+
isSignal: true,
|
|
1662
|
+
alias: "confirmParams",
|
|
1663
|
+
required: false
|
|
1664
|
+
}]
|
|
1665
|
+
}],
|
|
1666
|
+
redirect: [{
|
|
1667
|
+
type: i0.Input,
|
|
1668
|
+
args: [{
|
|
1669
|
+
isSignal: true,
|
|
1670
|
+
alias: "redirect",
|
|
1671
|
+
required: false
|
|
1672
|
+
}]
|
|
1673
|
+
}],
|
|
1674
|
+
submitBeforeConfirm: [{
|
|
1675
|
+
type: i0.Input,
|
|
1676
|
+
args: [{
|
|
1677
|
+
isSignal: true,
|
|
1678
|
+
alias: "submitBeforeConfirm",
|
|
1679
|
+
required: false
|
|
1680
|
+
}]
|
|
1681
|
+
}],
|
|
1682
|
+
autoHandleCardAction: [{
|
|
1683
|
+
type: i0.Input,
|
|
1684
|
+
args: [{
|
|
1685
|
+
isSignal: true,
|
|
1686
|
+
alias: "autoHandleCardAction",
|
|
1687
|
+
required: false
|
|
1688
|
+
}]
|
|
1689
|
+
}],
|
|
1690
|
+
submitLabel: [{
|
|
1691
|
+
type: i0.Input,
|
|
1692
|
+
args: [{
|
|
1693
|
+
isSignal: true,
|
|
1694
|
+
alias: "submitLabel",
|
|
1695
|
+
required: false
|
|
1696
|
+
}]
|
|
1697
|
+
}],
|
|
1698
|
+
showSubmit: [{
|
|
1699
|
+
type: i0.Input,
|
|
1700
|
+
args: [{
|
|
1701
|
+
isSignal: true,
|
|
1702
|
+
alias: "showSubmit",
|
|
1703
|
+
required: false
|
|
1704
|
+
}]
|
|
1705
|
+
}],
|
|
1706
|
+
disabled: [{
|
|
1707
|
+
type: i0.Input,
|
|
1708
|
+
args: [{
|
|
1709
|
+
isSignal: true,
|
|
1710
|
+
alias: "disabled",
|
|
1711
|
+
required: false
|
|
1712
|
+
}]
|
|
1713
|
+
}],
|
|
1714
|
+
pending: [{
|
|
1715
|
+
type: i0.Input,
|
|
1716
|
+
args: [{
|
|
1717
|
+
isSignal: true,
|
|
1718
|
+
alias: "pending",
|
|
1719
|
+
required: false
|
|
1720
|
+
}]
|
|
1721
|
+
}],
|
|
1722
|
+
label: [{
|
|
1723
|
+
type: i0.Input,
|
|
1724
|
+
args: [{
|
|
1725
|
+
isSignal: true,
|
|
1726
|
+
alias: "label",
|
|
1727
|
+
required: false
|
|
1728
|
+
}]
|
|
1729
|
+
}],
|
|
1730
|
+
mountId: [{
|
|
1731
|
+
type: i0.Input,
|
|
1732
|
+
args: [{
|
|
1733
|
+
isSignal: true,
|
|
1734
|
+
alias: "mountId",
|
|
1735
|
+
required: false
|
|
1736
|
+
}]
|
|
1737
|
+
}],
|
|
1738
|
+
mountClass: [{
|
|
1739
|
+
type: i0.Input,
|
|
1740
|
+
args: [{
|
|
1741
|
+
isSignal: true,
|
|
1742
|
+
alias: "mountClass",
|
|
1743
|
+
required: false
|
|
1744
|
+
}]
|
|
1745
|
+
}],
|
|
1746
|
+
showAchNotice: [{
|
|
1747
|
+
type: i0.Input,
|
|
1748
|
+
args: [{
|
|
1749
|
+
isSignal: true,
|
|
1750
|
+
alias: "showAchNotice",
|
|
1751
|
+
required: false
|
|
1752
|
+
}]
|
|
1753
|
+
}],
|
|
1754
|
+
achNotice: [{
|
|
1755
|
+
type: i0.Input,
|
|
1756
|
+
args: [{
|
|
1757
|
+
isSignal: true,
|
|
1758
|
+
alias: "achNotice",
|
|
1759
|
+
required: false
|
|
1760
|
+
}]
|
|
1761
|
+
}],
|
|
1762
|
+
achNoticeTestId: [{
|
|
1763
|
+
type: i0.Input,
|
|
1764
|
+
args: [{
|
|
1765
|
+
isSignal: true,
|
|
1766
|
+
alias: "achNoticeTestId",
|
|
1767
|
+
required: false
|
|
1768
|
+
}]
|
|
1769
|
+
}],
|
|
1770
|
+
initialPaymentMethodType: [{
|
|
1771
|
+
type: i0.Input,
|
|
1772
|
+
args: [{
|
|
1773
|
+
isSignal: true,
|
|
1774
|
+
alias: "initialPaymentMethodType",
|
|
1775
|
+
required: false
|
|
1776
|
+
}]
|
|
1777
|
+
}],
|
|
1778
|
+
showErrors: [{
|
|
1779
|
+
type: i0.Input,
|
|
1780
|
+
args: [{
|
|
1781
|
+
isSignal: true,
|
|
1782
|
+
alias: "showErrors",
|
|
1783
|
+
required: false
|
|
1784
|
+
}]
|
|
1785
|
+
}],
|
|
1786
|
+
errorDisplay: [{
|
|
1787
|
+
type: i0.Input,
|
|
1788
|
+
args: [{
|
|
1789
|
+
isSignal: true,
|
|
1790
|
+
alias: "errorDisplay",
|
|
1791
|
+
required: false
|
|
1792
|
+
}]
|
|
1793
|
+
}],
|
|
1794
|
+
errorDisplayByStage: [{
|
|
1795
|
+
type: i0.Input,
|
|
1796
|
+
args: [{
|
|
1797
|
+
isSignal: true,
|
|
1798
|
+
alias: "errorDisplayByStage",
|
|
1799
|
+
required: false
|
|
1800
|
+
}]
|
|
1801
|
+
}],
|
|
1802
|
+
errorFallback: [{
|
|
1803
|
+
type: i0.Input,
|
|
1804
|
+
args: [{
|
|
1805
|
+
isSignal: true,
|
|
1806
|
+
alias: "errorFallback",
|
|
1807
|
+
required: false
|
|
1808
|
+
}]
|
|
1809
|
+
}],
|
|
1810
|
+
errorFallbackByStage: [{
|
|
1811
|
+
type: i0.Input,
|
|
1812
|
+
args: [{
|
|
1813
|
+
isSignal: true,
|
|
1814
|
+
alias: "errorFallbackByStage",
|
|
1815
|
+
required: false
|
|
1816
|
+
}]
|
|
1817
|
+
}],
|
|
1818
|
+
errorMessages: [{
|
|
1819
|
+
type: i0.Input,
|
|
1820
|
+
args: [{
|
|
1821
|
+
isSignal: true,
|
|
1822
|
+
alias: "errorMessages",
|
|
1823
|
+
required: false
|
|
1824
|
+
}]
|
|
1825
|
+
}],
|
|
1826
|
+
loadErrorMessage: [{
|
|
1827
|
+
type: i0.Input,
|
|
1828
|
+
args: [{
|
|
1829
|
+
isSignal: true,
|
|
1830
|
+
alias: "loadErrorMessage",
|
|
1831
|
+
required: false
|
|
1832
|
+
}]
|
|
1833
|
+
}],
|
|
1834
|
+
a11yMessages: [{
|
|
1835
|
+
type: i0.Input,
|
|
1836
|
+
args: [{
|
|
1837
|
+
isSignal: true,
|
|
1838
|
+
alias: "a11yMessages",
|
|
1839
|
+
required: false
|
|
1840
|
+
}]
|
|
1841
|
+
}],
|
|
1842
|
+
ready: [{
|
|
1843
|
+
type: i0.Output,
|
|
1844
|
+
args: ["ready"]
|
|
1845
|
+
}],
|
|
1846
|
+
paymentMethodTypeChange: [{
|
|
1847
|
+
type: i0.Output,
|
|
1848
|
+
args: ["paymentMethodTypeChange"]
|
|
1849
|
+
}],
|
|
1850
|
+
elementChange: [{
|
|
1851
|
+
type: i0.Output,
|
|
1852
|
+
args: ["elementChange"]
|
|
1853
|
+
}],
|
|
1854
|
+
confirmed: [{
|
|
1855
|
+
type: i0.Output,
|
|
1856
|
+
args: ["confirmed"]
|
|
1857
|
+
}],
|
|
1858
|
+
failed: [{
|
|
1859
|
+
type: i0.Output,
|
|
1860
|
+
args: ["failed"]
|
|
1861
|
+
}],
|
|
1862
|
+
loadError: [{
|
|
1863
|
+
type: i0.Output,
|
|
1864
|
+
args: ["loadError"]
|
|
1865
|
+
}],
|
|
1866
|
+
mountRef: [{
|
|
1867
|
+
type: i0.ViewChild,
|
|
1868
|
+
args: ["mount", { isSignal: true }]
|
|
1869
|
+
}]
|
|
1870
|
+
}
|
|
1871
|
+
});
|
|
1872
|
+
const MICRODEPOSIT_COPY = {
|
|
1873
|
+
title: "Bank account waiting for verification",
|
|
1874
|
+
processingTitle: "Bank account being confirmed",
|
|
1875
|
+
processing: "Your bank is confirming this account; this usually takes up to a few business days. We will email you when it is ready.",
|
|
1876
|
+
cannotPay: "Until then this account can't be used to pay invoices.",
|
|
1877
|
+
readOnly: "An administrator of your organization can finish the verification.",
|
|
1878
|
+
keepsActive: "Your current payment method stays active until the new bank account is verified.",
|
|
1879
|
+
cancelTitle: "Cancel verification",
|
|
1880
|
+
verifyLabel: "Verify bank account",
|
|
1881
|
+
cancelBase: "Cancel the verification of this bank account? It will not be saved as a payment method and you can add it again later.",
|
|
1882
|
+
cancelKeepsActive: " Your current payment method stays active.",
|
|
1883
|
+
cancelNoOther: " You have no other payment method saved.",
|
|
1884
|
+
tooManyAttempts: "Too many failed attempts. Please try again later or contact support.",
|
|
1885
|
+
codeRequired: "Enter the 6-character code."
|
|
1886
|
+
};
|
|
1887
|
+
function microdepositArrivalText(iso) {
|
|
1888
|
+
if (!iso) return "";
|
|
1889
|
+
const date = new Date(iso);
|
|
1890
|
+
return Number.isNaN(date.getTime()) ? "" : date.toLocaleDateString("en-US", {
|
|
1891
|
+
month: "long",
|
|
1892
|
+
day: "numeric",
|
|
1893
|
+
year: "numeric",
|
|
1894
|
+
timeZone: "UTC"
|
|
1895
|
+
});
|
|
1896
|
+
}
|
|
1897
|
+
function depositAmountError(value) {
|
|
1898
|
+
if (value === "" || value === null || value === void 0) return "";
|
|
1899
|
+
const n = Number(value);
|
|
1900
|
+
if (!Number.isInteger(n)) return "Enter whole cents, for example 32.";
|
|
1901
|
+
if (n < 1 || n > 99) return "Enter a number of cents from 1 to 99.";
|
|
1902
|
+
return "";
|
|
1903
|
+
}
|
|
1904
|
+
const normalizeDescriptorCode = (value) => (value ?? "").trim().toUpperCase();
|
|
1905
|
+
function descriptorCodeError(value, requireSmPrefix = false) {
|
|
1906
|
+
const code = normalizeDescriptorCode(value);
|
|
1907
|
+
if (!code) return "";
|
|
1908
|
+
if (!/^[A-Z0-9]{6}$/.test(code)) return "The code has 6 letters or numbers.";
|
|
1909
|
+
if (requireSmPrefix && !/^SM[A-Z0-9]{4}$/.test(code)) return "Descriptor code must start with \"SM\" followed by 4 characters (e.g., SMXXXX)";
|
|
1910
|
+
return "";
|
|
1911
|
+
}
|
|
1912
|
+
function safeHostedUrl(url) {
|
|
1913
|
+
return /^https:\/\//.test(url ?? "") ? url : null;
|
|
1914
|
+
}
|
|
1915
|
+
const arrivalClause = (iso) => {
|
|
1916
|
+
const text = microdepositArrivalText(iso);
|
|
1917
|
+
return text ? ` (by ${text})` : "";
|
|
1918
|
+
};
|
|
1919
|
+
function microdepositStepsText(ctx) {
|
|
1920
|
+
const partner = ctx.partnerName ?? "";
|
|
1921
|
+
const holder = partner ? `${partner}'s account` : "your account";
|
|
1922
|
+
const clause = arrivalClause(ctx.arrivalDate);
|
|
1923
|
+
const deposits = ctx.type === "descriptor_code" ? `Stripe sent one small deposit to ${holder}${clause}, with a description that starts with SM followed by a 6-character code. ` : `Stripe sent two small deposits to ${holder}; they appear in 1-2 business days${clause}, with the description SMXXXX. `;
|
|
1924
|
+
if (ctx.readOnly) return `${deposits}${ctx.readOnlyText ?? (ctx.startedBy === "partner" ? `This bank account was started by ${partner}; it can be finished by them.` : ctx.startedBy === "other" ? "This bank account was started by another crematory; it can be finished by them." : partner ? `${partner} or the crematory that set it up can finish the verification.` : MICRODEPOSIT_COPY.readOnly)} ${MICRODEPOSIT_COPY.cannotPay}`;
|
|
1925
|
+
return `${deposits}${ctx.type === "descriptor_code" ? partner ? `Ask ${partner} for the code and enter it below to finish. ` : "When it arrives, enter that code below to finish. " : partner ? `Ask ${partner} for the two deposit amounts and enter them below to finish. ` : "When they arrive, enter the two amounts below to finish. "}${MICRODEPOSIT_COPY.cannotPay}`;
|
|
1926
|
+
}
|
|
1927
|
+
function microdepositProcessingText(partnerName = "") {
|
|
1928
|
+
return partnerName ? `${partnerName}'s bank is confirming this account; this usually takes up to a few business days. We will email you when it is ready.` : MICRODEPOSIT_COPY.processing;
|
|
1929
|
+
}
|
|
1930
|
+
function microdepositKeepsActiveText(partnerName = "") {
|
|
1931
|
+
return partnerName ? `${partnerName}'s current payment method stays active until the new bank account is verified.` : MICRODEPOSIT_COPY.keepsActive;
|
|
1932
|
+
}
|
|
1933
|
+
function microdepositCancelMessage(options = {}) {
|
|
1934
|
+
const partner = options.partnerName ?? "";
|
|
1935
|
+
if (partner) return `${MICRODEPOSIT_COPY.cancelBase} ${options.hasSavedMethod ? `${partner}'s current payment method stays active.` : `${partner} has no other payment method saved.`}`;
|
|
1936
|
+
return MICRODEPOSIT_COPY.cancelBase + (options.hasSavedMethod ? MICRODEPOSIT_COPY.cancelKeepsActive : MICRODEPOSIT_COPY.cancelNoOther);
|
|
1937
|
+
}
|
|
1938
|
+
var MicrodepositVerifyComponent = class MicrodepositVerifyComponent {
|
|
1939
|
+
constructor() {
|
|
1940
|
+
this.service = inject(StripePaymentService);
|
|
1941
|
+
this.type = input("amounts", ...ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []);
|
|
1942
|
+
this.bankName = input("", ...ngDevMode ? [{ debugName: "bankName" }] : /* istanbul ignore next */ []);
|
|
1943
|
+
this.last4 = input("", ...ngDevMode ? [{ debugName: "last4" }] : /* istanbul ignore next */ []);
|
|
1944
|
+
this.arrivalDate = input(null, ...ngDevMode ? [{ debugName: "arrivalDate" }] : /* istanbul ignore next */ []);
|
|
1945
|
+
this.hostedVerificationUrl = input(null, ...ngDevMode ? [{ debugName: "hostedVerificationUrl" }] : /* istanbul ignore next */ []);
|
|
1946
|
+
this.readOnly = input(false, ...ngDevMode ? [{ debugName: "readOnly" }] : /* istanbul ignore next */ []);
|
|
1947
|
+
this.statusOnly = input(false, ...ngDevMode ? [{ debugName: "statusOnly" }] : /* istanbul ignore next */ []);
|
|
1948
|
+
this.title = input("", ...ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []);
|
|
1949
|
+
this.stepsText = input("", ...ngDevMode ? [{ debugName: "stepsText" }] : /* istanbul ignore next */ []);
|
|
1950
|
+
this.readOnlyText = input(MICRODEPOSIT_COPY.readOnly, ...ngDevMode ? [{ debugName: "readOnlyText" }] : /* istanbul ignore next */ []);
|
|
1951
|
+
this.hideHostedLink = input(false, ...ngDevMode ? [{ debugName: "hideHostedLink" }] : /* istanbul ignore next */ []);
|
|
1952
|
+
this.cancelLabel = input("", ...ngDevMode ? [{ debugName: "cancelLabel" }] : /* istanbul ignore next */ []);
|
|
1953
|
+
this.verifyLabel = input("", ...ngDevMode ? [{ debugName: "verifyLabel" }] : /* istanbul ignore next */ []);
|
|
1954
|
+
this.keepsActiveText = input("", ...ngDevMode ? [{ debugName: "keepsActiveText" }] : /* istanbul ignore next */ []);
|
|
1955
|
+
this.cancelMessageText = input("", ...ngDevMode ? [{ debugName: "cancelMessageText" }] : /* istanbul ignore next */ []);
|
|
1956
|
+
this.hasSavedMethod = input(false, ...ngDevMode ? [{ debugName: "hasSavedMethod" }] : /* istanbul ignore next */ []);
|
|
1957
|
+
this.verifying = input(false, ...ngDevMode ? [{ debugName: "verifying" }] : /* istanbul ignore next */ []);
|
|
1958
|
+
this.cancelling = input(false, ...ngDevMode ? [{ debugName: "cancelling" }] : /* istanbul ignore next */ []);
|
|
1959
|
+
this.errorText = input("", ...ngDevMode ? [{ debugName: "errorText" }] : /* istanbul ignore next */ []);
|
|
1960
|
+
this.allowCancel = input(true, ...ngDevMode ? [{ debugName: "allowCancel" }] : /* istanbul ignore next */ []);
|
|
1961
|
+
this.requireSmPrefix = input(false, ...ngDevMode ? [{ debugName: "requireSmPrefix" }] : /* istanbul ignore next */ []);
|
|
1962
|
+
this.clientSecret = input(null, ...ngDevMode ? [{ debugName: "clientSecret" }] : /* istanbul ignore next */ []);
|
|
1963
|
+
this.publishableKey = input(null, ...ngDevMode ? [{ debugName: "publishableKey" }] : /* istanbul ignore next */ []);
|
|
1964
|
+
this.stripeAccount = input(null, ...ngDevMode ? [{ debugName: "stripeAccount" }] : /* istanbul ignore next */ []);
|
|
1965
|
+
this.flow = input("payment", ...ngDevMode ? [{ debugName: "flow" }] : /* istanbul ignore next */ []);
|
|
1966
|
+
this.maxAttempts = input(0, ...ngDevMode ? [{ debugName: "maxAttempts" }] : /* istanbul ignore next */ []);
|
|
1967
|
+
this.verify$ = output({ alias: "verify" });
|
|
1968
|
+
this.cancelVerification = output();
|
|
1969
|
+
this.verified = output();
|
|
1970
|
+
this.verifyFailed = output();
|
|
1971
|
+
this.copy = MICRODEPOSIT_COPY;
|
|
1972
|
+
this.first = signal("", ...ngDevMode ? [{ debugName: "first" }] : /* istanbul ignore next */ []);
|
|
1973
|
+
this.second = signal("", ...ngDevMode ? [{ debugName: "second" }] : /* istanbul ignore next */ []);
|
|
1974
|
+
this.code = signal("", ...ngDevMode ? [{ debugName: "code" }] : /* istanbul ignore next */ []);
|
|
1975
|
+
this.touched = signal(false, ...ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []);
|
|
1976
|
+
this.showCancelConfirm = signal(false, ...ngDevMode ? [{ debugName: "showCancelConfirm" }] : /* istanbul ignore next */ []);
|
|
1977
|
+
this.stripeBusy = signal(false, ...ngDevMode ? [{ debugName: "stripeBusy" }] : /* istanbul ignore next */ []);
|
|
1978
|
+
this.stripeError = signal("", ...ngDevMode ? [{ debugName: "stripeError" }] : /* istanbul ignore next */ []);
|
|
1979
|
+
this.failedAttempts = 0;
|
|
1980
|
+
this.formHidden = computed(() => this.readOnly() || this.statusOnly(), ...ngDevMode ? [{ debugName: "formHidden" }] : /* istanbul ignore next */ []);
|
|
1981
|
+
this.heading = computed(() => this.title() || (this.isProcessing() ? this.copy.processingTitle : this.copy.title), ...ngDevMode ? [{ debugName: "heading" }] : /* istanbul ignore next */ []);
|
|
1982
|
+
this.bankLine = computed(() => {
|
|
1983
|
+
const bank = this.bankName().trim();
|
|
1984
|
+
const last4 = this.last4().trim();
|
|
1985
|
+
if (!bank && !last4) return "";
|
|
1986
|
+
return `${bank || "Bank account"}${last4 ? ` ····${last4}` : ""}`;
|
|
1987
|
+
}, ...ngDevMode ? [{ debugName: "bankLine" }] : /* istanbul ignore next */ []);
|
|
1988
|
+
this.busy = computed(() => this.verifying() || this.stripeBusy(), ...ngDevMode ? [{ debugName: "busy" }] : /* istanbul ignore next */ []);
|
|
1989
|
+
this.shownError = computed(() => this.stripeError() || this.errorText(), ...ngDevMode ? [{ debugName: "shownError" }] : /* istanbul ignore next */ []);
|
|
1990
|
+
this.isProcessing = computed(() => this.type() === "processing", ...ngDevMode ? [{ debugName: "isProcessing" }] : /* istanbul ignore next */ []);
|
|
1991
|
+
this.safeUrl = computed(() => safeHostedUrl(this.hostedVerificationUrl()), ...ngDevMode ? [{ debugName: "safeUrl" }] : /* istanbul ignore next */ []);
|
|
1992
|
+
this.defaultSteps = computed(() => microdepositStepsText({
|
|
1993
|
+
type: this.type() === "descriptor_code" ? "descriptor_code" : "amounts",
|
|
1994
|
+
arrivalDate: this.arrivalDate(),
|
|
1995
|
+
readOnly: this.formHidden(),
|
|
1996
|
+
readOnlyText: this.readOnlyText()
|
|
1997
|
+
}), ...ngDevMode ? [{ debugName: "defaultSteps" }] : /* istanbul ignore next */ []);
|
|
1998
|
+
this.amountError = depositAmountError;
|
|
1999
|
+
this.codeError = computed(() => this.code().trim() ? descriptorCodeError(this.code(), this.requireSmPrefix()) : this.copy.codeRequired, ...ngDevMode ? [{ debugName: "codeError" }] : /* istanbul ignore next */ []);
|
|
2000
|
+
this.hasInvalid = computed(() => this.type() === "descriptor_code" ? !!this.codeError() : !!depositAmountError(this.first()) || !!depositAmountError(this.second()) || this.first() === "" || this.second() === "" || this.first() === null || this.second() === null, ...ngDevMode ? [{ debugName: "hasInvalid" }] : /* istanbul ignore next */ []);
|
|
2001
|
+
this.cancelMessage = computed(() => this.cancelMessageText() || this.copy.cancelBase + (this.hasSavedMethod() ? this.copy.cancelKeepsActive : this.copy.cancelNoOther), ...ngDevMode ? [{ debugName: "cancelMessage" }] : /* istanbul ignore next */ []);
|
|
2002
|
+
}
|
|
2003
|
+
async verify() {
|
|
2004
|
+
if (this.busy()) return;
|
|
2005
|
+
this.touched.set(true);
|
|
2006
|
+
if (this.hasInvalid()) return;
|
|
2007
|
+
const secret = this.clientSecret();
|
|
2008
|
+
if (!secret) {
|
|
2009
|
+
this.verify$.emit(this.type() === "descriptor_code" ? { descriptorCode: normalizeDescriptorCode(this.code()) } : { amounts: [Number(this.first()), Number(this.second())] });
|
|
2010
|
+
return;
|
|
2011
|
+
}
|
|
2012
|
+
const max = this.maxAttempts();
|
|
2013
|
+
if (max > 0 && this.failedAttempts >= max) {
|
|
2014
|
+
this.stripeError.set(this.copy.tooManyAttempts);
|
|
2015
|
+
return;
|
|
2016
|
+
}
|
|
2017
|
+
this.stripeBusy.set(true);
|
|
2018
|
+
this.stripeError.set("");
|
|
2019
|
+
const data = this.type() === "descriptor_code" ? { descriptor_code: normalizeDescriptorCode(this.code()) } : { amounts: [Number(this.first()), Number(this.second())] };
|
|
2020
|
+
const connection = {
|
|
2021
|
+
publishableKey: this.publishableKey(),
|
|
2022
|
+
stripeAccount: this.stripeAccount()
|
|
2023
|
+
};
|
|
2024
|
+
const result = this.flow() === "setup" ? await this.service.verifyMicrodepositsForSetup(secret, data, connection) : await this.service.verifyMicrodepositsForPayment(secret, data, connection);
|
|
2025
|
+
this.stripeBusy.set(false);
|
|
2026
|
+
if (result.ok) {
|
|
2027
|
+
this.verified.emit(result);
|
|
2028
|
+
return;
|
|
2029
|
+
}
|
|
2030
|
+
this.failedAttempts++;
|
|
2031
|
+
const message = result.failure?.message ?? "Verification failed";
|
|
2032
|
+
const remaining = max - this.failedAttempts;
|
|
2033
|
+
this.stripeError.set(max > 0 && remaining > 0 ? `${message} (${remaining} attempt${remaining === 1 ? "" : "s"} remaining)` : message);
|
|
2034
|
+
this.verifyFailed.emit(result);
|
|
2035
|
+
}
|
|
2036
|
+
confirmCancel() {
|
|
2037
|
+
if (this.cancelling()) return;
|
|
2038
|
+
this.showCancelConfirm.set(false);
|
|
2039
|
+
this.cancelVerification.emit();
|
|
2040
|
+
}
|
|
2041
|
+
static {
|
|
2042
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
2043
|
+
minVersion: "12.0.0",
|
|
2044
|
+
version: "22.2.2",
|
|
2045
|
+
ngImport: i0,
|
|
2046
|
+
type: MicrodepositVerifyComponent,
|
|
2047
|
+
deps: [],
|
|
2048
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
2049
|
+
});
|
|
2050
|
+
}
|
|
2051
|
+
static {
|
|
2052
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
2053
|
+
minVersion: "17.0.0",
|
|
2054
|
+
version: "22.2.2",
|
|
2055
|
+
type: MicrodepositVerifyComponent,
|
|
2056
|
+
isStandalone: true,
|
|
2057
|
+
selector: "ui-microdeposit-verify",
|
|
2058
|
+
inputs: {
|
|
2059
|
+
type: {
|
|
2060
|
+
classPropertyName: "type",
|
|
2061
|
+
publicName: "type",
|
|
2062
|
+
isSignal: true,
|
|
2063
|
+
isRequired: false,
|
|
2064
|
+
transformFunction: null
|
|
2065
|
+
},
|
|
2066
|
+
bankName: {
|
|
2067
|
+
classPropertyName: "bankName",
|
|
2068
|
+
publicName: "bankName",
|
|
2069
|
+
isSignal: true,
|
|
2070
|
+
isRequired: false,
|
|
2071
|
+
transformFunction: null
|
|
2072
|
+
},
|
|
2073
|
+
last4: {
|
|
2074
|
+
classPropertyName: "last4",
|
|
2075
|
+
publicName: "last4",
|
|
2076
|
+
isSignal: true,
|
|
2077
|
+
isRequired: false,
|
|
2078
|
+
transformFunction: null
|
|
2079
|
+
},
|
|
2080
|
+
arrivalDate: {
|
|
2081
|
+
classPropertyName: "arrivalDate",
|
|
2082
|
+
publicName: "arrivalDate",
|
|
2083
|
+
isSignal: true,
|
|
2084
|
+
isRequired: false,
|
|
2085
|
+
transformFunction: null
|
|
2086
|
+
},
|
|
2087
|
+
hostedVerificationUrl: {
|
|
2088
|
+
classPropertyName: "hostedVerificationUrl",
|
|
2089
|
+
publicName: "hostedVerificationUrl",
|
|
2090
|
+
isSignal: true,
|
|
2091
|
+
isRequired: false,
|
|
2092
|
+
transformFunction: null
|
|
2093
|
+
},
|
|
2094
|
+
readOnly: {
|
|
2095
|
+
classPropertyName: "readOnly",
|
|
2096
|
+
publicName: "readOnly",
|
|
2097
|
+
isSignal: true,
|
|
2098
|
+
isRequired: false,
|
|
2099
|
+
transformFunction: null
|
|
2100
|
+
},
|
|
2101
|
+
statusOnly: {
|
|
2102
|
+
classPropertyName: "statusOnly",
|
|
2103
|
+
publicName: "statusOnly",
|
|
2104
|
+
isSignal: true,
|
|
2105
|
+
isRequired: false,
|
|
2106
|
+
transformFunction: null
|
|
2107
|
+
},
|
|
2108
|
+
title: {
|
|
2109
|
+
classPropertyName: "title",
|
|
2110
|
+
publicName: "title",
|
|
2111
|
+
isSignal: true,
|
|
2112
|
+
isRequired: false,
|
|
2113
|
+
transformFunction: null
|
|
2114
|
+
},
|
|
2115
|
+
stepsText: {
|
|
2116
|
+
classPropertyName: "stepsText",
|
|
2117
|
+
publicName: "stepsText",
|
|
2118
|
+
isSignal: true,
|
|
2119
|
+
isRequired: false,
|
|
2120
|
+
transformFunction: null
|
|
2121
|
+
},
|
|
2122
|
+
readOnlyText: {
|
|
2123
|
+
classPropertyName: "readOnlyText",
|
|
2124
|
+
publicName: "readOnlyText",
|
|
2125
|
+
isSignal: true,
|
|
2126
|
+
isRequired: false,
|
|
2127
|
+
transformFunction: null
|
|
2128
|
+
},
|
|
2129
|
+
hideHostedLink: {
|
|
2130
|
+
classPropertyName: "hideHostedLink",
|
|
2131
|
+
publicName: "hideHostedLink",
|
|
2132
|
+
isSignal: true,
|
|
2133
|
+
isRequired: false,
|
|
2134
|
+
transformFunction: null
|
|
2135
|
+
},
|
|
2136
|
+
cancelLabel: {
|
|
2137
|
+
classPropertyName: "cancelLabel",
|
|
2138
|
+
publicName: "cancelLabel",
|
|
2139
|
+
isSignal: true,
|
|
2140
|
+
isRequired: false,
|
|
2141
|
+
transformFunction: null
|
|
2142
|
+
},
|
|
2143
|
+
verifyLabel: {
|
|
2144
|
+
classPropertyName: "verifyLabel",
|
|
2145
|
+
publicName: "verifyLabel",
|
|
2146
|
+
isSignal: true,
|
|
2147
|
+
isRequired: false,
|
|
2148
|
+
transformFunction: null
|
|
2149
|
+
},
|
|
2150
|
+
keepsActiveText: {
|
|
2151
|
+
classPropertyName: "keepsActiveText",
|
|
2152
|
+
publicName: "keepsActiveText",
|
|
2153
|
+
isSignal: true,
|
|
2154
|
+
isRequired: false,
|
|
2155
|
+
transformFunction: null
|
|
2156
|
+
},
|
|
2157
|
+
cancelMessageText: {
|
|
2158
|
+
classPropertyName: "cancelMessageText",
|
|
2159
|
+
publicName: "cancelMessageText",
|
|
2160
|
+
isSignal: true,
|
|
2161
|
+
isRequired: false,
|
|
2162
|
+
transformFunction: null
|
|
2163
|
+
},
|
|
2164
|
+
hasSavedMethod: {
|
|
2165
|
+
classPropertyName: "hasSavedMethod",
|
|
2166
|
+
publicName: "hasSavedMethod",
|
|
2167
|
+
isSignal: true,
|
|
2168
|
+
isRequired: false,
|
|
2169
|
+
transformFunction: null
|
|
2170
|
+
},
|
|
2171
|
+
verifying: {
|
|
2172
|
+
classPropertyName: "verifying",
|
|
2173
|
+
publicName: "verifying",
|
|
2174
|
+
isSignal: true,
|
|
2175
|
+
isRequired: false,
|
|
2176
|
+
transformFunction: null
|
|
2177
|
+
},
|
|
2178
|
+
cancelling: {
|
|
2179
|
+
classPropertyName: "cancelling",
|
|
2180
|
+
publicName: "cancelling",
|
|
2181
|
+
isSignal: true,
|
|
2182
|
+
isRequired: false,
|
|
2183
|
+
transformFunction: null
|
|
2184
|
+
},
|
|
2185
|
+
errorText: {
|
|
2186
|
+
classPropertyName: "errorText",
|
|
2187
|
+
publicName: "errorText",
|
|
2188
|
+
isSignal: true,
|
|
2189
|
+
isRequired: false,
|
|
2190
|
+
transformFunction: null
|
|
2191
|
+
},
|
|
2192
|
+
allowCancel: {
|
|
2193
|
+
classPropertyName: "allowCancel",
|
|
2194
|
+
publicName: "allowCancel",
|
|
2195
|
+
isSignal: true,
|
|
2196
|
+
isRequired: false,
|
|
2197
|
+
transformFunction: null
|
|
2198
|
+
},
|
|
2199
|
+
requireSmPrefix: {
|
|
2200
|
+
classPropertyName: "requireSmPrefix",
|
|
2201
|
+
publicName: "requireSmPrefix",
|
|
2202
|
+
isSignal: true,
|
|
2203
|
+
isRequired: false,
|
|
2204
|
+
transformFunction: null
|
|
2205
|
+
},
|
|
2206
|
+
clientSecret: {
|
|
2207
|
+
classPropertyName: "clientSecret",
|
|
2208
|
+
publicName: "clientSecret",
|
|
2209
|
+
isSignal: true,
|
|
2210
|
+
isRequired: false,
|
|
2211
|
+
transformFunction: null
|
|
2212
|
+
},
|
|
2213
|
+
publishableKey: {
|
|
2214
|
+
classPropertyName: "publishableKey",
|
|
2215
|
+
publicName: "publishableKey",
|
|
2216
|
+
isSignal: true,
|
|
2217
|
+
isRequired: false,
|
|
2218
|
+
transformFunction: null
|
|
2219
|
+
},
|
|
2220
|
+
stripeAccount: {
|
|
2221
|
+
classPropertyName: "stripeAccount",
|
|
2222
|
+
publicName: "stripeAccount",
|
|
2223
|
+
isSignal: true,
|
|
2224
|
+
isRequired: false,
|
|
2225
|
+
transformFunction: null
|
|
2226
|
+
},
|
|
2227
|
+
flow: {
|
|
2228
|
+
classPropertyName: "flow",
|
|
2229
|
+
publicName: "flow",
|
|
2230
|
+
isSignal: true,
|
|
2231
|
+
isRequired: false,
|
|
2232
|
+
transformFunction: null
|
|
2233
|
+
},
|
|
2234
|
+
maxAttempts: {
|
|
2235
|
+
classPropertyName: "maxAttempts",
|
|
2236
|
+
publicName: "maxAttempts",
|
|
2237
|
+
isSignal: true,
|
|
2238
|
+
isRequired: false,
|
|
2239
|
+
transformFunction: null
|
|
2240
|
+
}
|
|
2241
|
+
},
|
|
2242
|
+
outputs: {
|
|
2243
|
+
verify$: "verify",
|
|
2244
|
+
cancelVerification: "cancelVerification",
|
|
2245
|
+
verified: "verified",
|
|
2246
|
+
verifyFailed: "verifyFailed"
|
|
2247
|
+
},
|
|
2248
|
+
ngImport: i0,
|
|
2249
|
+
template: `
|
|
2250
|
+
<div data-testid="bank-pending-card">
|
|
2251
|
+
<ui-form-section [label]="heading()">
|
|
2252
|
+
<ui-alert variant="info" data-testid="bank-pending-alert">
|
|
2253
|
+
<div data-testid="bank-pending-summary">
|
|
2254
|
+
@if (bankLine(); as line) { <strong data-testid="bank-pending-bank">{{ line }}</strong> }
|
|
2255
|
+
<ui-badge label="Pending" variant="yellow" data-testid="bank-pending-badge" />
|
|
2256
|
+
</div>
|
|
2257
|
+
@if (stepsText().trim()) {
|
|
2258
|
+
<ui-text size="sm" [text]="stepsText()" data-testid="bank-pending-steps" />
|
|
2259
|
+
} @else if (isProcessing()) {
|
|
2260
|
+
<ui-text size="sm" [text]="copy.processing" data-testid="bank-pending-steps" />
|
|
2261
|
+
} @else {
|
|
2262
|
+
<ui-text size="sm" data-testid="bank-pending-steps" [text]="defaultSteps()" />
|
|
2263
|
+
}
|
|
2264
|
+
@if (hasSavedMethod()) {
|
|
2265
|
+
<ui-text size="sm" tone="muted" [text]="keepsActiveText() || copy.keepsActive" data-testid="bank-pending-keeps-active" />
|
|
2266
|
+
}
|
|
2267
|
+
<!-- Finishing the verification on Stripe's page saves the payment method (a write): never offered to a read-only user -->
|
|
2268
|
+
@if (!formHidden() && !hideHostedLink() && safeUrl(); as url) {
|
|
2269
|
+
<div><ui-button variant="link" size="sm" [href]="url" target="_blank" data-testid="bank-hosted-link">Open Stripe's verification page</ui-button></div>
|
|
2270
|
+
}
|
|
2271
|
+
</ui-alert>
|
|
2272
|
+
|
|
2273
|
+
@if (!formHidden() && !isProcessing()) {
|
|
2274
|
+
@if (type() === 'descriptor_code') {
|
|
2275
|
+
<ui-text-input label="Verification code" hint="6 letters or numbers from the deposit description" [maxlength]="6" [required]="true" [showErrors]="touched()"
|
|
2276
|
+
[error]="touched() ? codeError() : ''" data-testid="bank-code-input" [ngModel]="code()" (ngModelChange)="code.set($event)" />
|
|
2277
|
+
} @else {
|
|
2278
|
+
<ui-form-row data-testid="bank-amounts-row">
|
|
2279
|
+
<ui-text-input label="First deposit (cents)" type="number" [min]="1" [max]="99" [maxDecimals]="0" [required]="true" [showErrors]="touched()"
|
|
2280
|
+
[error]="touched() ? amountError(first()) : ''" data-testid="bank-amount-first" [ngModel]="first()" (ngModelChange)="first.set($event)" />
|
|
2281
|
+
<ui-text-input label="Second deposit (cents)" type="number" [min]="1" [max]="99" [maxDecimals]="0" [required]="true" [showErrors]="touched()"
|
|
2282
|
+
[error]="touched() ? amountError(second()) : ''" data-testid="bank-amount-second" [ngModel]="second()" (ngModelChange)="second.set($event)" />
|
|
2283
|
+
</ui-form-row>
|
|
2284
|
+
}
|
|
2285
|
+
@if (shownError(); as text) {
|
|
2286
|
+
<ui-alert variant="danger" data-testid="bank-verify-error">{{ text }}</ui-alert>
|
|
2287
|
+
}
|
|
2288
|
+
<ui-button variant="primary" size="sm" data-testid="bank-verify-button" [loading]="busy()" [disabled]="busy() || cancelling()" (click)="verify()">{{ verifyLabel() || copy.verifyLabel }}</ui-button>
|
|
2289
|
+
}
|
|
2290
|
+
|
|
2291
|
+
@if (!formHidden() && allowCancel()) {
|
|
2292
|
+
<ui-button variant="secondary" size="sm" data-testid="bank-cancel-button" [disabled]="busy() || cancelling()" (click)="showCancelConfirm.set(true)">{{ cancelLabel() || copy.cancelTitle }}</ui-button>
|
|
2293
|
+
}
|
|
2294
|
+
</ui-form-section>
|
|
2295
|
+
|
|
2296
|
+
<ui-modal [open]="showCancelConfirm()" [title]="cancelLabel() || copy.cancelTitle" maxWidth="460px" (close)="showCancelConfirm.set(false)">
|
|
2297
|
+
<ui-text size="sm" data-testid="bank-cancel-message" [text]="cancelMessage()" />
|
|
2298
|
+
<ui-button modal-footer-left variant="secondary" size="sm" data-testid="bank-cancel-keep" (click)="showCancelConfirm.set(false)">Keep waiting</ui-button>
|
|
2299
|
+
<ui-button modal-footer-right variant="danger" size="sm" data-testid="bank-cancel-confirm" [loading]="cancelling()" (click)="confirmCancel()">{{ cancelLabel() || copy.cancelTitle }}</ui-button>
|
|
2300
|
+
</ui-modal>
|
|
2301
|
+
</div>
|
|
2302
|
+
`,
|
|
2303
|
+
isInline: true,
|
|
2304
|
+
dependencies: [
|
|
2305
|
+
{
|
|
2306
|
+
kind: "ngmodule",
|
|
2307
|
+
type: FormsModule
|
|
2308
|
+
},
|
|
2309
|
+
{
|
|
2310
|
+
kind: "directive",
|
|
2311
|
+
type: i1.NgControlStatus,
|
|
2312
|
+
selector: "[formControlName],[ngModel],[formControl]"
|
|
2313
|
+
},
|
|
2314
|
+
{
|
|
2315
|
+
kind: "directive",
|
|
2316
|
+
type: i1.RequiredValidator,
|
|
2317
|
+
selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]",
|
|
2318
|
+
inputs: ["required"]
|
|
2319
|
+
},
|
|
2320
|
+
{
|
|
2321
|
+
kind: "directive",
|
|
2322
|
+
type: i1.MaxLengthValidator,
|
|
2323
|
+
selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]",
|
|
2324
|
+
inputs: ["maxlength"]
|
|
2325
|
+
},
|
|
2326
|
+
{
|
|
2327
|
+
kind: "directive",
|
|
2328
|
+
type: i1.NgModel,
|
|
2329
|
+
selector: "[ngModel]:not([formControlName]):not([formControl])",
|
|
2330
|
+
inputs: [
|
|
2331
|
+
"name",
|
|
2332
|
+
"disabled",
|
|
2333
|
+
"ngModel",
|
|
2334
|
+
"ngModelOptions"
|
|
2335
|
+
],
|
|
2336
|
+
outputs: ["ngModelChange"],
|
|
2337
|
+
exportAs: ["ngModel"]
|
|
2338
|
+
},
|
|
2339
|
+
{
|
|
2340
|
+
kind: "component",
|
|
2341
|
+
type: AlertComponent,
|
|
2342
|
+
selector: "ui-alert",
|
|
2343
|
+
inputs: [
|
|
2344
|
+
"variant",
|
|
2345
|
+
"title",
|
|
2346
|
+
"dismissible",
|
|
2347
|
+
"quiet",
|
|
2348
|
+
"compact"
|
|
2349
|
+
],
|
|
2350
|
+
outputs: ["dismissed"]
|
|
2351
|
+
},
|
|
2352
|
+
{
|
|
2353
|
+
kind: "component",
|
|
2354
|
+
type: BadgeComponent,
|
|
2355
|
+
selector: "ui-badge",
|
|
2356
|
+
inputs: ["label", "variant"]
|
|
2357
|
+
},
|
|
2358
|
+
{
|
|
2359
|
+
kind: "component",
|
|
2360
|
+
type: ButtonComponent,
|
|
2361
|
+
selector: "ui-button",
|
|
2362
|
+
inputs: [
|
|
2363
|
+
"variant",
|
|
2364
|
+
"routerLink",
|
|
2365
|
+
"queryParams",
|
|
2366
|
+
"href",
|
|
2367
|
+
"target",
|
|
2368
|
+
"rel",
|
|
2369
|
+
"color",
|
|
2370
|
+
"active",
|
|
2371
|
+
"size",
|
|
2372
|
+
"type",
|
|
2373
|
+
"disabled",
|
|
2374
|
+
"loading",
|
|
2375
|
+
"fullWidth",
|
|
2376
|
+
"ariaLabel",
|
|
2377
|
+
"ariaExpanded",
|
|
2378
|
+
"ariaPressed",
|
|
2379
|
+
"ariaDescribedBy",
|
|
2380
|
+
"modal-footer-left",
|
|
2381
|
+
"modal-footer-right"
|
|
2382
|
+
]
|
|
2383
|
+
},
|
|
2384
|
+
{
|
|
2385
|
+
kind: "component",
|
|
2386
|
+
type: FormRowComponent,
|
|
2387
|
+
selector: "ui-form-row",
|
|
2388
|
+
inputs: ["cols"]
|
|
2389
|
+
},
|
|
2390
|
+
{
|
|
2391
|
+
kind: "component",
|
|
2392
|
+
type: FormSectionComponent,
|
|
2393
|
+
selector: "ui-form-section",
|
|
2394
|
+
inputs: ["label", "divider"]
|
|
2395
|
+
},
|
|
2396
|
+
{
|
|
2397
|
+
kind: "component",
|
|
2398
|
+
type: ModalComponent,
|
|
2399
|
+
selector: "ui-modal",
|
|
2400
|
+
inputs: [
|
|
2401
|
+
"open",
|
|
2402
|
+
"title",
|
|
2403
|
+
"description",
|
|
2404
|
+
"maxWidth",
|
|
2405
|
+
"bodyOverflow"
|
|
2406
|
+
],
|
|
2407
|
+
outputs: ["close"]
|
|
2408
|
+
},
|
|
2409
|
+
{
|
|
2410
|
+
kind: "component",
|
|
2411
|
+
type: TextComponent,
|
|
2412
|
+
selector: "ui-text",
|
|
2413
|
+
inputs: [
|
|
2414
|
+
"text",
|
|
2415
|
+
"size",
|
|
2416
|
+
"tone"
|
|
2417
|
+
]
|
|
2418
|
+
},
|
|
2419
|
+
{
|
|
2420
|
+
kind: "component",
|
|
2421
|
+
type: TextInputComponent,
|
|
2422
|
+
selector: "ui-text-input",
|
|
2423
|
+
inputs: [
|
|
2424
|
+
"label",
|
|
2425
|
+
"ariaLabel",
|
|
2426
|
+
"placeholder",
|
|
2427
|
+
"type",
|
|
2428
|
+
"maxlength",
|
|
2429
|
+
"required",
|
|
2430
|
+
"autocomplete",
|
|
2431
|
+
"inputmode",
|
|
2432
|
+
"readonly",
|
|
2433
|
+
"hint",
|
|
2434
|
+
"error",
|
|
2435
|
+
"phoneFormat",
|
|
2436
|
+
"min",
|
|
2437
|
+
"max",
|
|
2438
|
+
"maxDecimals",
|
|
2439
|
+
"step",
|
|
2440
|
+
"valueType",
|
|
2441
|
+
"showErrors",
|
|
2442
|
+
"disabled"
|
|
2443
|
+
],
|
|
2444
|
+
outputs: [
|
|
2445
|
+
"focused",
|
|
2446
|
+
"blurred",
|
|
2447
|
+
"invalidChange"
|
|
2448
|
+
]
|
|
2449
|
+
}
|
|
2450
|
+
],
|
|
2451
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
2452
|
+
});
|
|
2453
|
+
}
|
|
2454
|
+
};
|
|
2455
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
2456
|
+
minVersion: "12.0.0",
|
|
2457
|
+
version: "22.2.2",
|
|
2458
|
+
ngImport: i0,
|
|
2459
|
+
type: MicrodepositVerifyComponent,
|
|
2460
|
+
decorators: [{
|
|
2461
|
+
type: Component,
|
|
2462
|
+
args: [{
|
|
2463
|
+
selector: "ui-microdeposit-verify",
|
|
2464
|
+
standalone: true,
|
|
2465
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2466
|
+
imports: [
|
|
2467
|
+
FormsModule,
|
|
2468
|
+
AlertComponent,
|
|
2469
|
+
BadgeComponent,
|
|
2470
|
+
ButtonComponent,
|
|
2471
|
+
FormRowComponent,
|
|
2472
|
+
FormSectionComponent,
|
|
2473
|
+
ModalComponent,
|
|
2474
|
+
TextComponent,
|
|
2475
|
+
TextInputComponent
|
|
2476
|
+
],
|
|
2477
|
+
template: `
|
|
2478
|
+
<div data-testid="bank-pending-card">
|
|
2479
|
+
<ui-form-section [label]="heading()">
|
|
2480
|
+
<ui-alert variant="info" data-testid="bank-pending-alert">
|
|
2481
|
+
<div data-testid="bank-pending-summary">
|
|
2482
|
+
@if (bankLine(); as line) { <strong data-testid="bank-pending-bank">{{ line }}</strong> }
|
|
2483
|
+
<ui-badge label="Pending" variant="yellow" data-testid="bank-pending-badge" />
|
|
2484
|
+
</div>
|
|
2485
|
+
@if (stepsText().trim()) {
|
|
2486
|
+
<ui-text size="sm" [text]="stepsText()" data-testid="bank-pending-steps" />
|
|
2487
|
+
} @else if (isProcessing()) {
|
|
2488
|
+
<ui-text size="sm" [text]="copy.processing" data-testid="bank-pending-steps" />
|
|
2489
|
+
} @else {
|
|
2490
|
+
<ui-text size="sm" data-testid="bank-pending-steps" [text]="defaultSteps()" />
|
|
2491
|
+
}
|
|
2492
|
+
@if (hasSavedMethod()) {
|
|
2493
|
+
<ui-text size="sm" tone="muted" [text]="keepsActiveText() || copy.keepsActive" data-testid="bank-pending-keeps-active" />
|
|
2494
|
+
}
|
|
2495
|
+
<!-- Finishing the verification on Stripe's page saves the payment method (a write): never offered to a read-only user -->
|
|
2496
|
+
@if (!formHidden() && !hideHostedLink() && safeUrl(); as url) {
|
|
2497
|
+
<div><ui-button variant="link" size="sm" [href]="url" target="_blank" data-testid="bank-hosted-link">Open Stripe's verification page</ui-button></div>
|
|
2498
|
+
}
|
|
2499
|
+
</ui-alert>
|
|
2500
|
+
|
|
2501
|
+
@if (!formHidden() && !isProcessing()) {
|
|
2502
|
+
@if (type() === 'descriptor_code') {
|
|
2503
|
+
<ui-text-input label="Verification code" hint="6 letters or numbers from the deposit description" [maxlength]="6" [required]="true" [showErrors]="touched()"
|
|
2504
|
+
[error]="touched() ? codeError() : ''" data-testid="bank-code-input" [ngModel]="code()" (ngModelChange)="code.set($event)" />
|
|
2505
|
+
} @else {
|
|
2506
|
+
<ui-form-row data-testid="bank-amounts-row">
|
|
2507
|
+
<ui-text-input label="First deposit (cents)" type="number" [min]="1" [max]="99" [maxDecimals]="0" [required]="true" [showErrors]="touched()"
|
|
2508
|
+
[error]="touched() ? amountError(first()) : ''" data-testid="bank-amount-first" [ngModel]="first()" (ngModelChange)="first.set($event)" />
|
|
2509
|
+
<ui-text-input label="Second deposit (cents)" type="number" [min]="1" [max]="99" [maxDecimals]="0" [required]="true" [showErrors]="touched()"
|
|
2510
|
+
[error]="touched() ? amountError(second()) : ''" data-testid="bank-amount-second" [ngModel]="second()" (ngModelChange)="second.set($event)" />
|
|
2511
|
+
</ui-form-row>
|
|
2512
|
+
}
|
|
2513
|
+
@if (shownError(); as text) {
|
|
2514
|
+
<ui-alert variant="danger" data-testid="bank-verify-error">{{ text }}</ui-alert>
|
|
2515
|
+
}
|
|
2516
|
+
<ui-button variant="primary" size="sm" data-testid="bank-verify-button" [loading]="busy()" [disabled]="busy() || cancelling()" (click)="verify()">{{ verifyLabel() || copy.verifyLabel }}</ui-button>
|
|
2517
|
+
}
|
|
2518
|
+
|
|
2519
|
+
@if (!formHidden() && allowCancel()) {
|
|
2520
|
+
<ui-button variant="secondary" size="sm" data-testid="bank-cancel-button" [disabled]="busy() || cancelling()" (click)="showCancelConfirm.set(true)">{{ cancelLabel() || copy.cancelTitle }}</ui-button>
|
|
2521
|
+
}
|
|
2522
|
+
</ui-form-section>
|
|
2523
|
+
|
|
2524
|
+
<ui-modal [open]="showCancelConfirm()" [title]="cancelLabel() || copy.cancelTitle" maxWidth="460px" (close)="showCancelConfirm.set(false)">
|
|
2525
|
+
<ui-text size="sm" data-testid="bank-cancel-message" [text]="cancelMessage()" />
|
|
2526
|
+
<ui-button modal-footer-left variant="secondary" size="sm" data-testid="bank-cancel-keep" (click)="showCancelConfirm.set(false)">Keep waiting</ui-button>
|
|
2527
|
+
<ui-button modal-footer-right variant="danger" size="sm" data-testid="bank-cancel-confirm" [loading]="cancelling()" (click)="confirmCancel()">{{ cancelLabel() || copy.cancelTitle }}</ui-button>
|
|
2528
|
+
</ui-modal>
|
|
2529
|
+
</div>
|
|
2530
|
+
`
|
|
2531
|
+
}]
|
|
2532
|
+
}],
|
|
2533
|
+
propDecorators: {
|
|
2534
|
+
type: [{
|
|
2535
|
+
type: i0.Input,
|
|
2536
|
+
args: [{
|
|
2537
|
+
isSignal: true,
|
|
2538
|
+
alias: "type",
|
|
2539
|
+
required: false
|
|
2540
|
+
}]
|
|
2541
|
+
}],
|
|
2542
|
+
bankName: [{
|
|
2543
|
+
type: i0.Input,
|
|
2544
|
+
args: [{
|
|
2545
|
+
isSignal: true,
|
|
2546
|
+
alias: "bankName",
|
|
2547
|
+
required: false
|
|
2548
|
+
}]
|
|
2549
|
+
}],
|
|
2550
|
+
last4: [{
|
|
2551
|
+
type: i0.Input,
|
|
2552
|
+
args: [{
|
|
2553
|
+
isSignal: true,
|
|
2554
|
+
alias: "last4",
|
|
2555
|
+
required: false
|
|
2556
|
+
}]
|
|
2557
|
+
}],
|
|
2558
|
+
arrivalDate: [{
|
|
2559
|
+
type: i0.Input,
|
|
2560
|
+
args: [{
|
|
2561
|
+
isSignal: true,
|
|
2562
|
+
alias: "arrivalDate",
|
|
2563
|
+
required: false
|
|
2564
|
+
}]
|
|
2565
|
+
}],
|
|
2566
|
+
hostedVerificationUrl: [{
|
|
2567
|
+
type: i0.Input,
|
|
2568
|
+
args: [{
|
|
2569
|
+
isSignal: true,
|
|
2570
|
+
alias: "hostedVerificationUrl",
|
|
2571
|
+
required: false
|
|
2572
|
+
}]
|
|
2573
|
+
}],
|
|
2574
|
+
readOnly: [{
|
|
2575
|
+
type: i0.Input,
|
|
2576
|
+
args: [{
|
|
2577
|
+
isSignal: true,
|
|
2578
|
+
alias: "readOnly",
|
|
2579
|
+
required: false
|
|
2580
|
+
}]
|
|
2581
|
+
}],
|
|
2582
|
+
statusOnly: [{
|
|
2583
|
+
type: i0.Input,
|
|
2584
|
+
args: [{
|
|
2585
|
+
isSignal: true,
|
|
2586
|
+
alias: "statusOnly",
|
|
2587
|
+
required: false
|
|
2588
|
+
}]
|
|
2589
|
+
}],
|
|
2590
|
+
title: [{
|
|
2591
|
+
type: i0.Input,
|
|
2592
|
+
args: [{
|
|
2593
|
+
isSignal: true,
|
|
2594
|
+
alias: "title",
|
|
2595
|
+
required: false
|
|
2596
|
+
}]
|
|
2597
|
+
}],
|
|
2598
|
+
stepsText: [{
|
|
2599
|
+
type: i0.Input,
|
|
2600
|
+
args: [{
|
|
2601
|
+
isSignal: true,
|
|
2602
|
+
alias: "stepsText",
|
|
2603
|
+
required: false
|
|
2604
|
+
}]
|
|
2605
|
+
}],
|
|
2606
|
+
readOnlyText: [{
|
|
2607
|
+
type: i0.Input,
|
|
2608
|
+
args: [{
|
|
2609
|
+
isSignal: true,
|
|
2610
|
+
alias: "readOnlyText",
|
|
2611
|
+
required: false
|
|
2612
|
+
}]
|
|
2613
|
+
}],
|
|
2614
|
+
hideHostedLink: [{
|
|
2615
|
+
type: i0.Input,
|
|
2616
|
+
args: [{
|
|
2617
|
+
isSignal: true,
|
|
2618
|
+
alias: "hideHostedLink",
|
|
2619
|
+
required: false
|
|
2620
|
+
}]
|
|
2621
|
+
}],
|
|
2622
|
+
cancelLabel: [{
|
|
2623
|
+
type: i0.Input,
|
|
2624
|
+
args: [{
|
|
2625
|
+
isSignal: true,
|
|
2626
|
+
alias: "cancelLabel",
|
|
2627
|
+
required: false
|
|
2628
|
+
}]
|
|
2629
|
+
}],
|
|
2630
|
+
verifyLabel: [{
|
|
2631
|
+
type: i0.Input,
|
|
2632
|
+
args: [{
|
|
2633
|
+
isSignal: true,
|
|
2634
|
+
alias: "verifyLabel",
|
|
2635
|
+
required: false
|
|
2636
|
+
}]
|
|
2637
|
+
}],
|
|
2638
|
+
keepsActiveText: [{
|
|
2639
|
+
type: i0.Input,
|
|
2640
|
+
args: [{
|
|
2641
|
+
isSignal: true,
|
|
2642
|
+
alias: "keepsActiveText",
|
|
2643
|
+
required: false
|
|
2644
|
+
}]
|
|
2645
|
+
}],
|
|
2646
|
+
cancelMessageText: [{
|
|
2647
|
+
type: i0.Input,
|
|
2648
|
+
args: [{
|
|
2649
|
+
isSignal: true,
|
|
2650
|
+
alias: "cancelMessageText",
|
|
2651
|
+
required: false
|
|
2652
|
+
}]
|
|
2653
|
+
}],
|
|
2654
|
+
hasSavedMethod: [{
|
|
2655
|
+
type: i0.Input,
|
|
2656
|
+
args: [{
|
|
2657
|
+
isSignal: true,
|
|
2658
|
+
alias: "hasSavedMethod",
|
|
2659
|
+
required: false
|
|
2660
|
+
}]
|
|
2661
|
+
}],
|
|
2662
|
+
verifying: [{
|
|
2663
|
+
type: i0.Input,
|
|
2664
|
+
args: [{
|
|
2665
|
+
isSignal: true,
|
|
2666
|
+
alias: "verifying",
|
|
2667
|
+
required: false
|
|
2668
|
+
}]
|
|
2669
|
+
}],
|
|
2670
|
+
cancelling: [{
|
|
2671
|
+
type: i0.Input,
|
|
2672
|
+
args: [{
|
|
2673
|
+
isSignal: true,
|
|
2674
|
+
alias: "cancelling",
|
|
2675
|
+
required: false
|
|
2676
|
+
}]
|
|
2677
|
+
}],
|
|
2678
|
+
errorText: [{
|
|
2679
|
+
type: i0.Input,
|
|
2680
|
+
args: [{
|
|
2681
|
+
isSignal: true,
|
|
2682
|
+
alias: "errorText",
|
|
2683
|
+
required: false
|
|
2684
|
+
}]
|
|
2685
|
+
}],
|
|
2686
|
+
allowCancel: [{
|
|
2687
|
+
type: i0.Input,
|
|
2688
|
+
args: [{
|
|
2689
|
+
isSignal: true,
|
|
2690
|
+
alias: "allowCancel",
|
|
2691
|
+
required: false
|
|
2692
|
+
}]
|
|
2693
|
+
}],
|
|
2694
|
+
requireSmPrefix: [{
|
|
2695
|
+
type: i0.Input,
|
|
2696
|
+
args: [{
|
|
2697
|
+
isSignal: true,
|
|
2698
|
+
alias: "requireSmPrefix",
|
|
2699
|
+
required: false
|
|
2700
|
+
}]
|
|
2701
|
+
}],
|
|
2702
|
+
clientSecret: [{
|
|
2703
|
+
type: i0.Input,
|
|
2704
|
+
args: [{
|
|
2705
|
+
isSignal: true,
|
|
2706
|
+
alias: "clientSecret",
|
|
2707
|
+
required: false
|
|
2708
|
+
}]
|
|
2709
|
+
}],
|
|
2710
|
+
publishableKey: [{
|
|
2711
|
+
type: i0.Input,
|
|
2712
|
+
args: [{
|
|
2713
|
+
isSignal: true,
|
|
2714
|
+
alias: "publishableKey",
|
|
2715
|
+
required: false
|
|
2716
|
+
}]
|
|
2717
|
+
}],
|
|
2718
|
+
stripeAccount: [{
|
|
2719
|
+
type: i0.Input,
|
|
2720
|
+
args: [{
|
|
2721
|
+
isSignal: true,
|
|
2722
|
+
alias: "stripeAccount",
|
|
2723
|
+
required: false
|
|
2724
|
+
}]
|
|
2725
|
+
}],
|
|
2726
|
+
flow: [{
|
|
2727
|
+
type: i0.Input,
|
|
2728
|
+
args: [{
|
|
2729
|
+
isSignal: true,
|
|
2730
|
+
alias: "flow",
|
|
2731
|
+
required: false
|
|
2732
|
+
}]
|
|
2733
|
+
}],
|
|
2734
|
+
maxAttempts: [{
|
|
2735
|
+
type: i0.Input,
|
|
2736
|
+
args: [{
|
|
2737
|
+
isSignal: true,
|
|
2738
|
+
alias: "maxAttempts",
|
|
2739
|
+
required: false
|
|
2740
|
+
}]
|
|
2741
|
+
}],
|
|
2742
|
+
verify$: [{
|
|
2743
|
+
type: i0.Output,
|
|
2744
|
+
args: ["verify"]
|
|
2745
|
+
}],
|
|
2746
|
+
cancelVerification: [{
|
|
2747
|
+
type: i0.Output,
|
|
2748
|
+
args: ["cancelVerification"]
|
|
2749
|
+
}],
|
|
2750
|
+
verified: [{
|
|
2751
|
+
type: i0.Output,
|
|
2752
|
+
args: ["verified"]
|
|
2753
|
+
}],
|
|
2754
|
+
verifyFailed: [{
|
|
2755
|
+
type: i0.Output,
|
|
2756
|
+
args: ["verifyFailed"]
|
|
2757
|
+
}]
|
|
2758
|
+
}
|
|
2759
|
+
});
|
|
2760
|
+
export { MICRODEPOSIT_COPY, MicrodepositVerifyComponent, STRIPE_A11Y_MESSAGES, STRIPE_ACH_NOTICE, STRIPE_DEFAULT_ERROR_MESSAGE, STRIPE_ERROR_MESSAGES, STRIPE_LOADER, STRIPE_PAYMENT_DEFAULTS, STRIPE_TECHNICAL_ERROR_MESSAGES, StripePaymentComponent, StripePaymentService, buildLoadOptions, defaultStripeLoader, depositAmountError, descriptorCodeError, getStripeErrorMessage, isDarkPage, microdepositArrivalText, microdepositCancelMessage, microdepositKeepsActiveText, microdepositProcessingText, microdepositStepsText, normalizeDescriptorCode, normalizeIntent, outcomeOf, paymentMethodIdOf, provideStripePayment, readStripeAppearance, readStripeReturnParams, retrieveIntent, verificationOf, verifyMicrodeposits };
|
|
2761
|
+
|
|
2762
|
+
//# sourceMappingURL=forgeroute-ui-stripe.mjs.map
|