stripe-pwa-elements 4.0.1 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/factory-Cm6zUD7R.js +1206 -0
- package/dist/cjs/{factory-Cd2VI_N2.js → i18n-lBbOeQt4.js} +12 -1149
- package/dist/cjs/ion-icon_2.cjs.entry.js +725 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/stripe-address-element.cjs.entry.js +5 -4
- package/dist/cjs/stripe-card-element-modal.cjs.entry.js +3 -2
- package/dist/cjs/{stripe-card-element_2.cjs.entry.js → stripe-card-element.cjs.entry.js} +8 -93
- package/dist/cjs/stripe-currency-selector.cjs.entry.js +4 -3
- package/dist/cjs/stripe-elements.cjs.js +1 -1
- package/dist/cjs/stripe-express-checkout-element.cjs.entry.js +24 -5
- package/dist/cjs/stripe-link-authentication-element.cjs.entry.js +4 -3
- package/dist/cjs/stripe-payment-element.cjs.entry.js +12 -124
- package/dist/cjs/stripe-payment-element.helpers-CvAhIqLt.js +119 -0
- package/dist/cjs/stripe-payment-request-button.cjs.entry.js +2 -2
- package/dist/cjs/stripe-payment-sheet.cjs.entry.js +987 -0
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/components/stripe-address-element/stripe-address-element.js +2 -2
- package/dist/collection/components/stripe-card-element/stripe-card-element.js +3 -2
- package/dist/collection/components/stripe-card-element-modal/stripe-card-element-modal.js +4 -3
- package/dist/collection/components/stripe-express-checkout-element/stripe-express-checkout-element.js +18 -0
- package/dist/collection/components/stripe-modal/stripe-modal.css +27 -1
- package/dist/collection/components/stripe-modal/stripe-modal.js +132 -1
- package/dist/collection/components/stripe-payment-element/stripe-payment-element.helpers.js +4 -7
- package/dist/collection/components/stripe-payment-element/stripe-payment-element.js +4 -4
- package/dist/collection/components/stripe-payment-request-button/stripe-payment-request-button.js +3 -3
- package/dist/collection/components/stripe-payment-sheet/payment-sheet-state.js +193 -0
- package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.checkout.js +94 -0
- package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.css +68 -0
- package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.helpers.js +274 -0
- package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.js +763 -0
- package/dist/collection/services/express-checkout-element-manager.js +36 -2
- package/dist/collection/services/link-authentication-element-manager.js +5 -0
- package/dist/collection/services/stripe-service.js +20 -6
- package/dist/collection/utils/focus.js +76 -0
- package/dist/collection/utils/i18n.js +12 -0
- package/dist/components/factory.js +1 -1
- package/dist/components/i18n.js +1 -0
- package/dist/components/stripe-address-element.js +1 -1
- package/dist/components/stripe-card-element-modal.js +1 -1
- package/dist/components/stripe-card-element2.js +1 -1
- package/dist/components/stripe-currency-selector.js +1 -1
- package/dist/components/stripe-express-checkout-element.js +1 -1
- package/dist/components/stripe-link-authentication-element.js +1 -1
- package/dist/components/stripe-modal2.js +1 -1
- package/dist/components/stripe-payment-element.helpers.js +1 -0
- package/dist/components/stripe-payment-element.js +1 -1
- package/dist/components/stripe-payment-request-button2.js +1 -1
- package/dist/components/stripe-payment-sheet.d.ts +11 -0
- package/dist/components/stripe-payment-sheet.js +1 -0
- package/dist/esm/factory-BaGv8K_i.js +1203 -0
- package/dist/esm/{factory-VTa1Gc94.js → i18n-CL5n3bOb.js} +13 -1149
- package/dist/esm/ion-icon_2.entry.js +722 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/stripe-address-element.entry.js +2 -1
- package/dist/esm/stripe-card-element-modal.entry.js +3 -2
- package/dist/esm/{stripe-card-element_2.entry.js → stripe-card-element.entry.js} +6 -90
- package/dist/esm/stripe-currency-selector.entry.js +2 -1
- package/dist/esm/stripe-elements.js +1 -1
- package/dist/esm/stripe-express-checkout-element.entry.js +20 -1
- package/dist/esm/stripe-link-authentication-element.entry.js +2 -1
- package/dist/esm/stripe-payment-element.entry.js +4 -116
- package/dist/esm/stripe-payment-element.helpers-Bu9RfxS4.js +114 -0
- package/dist/esm/stripe-payment-request-button.entry.js +2 -2
- package/dist/esm/stripe-payment-sheet.entry.js +985 -0
- package/dist/stripe-elements/p-2e41699e.entry.js +1 -0
- package/dist/stripe-elements/p-3fc4583a.entry.js +1 -0
- package/dist/stripe-elements/{p-ae0c336e.entry.js → p-4891edf0.entry.js} +1 -1
- package/dist/stripe-elements/p-7e826964.entry.js +1 -0
- package/dist/stripe-elements/p-BhKXGROE.js +1 -0
- package/dist/stripe-elements/p-CL5n3bOb.js +1 -0
- package/dist/stripe-elements/p-DlMEZwSe.js +1 -0
- package/dist/stripe-elements/p-a395a5d1.entry.js +1 -0
- package/dist/stripe-elements/p-b62c9dae.entry.js +1 -0
- package/dist/stripe-elements/p-b7c20e8e.entry.js +1 -0
- package/dist/stripe-elements/p-ba791c8f.entry.js +1 -0
- package/dist/stripe-elements/p-bec62526.entry.js +1 -0
- package/dist/stripe-elements/p-f5552c81.entry.js +1 -0
- package/dist/stripe-elements/stripe-elements.esm.js +1 -1
- package/dist/types/components/stripe-card-element/stripe-card-element.d.ts +2 -1
- package/dist/types/components/stripe-card-element-modal/stripe-card-element-modal.d.ts +2 -1
- package/dist/types/components/stripe-express-checkout-element/stripe-express-checkout-element.d.ts +5 -0
- package/dist/types/components/stripe-modal/stripe-modal.d.ts +43 -0
- package/dist/types/components/stripe-payment-element/stripe-payment-element.helpers.d.ts +7 -2
- package/dist/types/components/stripe-payment-request-button/stripe-payment-request-button.d.ts +1 -1
- package/dist/types/components/stripe-payment-sheet/payment-sheet-state.d.ts +121 -0
- package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.checkout.d.ts +39 -0
- package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.d.ts +157 -0
- package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.helpers.d.ts +153 -0
- package/dist/types/components.d.ts +182 -10
- package/dist/types/index.d.ts +2 -0
- package/dist/types/services/interfaces.d.ts +3 -0
- package/dist/types/services/stripe-service.d.ts +7 -2
- package/dist/types/utils/focus.d.ts +15 -0
- package/package.json +7 -3
- package/readme.md +59 -6
- package/dist/cjs/ion-icon.cjs.entry.js +0 -431
- package/dist/components/utils.js +0 -1
- package/dist/esm/ion-icon.entry.js +0 -429
- package/dist/stripe-elements/p-1bd46766.entry.js +0 -1
- package/dist/stripe-elements/p-1c6e0a45.entry.js +0 -1
- package/dist/stripe-elements/p-3f42ca0c.entry.js +0 -1
- package/dist/stripe-elements/p-5cf62945.entry.js +0 -1
- package/dist/stripe-elements/p-74de1556.entry.js +0 -1
- package/dist/stripe-elements/p-76e57d78.entry.js +0 -1
- package/dist/stripe-elements/p-840d499f.entry.js +0 -1
- package/dist/stripe-elements/p-CrjrbGJ3.js +0 -1
- package/dist/stripe-elements/p-cfd8e081.entry.js +0 -1
|
@@ -0,0 +1,987 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-Dkb0SxZc.js');
|
|
4
|
+
var i18n = require('./i18n-lBbOeQt4.js');
|
|
5
|
+
var factory = require('./factory-Cm6zUD7R.js');
|
|
6
|
+
var stripePaymentElement_helpers = require('./stripe-payment-element.helpers-CvAhIqLt.js');
|
|
7
|
+
var error = require('./error-FFC4kSs5.js');
|
|
8
|
+
require('./index-CYbA1N_k.js');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* State machine behind `<stripe-payment-sheet>`.
|
|
12
|
+
*
|
|
13
|
+
* Pure functions only: the component feeds events in and performs the returned effects
|
|
14
|
+
* (loading Stripe.js, showing the modal, confirming, emitting events, resolving `present()`).
|
|
15
|
+
* The same rules are model-checked in Quint; see the exhaustive test next to this file.
|
|
16
|
+
*/
|
|
17
|
+
const initialSheetState = {
|
|
18
|
+
phase: 'idle',
|
|
19
|
+
generation: 0,
|
|
20
|
+
pendingPresent: false,
|
|
21
|
+
openRequested: false,
|
|
22
|
+
};
|
|
23
|
+
const CLIENT_SECRET_PATTERNS = [
|
|
24
|
+
[/^pi_[A-Za-z0-9]+_secret_[A-Za-z0-9]+$/, 'payment'],
|
|
25
|
+
[/^seti_[A-Za-z0-9]+_secret_[A-Za-z0-9]+$/, 'setup'],
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* Tell whether a client secret belongs to a PaymentIntent or a SetupIntent from its prefix.
|
|
29
|
+
* @param clientSecret - The `client_secret` of a PaymentIntent (`pi_..._secret_...`) or SetupIntent (`seti_..._secret_...`)
|
|
30
|
+
* @returns The intent kind, or undefined when the format is not recognized
|
|
31
|
+
*/
|
|
32
|
+
const intentKindFromClientSecret = (clientSecret) => {
|
|
33
|
+
const match = CLIENT_SECRET_PATTERNS.find(([pattern]) => pattern.test(clientSecret));
|
|
34
|
+
return match === null || match === void 0 ? void 0 : match[1];
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Tell what a client secret belongs to.
|
|
38
|
+
* A secret from `checkout-session-client-secret` is always a Checkout Session: Stripe does not document the format
|
|
39
|
+
* of a Checkout Session client secret, so it is never inspected. Intent secrets are told apart by their prefix.
|
|
40
|
+
* @param clientSecret - The client secret
|
|
41
|
+
* @param source - The attribute the secret was set through
|
|
42
|
+
* @returns The kind, or undefined when an intent secret has an unknown format
|
|
43
|
+
*/
|
|
44
|
+
const intentKindOf = (clientSecret, source) => {
|
|
45
|
+
if (source === 'checkoutSession') {
|
|
46
|
+
return 'checkoutSession';
|
|
47
|
+
}
|
|
48
|
+
return intentKindFromClientSecret(clientSecret);
|
|
49
|
+
};
|
|
50
|
+
const unchanged = (state) => ({ state, effects: [] });
|
|
51
|
+
/**
|
|
52
|
+
* Resolve the pending `present()` promise, if any.
|
|
53
|
+
*/
|
|
54
|
+
const resolvePending = (state, result) => {
|
|
55
|
+
if (!state.pendingPresent) {
|
|
56
|
+
return unchanged(state);
|
|
57
|
+
}
|
|
58
|
+
return { state: Object.assign(Object.assign({}, state), { pendingPresent: false }), effects: [{ type: 'resolvePresent', result }] };
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Close the sheet as canceled: hide it, emit the event and resolve `present()`.
|
|
62
|
+
*/
|
|
63
|
+
const cancel = (state) => {
|
|
64
|
+
const resolved = resolvePending(Object.assign(Object.assign({}, state), { openRequested: false }), 'paymentSheetCanceled');
|
|
65
|
+
const visible = state.phase === 'presented' || state.phase === 'confirming';
|
|
66
|
+
return {
|
|
67
|
+
state: resolved.state,
|
|
68
|
+
effects: [...(visible ? [{ type: 'hide' }] : []), { type: 'emit', event: 'paymentSheetCanceled' }, ...resolved.effects],
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
const changeSecret = (state, clientSecret, source) => {
|
|
72
|
+
if (clientSecret === '') {
|
|
73
|
+
return unchanged(state);
|
|
74
|
+
}
|
|
75
|
+
// Never drop the result of a running confirmation; apply the new secret once it finishes
|
|
76
|
+
if (state.phase === 'confirming') {
|
|
77
|
+
return unchanged(Object.assign(Object.assign({}, state), { deferredSecret: { clientSecret, source } }));
|
|
78
|
+
}
|
|
79
|
+
const canceled = state.phase === 'presented' ? cancel(state) : unchanged(state);
|
|
80
|
+
const generation = state.generation + 1;
|
|
81
|
+
const intentKind = intentKindOf(clientSecret, source);
|
|
82
|
+
if (intentKind == null) {
|
|
83
|
+
const resolved = resolvePending(Object.assign(Object.assign({}, canceled.state), { phase: 'loadFailed', generation, intentKind: undefined, openRequested: false }), 'paymentSheetFailed');
|
|
84
|
+
return {
|
|
85
|
+
state: resolved.state,
|
|
86
|
+
effects: [...canceled.effects, { type: 'emit', event: 'paymentSheetFailedToLoad' }, ...resolved.effects],
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
state: Object.assign(Object.assign({}, canceled.state), { phase: 'loading', generation, intentKind }),
|
|
91
|
+
effects: [...canceled.effects, { type: 'load', generation, clientSecret, intentKind }],
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Apply a secret that arrived while confirming.
|
|
96
|
+
*/
|
|
97
|
+
const applyDeferredSecret = (result) => {
|
|
98
|
+
const { deferredSecret } = result.state;
|
|
99
|
+
if (deferredSecret == null) {
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
const next = changeSecret(Object.assign(Object.assign({}, result.state), { deferredSecret: undefined }), deferredSecret.clientSecret, deferredSecret.source);
|
|
103
|
+
return { state: next.state, effects: [...result.effects, ...next.effects] };
|
|
104
|
+
};
|
|
105
|
+
const isCurrentConfirmation = (state, generation) => state.phase === 'confirming' && state.generation === generation;
|
|
106
|
+
/**
|
|
107
|
+
* Compute the next state and the effects to perform for an event.
|
|
108
|
+
* @param state - Current state
|
|
109
|
+
* @param event - Event to handle
|
|
110
|
+
*/
|
|
111
|
+
const transition = (state, event) => {
|
|
112
|
+
switch (event.type) {
|
|
113
|
+
case 'secretChanged':
|
|
114
|
+
return changeSecret(state, event.clientSecret, event.source);
|
|
115
|
+
case 'loadSucceeded': {
|
|
116
|
+
if (event.generation !== state.generation || state.phase !== 'loading') {
|
|
117
|
+
return unchanged(state);
|
|
118
|
+
}
|
|
119
|
+
const open = state.openRequested;
|
|
120
|
+
return {
|
|
121
|
+
state: Object.assign(Object.assign({}, state), { phase: open ? 'presented' : 'ready', openRequested: false }),
|
|
122
|
+
effects: [{ type: 'emit', event: 'paymentSheetLoaded' }, ...(open ? [{ type: 'show' }] : [])],
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
case 'loadFailed': {
|
|
126
|
+
if (event.generation !== state.generation || state.phase !== 'loading') {
|
|
127
|
+
return unchanged(state);
|
|
128
|
+
}
|
|
129
|
+
const resolved = resolvePending(Object.assign(Object.assign({}, state), { phase: 'loadFailed', openRequested: false }), 'paymentSheetFailed');
|
|
130
|
+
return { state: resolved.state, effects: [{ type: 'emit', event: 'paymentSheetFailedToLoad' }, ...resolved.effects] };
|
|
131
|
+
}
|
|
132
|
+
case 'presentRequested':
|
|
133
|
+
if (state.pendingPresent) {
|
|
134
|
+
return unchanged(state);
|
|
135
|
+
}
|
|
136
|
+
switch (state.phase) {
|
|
137
|
+
case 'ready':
|
|
138
|
+
return { state: Object.assign(Object.assign({}, state), { phase: 'presented', pendingPresent: true }), effects: [{ type: 'show' }] };
|
|
139
|
+
case 'idle':
|
|
140
|
+
case 'loading':
|
|
141
|
+
return unchanged(Object.assign(Object.assign({}, state), { pendingPresent: true, openRequested: true }));
|
|
142
|
+
case 'presented':
|
|
143
|
+
case 'confirming':
|
|
144
|
+
// Already shown through the `open` attribute: wait for its result
|
|
145
|
+
return unchanged(Object.assign(Object.assign({}, state), { pendingPresent: true }));
|
|
146
|
+
default:
|
|
147
|
+
// loadFailed / completed / errored: nothing can be shown
|
|
148
|
+
return { state, effects: [{ type: 'resolvePresent', result: 'paymentSheetFailed' }] };
|
|
149
|
+
}
|
|
150
|
+
case 'openRequested':
|
|
151
|
+
if (state.phase === 'ready') {
|
|
152
|
+
return { state: Object.assign(Object.assign({}, state), { phase: 'presented' }), effects: [{ type: 'show' }] };
|
|
153
|
+
}
|
|
154
|
+
if (state.phase === 'idle' || state.phase === 'loading') {
|
|
155
|
+
return unchanged(Object.assign(Object.assign({}, state), { openRequested: true }));
|
|
156
|
+
}
|
|
157
|
+
return unchanged(state);
|
|
158
|
+
case 'closeRequested':
|
|
159
|
+
if (state.phase === 'presented') {
|
|
160
|
+
const canceled = cancel(state);
|
|
161
|
+
return { state: Object.assign(Object.assign({}, canceled.state), { phase: 'ready' }), effects: canceled.effects };
|
|
162
|
+
}
|
|
163
|
+
// Closing before the sheet was shown withdraws the request to open it
|
|
164
|
+
if ((state.phase === 'idle' || state.phase === 'loading') && state.openRequested) {
|
|
165
|
+
return cancel(state);
|
|
166
|
+
}
|
|
167
|
+
return unchanged(state);
|
|
168
|
+
case 'submitted':
|
|
169
|
+
if (state.phase !== 'presented' || state.intentKind == null) {
|
|
170
|
+
return unchanged(state);
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
state: Object.assign(Object.assign({}, state), { phase: 'confirming' }),
|
|
174
|
+
effects: [{ type: 'confirm', generation: state.generation, intentKind: state.intentKind }],
|
|
175
|
+
};
|
|
176
|
+
case 'confirmSucceeded': {
|
|
177
|
+
if (!isCurrentConfirmation(state, event.generation)) {
|
|
178
|
+
return unchanged(state);
|
|
179
|
+
}
|
|
180
|
+
const resolved = resolvePending(Object.assign(Object.assign({}, state), { phase: 'completed' }), 'paymentSheetCompleted');
|
|
181
|
+
return applyDeferredSecret({
|
|
182
|
+
state: resolved.state,
|
|
183
|
+
effects: [{ type: 'hide' }, { type: 'emit', event: 'paymentSheetCompleted' }, ...resolved.effects],
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
case 'confirmDeclined':
|
|
187
|
+
if (!isCurrentConfirmation(state, event.generation)) {
|
|
188
|
+
return unchanged(state);
|
|
189
|
+
}
|
|
190
|
+
return applyDeferredSecret({ state: Object.assign(Object.assign({}, state), { phase: 'presented' }), effects: [{ type: 'showError', message: event.message }] });
|
|
191
|
+
case 'confirmFailed': {
|
|
192
|
+
if (!isCurrentConfirmation(state, event.generation)) {
|
|
193
|
+
return unchanged(state);
|
|
194
|
+
}
|
|
195
|
+
const resolved = resolvePending(Object.assign(Object.assign({}, state), { phase: 'errored' }), 'paymentSheetFailed');
|
|
196
|
+
return applyDeferredSecret({
|
|
197
|
+
state: resolved.state,
|
|
198
|
+
effects: [{ type: 'hide' }, { type: 'emit', event: 'paymentSheetFailed' }, ...resolved.effects],
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
205
|
+
var t = {};
|
|
206
|
+
for (var p in s)
|
|
207
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
208
|
+
t[p] = s[p];
|
|
209
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
210
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
211
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
212
|
+
t[p[i]] = s[p[i]];
|
|
213
|
+
}
|
|
214
|
+
return t;
|
|
215
|
+
};
|
|
216
|
+
const SUPPORTED_OPTION_KEYS = [
|
|
217
|
+
'merchantDisplayName',
|
|
218
|
+
'paymentMethodLayout',
|
|
219
|
+
'defaultBillingDetails',
|
|
220
|
+
'returnURL',
|
|
221
|
+
'style',
|
|
222
|
+
'billingDetailsCollectionConfiguration',
|
|
223
|
+
'shippingDetails',
|
|
224
|
+
'enableApplePay',
|
|
225
|
+
'enableGooglePay',
|
|
226
|
+
];
|
|
227
|
+
const LAYOUTS = {
|
|
228
|
+
horizontal: 'tabs',
|
|
229
|
+
vertical: 'accordion',
|
|
230
|
+
automatic: 'auto',
|
|
231
|
+
};
|
|
232
|
+
const THEMES = {
|
|
233
|
+
alwaysLight: 'stripe',
|
|
234
|
+
alwaysDark: 'night',
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* Drop keys whose value is undefined.
|
|
238
|
+
*/
|
|
239
|
+
const compact = (value) => Object.fromEntries(Object.entries(value).filter(([, v]) => v !== undefined));
|
|
240
|
+
/**
|
|
241
|
+
* Convert a Capacitor address to the Stripe shape (`postalCode` → `postal_code`), dropping keys that are not given.
|
|
242
|
+
*/
|
|
243
|
+
const toStripeAddress = (address) => {
|
|
244
|
+
const { postalCode } = address, rest = __rest(address, ["postalCode"]);
|
|
245
|
+
return compact(Object.assign(Object.assign({}, rest), { postal_code: postalCode }));
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* Payment Element billing fields to turn off: the `never` ones (passed from `defaultBillingDetails` at confirmation)
|
|
249
|
+
* and the ones collected by a separate element (email element, billing Address Element).
|
|
250
|
+
*/
|
|
251
|
+
const toBillingDetailsFields = (config) => {
|
|
252
|
+
if (config == null) {
|
|
253
|
+
return undefined;
|
|
254
|
+
}
|
|
255
|
+
const { email, name, phone, address } = config;
|
|
256
|
+
const fields = compact({
|
|
257
|
+
email: email === 'never' || email === 'always' ? 'never' : undefined,
|
|
258
|
+
name: name === 'never' ? 'never' : undefined,
|
|
259
|
+
phone: phone === 'never' || (phone === 'always' && address === 'full') ? 'never' : undefined,
|
|
260
|
+
address: address === 'never' || address === 'full' ? 'never' : undefined,
|
|
261
|
+
});
|
|
262
|
+
return Object.keys(fields).length === 0 ? undefined : fields;
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* `true` → `auto` (shown when available), `false` → `never`, undefined → left to Stripe
|
|
266
|
+
*/
|
|
267
|
+
const toWalletOption = (enabled) => (enabled == null ? undefined : enabled ? 'auto' : 'never');
|
|
268
|
+
/**
|
|
269
|
+
* Build the Payment Element options from the payment sheet options.
|
|
270
|
+
* @param options - Payment sheet options
|
|
271
|
+
*/
|
|
272
|
+
const toPaymentElementOptions = (options) => {
|
|
273
|
+
if (options == null) {
|
|
274
|
+
return {};
|
|
275
|
+
}
|
|
276
|
+
const { merchantDisplayName, paymentMethodLayout, defaultBillingDetails, billingDetailsCollectionConfiguration, enableApplePay, enableGooglePay } = options;
|
|
277
|
+
const elementOptions = {};
|
|
278
|
+
const billingDetailsFields = toBillingDetailsFields(billingDetailsCollectionConfiguration);
|
|
279
|
+
const wallets = compact({ applePay: toWalletOption(enableApplePay), googlePay: toWalletOption(enableGooglePay) });
|
|
280
|
+
if (billingDetailsFields != null) {
|
|
281
|
+
elementOptions.fields = { billingDetails: billingDetailsFields };
|
|
282
|
+
}
|
|
283
|
+
if (Object.keys(wallets).length > 0) {
|
|
284
|
+
elementOptions.wallets = wallets;
|
|
285
|
+
}
|
|
286
|
+
if (merchantDisplayName != null) {
|
|
287
|
+
elementOptions.business = { name: merchantDisplayName };
|
|
288
|
+
}
|
|
289
|
+
if (paymentMethodLayout != null) {
|
|
290
|
+
elementOptions.layout = LAYOUTS[paymentMethodLayout];
|
|
291
|
+
}
|
|
292
|
+
if (defaultBillingDetails != null) {
|
|
293
|
+
const { address } = defaultBillingDetails, contact = __rest(defaultBillingDetails, ["address"]);
|
|
294
|
+
const billingDetails = compact(contact);
|
|
295
|
+
if (address != null) {
|
|
296
|
+
billingDetails.address = toStripeAddress(address);
|
|
297
|
+
}
|
|
298
|
+
elementOptions.defaultValues = { billingDetails };
|
|
299
|
+
}
|
|
300
|
+
return elementOptions;
|
|
301
|
+
};
|
|
302
|
+
/**
|
|
303
|
+
* Build the Elements appearance from the payment sheet style.
|
|
304
|
+
* @param style - `alwaysLight` or `alwaysDark`
|
|
305
|
+
*/
|
|
306
|
+
const toAppearance = (style) => {
|
|
307
|
+
if (style == null) {
|
|
308
|
+
return undefined;
|
|
309
|
+
}
|
|
310
|
+
return { theme: THEMES[style] };
|
|
311
|
+
};
|
|
312
|
+
/**
|
|
313
|
+
* List the given options (or option values, as `option.key`) that have no effect on the web (yet), sorted by name.
|
|
314
|
+
* @param options - Payment sheet options
|
|
315
|
+
* @param intentKind - Kind of the intent, when known
|
|
316
|
+
*/
|
|
317
|
+
const unsupportedOptionKeys = (options, intentKind) => {
|
|
318
|
+
if (options == null) {
|
|
319
|
+
return [];
|
|
320
|
+
}
|
|
321
|
+
const keys = Object.entries(options)
|
|
322
|
+
.filter(([key, value]) => value !== undefined && !SUPPORTED_OPTION_KEYS.includes(key))
|
|
323
|
+
.map(([key]) => key);
|
|
324
|
+
const config = options.billingDetailsCollectionConfiguration;
|
|
325
|
+
// `fields.billingDetails.name: 'always'` of the Payment Element requires Stripe beta access, so it is not sent
|
|
326
|
+
if ((config === null || config === void 0 ? void 0 : config.name) === 'always') {
|
|
327
|
+
keys.push('billingDetailsCollectionConfiguration.name');
|
|
328
|
+
}
|
|
329
|
+
// The phone can only be required through the billing Address Element
|
|
330
|
+
if ((config === null || config === void 0 ? void 0 : config.phone) === 'always' && config.address !== 'full') {
|
|
331
|
+
keys.push('billingDetailsCollectionConfiguration.phone');
|
|
332
|
+
}
|
|
333
|
+
// A SetupIntent has no shipping details
|
|
334
|
+
if (options.shippingDetails != null && intentKind === 'setup') {
|
|
335
|
+
keys.push('shippingDetails');
|
|
336
|
+
}
|
|
337
|
+
return keys.sort();
|
|
338
|
+
};
|
|
339
|
+
/**
|
|
340
|
+
* Prefill values of an Address Element. The address is left out without a country, which the Address Element requires.
|
|
341
|
+
*/
|
|
342
|
+
const toAddressDefaultValues = (details) => {
|
|
343
|
+
const { name, phone, address } = details;
|
|
344
|
+
const country = address === null || address === void 0 ? void 0 : address.country;
|
|
345
|
+
return compact({ name, phone, address: country == null || country === '' ? undefined : Object.assign(Object.assign({}, toStripeAddress(address)), { country }) });
|
|
346
|
+
};
|
|
347
|
+
const isBlank = (value) => value == null || value === '';
|
|
348
|
+
/**
|
|
349
|
+
* Loose email check, used only when the email element has not told whether its value is complete (a prefilled value nobody edited)
|
|
350
|
+
*/
|
|
351
|
+
const looksLikeEmail = (value) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
|
|
352
|
+
/**
|
|
353
|
+
* Error for a `never` field without a default value. Thrown while loading so that Stripe never rejects the confirmation.
|
|
354
|
+
*/
|
|
355
|
+
const missingDefaultError = (field, defaultKey) => new Error(`<stripe-payment-sheet>: billingDetailsCollectionConfiguration.${field} is 'never', so defaultBillingDetails.${defaultKey} is required`);
|
|
356
|
+
/**
|
|
357
|
+
* Error the customer can fix in the open sheet (handled like a Stripe `validation_error`).
|
|
358
|
+
* Its message is an English i18n key, translated when it is shown (see `isSheetValidationError`).
|
|
359
|
+
*/
|
|
360
|
+
const validationError = (message) => Object.assign(new Error(message), { type: 'validation_error', sheetValidation: true });
|
|
361
|
+
/**
|
|
362
|
+
* Tell whether an error was raised by this sheet's own validation (its message is an i18n key), rather than by Stripe (already localized).
|
|
363
|
+
* @param error - Error thrown while confirming
|
|
364
|
+
*/
|
|
365
|
+
const isSheetValidationError = (error) => (error === null || error === void 0 ? void 0 : error.sheetValidation) === true;
|
|
366
|
+
/**
|
|
367
|
+
* Decide which extra elements to show and which billing details to pass at confirmation (PaymentIntent / SetupIntent mode).
|
|
368
|
+
* @param options - Payment sheet options
|
|
369
|
+
* @param intentKind - Kind of the intent being confirmed
|
|
370
|
+
* @throws Error when a `never` field has no value in `defaultBillingDetails`
|
|
371
|
+
*/
|
|
372
|
+
const planBillingDetailsCollection = (options, intentKind) => {
|
|
373
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
374
|
+
const config = (_a = options === null || options === void 0 ? void 0 : options.billingDetailsCollectionConfiguration) !== null && _a !== void 0 ? _a : {};
|
|
375
|
+
const defaults = (_b = options === null || options === void 0 ? void 0 : options.defaultBillingDetails) !== null && _b !== void 0 ? _b : {};
|
|
376
|
+
const fixedBillingDetails = {};
|
|
377
|
+
['email', 'name', 'phone'].forEach(field => {
|
|
378
|
+
if (config[field] !== 'never') {
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
if (isBlank(defaults[field])) {
|
|
382
|
+
throw missingDefaultError(field, field);
|
|
383
|
+
}
|
|
384
|
+
fixedBillingDetails[field] = defaults[field];
|
|
385
|
+
});
|
|
386
|
+
if (config.address === 'never') {
|
|
387
|
+
const address = defaults.address;
|
|
388
|
+
if (address == null || isBlank(address.country)) {
|
|
389
|
+
throw missingDefaultError('address', 'address.country');
|
|
390
|
+
}
|
|
391
|
+
// Every key is passed: the Payment Element does not collect any part of the address
|
|
392
|
+
fixedBillingDetails.address = {
|
|
393
|
+
line1: (_c = address.line1) !== null && _c !== void 0 ? _c : '',
|
|
394
|
+
line2: (_d = address.line2) !== null && _d !== void 0 ? _d : '',
|
|
395
|
+
city: (_e = address.city) !== null && _e !== void 0 ? _e : '',
|
|
396
|
+
state: (_f = address.state) !== null && _f !== void 0 ? _f : '',
|
|
397
|
+
postal_code: (_g = address.postalCode) !== null && _g !== void 0 ? _g : '',
|
|
398
|
+
country: address.country,
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
const collectPhoneFromAddress = config.address === 'full' && config.phone === 'always';
|
|
402
|
+
const plan = { fixedBillingDetails, collectPhoneFromAddress };
|
|
403
|
+
if (config.address === 'full') {
|
|
404
|
+
const billingAddressElement = { mode: 'billing', defaultValues: toAddressDefaultValues(defaults) };
|
|
405
|
+
if (collectPhoneFromAddress) {
|
|
406
|
+
billingAddressElement.fields = { phone: 'always' };
|
|
407
|
+
billingAddressElement.validation = { phone: { required: 'always' } };
|
|
408
|
+
}
|
|
409
|
+
else if (config.phone === 'never') {
|
|
410
|
+
billingAddressElement.fields = { phone: 'never' };
|
|
411
|
+
}
|
|
412
|
+
plan.billingAddressElement = billingAddressElement;
|
|
413
|
+
}
|
|
414
|
+
if (config.email === 'always') {
|
|
415
|
+
plan.emailElement = isBlank(defaults.email) ? {} : { defaultValues: { email: defaults.email } };
|
|
416
|
+
}
|
|
417
|
+
const shippingDetails = options === null || options === void 0 ? void 0 : options.shippingDetails;
|
|
418
|
+
if (shippingDetails != null && intentKind === 'payment') {
|
|
419
|
+
const shippingAddressElement = { mode: 'shipping', defaultValues: toAddressDefaultValues(shippingDetails) };
|
|
420
|
+
// The Address Element hides the phone field by default; show it so that the given phone is kept and editable
|
|
421
|
+
if (!isBlank(shippingDetails.phone)) {
|
|
422
|
+
shippingAddressElement.fields = { phone: 'always' };
|
|
423
|
+
}
|
|
424
|
+
plan.shippingAddressElement = shippingAddressElement;
|
|
425
|
+
}
|
|
426
|
+
return plan;
|
|
427
|
+
};
|
|
428
|
+
/**
|
|
429
|
+
* Build `payment_method_data.billing_details` for the confirmation.
|
|
430
|
+
* Values fixed by a `never` field win over the values typed into the extra elements.
|
|
431
|
+
* @param plan - Result of `planBillingDetailsCollection`
|
|
432
|
+
* @param collected - Values read from the extra elements
|
|
433
|
+
* @returns The billing details, or undefined when nothing has to be passed
|
|
434
|
+
* @throws Error with `type: 'validation_error'` when an extra element is not complete
|
|
435
|
+
*/
|
|
436
|
+
const collectedBillingDetails = (plan, collected) => {
|
|
437
|
+
var _a, _b;
|
|
438
|
+
const details = {};
|
|
439
|
+
if (plan.billingAddressElement != null) {
|
|
440
|
+
const billingAddress = collected.billingAddress;
|
|
441
|
+
if (billingAddress == null || !billingAddress.complete) {
|
|
442
|
+
throw validationError('Please complete your billing address.');
|
|
443
|
+
}
|
|
444
|
+
details.name = billingAddress.value.name;
|
|
445
|
+
details.address = billingAddress.value.address;
|
|
446
|
+
if (plan.collectPhoneFromAddress) {
|
|
447
|
+
details.phone = billingAddress.value.phone;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
if (plan.emailElement != null) {
|
|
451
|
+
// Before any change event the element shows its prefilled value
|
|
452
|
+
const email = (_a = collected.email) !== null && _a !== void 0 ? _a : (_b = plan.emailElement.defaultValues) === null || _b === void 0 ? void 0 : _b.email;
|
|
453
|
+
if (isBlank(email)) {
|
|
454
|
+
throw validationError('Please enter your email address.');
|
|
455
|
+
}
|
|
456
|
+
if (collected.emailComplete === false || (collected.emailComplete == null && !looksLikeEmail(email))) {
|
|
457
|
+
throw validationError('Please enter a valid email address.');
|
|
458
|
+
}
|
|
459
|
+
details.email = email;
|
|
460
|
+
}
|
|
461
|
+
Object.assign(details, plan.fixedBillingDetails);
|
|
462
|
+
return Object.keys(details).length === 0 ? undefined : details;
|
|
463
|
+
};
|
|
464
|
+
/**
|
|
465
|
+
* Stripe error types after which the customer can fix the input or simply try again.
|
|
466
|
+
* Types are listed at https://docs.stripe.com/api/errors and in `StripeErrorType` of @stripe/stripe-js.
|
|
467
|
+
*/
|
|
468
|
+
const RECOVERABLE_ERROR_TYPES = ['card_error', 'validation_error', 'api_connection_error', 'rate_limit_error', 'api_error'];
|
|
469
|
+
/**
|
|
470
|
+
* Tell whether a confirmation error lets the customer try again in the open sheet.
|
|
471
|
+
* Other errors (for example `invalid_request_error` for an intent that already succeeded) end the sheet with `paymentSheetFailed`.
|
|
472
|
+
* @param error - Error thrown while confirming
|
|
473
|
+
*/
|
|
474
|
+
const isRecoverableConfirmError = (error) => {
|
|
475
|
+
const type = error === null || error === void 0 ? void 0 : error.type;
|
|
476
|
+
return typeof type === 'string' && RECOVERABLE_ERROR_TYPES.includes(type);
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Build the Checkout Payment Element options from the payment sheet options.
|
|
481
|
+
* The Checkout Payment Element takes fewer options than the regular one: `business` and `defaultValues` are not
|
|
482
|
+
* available, so only the layout is passed.
|
|
483
|
+
* @param options - Payment sheet options
|
|
484
|
+
*/
|
|
485
|
+
const toCheckoutPaymentElementOptions = (options) => {
|
|
486
|
+
const { layout } = toPaymentElementOptions(options);
|
|
487
|
+
return layout == null ? {} : { layout };
|
|
488
|
+
};
|
|
489
|
+
/**
|
|
490
|
+
* List the given options that a Checkout Session does not use, sorted by name.
|
|
491
|
+
* Name, phone and address come from the session or from other Checkout elements; the email is passed to `confirm`.
|
|
492
|
+
* @param options - Payment sheet options
|
|
493
|
+
*/
|
|
494
|
+
const checkoutIgnoredOptionKeys = (options) => {
|
|
495
|
+
if (options == null) {
|
|
496
|
+
return [];
|
|
497
|
+
}
|
|
498
|
+
const { merchantDisplayName, defaultBillingDetails } = options;
|
|
499
|
+
const keys = ['name', 'phone', 'address'].filter(key => (defaultBillingDetails === null || defaultBillingDetails === void 0 ? void 0 : defaultBillingDetails[key]) != null).map(key => `defaultBillingDetails.${key}`);
|
|
500
|
+
if (merchantDisplayName != null) {
|
|
501
|
+
keys.push('merchantDisplayName');
|
|
502
|
+
}
|
|
503
|
+
// The extra billing elements and the wallet mapping are implemented for PaymentIntent / SetupIntent mode only
|
|
504
|
+
['billingDetailsCollectionConfiguration', 'shippingDetails', 'enableApplePay', 'enableGooglePay']
|
|
505
|
+
.filter(key => options[key] !== undefined)
|
|
506
|
+
.forEach(key => keys.push(key));
|
|
507
|
+
return keys.sort();
|
|
508
|
+
};
|
|
509
|
+
/**
|
|
510
|
+
* Build the `elementsOptions` passed to `initCheckoutElementsSdk` from the payment sheet options.
|
|
511
|
+
* @param options - Payment sheet options
|
|
512
|
+
*/
|
|
513
|
+
const toCheckoutElementsOptions = (options) => {
|
|
514
|
+
const appearance = toAppearance(options === null || options === void 0 ? void 0 : options.style);
|
|
515
|
+
return appearance == null ? undefined : { appearance };
|
|
516
|
+
};
|
|
517
|
+
/**
|
|
518
|
+
* Throw when the session can no longer be paid. Stripe documents an `expired` session as "No further processing will occur",
|
|
519
|
+
* and a `complete` one is already paid or being paid, so confirming again cannot succeed.
|
|
520
|
+
* @param status - `session.status` from `getSession()`; undefined when it cannot be read
|
|
521
|
+
* @param message - Message of the confirm error, if any
|
|
522
|
+
* @throws StripeAPIError of type `invalid_request_error` (unrecoverable), with the code `checkout_session_expired` or `checkout_session_complete`
|
|
523
|
+
*/
|
|
524
|
+
const assertSessionOpen = (status, message) => {
|
|
525
|
+
if (status == null || status.type === 'open') {
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
throw new error.StripeAPIError({
|
|
529
|
+
type: 'invalid_request_error',
|
|
530
|
+
code: `checkout_session_${status.type}`,
|
|
531
|
+
message: message !== null && message !== void 0 ? message : `The Checkout Session is ${status.type} and can no longer be paid.`,
|
|
532
|
+
});
|
|
533
|
+
};
|
|
534
|
+
/**
|
|
535
|
+
* Confirm a Checkout Session from the payment sheet.
|
|
536
|
+
*
|
|
537
|
+
* Unlike the default of `confirm`, which always redirects to `returnUrl`, this passes `redirect: 'if_required'`
|
|
538
|
+
* so that payment methods without a redirect finish in the page and can be reported as `paymentSheetCompleted`.
|
|
539
|
+
*
|
|
540
|
+
* Errors are thrown as `StripeAPIError` with a `type` that `isRecoverableConfirmError` understands.
|
|
541
|
+
* A confirm error only carries `code: 'paymentFailed'` or `code: null` (`StripeCheckoutConfirmResult` in @stripe/stripe-js),
|
|
542
|
+
* so whether the session can still be paid is read from `session.status`:
|
|
543
|
+
* - session `expired` or `complete` (before confirming or after a failed confirm): `invalid_request_error`, which ends the sheet
|
|
544
|
+
* - `paymentFailed` on an open session (a decline): `card_error`, which keeps the sheet open
|
|
545
|
+
* - any other confirm error on an open session, or a failure to load the actions: `api_error`, which keeps the sheet open
|
|
546
|
+
* @param checkout - The Checkout instance from `initCheckoutElementsSdk`
|
|
547
|
+
* @param returnUrl - Where Stripe redirects after a redirect-based payment method
|
|
548
|
+
* @param email - Customer email; needed when the session was created without `customer_email` or `customer`
|
|
549
|
+
* @returns The confirmation result
|
|
550
|
+
* @throws StripeAPIError when the actions cannot be loaded, the session can no longer be paid, or the confirmation fails
|
|
551
|
+
*/
|
|
552
|
+
const confirmCheckoutSessionSheet = async (checkout, returnUrl, email) => {
|
|
553
|
+
const loadActionsResult = await checkout.loadActions();
|
|
554
|
+
if (loadActionsResult.type === 'error') {
|
|
555
|
+
throw new error.StripeAPIError({ type: 'api_error', code: 'checkout_session_error', message: loadActionsResult.error.message });
|
|
556
|
+
}
|
|
557
|
+
const { actions } = loadActionsResult;
|
|
558
|
+
const sessionStatus = () => { var _a, _b; return (_b = (_a = actions.getSession) === null || _a === void 0 ? void 0 : _a.call(actions)) === null || _b === void 0 ? void 0 : _b.status; };
|
|
559
|
+
assertSessionOpen(sessionStatus());
|
|
560
|
+
const result = await actions.confirm(Object.assign({ returnUrl, redirect: 'if_required' }, (email != null && email !== '' ? { email } : {})));
|
|
561
|
+
if (result.type === 'error') {
|
|
562
|
+
const { code, message } = result.error;
|
|
563
|
+
assertSessionOpen(sessionStatus(), message);
|
|
564
|
+
if (code === 'paymentFailed') {
|
|
565
|
+
throw new error.StripeAPIError({ type: 'card_error', code, message });
|
|
566
|
+
}
|
|
567
|
+
throw new error.StripeAPIError({ type: 'api_error', code: 'checkout_session_error', message });
|
|
568
|
+
}
|
|
569
|
+
return result;
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
const stripePaymentSheetCss = () => `:root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}stripe-payment-sheet{display:contents}.stripe-payment-sheet-wrap{box-sizing:border-box}.stripe-payment-sheet-wrap *:where(:not(iframe,canvas,img,svg,video):not(svg *)){all:unset;display:revert;background:none;border:none;font-family:"Roboto", sans-serif;box-sizing:border-box}.stripe-payment-sheet-wrap button{cursor:pointer}.stripe-payment-sheet-wrap{display:block;width:100%;background:#fff;padding:32px 16px}.stripe-payment-sheet-wrap .stripe-heading{font-size:24px;font-weight:bold;color:var(--color-heading-text);margin-bottom:24px}.stripe-payment-sheet-wrap .payment-info{margin-top:8px}.stripe-payment-sheet-wrap .stripe-element-errors{margin-top:8px;font-size:14px;color:var(--color-text-error)}.stripe-payment-sheet-wrap .stripe-submit{margin-top:32px}.stripe-payment-sheet-wrap button{display:block;color:var(--color-button-text);background-color:var(--color-primary);width:100%;text-align:center;padding:16px 16px;font-size:18px;border-radius:6px;min-height:42px}.stripe-payment-sheet-wrap button:disabled{color:var(--color-button-text-disabled)}`;
|
|
573
|
+
|
|
574
|
+
const nonEmpty = (value) => (value == null || value === '' ? undefined : value);
|
|
575
|
+
const StripePaymentSheet = class {
|
|
576
|
+
/**
|
|
577
|
+
* Show the sheet and wait for its result.
|
|
578
|
+
* Calling it again while a result is pending returns the same promise.
|
|
579
|
+
* @returns `{ paymentResult }`, where `paymentResult` is `paymentSheetCompleted`, `paymentSheetCanceled` or `paymentSheetFailed`
|
|
580
|
+
* @example
|
|
581
|
+
* ```
|
|
582
|
+
* const sheet = document.querySelector('stripe-payment-sheet');
|
|
583
|
+
* const { paymentResult } = await sheet.present();
|
|
584
|
+
* ```
|
|
585
|
+
*/
|
|
586
|
+
async present() {
|
|
587
|
+
if (this.presentPromise == null) {
|
|
588
|
+
this.presentPromise = new Promise(resolve => {
|
|
589
|
+
this.resolvePresent = resolve;
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
const promise = this.presentPromise;
|
|
593
|
+
this.dispatch({ type: 'presentRequested' });
|
|
594
|
+
return promise;
|
|
595
|
+
}
|
|
596
|
+
handleSecretChange() {
|
|
597
|
+
this.startLoading();
|
|
598
|
+
}
|
|
599
|
+
handleOpenChange(open) {
|
|
600
|
+
this.dispatch({ type: open ? 'openRequested' : 'closeRequested' });
|
|
601
|
+
}
|
|
602
|
+
constructor(hostRef) {
|
|
603
|
+
index.registerInstance(this, hostRef);
|
|
604
|
+
this.paymentSheetLoaded = index.createEvent(this, "paymentSheetLoaded", 7);
|
|
605
|
+
this.paymentSheetFailedToLoad = index.createEvent(this, "paymentSheetFailedToLoad", 7);
|
|
606
|
+
this.paymentSheetCompleted = index.createEvent(this, "paymentSheetCompleted", 7);
|
|
607
|
+
this.paymentSheetCanceled = index.createEvent(this, "paymentSheetCanceled", 7);
|
|
608
|
+
this.paymentSheetFailed = index.createEvent(this, "paymentSheetFailed", 7);
|
|
609
|
+
this.warnedUnsupportedOptions = false;
|
|
610
|
+
this.warnedCheckoutIgnoredOptions = false;
|
|
611
|
+
/**
|
|
612
|
+
* Whether the sheet is shown. Setting it to false closes the sheet as canceled.
|
|
613
|
+
*/
|
|
614
|
+
this.open = false;
|
|
615
|
+
/**
|
|
616
|
+
* Sheet title. Translated automatically by this library.
|
|
617
|
+
*/
|
|
618
|
+
this.sheetTitle = 'Add your payment information';
|
|
619
|
+
/**
|
|
620
|
+
* Submit button label. Translated automatically by this library.
|
|
621
|
+
*/
|
|
622
|
+
this.buttonLabel = 'Pay';
|
|
623
|
+
/**
|
|
624
|
+
* Application name registered to Stripe.js, for wrapper libraries such as `@capacitor-community/stripe`.
|
|
625
|
+
*/
|
|
626
|
+
this.applicationName = 'stripe-pwa-elements';
|
|
627
|
+
this.sheet = initialSheetState;
|
|
628
|
+
this.visible = false;
|
|
629
|
+
this.errorMessage = '';
|
|
630
|
+
this.handleSubmit = (e) => {
|
|
631
|
+
e.preventDefault();
|
|
632
|
+
this.errorMessage = '';
|
|
633
|
+
this.dispatch({ type: 'submitted' });
|
|
634
|
+
};
|
|
635
|
+
/**
|
|
636
|
+
* The modal closes itself on a backdrop or close button click. Keep it open when the sheet refuses to close (while confirming).
|
|
637
|
+
*/
|
|
638
|
+
this.handleModalClose = () => {
|
|
639
|
+
var _a;
|
|
640
|
+
this.dispatch({ type: 'closeRequested' });
|
|
641
|
+
if (this.visible) {
|
|
642
|
+
(_a = this.el.querySelector('stripe-modal')) === null || _a === void 0 ? void 0 : _a.openModal();
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
this.stripeService = factory.serviceFactory.createStripeService();
|
|
646
|
+
this.paymentElementManager = factory.serviceFactory.createPaymentElementManager(this.stripeService);
|
|
647
|
+
this.billingAddressElementManager = factory.serviceFactory.createAddressElementManager(this.stripeService);
|
|
648
|
+
this.shippingAddressElementManager = factory.serviceFactory.createAddressElementManager(this.stripeService);
|
|
649
|
+
this.emailElementManager = factory.serviceFactory.createLinkAuthenticationElementManager(this.stripeService);
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Props are not yet populated inside the constructor with the custom-elements build,
|
|
653
|
+
* so loading starts here.
|
|
654
|
+
*/
|
|
655
|
+
componentWillLoad() {
|
|
656
|
+
if (this.open) {
|
|
657
|
+
this.dispatch({ type: 'openRequested' });
|
|
658
|
+
}
|
|
659
|
+
this.startLoading();
|
|
660
|
+
}
|
|
661
|
+
componentDidLoad() {
|
|
662
|
+
this.el.classList.add(i18n.checkPlatform());
|
|
663
|
+
}
|
|
664
|
+
disconnectedCallback() {
|
|
665
|
+
this.paymentElementManager.unmount();
|
|
666
|
+
this.unmountExtraElements();
|
|
667
|
+
}
|
|
668
|
+
unmountExtraElements() {
|
|
669
|
+
this.billingAddressElementManager.unmount();
|
|
670
|
+
this.shippingAddressElementManager.unmount();
|
|
671
|
+
this.emailElementManager.unmount();
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Decide what to load from the attributes and load it only when it differs from the last load.
|
|
675
|
+
* A change that does not alter the result (the attribute that is not used, or an empty value that means unset)
|
|
676
|
+
* must neither reload Stripe.js nor cancel an open sheet.
|
|
677
|
+
*/
|
|
678
|
+
startLoading() {
|
|
679
|
+
const target = this.loadTarget();
|
|
680
|
+
if (target == null || target.key === this.lastLoadKey) {
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
this.lastLoadKey = target.key;
|
|
684
|
+
this.dispatch({ type: 'secretChanged', clientSecret: target.clientSecret, source: target.source });
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* The secret to load and a key of everything the load depends on, or undefined when nothing can be loaded.
|
|
688
|
+
* The Checkout Session wins when both secrets are set (the same rule as `stripe-payment-element`).
|
|
689
|
+
*/
|
|
690
|
+
loadTarget() {
|
|
691
|
+
var _a;
|
|
692
|
+
const publishableKey = nonEmpty(this.publishableKey);
|
|
693
|
+
if (publishableKey == null) {
|
|
694
|
+
return undefined;
|
|
695
|
+
}
|
|
696
|
+
const checkoutSessionClientSecret = nonEmpty(this.checkoutSessionClientSecret);
|
|
697
|
+
const intentClientSecret = nonEmpty(this.intentClientSecret);
|
|
698
|
+
const [clientSecret, source] = checkoutSessionClientSecret != null ? [checkoutSessionClientSecret, 'checkoutSession'] : [intentClientSecret, 'intent'];
|
|
699
|
+
if (clientSecret == null) {
|
|
700
|
+
return undefined;
|
|
701
|
+
}
|
|
702
|
+
return { key: JSON.stringify([publishableKey, (_a = nonEmpty(this.stripeAccount)) !== null && _a !== void 0 ? _a : null, source, clientSecret]), clientSecret, source };
|
|
703
|
+
}
|
|
704
|
+
dispatch(event) {
|
|
705
|
+
const { state, effects } = transition(this.sheet, event);
|
|
706
|
+
this.sheet = state;
|
|
707
|
+
effects.forEach(effect => this.perform(effect));
|
|
708
|
+
}
|
|
709
|
+
perform(effect) {
|
|
710
|
+
var _a;
|
|
711
|
+
switch (effect.type) {
|
|
712
|
+
case 'load':
|
|
713
|
+
if (effect.intentKind === 'checkoutSession') {
|
|
714
|
+
this.loadCheckoutSession(effect.generation, effect.clientSecret);
|
|
715
|
+
}
|
|
716
|
+
else {
|
|
717
|
+
this.load(effect.generation, effect.clientSecret, effect.intentKind);
|
|
718
|
+
}
|
|
719
|
+
break;
|
|
720
|
+
case 'show':
|
|
721
|
+
this.visible = true;
|
|
722
|
+
this.open = true;
|
|
723
|
+
break;
|
|
724
|
+
case 'hide':
|
|
725
|
+
this.visible = false;
|
|
726
|
+
this.open = false;
|
|
727
|
+
break;
|
|
728
|
+
case 'confirm':
|
|
729
|
+
if (effect.intentKind === 'checkoutSession') {
|
|
730
|
+
this.confirmCheckoutSession(effect.generation);
|
|
731
|
+
}
|
|
732
|
+
else {
|
|
733
|
+
this.confirm(effect.generation, effect.intentKind);
|
|
734
|
+
}
|
|
735
|
+
break;
|
|
736
|
+
case 'showError':
|
|
737
|
+
this.errorMessage = effect.message;
|
|
738
|
+
break;
|
|
739
|
+
case 'emit':
|
|
740
|
+
this.emit(effect.event);
|
|
741
|
+
break;
|
|
742
|
+
case 'resolvePresent':
|
|
743
|
+
(_a = this.resolvePresent) === null || _a === void 0 ? void 0 : _a.call(this, { paymentResult: effect.result });
|
|
744
|
+
this.presentPromise = undefined;
|
|
745
|
+
this.resolvePresent = undefined;
|
|
746
|
+
break;
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
async load(generation, clientSecret, intentKind) {
|
|
750
|
+
var _a;
|
|
751
|
+
this.warnUnsupportedOptions(intentKind);
|
|
752
|
+
// A newer load started while this one was waiting: stop before touching the elements, so that only the latest load mounts and emits
|
|
753
|
+
const superseded = () => generation !== this.sheet.generation;
|
|
754
|
+
try {
|
|
755
|
+
// Fails before loading Stripe.js when a `never` field has no default value, so that Stripe never rejects the confirmation
|
|
756
|
+
const collection = planBillingDetailsCollection(this.options, intentKind);
|
|
757
|
+
await this.stripeService.initialize(this.publishableKey, {
|
|
758
|
+
stripeAccount: this.stripeAccount,
|
|
759
|
+
applicationName: this.applicationName,
|
|
760
|
+
clientSecret,
|
|
761
|
+
});
|
|
762
|
+
if (superseded()) {
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
if (this.stripeService.state.loadStripeStatus !== 'success') {
|
|
766
|
+
throw new Error('Failed to load Stripe.js');
|
|
767
|
+
}
|
|
768
|
+
const appearance = toAppearance((_a = this.options) === null || _a === void 0 ? void 0 : _a.style);
|
|
769
|
+
if (appearance != null) {
|
|
770
|
+
await this.stripeService.getElements().update({ appearance });
|
|
771
|
+
if (superseded()) {
|
|
772
|
+
return;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
if (!(await this.mountExtraElements(collection, superseded))) {
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
await this.paymentElementManager.initialize(this.el, toPaymentElementOptions(this.options));
|
|
779
|
+
this.dispatch({ type: 'loadSucceeded', generation });
|
|
780
|
+
}
|
|
781
|
+
catch (e) {
|
|
782
|
+
if (superseded()) {
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
this.lastError = e;
|
|
786
|
+
this.dispatch({ type: 'loadFailed', generation });
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* Render the mount points of the plan's extra elements and mount them. Elements a previous load needed but this one does not are unmounted
|
|
791
|
+
* (the managers unmount their previous element themselves when initialized again).
|
|
792
|
+
*/
|
|
793
|
+
async mountExtraElements(collection, superseded) {
|
|
794
|
+
this.collection = collection;
|
|
795
|
+
const { emailElement, shippingAddressElement, billingAddressElement } = collection;
|
|
796
|
+
const extraElements = [
|
|
797
|
+
{
|
|
798
|
+
manager: this.emailElementManager,
|
|
799
|
+
selector: '.stripe-payment-sheet-email',
|
|
800
|
+
mount: emailElement && (container => this.emailElementManager.initialize(container, emailElement)),
|
|
801
|
+
},
|
|
802
|
+
{
|
|
803
|
+
manager: this.shippingAddressElementManager,
|
|
804
|
+
selector: '.stripe-payment-sheet-shipping-address',
|
|
805
|
+
mount: shippingAddressElement && (container => this.shippingAddressElementManager.initialize(container, shippingAddressElement)),
|
|
806
|
+
},
|
|
807
|
+
{
|
|
808
|
+
manager: this.billingAddressElementManager,
|
|
809
|
+
selector: '.stripe-payment-sheet-billing-address',
|
|
810
|
+
mount: billingAddressElement && (container => this.billingAddressElementManager.initialize(container, billingAddressElement)),
|
|
811
|
+
},
|
|
812
|
+
];
|
|
813
|
+
for (const { manager, selector, mount } of extraElements) {
|
|
814
|
+
if (mount == null) {
|
|
815
|
+
manager.unmount();
|
|
816
|
+
continue;
|
|
817
|
+
}
|
|
818
|
+
// The container is looked up with findElement, which waits for it in case the sheet has not rendered yet
|
|
819
|
+
const container = await factory.findElement(this.el, selector);
|
|
820
|
+
if (superseded()) {
|
|
821
|
+
return false;
|
|
822
|
+
}
|
|
823
|
+
await mount(container);
|
|
824
|
+
if (superseded()) {
|
|
825
|
+
return false;
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
return true;
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* Billing details read from the extra elements and the `never` fields, as extra confirm params
|
|
832
|
+
*/
|
|
833
|
+
async confirmParams() {
|
|
834
|
+
var _a;
|
|
835
|
+
const collection = this.collection;
|
|
836
|
+
if (collection == null) {
|
|
837
|
+
return undefined;
|
|
838
|
+
}
|
|
839
|
+
const billingAddress = collection.billingAddressElement != null ? await ((_a = this.billingAddressElementManager.getElement()) === null || _a === void 0 ? void 0 : _a.getValue()) : undefined;
|
|
840
|
+
const emailState = collection.emailElement != null ? this.emailElementManager.getState() : undefined;
|
|
841
|
+
const billingDetails = collectedBillingDetails(collection, { billingAddress, email: emailState === null || emailState === void 0 ? void 0 : emailState.email, emailComplete: emailState === null || emailState === void 0 ? void 0 : emailState.complete });
|
|
842
|
+
return billingDetails == null ? undefined : { payment_method_data: { billing_details: billingDetails } };
|
|
843
|
+
}
|
|
844
|
+
confirm(generation, intentKind) {
|
|
845
|
+
return this.runConfirm(generation, async () => {
|
|
846
|
+
var _a, _b;
|
|
847
|
+
const elements = this.stripeService.getElements();
|
|
848
|
+
// elements.submit() comes first, with nothing awaited before it, as in Stripe's submit handler examples:
|
|
849
|
+
// it validates the elements and collects what wallets (Apple Pay, Google Pay) need while the customer's click still counts,
|
|
850
|
+
// and other asynchronous work may follow once it has resolved
|
|
851
|
+
const { error: submitError } = await elements.submit();
|
|
852
|
+
if (submitError != null) {
|
|
853
|
+
throw submitError;
|
|
854
|
+
}
|
|
855
|
+
const returnUrl = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.returnURL) !== null && _b !== void 0 ? _b : window.location.href;
|
|
856
|
+
const extraConfirmParams = await this.confirmParams();
|
|
857
|
+
return stripePaymentElement_helpers.confirmPaymentOrSetup(this.stripeService.getStripe(), elements, intentKind, returnUrl, extraConfirmParams);
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* Run a confirmation and report its result to the state machine.
|
|
862
|
+
* `confirm` is called synchronously, so that its first step still runs inside the customer's submit event.
|
|
863
|
+
* Errors the customer can fix or retry keep the sheet open; others end it with `paymentSheetFailed`.
|
|
864
|
+
*/
|
|
865
|
+
async runConfirm(generation, confirm) {
|
|
866
|
+
var _a;
|
|
867
|
+
try {
|
|
868
|
+
this.lastResult = await confirm();
|
|
869
|
+
this.dispatch({ type: 'confirmSucceeded', generation });
|
|
870
|
+
}
|
|
871
|
+
catch (e) {
|
|
872
|
+
const rawMessage = (_a = e.message) !== null && _a !== void 0 ? _a : String(e);
|
|
873
|
+
// Stripe's messages are already localized; the sheet's own validation messages are i18n keys
|
|
874
|
+
const message = isSheetValidationError(e) ? i18n.i18n.t(rawMessage) : rawMessage;
|
|
875
|
+
if (isRecoverableConfirmError(e)) {
|
|
876
|
+
this.dispatch({ type: 'confirmDeclined', generation, message });
|
|
877
|
+
return;
|
|
878
|
+
}
|
|
879
|
+
this.lastError = e;
|
|
880
|
+
this.dispatch({ type: 'confirmFailed', generation, message });
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
async loadCheckoutSession(generation, clientSecret) {
|
|
884
|
+
this.warnUnsupportedOptions('checkoutSession');
|
|
885
|
+
this.warnCheckoutIgnoredOptions();
|
|
886
|
+
// The extra billing elements belong to intent mode; remove those of an earlier intent load
|
|
887
|
+
this.collection = undefined;
|
|
888
|
+
this.unmountExtraElements();
|
|
889
|
+
try {
|
|
890
|
+
await this.stripeService.initializeWithCheckoutSession(this.publishableKey, clientSecret, {
|
|
891
|
+
stripeAccount: this.stripeAccount,
|
|
892
|
+
applicationName: this.applicationName,
|
|
893
|
+
elementsOptions: toCheckoutElementsOptions(this.options),
|
|
894
|
+
});
|
|
895
|
+
if (generation !== this.sheet.generation) {
|
|
896
|
+
return;
|
|
897
|
+
}
|
|
898
|
+
if (this.stripeService.state.loadStripeStatus !== 'success') {
|
|
899
|
+
throw new Error('Failed to load Stripe.js');
|
|
900
|
+
}
|
|
901
|
+
await this.paymentElementManager.initialize(this.el, toCheckoutPaymentElementOptions(this.options));
|
|
902
|
+
this.dispatch({ type: 'loadSucceeded', generation });
|
|
903
|
+
}
|
|
904
|
+
catch (e) {
|
|
905
|
+
// An error of a load that a newer load replaced is not reported
|
|
906
|
+
if (generation !== this.sheet.generation) {
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
909
|
+
this.lastError = e;
|
|
910
|
+
this.dispatch({ type: 'loadFailed', generation });
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
confirmCheckoutSession(generation) {
|
|
914
|
+
var _a, _b;
|
|
915
|
+
const returnUrl = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.returnURL) !== null && _b !== void 0 ? _b : window.location.href;
|
|
916
|
+
return this.runConfirm(generation, async () => {
|
|
917
|
+
var _a, _b;
|
|
918
|
+
const checkout = this.stripeService.getCheckout();
|
|
919
|
+
if (checkout == null) {
|
|
920
|
+
throw new Error('Checkout Session is not initialized');
|
|
921
|
+
}
|
|
922
|
+
return confirmCheckoutSessionSheet(checkout, returnUrl, (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.defaultBillingDetails) === null || _b === void 0 ? void 0 : _b.email);
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
emit(event) {
|
|
926
|
+
switch (event) {
|
|
927
|
+
case 'paymentSheetLoaded':
|
|
928
|
+
this.paymentSheetLoaded.emit({ stripe: this.stripeService.getStripe() });
|
|
929
|
+
break;
|
|
930
|
+
case 'paymentSheetFailedToLoad':
|
|
931
|
+
this.paymentSheetFailedToLoad.emit(this.lastError);
|
|
932
|
+
break;
|
|
933
|
+
case 'paymentSheetCompleted':
|
|
934
|
+
this.paymentSheetCompleted.emit(this.lastResult);
|
|
935
|
+
break;
|
|
936
|
+
case 'paymentSheetCanceled':
|
|
937
|
+
this.paymentSheetCanceled.emit();
|
|
938
|
+
break;
|
|
939
|
+
case 'paymentSheetFailed':
|
|
940
|
+
this.paymentSheetFailed.emit(this.lastError);
|
|
941
|
+
break;
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
warnUnsupportedOptions(intentKind) {
|
|
945
|
+
const keys = unsupportedOptionKeys(this.options, intentKind);
|
|
946
|
+
if (this.warnedUnsupportedOptions || keys.length === 0) {
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
949
|
+
this.warnedUnsupportedOptions = true;
|
|
950
|
+
console.warn(`<stripe-payment-sheet>: these options have no effect on the web yet: ${keys.join(', ')}`);
|
|
951
|
+
}
|
|
952
|
+
warnCheckoutIgnoredOptions() {
|
|
953
|
+
const keys = checkoutIgnoredOptionKeys(this.options);
|
|
954
|
+
if (this.warnedCheckoutIgnoredOptions || keys.length === 0) {
|
|
955
|
+
return;
|
|
956
|
+
}
|
|
957
|
+
this.warnedCheckoutIgnoredOptions = true;
|
|
958
|
+
console.warn(`<stripe-payment-sheet>: these options have no effect with a Checkout Session: ${keys.join(', ')}`);
|
|
959
|
+
}
|
|
960
|
+
render() {
|
|
961
|
+
var _a, _b, _c;
|
|
962
|
+
const { phase } = this.sheet;
|
|
963
|
+
const confirming = phase === 'confirming';
|
|
964
|
+
return (index.h(index.Host, { key: 'e6b2c3cb168039eb428eaaee1dce598f534c18e7' }, index.h("stripe-modal", { key: 'ef1515b07cca402c4db8818e2e94ca80e4d954c2', open: this.visible, showCloseButton: !confirming, onClose: this.handleModalClose }, index.h("div", { key: '9252fa1653b206d211756c94325c73a8ec482a37', class: "stripe-payment-sheet-wrap" }, index.h("form", { key: '904a54f2439e0356c2cbf9227326efe446aa08ce', id: "stripe-payment-sheet", onSubmit: this.handleSubmit }, index.h("div", { key: '103d81e3c56cfba1c421e1bf140a49e2b392c6b5', class: "stripe-heading" }, i18n.i18n.t(this.sheetTitle)), index.h("div", { key: 'cda58a48db7b04af1981407b7100def815404e35', class: "payment-info visible" }, index.h("div", { key: 'cbe248666aa4807c25d492df1ab1de017bc78e2c', class: "stripe-payment-sheet-email" }, ((_a = this.collection) === null || _a === void 0 ? void 0 : _a.emailElement) != null && index.h("div", { key: 'b0210c6cce85d1affaa83e3fa30785158c9bab98', id: "link-authentication-element" })), index.h("div", { key: '2420956298e5b36c63f3fbea6b4e32429b7ace27', class: "stripe-payment-sheet-shipping-address" }, ((_b = this.collection) === null || _b === void 0 ? void 0 : _b.shippingAddressElement) != null && index.h("div", { key: 'ae41335a42c59598e1addbfdea0a13342c026456', id: "address-element" })), index.h("div", { key: '3196844c9396c40548a3c632733565027df3cea7', class: "stripe-payment-sheet-billing-address" }, ((_c = this.collection) === null || _c === void 0 ? void 0 : _c.billingAddressElement) != null && index.h("div", { key: '269a99368975db70722fc181a1c099859f23d3d6', id: "address-element" })), index.h("div", { key: '2a63173a607501ff08ac072956cdbe462a4400c1', id: "payment-element" })), index.h("div", { key: '7a72a86097aca2af6491c56b52258286ef820283', class: "stripe-element-errors", role: "alert" }, this.errorMessage), index.h("div", { key: '10f05d5ecfa53cde350f00acffd86e232e370fe7', class: "stripe-submit" }, index.h("button", { key: 'a7ad3e538b94403bd8c71b31bd405c1b0c59543c', type: "submit", disabled: phase !== 'presented' }, confirming ? i18n.i18n.t('Loading') : i18n.i18n.t(this.buttonLabel))))))));
|
|
965
|
+
}
|
|
966
|
+
get el() { return index.getElement(this); }
|
|
967
|
+
static get watchers() { return {
|
|
968
|
+
"publishableKey": [{
|
|
969
|
+
"handleSecretChange": 0
|
|
970
|
+
}],
|
|
971
|
+
"intentClientSecret": [{
|
|
972
|
+
"handleSecretChange": 0
|
|
973
|
+
}],
|
|
974
|
+
"checkoutSessionClientSecret": [{
|
|
975
|
+
"handleSecretChange": 0
|
|
976
|
+
}],
|
|
977
|
+
"stripeAccount": [{
|
|
978
|
+
"handleSecretChange": 0
|
|
979
|
+
}],
|
|
980
|
+
"open": [{
|
|
981
|
+
"handleOpenChange": 0
|
|
982
|
+
}]
|
|
983
|
+
}; }
|
|
984
|
+
};
|
|
985
|
+
StripePaymentSheet.style = stripePaymentSheetCss();
|
|
986
|
+
|
|
987
|
+
exports.stripe_payment_sheet = StripePaymentSheet;
|