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,763 @@
|
|
|
1
|
+
import { h, Host } from "@stencil/core";
|
|
2
|
+
import { i18n } from "../../utils/i18n";
|
|
3
|
+
import { checkPlatform } from "../../utils/utils";
|
|
4
|
+
import { findElement } from "../../utils/element-finder";
|
|
5
|
+
import { serviceFactory } from "../../services/factory";
|
|
6
|
+
import { confirmPaymentOrSetup } from "../stripe-payment-element/stripe-payment-element.helpers";
|
|
7
|
+
import { initialSheetState, transition } from "./payment-sheet-state";
|
|
8
|
+
import { collectedBillingDetails, isRecoverableConfirmError, isSheetValidationError, planBillingDetailsCollection, toAppearance, toPaymentElementOptions, unsupportedOptionKeys, } from "./stripe-payment-sheet.helpers";
|
|
9
|
+
import { checkoutIgnoredOptionKeys, confirmCheckoutSessionSheet, toCheckoutElementsOptions, toCheckoutPaymentElementOptions } from "./stripe-payment-sheet.checkout";
|
|
10
|
+
const nonEmpty = (value) => (value == null || value === '' ? undefined : value);
|
|
11
|
+
/**
|
|
12
|
+
* A payment sheet: the Payment Element in a modal, with the same events and results as the native PaymentSheet
|
|
13
|
+
* of `@capacitor-community/stripe`. PaymentIntent and SetupIntent are told apart by the client secret prefix;
|
|
14
|
+
* a Checkout Session is used when `checkout-session-client-secret` is set.
|
|
15
|
+
*/
|
|
16
|
+
export class StripePaymentSheet {
|
|
17
|
+
/**
|
|
18
|
+
* Show the sheet and wait for its result.
|
|
19
|
+
* Calling it again while a result is pending returns the same promise.
|
|
20
|
+
* @returns `{ paymentResult }`, where `paymentResult` is `paymentSheetCompleted`, `paymentSheetCanceled` or `paymentSheetFailed`
|
|
21
|
+
* @example
|
|
22
|
+
* ```
|
|
23
|
+
* const sheet = document.querySelector('stripe-payment-sheet');
|
|
24
|
+
* const { paymentResult } = await sheet.present();
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
async present() {
|
|
28
|
+
if (this.presentPromise == null) {
|
|
29
|
+
this.presentPromise = new Promise(resolve => {
|
|
30
|
+
this.resolvePresent = resolve;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const promise = this.presentPromise;
|
|
34
|
+
this.dispatch({ type: 'presentRequested' });
|
|
35
|
+
return promise;
|
|
36
|
+
}
|
|
37
|
+
handleSecretChange() {
|
|
38
|
+
this.startLoading();
|
|
39
|
+
}
|
|
40
|
+
handleOpenChange(open) {
|
|
41
|
+
this.dispatch({ type: open ? 'openRequested' : 'closeRequested' });
|
|
42
|
+
}
|
|
43
|
+
constructor() {
|
|
44
|
+
this.warnedUnsupportedOptions = false;
|
|
45
|
+
this.warnedCheckoutIgnoredOptions = false;
|
|
46
|
+
/**
|
|
47
|
+
* Whether the sheet is shown. Setting it to false closes the sheet as canceled.
|
|
48
|
+
*/
|
|
49
|
+
this.open = false;
|
|
50
|
+
/**
|
|
51
|
+
* Sheet title. Translated automatically by this library.
|
|
52
|
+
*/
|
|
53
|
+
this.sheetTitle = 'Add your payment information';
|
|
54
|
+
/**
|
|
55
|
+
* Submit button label. Translated automatically by this library.
|
|
56
|
+
*/
|
|
57
|
+
this.buttonLabel = 'Pay';
|
|
58
|
+
/**
|
|
59
|
+
* Application name registered to Stripe.js, for wrapper libraries such as `@capacitor-community/stripe`.
|
|
60
|
+
*/
|
|
61
|
+
this.applicationName = 'stripe-pwa-elements';
|
|
62
|
+
this.sheet = initialSheetState;
|
|
63
|
+
this.visible = false;
|
|
64
|
+
this.errorMessage = '';
|
|
65
|
+
this.handleSubmit = (e) => {
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
this.errorMessage = '';
|
|
68
|
+
this.dispatch({ type: 'submitted' });
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* The modal closes itself on a backdrop or close button click. Keep it open when the sheet refuses to close (while confirming).
|
|
72
|
+
*/
|
|
73
|
+
this.handleModalClose = () => {
|
|
74
|
+
var _a;
|
|
75
|
+
this.dispatch({ type: 'closeRequested' });
|
|
76
|
+
if (this.visible) {
|
|
77
|
+
(_a = this.el.querySelector('stripe-modal')) === null || _a === void 0 ? void 0 : _a.openModal();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
this.stripeService = serviceFactory.createStripeService();
|
|
81
|
+
this.paymentElementManager = serviceFactory.createPaymentElementManager(this.stripeService);
|
|
82
|
+
this.billingAddressElementManager = serviceFactory.createAddressElementManager(this.stripeService);
|
|
83
|
+
this.shippingAddressElementManager = serviceFactory.createAddressElementManager(this.stripeService);
|
|
84
|
+
this.emailElementManager = serviceFactory.createLinkAuthenticationElementManager(this.stripeService);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Props are not yet populated inside the constructor with the custom-elements build,
|
|
88
|
+
* so loading starts here.
|
|
89
|
+
*/
|
|
90
|
+
componentWillLoad() {
|
|
91
|
+
if (this.open) {
|
|
92
|
+
this.dispatch({ type: 'openRequested' });
|
|
93
|
+
}
|
|
94
|
+
this.startLoading();
|
|
95
|
+
}
|
|
96
|
+
componentDidLoad() {
|
|
97
|
+
this.el.classList.add(checkPlatform());
|
|
98
|
+
}
|
|
99
|
+
disconnectedCallback() {
|
|
100
|
+
this.paymentElementManager.unmount();
|
|
101
|
+
this.unmountExtraElements();
|
|
102
|
+
}
|
|
103
|
+
unmountExtraElements() {
|
|
104
|
+
this.billingAddressElementManager.unmount();
|
|
105
|
+
this.shippingAddressElementManager.unmount();
|
|
106
|
+
this.emailElementManager.unmount();
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Decide what to load from the attributes and load it only when it differs from the last load.
|
|
110
|
+
* A change that does not alter the result (the attribute that is not used, or an empty value that means unset)
|
|
111
|
+
* must neither reload Stripe.js nor cancel an open sheet.
|
|
112
|
+
*/
|
|
113
|
+
startLoading() {
|
|
114
|
+
const target = this.loadTarget();
|
|
115
|
+
if (target == null || target.key === this.lastLoadKey) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
this.lastLoadKey = target.key;
|
|
119
|
+
this.dispatch({ type: 'secretChanged', clientSecret: target.clientSecret, source: target.source });
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The secret to load and a key of everything the load depends on, or undefined when nothing can be loaded.
|
|
123
|
+
* The Checkout Session wins when both secrets are set (the same rule as `stripe-payment-element`).
|
|
124
|
+
*/
|
|
125
|
+
loadTarget() {
|
|
126
|
+
var _a;
|
|
127
|
+
const publishableKey = nonEmpty(this.publishableKey);
|
|
128
|
+
if (publishableKey == null) {
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
const checkoutSessionClientSecret = nonEmpty(this.checkoutSessionClientSecret);
|
|
132
|
+
const intentClientSecret = nonEmpty(this.intentClientSecret);
|
|
133
|
+
const [clientSecret, source] = checkoutSessionClientSecret != null ? [checkoutSessionClientSecret, 'checkoutSession'] : [intentClientSecret, 'intent'];
|
|
134
|
+
if (clientSecret == null) {
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
137
|
+
return { key: JSON.stringify([publishableKey, (_a = nonEmpty(this.stripeAccount)) !== null && _a !== void 0 ? _a : null, source, clientSecret]), clientSecret, source };
|
|
138
|
+
}
|
|
139
|
+
dispatch(event) {
|
|
140
|
+
const { state, effects } = transition(this.sheet, event);
|
|
141
|
+
this.sheet = state;
|
|
142
|
+
effects.forEach(effect => this.perform(effect));
|
|
143
|
+
}
|
|
144
|
+
perform(effect) {
|
|
145
|
+
var _a;
|
|
146
|
+
switch (effect.type) {
|
|
147
|
+
case 'load':
|
|
148
|
+
if (effect.intentKind === 'checkoutSession') {
|
|
149
|
+
this.loadCheckoutSession(effect.generation, effect.clientSecret);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
this.load(effect.generation, effect.clientSecret, effect.intentKind);
|
|
153
|
+
}
|
|
154
|
+
break;
|
|
155
|
+
case 'show':
|
|
156
|
+
this.visible = true;
|
|
157
|
+
this.open = true;
|
|
158
|
+
break;
|
|
159
|
+
case 'hide':
|
|
160
|
+
this.visible = false;
|
|
161
|
+
this.open = false;
|
|
162
|
+
break;
|
|
163
|
+
case 'confirm':
|
|
164
|
+
if (effect.intentKind === 'checkoutSession') {
|
|
165
|
+
this.confirmCheckoutSession(effect.generation);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
this.confirm(effect.generation, effect.intentKind);
|
|
169
|
+
}
|
|
170
|
+
break;
|
|
171
|
+
case 'showError':
|
|
172
|
+
this.errorMessage = effect.message;
|
|
173
|
+
break;
|
|
174
|
+
case 'emit':
|
|
175
|
+
this.emit(effect.event);
|
|
176
|
+
break;
|
|
177
|
+
case 'resolvePresent':
|
|
178
|
+
(_a = this.resolvePresent) === null || _a === void 0 ? void 0 : _a.call(this, { paymentResult: effect.result });
|
|
179
|
+
this.presentPromise = undefined;
|
|
180
|
+
this.resolvePresent = undefined;
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
async load(generation, clientSecret, intentKind) {
|
|
185
|
+
var _a;
|
|
186
|
+
this.warnUnsupportedOptions(intentKind);
|
|
187
|
+
// A newer load started while this one was waiting: stop before touching the elements, so that only the latest load mounts and emits
|
|
188
|
+
const superseded = () => generation !== this.sheet.generation;
|
|
189
|
+
try {
|
|
190
|
+
// Fails before loading Stripe.js when a `never` field has no default value, so that Stripe never rejects the confirmation
|
|
191
|
+
const collection = planBillingDetailsCollection(this.options, intentKind);
|
|
192
|
+
await this.stripeService.initialize(this.publishableKey, {
|
|
193
|
+
stripeAccount: this.stripeAccount,
|
|
194
|
+
applicationName: this.applicationName,
|
|
195
|
+
clientSecret,
|
|
196
|
+
});
|
|
197
|
+
if (superseded()) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (this.stripeService.state.loadStripeStatus !== 'success') {
|
|
201
|
+
throw new Error('Failed to load Stripe.js');
|
|
202
|
+
}
|
|
203
|
+
const appearance = toAppearance((_a = this.options) === null || _a === void 0 ? void 0 : _a.style);
|
|
204
|
+
if (appearance != null) {
|
|
205
|
+
await this.stripeService.getElements().update({ appearance });
|
|
206
|
+
if (superseded()) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (!(await this.mountExtraElements(collection, superseded))) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
await this.paymentElementManager.initialize(this.el, toPaymentElementOptions(this.options));
|
|
214
|
+
this.dispatch({ type: 'loadSucceeded', generation });
|
|
215
|
+
}
|
|
216
|
+
catch (e) {
|
|
217
|
+
if (superseded()) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
this.lastError = e;
|
|
221
|
+
this.dispatch({ type: 'loadFailed', generation });
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* 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
|
|
226
|
+
* (the managers unmount their previous element themselves when initialized again).
|
|
227
|
+
*/
|
|
228
|
+
async mountExtraElements(collection, superseded) {
|
|
229
|
+
this.collection = collection;
|
|
230
|
+
const { emailElement, shippingAddressElement, billingAddressElement } = collection;
|
|
231
|
+
const extraElements = [
|
|
232
|
+
{
|
|
233
|
+
manager: this.emailElementManager,
|
|
234
|
+
selector: '.stripe-payment-sheet-email',
|
|
235
|
+
mount: emailElement && (container => this.emailElementManager.initialize(container, emailElement)),
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
manager: this.shippingAddressElementManager,
|
|
239
|
+
selector: '.stripe-payment-sheet-shipping-address',
|
|
240
|
+
mount: shippingAddressElement && (container => this.shippingAddressElementManager.initialize(container, shippingAddressElement)),
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
manager: this.billingAddressElementManager,
|
|
244
|
+
selector: '.stripe-payment-sheet-billing-address',
|
|
245
|
+
mount: billingAddressElement && (container => this.billingAddressElementManager.initialize(container, billingAddressElement)),
|
|
246
|
+
},
|
|
247
|
+
];
|
|
248
|
+
for (const { manager, selector, mount } of extraElements) {
|
|
249
|
+
if (mount == null) {
|
|
250
|
+
manager.unmount();
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
// The container is looked up with findElement, which waits for it in case the sheet has not rendered yet
|
|
254
|
+
const container = await findElement(this.el, selector);
|
|
255
|
+
if (superseded()) {
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
await mount(container);
|
|
259
|
+
if (superseded()) {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Billing details read from the extra elements and the `never` fields, as extra confirm params
|
|
267
|
+
*/
|
|
268
|
+
async confirmParams() {
|
|
269
|
+
var _a;
|
|
270
|
+
const collection = this.collection;
|
|
271
|
+
if (collection == null) {
|
|
272
|
+
return undefined;
|
|
273
|
+
}
|
|
274
|
+
const billingAddress = collection.billingAddressElement != null ? await ((_a = this.billingAddressElementManager.getElement()) === null || _a === void 0 ? void 0 : _a.getValue()) : undefined;
|
|
275
|
+
const emailState = collection.emailElement != null ? this.emailElementManager.getState() : undefined;
|
|
276
|
+
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 });
|
|
277
|
+
return billingDetails == null ? undefined : { payment_method_data: { billing_details: billingDetails } };
|
|
278
|
+
}
|
|
279
|
+
confirm(generation, intentKind) {
|
|
280
|
+
return this.runConfirm(generation, async () => {
|
|
281
|
+
var _a, _b;
|
|
282
|
+
const elements = this.stripeService.getElements();
|
|
283
|
+
// elements.submit() comes first, with nothing awaited before it, as in Stripe's submit handler examples:
|
|
284
|
+
// it validates the elements and collects what wallets (Apple Pay, Google Pay) need while the customer's click still counts,
|
|
285
|
+
// and other asynchronous work may follow once it has resolved
|
|
286
|
+
const { error: submitError } = await elements.submit();
|
|
287
|
+
if (submitError != null) {
|
|
288
|
+
throw submitError;
|
|
289
|
+
}
|
|
290
|
+
const returnUrl = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.returnURL) !== null && _b !== void 0 ? _b : window.location.href;
|
|
291
|
+
const extraConfirmParams = await this.confirmParams();
|
|
292
|
+
return confirmPaymentOrSetup(this.stripeService.getStripe(), elements, intentKind, returnUrl, extraConfirmParams);
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Run a confirmation and report its result to the state machine.
|
|
297
|
+
* `confirm` is called synchronously, so that its first step still runs inside the customer's submit event.
|
|
298
|
+
* Errors the customer can fix or retry keep the sheet open; others end it with `paymentSheetFailed`.
|
|
299
|
+
*/
|
|
300
|
+
async runConfirm(generation, confirm) {
|
|
301
|
+
var _a;
|
|
302
|
+
try {
|
|
303
|
+
this.lastResult = await confirm();
|
|
304
|
+
this.dispatch({ type: 'confirmSucceeded', generation });
|
|
305
|
+
}
|
|
306
|
+
catch (e) {
|
|
307
|
+
const rawMessage = (_a = e.message) !== null && _a !== void 0 ? _a : String(e);
|
|
308
|
+
// Stripe's messages are already localized; the sheet's own validation messages are i18n keys
|
|
309
|
+
const message = isSheetValidationError(e) ? i18n.t(rawMessage) : rawMessage;
|
|
310
|
+
if (isRecoverableConfirmError(e)) {
|
|
311
|
+
this.dispatch({ type: 'confirmDeclined', generation, message });
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
this.lastError = e;
|
|
315
|
+
this.dispatch({ type: 'confirmFailed', generation, message });
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
async loadCheckoutSession(generation, clientSecret) {
|
|
319
|
+
this.warnUnsupportedOptions('checkoutSession');
|
|
320
|
+
this.warnCheckoutIgnoredOptions();
|
|
321
|
+
// The extra billing elements belong to intent mode; remove those of an earlier intent load
|
|
322
|
+
this.collection = undefined;
|
|
323
|
+
this.unmountExtraElements();
|
|
324
|
+
try {
|
|
325
|
+
await this.stripeService.initializeWithCheckoutSession(this.publishableKey, clientSecret, {
|
|
326
|
+
stripeAccount: this.stripeAccount,
|
|
327
|
+
applicationName: this.applicationName,
|
|
328
|
+
elementsOptions: toCheckoutElementsOptions(this.options),
|
|
329
|
+
});
|
|
330
|
+
if (generation !== this.sheet.generation) {
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
if (this.stripeService.state.loadStripeStatus !== 'success') {
|
|
334
|
+
throw new Error('Failed to load Stripe.js');
|
|
335
|
+
}
|
|
336
|
+
await this.paymentElementManager.initialize(this.el, toCheckoutPaymentElementOptions(this.options));
|
|
337
|
+
this.dispatch({ type: 'loadSucceeded', generation });
|
|
338
|
+
}
|
|
339
|
+
catch (e) {
|
|
340
|
+
// An error of a load that a newer load replaced is not reported
|
|
341
|
+
if (generation !== this.sheet.generation) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
this.lastError = e;
|
|
345
|
+
this.dispatch({ type: 'loadFailed', generation });
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
confirmCheckoutSession(generation) {
|
|
349
|
+
var _a, _b;
|
|
350
|
+
const returnUrl = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.returnURL) !== null && _b !== void 0 ? _b : window.location.href;
|
|
351
|
+
return this.runConfirm(generation, async () => {
|
|
352
|
+
var _a, _b;
|
|
353
|
+
const checkout = this.stripeService.getCheckout();
|
|
354
|
+
if (checkout == null) {
|
|
355
|
+
throw new Error('Checkout Session is not initialized');
|
|
356
|
+
}
|
|
357
|
+
return confirmCheckoutSessionSheet(checkout, returnUrl, (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.defaultBillingDetails) === null || _b === void 0 ? void 0 : _b.email);
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
emit(event) {
|
|
361
|
+
switch (event) {
|
|
362
|
+
case 'paymentSheetLoaded':
|
|
363
|
+
this.paymentSheetLoaded.emit({ stripe: this.stripeService.getStripe() });
|
|
364
|
+
break;
|
|
365
|
+
case 'paymentSheetFailedToLoad':
|
|
366
|
+
this.paymentSheetFailedToLoad.emit(this.lastError);
|
|
367
|
+
break;
|
|
368
|
+
case 'paymentSheetCompleted':
|
|
369
|
+
this.paymentSheetCompleted.emit(this.lastResult);
|
|
370
|
+
break;
|
|
371
|
+
case 'paymentSheetCanceled':
|
|
372
|
+
this.paymentSheetCanceled.emit();
|
|
373
|
+
break;
|
|
374
|
+
case 'paymentSheetFailed':
|
|
375
|
+
this.paymentSheetFailed.emit(this.lastError);
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
warnUnsupportedOptions(intentKind) {
|
|
380
|
+
const keys = unsupportedOptionKeys(this.options, intentKind);
|
|
381
|
+
if (this.warnedUnsupportedOptions || keys.length === 0) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
this.warnedUnsupportedOptions = true;
|
|
385
|
+
console.warn(`<stripe-payment-sheet>: these options have no effect on the web yet: ${keys.join(', ')}`);
|
|
386
|
+
}
|
|
387
|
+
warnCheckoutIgnoredOptions() {
|
|
388
|
+
const keys = checkoutIgnoredOptionKeys(this.options);
|
|
389
|
+
if (this.warnedCheckoutIgnoredOptions || keys.length === 0) {
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
this.warnedCheckoutIgnoredOptions = true;
|
|
393
|
+
console.warn(`<stripe-payment-sheet>: these options have no effect with a Checkout Session: ${keys.join(', ')}`);
|
|
394
|
+
}
|
|
395
|
+
render() {
|
|
396
|
+
var _a, _b, _c;
|
|
397
|
+
const { phase } = this.sheet;
|
|
398
|
+
const confirming = phase === 'confirming';
|
|
399
|
+
return (h(Host, { key: 'e6b2c3cb168039eb428eaaee1dce598f534c18e7' }, h("stripe-modal", { key: 'ef1515b07cca402c4db8818e2e94ca80e4d954c2', open: this.visible, showCloseButton: !confirming, onClose: this.handleModalClose }, h("div", { key: '9252fa1653b206d211756c94325c73a8ec482a37', class: "stripe-payment-sheet-wrap" }, h("form", { key: '904a54f2439e0356c2cbf9227326efe446aa08ce', id: "stripe-payment-sheet", onSubmit: this.handleSubmit }, h("div", { key: '103d81e3c56cfba1c421e1bf140a49e2b392c6b5', class: "stripe-heading" }, i18n.t(this.sheetTitle)), h("div", { key: 'cda58a48db7b04af1981407b7100def815404e35', class: "payment-info visible" }, h("div", { key: 'cbe248666aa4807c25d492df1ab1de017bc78e2c', class: "stripe-payment-sheet-email" }, ((_a = this.collection) === null || _a === void 0 ? void 0 : _a.emailElement) != null && h("div", { key: 'b0210c6cce85d1affaa83e3fa30785158c9bab98', id: "link-authentication-element" })), h("div", { key: '2420956298e5b36c63f3fbea6b4e32429b7ace27', class: "stripe-payment-sheet-shipping-address" }, ((_b = this.collection) === null || _b === void 0 ? void 0 : _b.shippingAddressElement) != null && h("div", { key: 'ae41335a42c59598e1addbfdea0a13342c026456', id: "address-element" })), h("div", { key: '3196844c9396c40548a3c632733565027df3cea7', class: "stripe-payment-sheet-billing-address" }, ((_c = this.collection) === null || _c === void 0 ? void 0 : _c.billingAddressElement) != null && h("div", { key: '269a99368975db70722fc181a1c099859f23d3d6', id: "address-element" })), h("div", { key: '2a63173a607501ff08ac072956cdbe462a4400c1', id: "payment-element" })), h("div", { key: '7a72a86097aca2af6491c56b52258286ef820283', class: "stripe-element-errors", role: "alert" }, this.errorMessage), h("div", { key: '10f05d5ecfa53cde350f00acffd86e232e370fe7', class: "stripe-submit" }, h("button", { key: 'a7ad3e538b94403bd8c71b31bd405c1b0c59543c', type: "submit", disabled: phase !== 'presented' }, confirming ? i18n.t('Loading') : i18n.t(this.buttonLabel))))))));
|
|
400
|
+
}
|
|
401
|
+
static get is() { return "stripe-payment-sheet"; }
|
|
402
|
+
static get originalStyleUrls() {
|
|
403
|
+
return {
|
|
404
|
+
"$": ["stripe-payment-sheet.scss"]
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
static get styleUrls() {
|
|
408
|
+
return {
|
|
409
|
+
"$": ["stripe-payment-sheet.css"]
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
static get properties() {
|
|
413
|
+
return {
|
|
414
|
+
"publishableKey": {
|
|
415
|
+
"type": "string",
|
|
416
|
+
"mutable": false,
|
|
417
|
+
"complexType": {
|
|
418
|
+
"original": "string",
|
|
419
|
+
"resolved": "string",
|
|
420
|
+
"references": {}
|
|
421
|
+
},
|
|
422
|
+
"required": false,
|
|
423
|
+
"optional": true,
|
|
424
|
+
"docs": {
|
|
425
|
+
"tags": [],
|
|
426
|
+
"text": "Your Stripe publishable API key."
|
|
427
|
+
},
|
|
428
|
+
"getter": false,
|
|
429
|
+
"setter": false,
|
|
430
|
+
"reflect": false,
|
|
431
|
+
"attribute": "publishable-key"
|
|
432
|
+
},
|
|
433
|
+
"intentClientSecret": {
|
|
434
|
+
"type": "string",
|
|
435
|
+
"mutable": false,
|
|
436
|
+
"complexType": {
|
|
437
|
+
"original": "string",
|
|
438
|
+
"resolved": "string",
|
|
439
|
+
"references": {}
|
|
440
|
+
},
|
|
441
|
+
"required": false,
|
|
442
|
+
"optional": true,
|
|
443
|
+
"docs": {
|
|
444
|
+
"tags": [],
|
|
445
|
+
"text": "The client secret of a PaymentIntent (`pi_..._secret_...`) or a SetupIntent (`seti_..._secret_...`).\nThe prefix decides whether `confirmPayment` or `confirmSetup` is used."
|
|
446
|
+
},
|
|
447
|
+
"getter": false,
|
|
448
|
+
"setter": false,
|
|
449
|
+
"reflect": false,
|
|
450
|
+
"attribute": "intent-client-secret"
|
|
451
|
+
},
|
|
452
|
+
"checkoutSessionClientSecret": {
|
|
453
|
+
"type": "string",
|
|
454
|
+
"mutable": false,
|
|
455
|
+
"complexType": {
|
|
456
|
+
"original": "string",
|
|
457
|
+
"resolved": "string",
|
|
458
|
+
"references": {}
|
|
459
|
+
},
|
|
460
|
+
"required": false,
|
|
461
|
+
"optional": true,
|
|
462
|
+
"docs": {
|
|
463
|
+
"tags": [],
|
|
464
|
+
"text": "The client secret of a Checkout Session created with `ui_mode: 'elements'` (named `custom` in older Stripe API versions). Its format is not inspected.\nWhen it is set, it is used instead of `intent-client-secret` (the same rule as `stripe-payment-element`).\nCreate the session with `customer_email` or `customer`, or pass `options.defaultBillingDetails.email`, because the sheet has no email field."
|
|
465
|
+
},
|
|
466
|
+
"getter": false,
|
|
467
|
+
"setter": false,
|
|
468
|
+
"reflect": false,
|
|
469
|
+
"attribute": "checkout-session-client-secret"
|
|
470
|
+
},
|
|
471
|
+
"stripeAccount": {
|
|
472
|
+
"type": "string",
|
|
473
|
+
"mutable": false,
|
|
474
|
+
"complexType": {
|
|
475
|
+
"original": "string",
|
|
476
|
+
"resolved": "string",
|
|
477
|
+
"references": {}
|
|
478
|
+
},
|
|
479
|
+
"required": false,
|
|
480
|
+
"optional": true,
|
|
481
|
+
"docs": {
|
|
482
|
+
"tags": [{
|
|
483
|
+
"name": "info",
|
|
484
|
+
"text": "https://stripe.com/docs/connect/authentication"
|
|
485
|
+
}],
|
|
486
|
+
"text": "Optional. Making API calls for connected accounts"
|
|
487
|
+
},
|
|
488
|
+
"getter": false,
|
|
489
|
+
"setter": false,
|
|
490
|
+
"reflect": false,
|
|
491
|
+
"attribute": "stripe-account"
|
|
492
|
+
},
|
|
493
|
+
"open": {
|
|
494
|
+
"type": "boolean",
|
|
495
|
+
"mutable": true,
|
|
496
|
+
"complexType": {
|
|
497
|
+
"original": "boolean",
|
|
498
|
+
"resolved": "boolean",
|
|
499
|
+
"references": {}
|
|
500
|
+
},
|
|
501
|
+
"required": false,
|
|
502
|
+
"optional": false,
|
|
503
|
+
"docs": {
|
|
504
|
+
"tags": [],
|
|
505
|
+
"text": "Whether the sheet is shown. Setting it to false closes the sheet as canceled."
|
|
506
|
+
},
|
|
507
|
+
"getter": false,
|
|
508
|
+
"setter": false,
|
|
509
|
+
"reflect": true,
|
|
510
|
+
"attribute": "open",
|
|
511
|
+
"defaultValue": "false"
|
|
512
|
+
},
|
|
513
|
+
"sheetTitle": {
|
|
514
|
+
"type": "string",
|
|
515
|
+
"mutable": false,
|
|
516
|
+
"complexType": {
|
|
517
|
+
"original": "string",
|
|
518
|
+
"resolved": "string",
|
|
519
|
+
"references": {}
|
|
520
|
+
},
|
|
521
|
+
"required": false,
|
|
522
|
+
"optional": false,
|
|
523
|
+
"docs": {
|
|
524
|
+
"tags": [],
|
|
525
|
+
"text": "Sheet title. Translated automatically by this library."
|
|
526
|
+
},
|
|
527
|
+
"getter": false,
|
|
528
|
+
"setter": false,
|
|
529
|
+
"reflect": false,
|
|
530
|
+
"attribute": "sheet-title",
|
|
531
|
+
"defaultValue": "'Add your payment information'"
|
|
532
|
+
},
|
|
533
|
+
"buttonLabel": {
|
|
534
|
+
"type": "string",
|
|
535
|
+
"mutable": false,
|
|
536
|
+
"complexType": {
|
|
537
|
+
"original": "string",
|
|
538
|
+
"resolved": "string",
|
|
539
|
+
"references": {}
|
|
540
|
+
},
|
|
541
|
+
"required": false,
|
|
542
|
+
"optional": false,
|
|
543
|
+
"docs": {
|
|
544
|
+
"tags": [],
|
|
545
|
+
"text": "Submit button label. Translated automatically by this library."
|
|
546
|
+
},
|
|
547
|
+
"getter": false,
|
|
548
|
+
"setter": false,
|
|
549
|
+
"reflect": false,
|
|
550
|
+
"attribute": "button-label",
|
|
551
|
+
"defaultValue": "'Pay'"
|
|
552
|
+
},
|
|
553
|
+
"applicationName": {
|
|
554
|
+
"type": "string",
|
|
555
|
+
"mutable": false,
|
|
556
|
+
"complexType": {
|
|
557
|
+
"original": "string",
|
|
558
|
+
"resolved": "string",
|
|
559
|
+
"references": {}
|
|
560
|
+
},
|
|
561
|
+
"required": false,
|
|
562
|
+
"optional": false,
|
|
563
|
+
"docs": {
|
|
564
|
+
"tags": [],
|
|
565
|
+
"text": "Application name registered to Stripe.js, for wrapper libraries such as `@capacitor-community/stripe`."
|
|
566
|
+
},
|
|
567
|
+
"getter": false,
|
|
568
|
+
"setter": false,
|
|
569
|
+
"reflect": false,
|
|
570
|
+
"attribute": "application-name",
|
|
571
|
+
"defaultValue": "'stripe-pwa-elements'"
|
|
572
|
+
},
|
|
573
|
+
"options": {
|
|
574
|
+
"type": "unknown",
|
|
575
|
+
"mutable": false,
|
|
576
|
+
"complexType": {
|
|
577
|
+
"original": "PaymentSheetOptions",
|
|
578
|
+
"resolved": "{ merchantDisplayName?: string; paymentMethodLayout?: \"horizontal\" | \"vertical\" | \"automatic\"; defaultBillingDetails?: { email?: string; name?: string; phone?: string; address?: PaymentSheetAddress; }; returnURL?: string; style?: \"alwaysLight\" | \"alwaysDark\"; billingDetailsCollectionConfiguration?: { email?: \"never\" | \"always\" | \"automatic\"; name?: \"never\" | \"always\" | \"automatic\"; phone?: \"never\" | \"always\" | \"automatic\"; address?: \"never\" | \"automatic\" | \"full\"; }; shippingDetails?: { name?: string; phone?: string; address?: PaymentSheetAddress; }; enableApplePay?: boolean; enableGooglePay?: boolean; customerId?: string; customerEphemeralKeySecret?: string; applePayMerchantId?: string; GooglePayIsTesting?: boolean; countryCode?: string; currencyCode?: string; withZipCode?: boolean; allowsDelayedPaymentMethods?: boolean; }",
|
|
579
|
+
"references": {
|
|
580
|
+
"PaymentSheetOptions": {
|
|
581
|
+
"location": "import",
|
|
582
|
+
"path": "./stripe-payment-sheet.helpers",
|
|
583
|
+
"id": "src/components/stripe-payment-sheet/stripe-payment-sheet.helpers.ts::PaymentSheetOptions",
|
|
584
|
+
"referenceLocation": "PaymentSheetOptions"
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
},
|
|
588
|
+
"required": false,
|
|
589
|
+
"optional": true,
|
|
590
|
+
"docs": {
|
|
591
|
+
"tags": [],
|
|
592
|
+
"text": "Options with the same keys as `CreatePaymentSheetOption` of `@capacitor-community/stripe`. JavaScript property only."
|
|
593
|
+
},
|
|
594
|
+
"getter": false,
|
|
595
|
+
"setter": false
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
static get states() {
|
|
600
|
+
return {
|
|
601
|
+
"sheet": {},
|
|
602
|
+
"visible": {},
|
|
603
|
+
"errorMessage": {},
|
|
604
|
+
"collection": {}
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
static get events() {
|
|
608
|
+
return [{
|
|
609
|
+
"method": "paymentSheetLoaded",
|
|
610
|
+
"name": "paymentSheetLoaded",
|
|
611
|
+
"bubbles": true,
|
|
612
|
+
"cancelable": true,
|
|
613
|
+
"composed": true,
|
|
614
|
+
"docs": {
|
|
615
|
+
"tags": [],
|
|
616
|
+
"text": "Stripe.js and the Payment Element are ready"
|
|
617
|
+
},
|
|
618
|
+
"complexType": {
|
|
619
|
+
"original": "StripeLoadedEvent",
|
|
620
|
+
"resolved": "{ stripe: Stripe; }",
|
|
621
|
+
"references": {
|
|
622
|
+
"StripeLoadedEvent": {
|
|
623
|
+
"location": "import",
|
|
624
|
+
"path": "../../interfaces",
|
|
625
|
+
"id": "src/interfaces.ts::StripeLoadedEvent",
|
|
626
|
+
"referenceLocation": "StripeLoadedEvent"
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}, {
|
|
631
|
+
"method": "paymentSheetFailedToLoad",
|
|
632
|
+
"name": "paymentSheetFailedToLoad",
|
|
633
|
+
"bubbles": true,
|
|
634
|
+
"cancelable": true,
|
|
635
|
+
"composed": true,
|
|
636
|
+
"docs": {
|
|
637
|
+
"tags": [],
|
|
638
|
+
"text": "Stripe.js or the Payment Element failed to load, or the client secret format is unknown"
|
|
639
|
+
},
|
|
640
|
+
"complexType": {
|
|
641
|
+
"original": "unknown",
|
|
642
|
+
"resolved": "unknown",
|
|
643
|
+
"references": {}
|
|
644
|
+
}
|
|
645
|
+
}, {
|
|
646
|
+
"method": "paymentSheetCompleted",
|
|
647
|
+
"name": "paymentSheetCompleted",
|
|
648
|
+
"bubbles": true,
|
|
649
|
+
"cancelable": true,
|
|
650
|
+
"composed": true,
|
|
651
|
+
"docs": {
|
|
652
|
+
"tags": [],
|
|
653
|
+
"text": "The payment or setup succeeded. In Checkout Session mode the detail is the result of `confirm` (`{ type: 'success', session }`)"
|
|
654
|
+
},
|
|
655
|
+
"complexType": {
|
|
656
|
+
"original": "PaymentIntentResult | SetupIntentResult | StripeCheckoutConfirmResult",
|
|
657
|
+
"resolved": "{ paymentIntent: PaymentIntent; error?: undefined; } | { paymentIntent?: undefined; error: StripeError; } | { setupIntent: SetupIntent; error?: undefined; } | { setupIntent?: undefined; error: StripeError; } | { type: \"error\"; error: ConfirmError; } | { type: \"success\"; session: StripeCheckoutSession; }",
|
|
658
|
+
"references": {
|
|
659
|
+
"PaymentIntentResult": {
|
|
660
|
+
"location": "import",
|
|
661
|
+
"path": "@stripe/stripe-js",
|
|
662
|
+
"id": "node_modules::PaymentIntentResult",
|
|
663
|
+
"referenceLocation": "PaymentIntentResult"
|
|
664
|
+
},
|
|
665
|
+
"SetupIntentResult": {
|
|
666
|
+
"location": "import",
|
|
667
|
+
"path": "@stripe/stripe-js",
|
|
668
|
+
"id": "node_modules::SetupIntentResult",
|
|
669
|
+
"referenceLocation": "SetupIntentResult"
|
|
670
|
+
},
|
|
671
|
+
"StripeCheckoutConfirmResult": {
|
|
672
|
+
"location": "import",
|
|
673
|
+
"path": "@stripe/stripe-js",
|
|
674
|
+
"id": "node_modules::StripeCheckoutConfirmResult",
|
|
675
|
+
"referenceLocation": "StripeCheckoutConfirmResult"
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
}, {
|
|
680
|
+
"method": "paymentSheetCanceled",
|
|
681
|
+
"name": "paymentSheetCanceled",
|
|
682
|
+
"bubbles": true,
|
|
683
|
+
"cancelable": true,
|
|
684
|
+
"composed": true,
|
|
685
|
+
"docs": {
|
|
686
|
+
"tags": [],
|
|
687
|
+
"text": "The customer closed the sheet"
|
|
688
|
+
},
|
|
689
|
+
"complexType": {
|
|
690
|
+
"original": "void",
|
|
691
|
+
"resolved": "void",
|
|
692
|
+
"references": {}
|
|
693
|
+
}
|
|
694
|
+
}, {
|
|
695
|
+
"method": "paymentSheetFailed",
|
|
696
|
+
"name": "paymentSheetFailed",
|
|
697
|
+
"bubbles": true,
|
|
698
|
+
"cancelable": true,
|
|
699
|
+
"composed": true,
|
|
700
|
+
"docs": {
|
|
701
|
+
"tags": [],
|
|
702
|
+
"text": "The confirmation failed with an error the customer cannot fix in the sheet"
|
|
703
|
+
},
|
|
704
|
+
"complexType": {
|
|
705
|
+
"original": "unknown",
|
|
706
|
+
"resolved": "unknown",
|
|
707
|
+
"references": {}
|
|
708
|
+
}
|
|
709
|
+
}];
|
|
710
|
+
}
|
|
711
|
+
static get methods() {
|
|
712
|
+
return {
|
|
713
|
+
"present": {
|
|
714
|
+
"complexType": {
|
|
715
|
+
"signature": "() => Promise<PaymentSheetPresentResult>",
|
|
716
|
+
"parameters": [],
|
|
717
|
+
"references": {
|
|
718
|
+
"Promise": {
|
|
719
|
+
"location": "global",
|
|
720
|
+
"id": "global::Promise"
|
|
721
|
+
},
|
|
722
|
+
"PaymentSheetPresentResult": {
|
|
723
|
+
"location": "import",
|
|
724
|
+
"path": "./stripe-payment-sheet.helpers",
|
|
725
|
+
"id": "src/components/stripe-payment-sheet/stripe-payment-sheet.helpers.ts::PaymentSheetPresentResult",
|
|
726
|
+
"referenceLocation": "PaymentSheetPresentResult"
|
|
727
|
+
}
|
|
728
|
+
},
|
|
729
|
+
"return": "Promise<PaymentSheetPresentResult>"
|
|
730
|
+
},
|
|
731
|
+
"docs": {
|
|
732
|
+
"text": "Show the sheet and wait for its result.\nCalling it again while a result is pending returns the same promise.",
|
|
733
|
+
"tags": [{
|
|
734
|
+
"name": "returns",
|
|
735
|
+
"text": "`{ paymentResult }`, where `paymentResult` is `paymentSheetCompleted`, `paymentSheetCanceled` or `paymentSheetFailed`"
|
|
736
|
+
}, {
|
|
737
|
+
"name": "example",
|
|
738
|
+
"text": "```\nconst sheet = document.querySelector('stripe-payment-sheet');\nconst { paymentResult } = await sheet.present();\n```"
|
|
739
|
+
}]
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
static get elementRef() { return "el"; }
|
|
745
|
+
static get watchers() {
|
|
746
|
+
return [{
|
|
747
|
+
"propName": "publishableKey",
|
|
748
|
+
"methodName": "handleSecretChange"
|
|
749
|
+
}, {
|
|
750
|
+
"propName": "intentClientSecret",
|
|
751
|
+
"methodName": "handleSecretChange"
|
|
752
|
+
}, {
|
|
753
|
+
"propName": "checkoutSessionClientSecret",
|
|
754
|
+
"methodName": "handleSecretChange"
|
|
755
|
+
}, {
|
|
756
|
+
"propName": "stripeAccount",
|
|
757
|
+
"methodName": "handleSecretChange"
|
|
758
|
+
}, {
|
|
759
|
+
"propName": "open",
|
|
760
|
+
"methodName": "handleOpenChange"
|
|
761
|
+
}];
|
|
762
|
+
}
|
|
763
|
+
}
|