stripe-pwa-elements 4.0.0 → 4.0.2
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-tenFFIul.js +1200 -0
- package/dist/cjs/{factory-da3xAKkz.js → i18n-FhEOc8vz.js} +6 -1131
- package/dist/cjs/ion-icon_2.cjs.entry.js +723 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/stripe-address-element.cjs.entry.js +12 -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} +15 -82
- package/dist/cjs/stripe-currency-selector.cjs.entry.js +11 -3
- package/dist/cjs/stripe-elements.cjs.js +1 -1
- package/dist/cjs/stripe-express-checkout-element.cjs.entry.js +31 -5
- package/dist/cjs/stripe-link-authentication-element.cjs.entry.js +11 -3
- package/dist/cjs/stripe-payment-element.cjs.entry.js +106 -161
- package/dist/cjs/stripe-payment-element.helpers-DukP33RI.js +122 -0
- package/dist/cjs/stripe-payment-request-button.cjs.entry.js +23 -16
- package/dist/cjs/stripe-payment-sheet.cjs.entry.js +506 -0
- package/dist/collection/collection-manifest.json +3 -2
- package/dist/collection/components/stripe-address-element/stripe-address-element.js +7 -0
- package/dist/collection/components/stripe-card-element/stripe-card-element.js +10 -2
- package/dist/collection/components/stripe-card-element-modal/stripe-card-element-modal.js +4 -3
- package/dist/collection/components/stripe-currency-selector/stripe-currency-selector.js +7 -0
- package/dist/collection/components/stripe-express-checkout-element/stripe-express-checkout-element.js +25 -0
- package/dist/collection/components/stripe-link-authentication-element/stripe-link-authentication-element.js +7 -0
- package/dist/collection/components/stripe-modal/stripe-modal.css +23 -1
- package/dist/collection/components/stripe-modal/stripe-modal.js +147 -6
- package/dist/collection/components/stripe-payment-element/stripe-payment-element.js +94 -37
- package/dist/collection/components/stripe-payment-request-button/stripe-payment-request-button.js +17 -10
- package/dist/collection/components/stripe-payment-sheet/payment-sheet-state.js +179 -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 +90 -0
- package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.js +544 -0
- package/dist/collection/services/express-checkout-element-manager.js +36 -2
- package/dist/collection/services/stripe-service.js +37 -5
- package/dist/collection/utils/focus.js +76 -0
- package/dist/collection/utils/i18n.js +6 -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-Cd6OGTWN.js +1198 -0
- package/dist/esm/{factory-DeqoYLf_.js → i18n-B6JoQetF.js} +7 -1131
- package/dist/esm/ion-icon_2.entry.js +720 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/stripe-address-element.entry.js +9 -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} +13 -79
- package/dist/esm/stripe-currency-selector.entry.js +9 -1
- package/dist/esm/stripe-elements.js +1 -1
- package/dist/esm/stripe-express-checkout-element.entry.js +27 -1
- package/dist/esm/stripe-link-authentication-element.entry.js +9 -1
- package/dist/esm/stripe-payment-element.entry.js +98 -153
- package/dist/esm/stripe-payment-element.helpers-CipV87b8.js +117 -0
- package/dist/esm/stripe-payment-request-button.entry.js +18 -11
- package/dist/esm/stripe-payment-sheet.entry.js +504 -0
- package/dist/stripe-elements/{p-38e7b187.entry.js → p-4891edf0.entry.js} +1 -1
- package/dist/stripe-elements/p-5338bc5e.entry.js +1 -0
- package/dist/stripe-elements/p-6a9c8b7a.entry.js +1 -0
- package/dist/stripe-elements/p-7fe4a287.entry.js +1 -0
- package/dist/stripe-elements/p-915b86ed.entry.js +1 -0
- package/dist/stripe-elements/p-B6JoQetF.js +1 -0
- package/dist/stripe-elements/p-C7MQk9FK.js +1 -0
- package/dist/stripe-elements/p-DFAhQS0n.js +1 -0
- package/dist/stripe-elements/p-b06a254f.entry.js +1 -0
- package/dist/stripe-elements/p-b91c4fa7.entry.js +1 -0
- package/dist/stripe-elements/p-ba791c8f.entry.js +1 -0
- package/dist/stripe-elements/p-e7372ca7.entry.js +1 -0
- package/dist/stripe-elements/p-f892e375.entry.js +1 -0
- package/dist/stripe-elements/stripe-elements.esm.js +1 -1
- package/dist/types/components/stripe-address-element/stripe-address-element.d.ts +6 -0
- package/dist/types/components/stripe-card-element/stripe-card-element.d.ts +8 -1
- package/dist/types/components/stripe-card-element-modal/stripe-card-element-modal.d.ts +2 -1
- package/dist/types/components/stripe-currency-selector/stripe-currency-selector.d.ts +6 -0
- package/dist/types/components/stripe-express-checkout-element/stripe-express-checkout-element.d.ts +11 -0
- package/dist/types/components/stripe-link-authentication-element/stripe-link-authentication-element.d.ts +6 -0
- package/dist/types/components/stripe-modal/stripe-modal.d.ts +44 -0
- package/dist/types/components/stripe-payment-element/stripe-payment-element.d.ts +18 -0
- package/dist/types/components/stripe-payment-request-button/stripe-payment-request-button.d.ts +7 -2
- package/dist/types/components/stripe-payment-sheet/payment-sheet-state.d.ts +104 -0
- package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.d.ts +112 -0
- package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.helpers.d.ts +95 -0
- package/dist/types/components.d.ts +169 -10
- package/dist/types/index.d.ts +2 -0
- package/dist/types/services/interfaces.d.ts +2 -0
- package/dist/types/services/stripe-service.d.ts +12 -3
- package/dist/types/utils/focus.d.ts +15 -0
- package/package.json +5 -3
- package/readme.md +46 -10
- 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--sA2m1ad.js +0 -1
- package/dist/stripe-elements/p-44495284.entry.js +0 -1
- package/dist/stripe-elements/p-4ba675fa.entry.js +0 -1
- package/dist/stripe-elements/p-5cf62945.entry.js +0 -1
- package/dist/stripe-elements/p-c24ae181.entry.js +0 -1
- package/dist/stripe-elements/p-d9e86451.entry.js +0 -1
- package/dist/stripe-elements/p-f09c86a0.entry.js +0 -1
- package/dist/stripe-elements/p-f64f394d.entry.js +0 -1
- package/dist/stripe-elements/p-f6d2425e.entry.js +0 -1
|
@@ -0,0 +1,544 @@
|
|
|
1
|
+
import { h, Host } from "@stencil/core";
|
|
2
|
+
import { i18n } from "../../utils/i18n";
|
|
3
|
+
import { checkPlatform } from "../../utils/utils";
|
|
4
|
+
import { serviceFactory } from "../../services/factory";
|
|
5
|
+
import { confirmPaymentOrSetup } from "../stripe-payment-element/stripe-payment-element.helpers";
|
|
6
|
+
import { initialSheetState, transition } from "./payment-sheet-state";
|
|
7
|
+
import { isRecoverableConfirmError, toAppearance, toPaymentElementOptions, unsupportedOptionKeys } from "./stripe-payment-sheet.helpers";
|
|
8
|
+
/**
|
|
9
|
+
* A payment sheet: the Payment Element in a modal, with the same events and results as the native PaymentSheet
|
|
10
|
+
* of `@capacitor-community/stripe`. PaymentIntent and SetupIntent are told apart by the client secret prefix.
|
|
11
|
+
*/
|
|
12
|
+
export class StripePaymentSheet {
|
|
13
|
+
/**
|
|
14
|
+
* Show the sheet and wait for its result.
|
|
15
|
+
* Calling it again while a result is pending returns the same promise.
|
|
16
|
+
* @returns `{ paymentResult }`, where `paymentResult` is `paymentSheetCompleted`, `paymentSheetCanceled` or `paymentSheetFailed`
|
|
17
|
+
* @example
|
|
18
|
+
* ```
|
|
19
|
+
* const sheet = document.querySelector('stripe-payment-sheet');
|
|
20
|
+
* const { paymentResult } = await sheet.present();
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
async present() {
|
|
24
|
+
if (this.presentPromise == null) {
|
|
25
|
+
this.presentPromise = new Promise(resolve => {
|
|
26
|
+
this.resolvePresent = resolve;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const promise = this.presentPromise;
|
|
30
|
+
this.dispatch({ type: 'presentRequested' });
|
|
31
|
+
return promise;
|
|
32
|
+
}
|
|
33
|
+
handleSecretChange() {
|
|
34
|
+
this.startLoading();
|
|
35
|
+
}
|
|
36
|
+
handleOpenChange(open) {
|
|
37
|
+
this.dispatch({ type: open ? 'openRequested' : 'closeRequested' });
|
|
38
|
+
}
|
|
39
|
+
constructor() {
|
|
40
|
+
this.warnedUnsupportedOptions = false;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the sheet is shown. Setting it to false closes the sheet as canceled.
|
|
43
|
+
*/
|
|
44
|
+
this.open = false;
|
|
45
|
+
/**
|
|
46
|
+
* Sheet title. Translated automatically by this library.
|
|
47
|
+
*/
|
|
48
|
+
this.sheetTitle = 'Add your payment information';
|
|
49
|
+
/**
|
|
50
|
+
* Submit button label. Translated automatically by this library.
|
|
51
|
+
*/
|
|
52
|
+
this.buttonLabel = 'Pay';
|
|
53
|
+
/**
|
|
54
|
+
* Application name registered to Stripe.js, for wrapper libraries such as `@capacitor-community/stripe`.
|
|
55
|
+
*/
|
|
56
|
+
this.applicationName = 'stripe-pwa-elements';
|
|
57
|
+
this.sheet = initialSheetState;
|
|
58
|
+
this.visible = false;
|
|
59
|
+
this.errorMessage = '';
|
|
60
|
+
this.handleSubmit = (e) => {
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
this.errorMessage = '';
|
|
63
|
+
this.dispatch({ type: 'submitted' });
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* The modal closes itself on a backdrop or close button click. Keep it open when the sheet refuses to close (while confirming).
|
|
67
|
+
*/
|
|
68
|
+
this.handleModalClose = () => {
|
|
69
|
+
var _a;
|
|
70
|
+
this.dispatch({ type: 'closeRequested' });
|
|
71
|
+
if (this.visible) {
|
|
72
|
+
(_a = this.el.querySelector('stripe-modal')) === null || _a === void 0 ? void 0 : _a.openModal();
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
this.stripeService = serviceFactory.createStripeService();
|
|
76
|
+
this.paymentElementManager = serviceFactory.createPaymentElementManager(this.stripeService);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Props are not yet populated inside the constructor with the custom-elements build,
|
|
80
|
+
* so loading starts here.
|
|
81
|
+
*/
|
|
82
|
+
componentWillLoad() {
|
|
83
|
+
if (this.open) {
|
|
84
|
+
this.dispatch({ type: 'openRequested' });
|
|
85
|
+
}
|
|
86
|
+
this.startLoading();
|
|
87
|
+
}
|
|
88
|
+
componentDidLoad() {
|
|
89
|
+
this.el.classList.add(checkPlatform());
|
|
90
|
+
}
|
|
91
|
+
disconnectedCallback() {
|
|
92
|
+
this.paymentElementManager.unmount();
|
|
93
|
+
}
|
|
94
|
+
startLoading() {
|
|
95
|
+
if (this.publishableKey == null || this.publishableKey === '' || this.intentClientSecret == null) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
this.dispatch({ type: 'secretChanged', clientSecret: this.intentClientSecret });
|
|
99
|
+
}
|
|
100
|
+
dispatch(event) {
|
|
101
|
+
const { state, effects } = transition(this.sheet, event);
|
|
102
|
+
this.sheet = state;
|
|
103
|
+
effects.forEach(effect => this.perform(effect));
|
|
104
|
+
}
|
|
105
|
+
perform(effect) {
|
|
106
|
+
var _a;
|
|
107
|
+
switch (effect.type) {
|
|
108
|
+
case 'load':
|
|
109
|
+
this.load(effect.generation, effect.clientSecret);
|
|
110
|
+
break;
|
|
111
|
+
case 'show':
|
|
112
|
+
this.visible = true;
|
|
113
|
+
this.open = true;
|
|
114
|
+
break;
|
|
115
|
+
case 'hide':
|
|
116
|
+
this.visible = false;
|
|
117
|
+
this.open = false;
|
|
118
|
+
break;
|
|
119
|
+
case 'confirm':
|
|
120
|
+
this.confirm(effect.generation, effect.intentKind);
|
|
121
|
+
break;
|
|
122
|
+
case 'showError':
|
|
123
|
+
this.errorMessage = effect.message;
|
|
124
|
+
break;
|
|
125
|
+
case 'emit':
|
|
126
|
+
this.emit(effect.event);
|
|
127
|
+
break;
|
|
128
|
+
case 'resolvePresent':
|
|
129
|
+
(_a = this.resolvePresent) === null || _a === void 0 ? void 0 : _a.call(this, { paymentResult: effect.result });
|
|
130
|
+
this.presentPromise = undefined;
|
|
131
|
+
this.resolvePresent = undefined;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async load(generation, clientSecret) {
|
|
136
|
+
var _a;
|
|
137
|
+
this.warnUnsupportedOptions();
|
|
138
|
+
try {
|
|
139
|
+
await this.stripeService.initialize(this.publishableKey, {
|
|
140
|
+
stripeAccount: this.stripeAccount,
|
|
141
|
+
applicationName: this.applicationName,
|
|
142
|
+
clientSecret,
|
|
143
|
+
});
|
|
144
|
+
if (generation !== this.sheet.generation) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (this.stripeService.state.loadStripeStatus !== 'success') {
|
|
148
|
+
throw new Error('Failed to load Stripe.js');
|
|
149
|
+
}
|
|
150
|
+
const appearance = toAppearance((_a = this.options) === null || _a === void 0 ? void 0 : _a.style);
|
|
151
|
+
if (appearance != null) {
|
|
152
|
+
await this.stripeService.getElements().update({ appearance });
|
|
153
|
+
}
|
|
154
|
+
await this.paymentElementManager.initialize(this.el, toPaymentElementOptions(this.options));
|
|
155
|
+
this.dispatch({ type: 'loadSucceeded', generation });
|
|
156
|
+
}
|
|
157
|
+
catch (e) {
|
|
158
|
+
this.lastError = e;
|
|
159
|
+
this.dispatch({ type: 'loadFailed', generation });
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
async confirm(generation, intentKind) {
|
|
163
|
+
var _a, _b, _c;
|
|
164
|
+
try {
|
|
165
|
+
const returnUrl = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.returnURL) !== null && _b !== void 0 ? _b : window.location.href;
|
|
166
|
+
this.lastResult = await confirmPaymentOrSetup(this.stripeService.getStripe(), this.stripeService.getElements(), intentKind, returnUrl);
|
|
167
|
+
this.dispatch({ type: 'confirmSucceeded', generation });
|
|
168
|
+
}
|
|
169
|
+
catch (e) {
|
|
170
|
+
const message = (_c = e.message) !== null && _c !== void 0 ? _c : String(e);
|
|
171
|
+
if (isRecoverableConfirmError(e)) {
|
|
172
|
+
this.dispatch({ type: 'confirmDeclined', generation, message });
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
this.lastError = e;
|
|
176
|
+
this.dispatch({ type: 'confirmFailed', generation, message });
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
emit(event) {
|
|
180
|
+
switch (event) {
|
|
181
|
+
case 'paymentSheetLoaded':
|
|
182
|
+
this.paymentSheetLoaded.emit({ stripe: this.stripeService.getStripe() });
|
|
183
|
+
break;
|
|
184
|
+
case 'paymentSheetFailedToLoad':
|
|
185
|
+
this.paymentSheetFailedToLoad.emit(this.lastError);
|
|
186
|
+
break;
|
|
187
|
+
case 'paymentSheetCompleted':
|
|
188
|
+
this.paymentSheetCompleted.emit(this.lastResult);
|
|
189
|
+
break;
|
|
190
|
+
case 'paymentSheetCanceled':
|
|
191
|
+
this.paymentSheetCanceled.emit();
|
|
192
|
+
break;
|
|
193
|
+
case 'paymentSheetFailed':
|
|
194
|
+
this.paymentSheetFailed.emit(this.lastError);
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
warnUnsupportedOptions() {
|
|
199
|
+
const keys = unsupportedOptionKeys(this.options);
|
|
200
|
+
if (this.warnedUnsupportedOptions || keys.length === 0) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
this.warnedUnsupportedOptions = true;
|
|
204
|
+
console.warn(`<stripe-payment-sheet>: these options have no effect on the web yet: ${keys.join(', ')}`);
|
|
205
|
+
}
|
|
206
|
+
render() {
|
|
207
|
+
const { phase } = this.sheet;
|
|
208
|
+
const confirming = phase === 'confirming';
|
|
209
|
+
return (h(Host, { key: 'ecb6de4b0674af9f5ecf86acce93e092c3bee881' }, h("stripe-modal", { key: '137473608d8cc3c0833c34529f1dafb9fc0cba34', open: this.visible, showCloseButton: !confirming, onClose: this.handleModalClose }, h("div", { key: '0da153ef48ddc5464f050ea1921a69f975a7d8e1', class: "stripe-payment-sheet-wrap" }, h("form", { key: '6f6653aee9d0ad54c8bf935ace2f6d4fdc648e1f', id: "stripe-payment-sheet", onSubmit: this.handleSubmit }, h("div", { key: '85d3e28a20679051decdb02d590c2144e652f0bd', class: "stripe-heading" }, i18n.t(this.sheetTitle)), h("div", { key: 'f6b8d90a3731732c0b36af0512a5ace87a12f98d', class: "payment-info visible" }, h("div", { key: '813a1ad3a0db2efa650aceff828412999f34ff2b', id: "payment-element" })), h("div", { key: '63bd6a8c20dd7b8b92aa2171553c13570ab17808', class: "stripe-element-errors", role: "alert" }, this.errorMessage), h("div", { key: 'f70e9b353ae9eecd1300bbbd40ebb731ef44c344', class: "stripe-submit" }, h("button", { key: '6f32a7b94132091348680476b0e7292072800dbf', type: "submit", disabled: phase !== 'presented' }, confirming ? i18n.t('Loading') : i18n.t(this.buttonLabel))))))));
|
|
210
|
+
}
|
|
211
|
+
static get is() { return "stripe-payment-sheet"; }
|
|
212
|
+
static get originalStyleUrls() {
|
|
213
|
+
return {
|
|
214
|
+
"$": ["stripe-payment-sheet.scss"]
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
static get styleUrls() {
|
|
218
|
+
return {
|
|
219
|
+
"$": ["stripe-payment-sheet.css"]
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
static get properties() {
|
|
223
|
+
return {
|
|
224
|
+
"publishableKey": {
|
|
225
|
+
"type": "string",
|
|
226
|
+
"mutable": false,
|
|
227
|
+
"complexType": {
|
|
228
|
+
"original": "string",
|
|
229
|
+
"resolved": "string",
|
|
230
|
+
"references": {}
|
|
231
|
+
},
|
|
232
|
+
"required": false,
|
|
233
|
+
"optional": true,
|
|
234
|
+
"docs": {
|
|
235
|
+
"tags": [],
|
|
236
|
+
"text": "Your Stripe publishable API key."
|
|
237
|
+
},
|
|
238
|
+
"getter": false,
|
|
239
|
+
"setter": false,
|
|
240
|
+
"reflect": false,
|
|
241
|
+
"attribute": "publishable-key"
|
|
242
|
+
},
|
|
243
|
+
"intentClientSecret": {
|
|
244
|
+
"type": "string",
|
|
245
|
+
"mutable": false,
|
|
246
|
+
"complexType": {
|
|
247
|
+
"original": "string",
|
|
248
|
+
"resolved": "string",
|
|
249
|
+
"references": {}
|
|
250
|
+
},
|
|
251
|
+
"required": false,
|
|
252
|
+
"optional": true,
|
|
253
|
+
"docs": {
|
|
254
|
+
"tags": [],
|
|
255
|
+
"text": "The client secret of a PaymentIntent (`pi_..._secret_...`) or a SetupIntent (`seti_..._secret_...`).\nThe prefix decides whether `confirmPayment` or `confirmSetup` is used."
|
|
256
|
+
},
|
|
257
|
+
"getter": false,
|
|
258
|
+
"setter": false,
|
|
259
|
+
"reflect": false,
|
|
260
|
+
"attribute": "intent-client-secret"
|
|
261
|
+
},
|
|
262
|
+
"stripeAccount": {
|
|
263
|
+
"type": "string",
|
|
264
|
+
"mutable": false,
|
|
265
|
+
"complexType": {
|
|
266
|
+
"original": "string",
|
|
267
|
+
"resolved": "string",
|
|
268
|
+
"references": {}
|
|
269
|
+
},
|
|
270
|
+
"required": false,
|
|
271
|
+
"optional": true,
|
|
272
|
+
"docs": {
|
|
273
|
+
"tags": [{
|
|
274
|
+
"name": "info",
|
|
275
|
+
"text": "https://stripe.com/docs/connect/authentication"
|
|
276
|
+
}],
|
|
277
|
+
"text": "Optional. Making API calls for connected accounts"
|
|
278
|
+
},
|
|
279
|
+
"getter": false,
|
|
280
|
+
"setter": false,
|
|
281
|
+
"reflect": false,
|
|
282
|
+
"attribute": "stripe-account"
|
|
283
|
+
},
|
|
284
|
+
"open": {
|
|
285
|
+
"type": "boolean",
|
|
286
|
+
"mutable": true,
|
|
287
|
+
"complexType": {
|
|
288
|
+
"original": "boolean",
|
|
289
|
+
"resolved": "boolean",
|
|
290
|
+
"references": {}
|
|
291
|
+
},
|
|
292
|
+
"required": false,
|
|
293
|
+
"optional": false,
|
|
294
|
+
"docs": {
|
|
295
|
+
"tags": [],
|
|
296
|
+
"text": "Whether the sheet is shown. Setting it to false closes the sheet as canceled."
|
|
297
|
+
},
|
|
298
|
+
"getter": false,
|
|
299
|
+
"setter": false,
|
|
300
|
+
"reflect": true,
|
|
301
|
+
"attribute": "open",
|
|
302
|
+
"defaultValue": "false"
|
|
303
|
+
},
|
|
304
|
+
"sheetTitle": {
|
|
305
|
+
"type": "string",
|
|
306
|
+
"mutable": false,
|
|
307
|
+
"complexType": {
|
|
308
|
+
"original": "string",
|
|
309
|
+
"resolved": "string",
|
|
310
|
+
"references": {}
|
|
311
|
+
},
|
|
312
|
+
"required": false,
|
|
313
|
+
"optional": false,
|
|
314
|
+
"docs": {
|
|
315
|
+
"tags": [],
|
|
316
|
+
"text": "Sheet title. Translated automatically by this library."
|
|
317
|
+
},
|
|
318
|
+
"getter": false,
|
|
319
|
+
"setter": false,
|
|
320
|
+
"reflect": false,
|
|
321
|
+
"attribute": "sheet-title",
|
|
322
|
+
"defaultValue": "'Add your payment information'"
|
|
323
|
+
},
|
|
324
|
+
"buttonLabel": {
|
|
325
|
+
"type": "string",
|
|
326
|
+
"mutable": false,
|
|
327
|
+
"complexType": {
|
|
328
|
+
"original": "string",
|
|
329
|
+
"resolved": "string",
|
|
330
|
+
"references": {}
|
|
331
|
+
},
|
|
332
|
+
"required": false,
|
|
333
|
+
"optional": false,
|
|
334
|
+
"docs": {
|
|
335
|
+
"tags": [],
|
|
336
|
+
"text": "Submit button label. Translated automatically by this library."
|
|
337
|
+
},
|
|
338
|
+
"getter": false,
|
|
339
|
+
"setter": false,
|
|
340
|
+
"reflect": false,
|
|
341
|
+
"attribute": "button-label",
|
|
342
|
+
"defaultValue": "'Pay'"
|
|
343
|
+
},
|
|
344
|
+
"applicationName": {
|
|
345
|
+
"type": "string",
|
|
346
|
+
"mutable": false,
|
|
347
|
+
"complexType": {
|
|
348
|
+
"original": "string",
|
|
349
|
+
"resolved": "string",
|
|
350
|
+
"references": {}
|
|
351
|
+
},
|
|
352
|
+
"required": false,
|
|
353
|
+
"optional": false,
|
|
354
|
+
"docs": {
|
|
355
|
+
"tags": [],
|
|
356
|
+
"text": "Application name registered to Stripe.js, for wrapper libraries such as `@capacitor-community/stripe`."
|
|
357
|
+
},
|
|
358
|
+
"getter": false,
|
|
359
|
+
"setter": false,
|
|
360
|
+
"reflect": false,
|
|
361
|
+
"attribute": "application-name",
|
|
362
|
+
"defaultValue": "'stripe-pwa-elements'"
|
|
363
|
+
},
|
|
364
|
+
"options": {
|
|
365
|
+
"type": "unknown",
|
|
366
|
+
"mutable": false,
|
|
367
|
+
"complexType": {
|
|
368
|
+
"original": "PaymentSheetOptions",
|
|
369
|
+
"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; }",
|
|
370
|
+
"references": {
|
|
371
|
+
"PaymentSheetOptions": {
|
|
372
|
+
"location": "import",
|
|
373
|
+
"path": "./stripe-payment-sheet.helpers",
|
|
374
|
+
"id": "src/components/stripe-payment-sheet/stripe-payment-sheet.helpers.ts::PaymentSheetOptions",
|
|
375
|
+
"referenceLocation": "PaymentSheetOptions"
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
},
|
|
379
|
+
"required": false,
|
|
380
|
+
"optional": true,
|
|
381
|
+
"docs": {
|
|
382
|
+
"tags": [],
|
|
383
|
+
"text": "Options with the same keys as `CreatePaymentSheetOption` of `@capacitor-community/stripe`. JavaScript property only."
|
|
384
|
+
},
|
|
385
|
+
"getter": false,
|
|
386
|
+
"setter": false
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
static get states() {
|
|
391
|
+
return {
|
|
392
|
+
"sheet": {},
|
|
393
|
+
"visible": {},
|
|
394
|
+
"errorMessage": {}
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
static get events() {
|
|
398
|
+
return [{
|
|
399
|
+
"method": "paymentSheetLoaded",
|
|
400
|
+
"name": "paymentSheetLoaded",
|
|
401
|
+
"bubbles": true,
|
|
402
|
+
"cancelable": true,
|
|
403
|
+
"composed": true,
|
|
404
|
+
"docs": {
|
|
405
|
+
"tags": [],
|
|
406
|
+
"text": "Stripe.js and the Payment Element are ready"
|
|
407
|
+
},
|
|
408
|
+
"complexType": {
|
|
409
|
+
"original": "StripeLoadedEvent",
|
|
410
|
+
"resolved": "{ stripe: Stripe; }",
|
|
411
|
+
"references": {
|
|
412
|
+
"StripeLoadedEvent": {
|
|
413
|
+
"location": "import",
|
|
414
|
+
"path": "../../interfaces",
|
|
415
|
+
"id": "src/interfaces.ts::StripeLoadedEvent",
|
|
416
|
+
"referenceLocation": "StripeLoadedEvent"
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}, {
|
|
421
|
+
"method": "paymentSheetFailedToLoad",
|
|
422
|
+
"name": "paymentSheetFailedToLoad",
|
|
423
|
+
"bubbles": true,
|
|
424
|
+
"cancelable": true,
|
|
425
|
+
"composed": true,
|
|
426
|
+
"docs": {
|
|
427
|
+
"tags": [],
|
|
428
|
+
"text": "Stripe.js or the Payment Element failed to load, or the client secret format is unknown"
|
|
429
|
+
},
|
|
430
|
+
"complexType": {
|
|
431
|
+
"original": "unknown",
|
|
432
|
+
"resolved": "unknown",
|
|
433
|
+
"references": {}
|
|
434
|
+
}
|
|
435
|
+
}, {
|
|
436
|
+
"method": "paymentSheetCompleted",
|
|
437
|
+
"name": "paymentSheetCompleted",
|
|
438
|
+
"bubbles": true,
|
|
439
|
+
"cancelable": true,
|
|
440
|
+
"composed": true,
|
|
441
|
+
"docs": {
|
|
442
|
+
"tags": [],
|
|
443
|
+
"text": "The payment or setup succeeded"
|
|
444
|
+
},
|
|
445
|
+
"complexType": {
|
|
446
|
+
"original": "PaymentIntentResult | SetupIntentResult",
|
|
447
|
+
"resolved": "{ paymentIntent: PaymentIntent; error?: undefined; } | { paymentIntent?: undefined; error: StripeError; } | { setupIntent: SetupIntent; error?: undefined; } | { setupIntent?: undefined; error: StripeError; }",
|
|
448
|
+
"references": {
|
|
449
|
+
"PaymentIntentResult": {
|
|
450
|
+
"location": "import",
|
|
451
|
+
"path": "@stripe/stripe-js",
|
|
452
|
+
"id": "node_modules::PaymentIntentResult",
|
|
453
|
+
"referenceLocation": "PaymentIntentResult"
|
|
454
|
+
},
|
|
455
|
+
"SetupIntentResult": {
|
|
456
|
+
"location": "import",
|
|
457
|
+
"path": "@stripe/stripe-js",
|
|
458
|
+
"id": "node_modules::SetupIntentResult",
|
|
459
|
+
"referenceLocation": "SetupIntentResult"
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}, {
|
|
464
|
+
"method": "paymentSheetCanceled",
|
|
465
|
+
"name": "paymentSheetCanceled",
|
|
466
|
+
"bubbles": true,
|
|
467
|
+
"cancelable": true,
|
|
468
|
+
"composed": true,
|
|
469
|
+
"docs": {
|
|
470
|
+
"tags": [],
|
|
471
|
+
"text": "The customer closed the sheet"
|
|
472
|
+
},
|
|
473
|
+
"complexType": {
|
|
474
|
+
"original": "void",
|
|
475
|
+
"resolved": "void",
|
|
476
|
+
"references": {}
|
|
477
|
+
}
|
|
478
|
+
}, {
|
|
479
|
+
"method": "paymentSheetFailed",
|
|
480
|
+
"name": "paymentSheetFailed",
|
|
481
|
+
"bubbles": true,
|
|
482
|
+
"cancelable": true,
|
|
483
|
+
"composed": true,
|
|
484
|
+
"docs": {
|
|
485
|
+
"tags": [],
|
|
486
|
+
"text": "The confirmation failed with an error the customer cannot fix in the sheet"
|
|
487
|
+
},
|
|
488
|
+
"complexType": {
|
|
489
|
+
"original": "unknown",
|
|
490
|
+
"resolved": "unknown",
|
|
491
|
+
"references": {}
|
|
492
|
+
}
|
|
493
|
+
}];
|
|
494
|
+
}
|
|
495
|
+
static get methods() {
|
|
496
|
+
return {
|
|
497
|
+
"present": {
|
|
498
|
+
"complexType": {
|
|
499
|
+
"signature": "() => Promise<PaymentSheetPresentResult>",
|
|
500
|
+
"parameters": [],
|
|
501
|
+
"references": {
|
|
502
|
+
"Promise": {
|
|
503
|
+
"location": "global",
|
|
504
|
+
"id": "global::Promise"
|
|
505
|
+
},
|
|
506
|
+
"PaymentSheetPresentResult": {
|
|
507
|
+
"location": "import",
|
|
508
|
+
"path": "./stripe-payment-sheet.helpers",
|
|
509
|
+
"id": "src/components/stripe-payment-sheet/stripe-payment-sheet.helpers.ts::PaymentSheetPresentResult",
|
|
510
|
+
"referenceLocation": "PaymentSheetPresentResult"
|
|
511
|
+
}
|
|
512
|
+
},
|
|
513
|
+
"return": "Promise<PaymentSheetPresentResult>"
|
|
514
|
+
},
|
|
515
|
+
"docs": {
|
|
516
|
+
"text": "Show the sheet and wait for its result.\nCalling it again while a result is pending returns the same promise.",
|
|
517
|
+
"tags": [{
|
|
518
|
+
"name": "returns",
|
|
519
|
+
"text": "`{ paymentResult }`, where `paymentResult` is `paymentSheetCompleted`, `paymentSheetCanceled` or `paymentSheetFailed`"
|
|
520
|
+
}, {
|
|
521
|
+
"name": "example",
|
|
522
|
+
"text": "```\nconst sheet = document.querySelector('stripe-payment-sheet');\nconst { paymentResult } = await sheet.present();\n```"
|
|
523
|
+
}]
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
static get elementRef() { return "el"; }
|
|
529
|
+
static get watchers() {
|
|
530
|
+
return [{
|
|
531
|
+
"propName": "publishableKey",
|
|
532
|
+
"methodName": "handleSecretChange"
|
|
533
|
+
}, {
|
|
534
|
+
"propName": "intentClientSecret",
|
|
535
|
+
"methodName": "handleSecretChange"
|
|
536
|
+
}, {
|
|
537
|
+
"propName": "stripeAccount",
|
|
538
|
+
"methodName": "handleSecretChange"
|
|
539
|
+
}, {
|
|
540
|
+
"propName": "open",
|
|
541
|
+
"methodName": "handleOpenChange"
|
|
542
|
+
}];
|
|
543
|
+
}
|
|
544
|
+
}
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s)
|
|
4
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
1
13
|
import { createStore } from "@stencil/store";
|
|
2
14
|
import { findElement } from "../utils/element-finder";
|
|
3
15
|
/**
|
|
@@ -39,8 +51,11 @@ export class ExpressCheckoutElementManager {
|
|
|
39
51
|
if (this.expressCheckoutElement != null) {
|
|
40
52
|
this.unmount();
|
|
41
53
|
}
|
|
54
|
+
// mode / amount / currency belong to stripe.elements(), not to elements.create('expressCheckout')
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
56
|
+
const { mode, amount, currency } = options, restOptions = __rest(options, ["mode", "amount", "currency"]);
|
|
57
|
+
const createOptions = Object.assign({}, restOptions);
|
|
42
58
|
// Convert buttonHeight from string to number if present
|
|
43
|
-
const createOptions = Object.assign({}, options);
|
|
44
59
|
if (createOptions.buttonHeight && typeof createOptions.buttonHeight === 'string') {
|
|
45
60
|
const height = parseInt(createOptions.buttonHeight.replace('px', ''), 10);
|
|
46
61
|
if (!isNaN(height)) {
|
|
@@ -89,18 +104,37 @@ export class ExpressCheckoutElementManager {
|
|
|
89
104
|
* @param options - Partial options to update
|
|
90
105
|
*/
|
|
91
106
|
update(options) {
|
|
107
|
+
var _a;
|
|
92
108
|
if (this.expressCheckoutElement == null) {
|
|
93
109
|
console.warn('Express Checkout Element not initialized. Cannot update options.');
|
|
94
110
|
return;
|
|
95
111
|
}
|
|
112
|
+
// mode / amount / currency are Elements group options, so they are updated with elements.update()
|
|
113
|
+
const { mode, amount, currency } = options, elementOptions = __rest(options, ["mode", "amount", "currency"]);
|
|
114
|
+
const groupOptions = {};
|
|
115
|
+
if (mode !== undefined) {
|
|
116
|
+
groupOptions.mode = mode;
|
|
117
|
+
}
|
|
118
|
+
if (amount !== undefined) {
|
|
119
|
+
groupOptions.amount = amount;
|
|
120
|
+
}
|
|
121
|
+
if (currency !== undefined) {
|
|
122
|
+
groupOptions.currency = currency;
|
|
123
|
+
}
|
|
124
|
+
if (Object.keys(groupOptions).length > 0) {
|
|
125
|
+
(_a = this.stripeService.getElements()) === null || _a === void 0 ? void 0 : _a.update(groupOptions);
|
|
126
|
+
}
|
|
96
127
|
// Convert buttonHeight from string to number if present
|
|
97
|
-
const updateOptions = Object.assign({},
|
|
128
|
+
const updateOptions = Object.assign({}, elementOptions);
|
|
98
129
|
if (updateOptions.buttonHeight && typeof updateOptions.buttonHeight === 'string') {
|
|
99
130
|
const height = parseInt(updateOptions.buttonHeight.replace('px', ''), 10);
|
|
100
131
|
if (!isNaN(height)) {
|
|
101
132
|
updateOptions.buttonHeight = height;
|
|
102
133
|
}
|
|
103
134
|
}
|
|
135
|
+
if (Object.keys(updateOptions).length === 0) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
104
138
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
105
139
|
this.expressCheckoutElement.update(updateOptions);
|
|
106
140
|
}
|