stripe-pwa-elements 3.2.0 → 4.0.0
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/app-globals-V2Kpy_OQ.js +0 -3
- package/dist/cjs/error-FFC4kSs5.js +0 -3
- package/dist/cjs/{factory-CbbbSvkg.js → factory-da3xAKkz.js} +194 -73
- package/dist/cjs/{index-Ba1pBePA.js → index-CYbA1N_k.js} +24 -6
- package/dist/cjs/index-Dkb0SxZc.js +4694 -0
- package/dist/cjs/index.cjs.js +0 -1
- package/dist/cjs/ion-icon.cjs.entry.js +22 -13
- package/dist/cjs/loader.cjs.js +2 -3
- package/dist/cjs/stripe-address-element.cjs.entry.js +34 -26
- package/dist/cjs/stripe-card-element-modal.cjs.entry.js +6 -7
- package/dist/cjs/stripe-card-element_2.cjs.entry.js +106 -67
- package/dist/cjs/stripe-currency-selector.cjs.entry.js +13 -10
- package/dist/cjs/stripe-elements.cjs.js +31 -5
- package/dist/cjs/stripe-express-checkout-element.cjs.entry.js +25 -22
- package/dist/cjs/stripe-link-authentication-element.cjs.entry.js +13 -10
- package/dist/cjs/stripe-payment-element.cjs.entry.js +190 -131
- package/dist/cjs/stripe-payment-request-button.cjs.entry.js +12 -7
- package/dist/collection/collection-manifest.json +3 -2
- package/dist/collection/components/stripe-address-element/stripe-address-element.js +29 -21
- package/dist/collection/components/stripe-card-element/stripe-card-element.helpers.js +57 -0
- package/dist/collection/components/stripe-card-element/stripe-card-element.js +55 -68
- package/dist/collection/components/stripe-card-element-modal/stripe-card-element-modal.js +15 -11
- package/dist/collection/components/stripe-currency-selector/stripe-currency-selector.js +10 -6
- package/dist/collection/components/stripe-express-checkout-element/stripe-express-checkout-element.js +28 -20
- package/dist/collection/components/stripe-link-authentication-element/stripe-link-authentication-element.js +12 -7
- package/dist/collection/components/stripe-modal/stripe-modal.js +0 -1
- package/dist/collection/components/stripe-payment-element/stripe-payment-element.helpers.js +114 -0
- package/dist/collection/components/stripe-payment-element/stripe-payment-element.js +69 -126
- package/dist/collection/components/stripe-payment-request-button/stripe-payment-request-button.js +34 -12
- package/dist/collection/index.js +0 -1
- package/dist/collection/interfaces.js +0 -1
- package/dist/collection/services/address-element-manager.js +3 -4
- package/dist/collection/services/card-element-manager.js +3 -4
- package/dist/collection/services/currency-selector-element-manager.js +3 -4
- package/dist/collection/services/express-checkout-element-manager.js +9 -10
- package/dist/collection/services/factory.js +0 -1
- package/dist/collection/services/interfaces.js +0 -1
- package/dist/collection/services/link-authentication-element-manager.js +3 -4
- package/dist/collection/services/payment-element-manager.js +4 -5
- package/dist/collection/services/stripe-service.js +5 -6
- package/dist/collection/utils/element-finder.js +2 -3
- package/dist/collection/utils/error.js +0 -1
- package/dist/collection/utils/i18n.js +0 -1
- package/dist/collection/utils/platform.js +0 -1
- package/dist/collection/utils/test-setup.js +0 -1
- package/dist/collection/utils/utils.js +2 -3
- package/dist/components/error.js +1 -16
- package/dist/components/factory.js +1 -3736
- package/dist/components/icon.js +1 -459
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +1 -4
- package/dist/components/index2.js +1 -192
- package/dist/components/ion-icon.js +1 -9
- package/dist/components/stripe-address-element.js +1 -327
- package/dist/components/stripe-card-element-modal.js +1 -174
- package/dist/components/stripe-card-element.js +1 -9
- package/dist/components/stripe-card-element2.js +1 -440
- package/dist/components/stripe-currency-selector.js +1 -218
- package/dist/components/stripe-express-checkout-element.js +1 -332
- package/dist/components/stripe-link-authentication-element.js +1 -256
- package/dist/components/stripe-modal.js +1 -9
- package/dist/components/stripe-modal2.js +1 -112
- package/dist/components/stripe-payment-element.js +1 -510
- package/dist/components/stripe-payment-request-button.js +1 -9
- package/dist/components/stripe-payment-request-button2.js +1 -224
- package/dist/components/utils.js +1 -89
- package/dist/esm/app-globals-DQuL1Twl.js +0 -3
- package/dist/esm/error-XRfh5Wrs.js +0 -3
- package/dist/esm/{factory-Drde6-y7.js → factory-DeqoYLf_.js} +194 -73
- package/dist/esm/index-C6bbmyga.js +4677 -0
- package/dist/esm/{index-BHDCxQOb.js → index-CBXaOfXU.js} +24 -6
- package/dist/esm/index.js +0 -1
- package/dist/esm/ion-icon.entry.js +22 -13
- package/dist/esm/loader.js +3 -4
- package/dist/esm/stripe-address-element.entry.js +34 -26
- package/dist/esm/stripe-card-element-modal.entry.js +6 -7
- package/dist/esm/stripe-card-element_2.entry.js +106 -67
- package/dist/esm/stripe-currency-selector.entry.js +13 -10
- package/dist/esm/stripe-elements.js +32 -6
- package/dist/esm/stripe-express-checkout-element.entry.js +25 -22
- package/dist/esm/stripe-link-authentication-element.entry.js +13 -10
- package/dist/esm/stripe-payment-element.entry.js +190 -131
- package/dist/esm/stripe-payment-request-button.entry.js +12 -7
- package/dist/stripe-elements/index.esm.js +0 -2
- package/dist/stripe-elements/p--sA2m1ad.js +1 -0
- package/dist/stripe-elements/p-38e7b187.entry.js +1 -0
- package/dist/stripe-elements/p-44495284.entry.js +1 -0
- package/dist/stripe-elements/p-4ba675fa.entry.js +1 -0
- package/dist/stripe-elements/p-5cf62945.entry.js +1 -0
- package/dist/stripe-elements/p-C6bbmyga.js +2 -0
- package/dist/stripe-elements/p-CBXaOfXU.js +1 -0
- package/dist/stripe-elements/p-DQuL1Twl.js +1 -2
- package/dist/stripe-elements/p-XRfh5Wrs.js +1 -2
- package/dist/stripe-elements/p-c24ae181.entry.js +1 -0
- package/dist/stripe-elements/p-d9e86451.entry.js +1 -0
- package/dist/stripe-elements/p-f09c86a0.entry.js +1 -0
- package/dist/stripe-elements/p-f64f394d.entry.js +1 -0
- package/dist/stripe-elements/p-f6d2425e.entry.js +1 -0
- package/dist/stripe-elements/stripe-elements.esm.js +1 -2
- package/dist/stripe-elements/svg/.gitignore +4 -0
- package/dist/types/components/stripe-card-element/stripe-card-element.d.ts +5 -1
- package/dist/types/components/stripe-card-element/stripe-card-element.helpers.d.ts +29 -0
- package/dist/types/components/stripe-card-element-modal/stripe-card-element-modal.d.ts +4 -4
- package/dist/types/components/stripe-payment-element/stripe-payment-element.d.ts +2 -2
- package/dist/types/components/stripe-payment-element/stripe-payment-element.helpers.d.ts +54 -0
- package/dist/types/components/stripe-payment-request-button/stripe-payment-request-button.d.ts +8 -0
- package/dist/types/components.d.ts +139 -29
- package/dist/types/index.d.ts +1 -0
- package/dist/types/services/interfaces.d.ts +3 -3
- package/dist/types/services/stripe-service.d.ts +2 -2
- package/dist/types/stencil-public-runtime.d.ts +110 -5
- package/package.json +50 -30
- package/readme.md +386 -133
- package/dist/cjs/app-globals-V2Kpy_OQ.js.map +0 -1
- package/dist/cjs/error-FFC4kSs5.js.map +0 -1
- package/dist/cjs/factory-CbbbSvkg.js.map +0 -1
- package/dist/cjs/index-BXVW_rzh.js +0 -1932
- package/dist/cjs/index-BXVW_rzh.js.map +0 -1
- package/dist/cjs/index-Ba1pBePA.js.map +0 -1
- package/dist/cjs/index.cjs.js.map +0 -1
- package/dist/cjs/ion-icon.entry.cjs.js.map +0 -1
- package/dist/cjs/loader.cjs.js.map +0 -1
- package/dist/cjs/stripe-address-element.entry.cjs.js.map +0 -1
- package/dist/cjs/stripe-card-element-modal.entry.cjs.js.map +0 -1
- package/dist/cjs/stripe-card-element.stripe-modal.entry.cjs.js.map +0 -1
- package/dist/cjs/stripe-currency-selector.entry.cjs.js.map +0 -1
- package/dist/cjs/stripe-elements.cjs.js.map +0 -1
- package/dist/cjs/stripe-express-checkout-element.entry.cjs.js.map +0 -1
- package/dist/cjs/stripe-link-authentication-element.entry.cjs.js.map +0 -1
- package/dist/cjs/stripe-payment-element.entry.cjs.js.map +0 -1
- package/dist/cjs/stripe-payment-request-button.entry.cjs.js.map +0 -1
- package/dist/collection/components/stripe-address-element/stripe-address-element.js.map +0 -1
- package/dist/collection/components/stripe-card-element/stripe-card-element.js.map +0 -1
- package/dist/collection/components/stripe-card-element-modal/stripe-card-element-modal.js.map +0 -1
- package/dist/collection/components/stripe-currency-selector/stripe-currency-selector.js.map +0 -1
- package/dist/collection/components/stripe-express-checkout-element/stripe-express-checkout-element.js.map +0 -1
- package/dist/collection/components/stripe-link-authentication-element/stripe-link-authentication-element.js.map +0 -1
- package/dist/collection/components/stripe-modal/stripe-modal.js.map +0 -1
- package/dist/collection/components/stripe-payment-element/stripe-payment-element.js.map +0 -1
- package/dist/collection/components/stripe-payment-request-button/stripe-payment-request-button.js.map +0 -1
- package/dist/collection/index.js.map +0 -1
- package/dist/collection/interfaces.js.map +0 -1
- package/dist/collection/services/address-element-manager.js.map +0 -1
- package/dist/collection/services/card-element-manager.js.map +0 -1
- package/dist/collection/services/currency-selector-element-manager.js.map +0 -1
- package/dist/collection/services/express-checkout-element-manager.js.map +0 -1
- package/dist/collection/services/factory.js.map +0 -1
- package/dist/collection/services/interfaces.js.map +0 -1
- package/dist/collection/services/link-authentication-element-manager.js.map +0 -1
- package/dist/collection/services/payment-element-manager.js.map +0 -1
- package/dist/collection/services/stripe-service.js.map +0 -1
- package/dist/collection/utils/element-finder.js.map +0 -1
- package/dist/collection/utils/error.js.map +0 -1
- package/dist/collection/utils/i18n.js.map +0 -1
- package/dist/collection/utils/platform.js.map +0 -1
- package/dist/collection/utils/test-setup.js.map +0 -1
- package/dist/collection/utils/utils.js.map +0 -1
- package/dist/components/error.js.map +0 -1
- package/dist/components/factory.js.map +0 -1
- package/dist/components/icon.js.map +0 -1
- package/dist/components/index.js.map +0 -1
- package/dist/components/index2.js.map +0 -1
- package/dist/components/ion-icon.js.map +0 -1
- package/dist/components/stripe-address-element.js.map +0 -1
- package/dist/components/stripe-card-element-modal.js.map +0 -1
- package/dist/components/stripe-card-element.js.map +0 -1
- package/dist/components/stripe-card-element2.js.map +0 -1
- package/dist/components/stripe-currency-selector.js.map +0 -1
- package/dist/components/stripe-express-checkout-element.js.map +0 -1
- package/dist/components/stripe-link-authentication-element.js.map +0 -1
- package/dist/components/stripe-modal.js.map +0 -1
- package/dist/components/stripe-modal2.js.map +0 -1
- package/dist/components/stripe-payment-element.js.map +0 -1
- package/dist/components/stripe-payment-request-button.js.map +0 -1
- package/dist/components/stripe-payment-request-button2.js.map +0 -1
- package/dist/components/utils.js.map +0 -1
- package/dist/esm/app-globals-DQuL1Twl.js.map +0 -1
- package/dist/esm/error-XRfh5Wrs.js.map +0 -1
- package/dist/esm/factory-Drde6-y7.js.map +0 -1
- package/dist/esm/index-BHDCxQOb.js.map +0 -1
- package/dist/esm/index-DJwTOfxZ.js +0 -1920
- package/dist/esm/index-DJwTOfxZ.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/ion-icon.entry.js.map +0 -1
- package/dist/esm/loader.js.map +0 -1
- package/dist/esm/stripe-address-element.entry.js.map +0 -1
- package/dist/esm/stripe-card-element-modal.entry.js.map +0 -1
- package/dist/esm/stripe-card-element.stripe-modal.entry.js.map +0 -1
- package/dist/esm/stripe-currency-selector.entry.js.map +0 -1
- package/dist/esm/stripe-elements.js.map +0 -1
- package/dist/esm/stripe-express-checkout-element.entry.js.map +0 -1
- package/dist/esm/stripe-link-authentication-element.entry.js.map +0 -1
- package/dist/esm/stripe-payment-element.entry.js.map +0 -1
- package/dist/esm/stripe-payment-request-button.entry.js.map +0 -1
- package/dist/stripe-elements/index.esm.js.map +0 -1
- package/dist/stripe-elements/ion-icon.entry.esm.js.map +0 -1
- package/dist/stripe-elements/loader.esm.js.map +0 -1
- package/dist/stripe-elements/p-02f6e421.entry.js +0 -2
- package/dist/stripe-elements/p-02f6e421.entry.js.map +0 -1
- package/dist/stripe-elements/p-19888fa6.entry.js +0 -2
- package/dist/stripe-elements/p-19888fa6.entry.js.map +0 -1
- package/dist/stripe-elements/p-4d505729.entry.js +0 -2
- package/dist/stripe-elements/p-4d505729.entry.js.map +0 -1
- package/dist/stripe-elements/p-7e7ad92a.entry.js +0 -2
- package/dist/stripe-elements/p-7e7ad92a.entry.js.map +0 -1
- package/dist/stripe-elements/p-8bb4212c.entry.js +0 -2
- package/dist/stripe-elements/p-8bb4212c.entry.js.map +0 -1
- package/dist/stripe-elements/p-9aee2b6b.entry.js +0 -2
- package/dist/stripe-elements/p-9aee2b6b.entry.js.map +0 -1
- package/dist/stripe-elements/p-BHDCxQOb.js +0 -2
- package/dist/stripe-elements/p-BHDCxQOb.js.map +0 -1
- package/dist/stripe-elements/p-DI2vmGaI.js +0 -2
- package/dist/stripe-elements/p-DI2vmGaI.js.map +0 -1
- package/dist/stripe-elements/p-DJwTOfxZ.js +0 -3
- package/dist/stripe-elements/p-DJwTOfxZ.js.map +0 -1
- package/dist/stripe-elements/p-DQuL1Twl.js.map +0 -1
- package/dist/stripe-elements/p-XRfh5Wrs.js.map +0 -1
- package/dist/stripe-elements/p-ba251393.entry.js +0 -2
- package/dist/stripe-elements/p-ba251393.entry.js.map +0 -1
- package/dist/stripe-elements/p-c649edfc.entry.js +0 -2
- package/dist/stripe-elements/p-c649edfc.entry.js.map +0 -1
- package/dist/stripe-elements/p-e8bb43ae.entry.js +0 -2
- package/dist/stripe-elements/p-e8bb43ae.entry.js.map +0 -1
- package/dist/stripe-elements/stripe-address-element.entry.esm.js.map +0 -1
- package/dist/stripe-elements/stripe-card-element-modal.entry.esm.js.map +0 -1
- package/dist/stripe-elements/stripe-card-element.stripe-modal.entry.esm.js.map +0 -1
- package/dist/stripe-elements/stripe-currency-selector.entry.esm.js.map +0 -1
- package/dist/stripe-elements/stripe-elements.esm.js.map +0 -1
- package/dist/stripe-elements/stripe-express-checkout-element.entry.esm.js.map +0 -1
- package/dist/stripe-elements/stripe-link-authentication-element.entry.esm.js.map +0 -1
- package/dist/stripe-elements/stripe-payment-element.entry.esm.js.map +0 -1
- package/dist/stripe-elements/stripe-payment-request-button.entry.esm.js.map +0 -1
|
@@ -1,440 +1 @@
|
|
|
1
|
-
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
-
import { c as checkPlatform } from './utils.js';
|
|
3
|
-
import { s as serviceFactory, i as i18n } from './factory.js';
|
|
4
|
-
import { S as StripeAPIError } from './error.js';
|
|
5
|
-
import { d as defineCustomElement$1 } from './stripe-payment-request-button2.js';
|
|
6
|
-
|
|
7
|
-
const stripeCardElementCss = ":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-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 .StripeElement{padding:8px 16px;min-height:64px;display:flex;justify-content:center;align-items:center}.stripe-payment-sheet-wrap .StripeElement>.__PrivateStripeElement{width:100%}.stripe-payment-sheet-wrap .stripe-input-box{background-color:#fff;border-radius:6px;border:1px solid var(--color-input-border);overflow:hidden;filter:drop-shadow(0 0 2px var(--color-input-border-shadow))}.stripe-payment-sheet-wrap .stripe-input-box>*{border-bottom:1px solid var(--color-input-border)}.stripe-payment-sheet-wrap .stripe-input-box>*:last-child{border-bottom:none}.stripe-payment-sheet-wrap .stripe-input-column>*{border-right:1px solid var(--color-input-border)}.stripe-payment-sheet-wrap .stripe-input-column>*:last-child{border-right:none}.stripe-payment-sheet-wrap .stripe-heading{font-size:24px;font-weight:bold;color:var(--color-heading-text);margin-bottom:24px}.stripe-payment-sheet-wrap .stripe-section-title{font-size:14px;font-weight:bold;color:var(--color-label);margin-bottom:8px}.stripe-payment-sheet-wrap .payment-info label{color:var(--color-label)}.stripe-payment-sheet-wrap .stripe-element-errors{margin-top:8px;font-size:14px;color:var(--color-text-error)}.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)}";
|
|
8
|
-
|
|
9
|
-
const StripeCardElement = /*@__PURE__*/ proxyCustomElement(class StripeCardElement extends HTMLElement {
|
|
10
|
-
/**
|
|
11
|
-
* Get Stripe.js, and initialize elements
|
|
12
|
-
* @param publishableKey
|
|
13
|
-
* @param options
|
|
14
|
-
* @example
|
|
15
|
-
* ```
|
|
16
|
-
* const stripeElement = document.createElement('stripe-card-element');
|
|
17
|
-
* customElements
|
|
18
|
-
* .whenDefined('stripe-card-element')
|
|
19
|
-
* .then(() => {
|
|
20
|
-
* tripeElement.initStripe('pk_test_XXXXXXXXX')
|
|
21
|
-
* })
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
async initStripe(publishableKey, options) {
|
|
25
|
-
await this.stripeService.initialize(publishableKey, {
|
|
26
|
-
stripeAccount: options === null || options === void 0 ? void 0 : options.stripeAccount,
|
|
27
|
-
applicationName: this.applicationName,
|
|
28
|
-
});
|
|
29
|
-
// If already successfully loaded, initialize elements immediately
|
|
30
|
-
if (this.stripeService.state.loadStripeStatus === 'success') {
|
|
31
|
-
await this.initElement();
|
|
32
|
-
this.stripeLoadedEventHandler();
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
// Otherwise, wait for successful load
|
|
36
|
-
const unsubscribe = this.stripeService.onChange('loadStripeStatus', async (newState) => {
|
|
37
|
-
if (newState !== 'success') {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
await this.initElement();
|
|
41
|
-
this.stripeLoadedEventHandler();
|
|
42
|
-
unsubscribe(); // Clean up listener after first success
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Update the form submit progress
|
|
48
|
-
* @param progress
|
|
49
|
-
* @returns
|
|
50
|
-
* @example
|
|
51
|
-
* ```
|
|
52
|
-
* const stripeElement = document.createElement('stripe-card-element');
|
|
53
|
-
* customElements
|
|
54
|
-
* .whenDefined('stripe-card-element')
|
|
55
|
-
* .then(() => {
|
|
56
|
-
* // You must set the attributes to stop running default form submit action when you want to listen the 'formSubmit' event.
|
|
57
|
-
* stripeElement.setAttribute('should-use-default-form-submit-action', false)
|
|
58
|
-
* stripeElement.addEventListener('formSubmit', async props => {
|
|
59
|
-
* const {
|
|
60
|
-
* detail: { stripe, cardNumber, event },
|
|
61
|
-
* } = props;
|
|
62
|
-
* const result = await stripe.createPaymentMethod({
|
|
63
|
-
* type: 'card',
|
|
64
|
-
* card: cardNumber,
|
|
65
|
-
* });
|
|
66
|
-
* console.log(result);
|
|
67
|
-
* stripeElement.updateProgress('success')
|
|
68
|
-
* });
|
|
69
|
-
* })
|
|
70
|
-
*/
|
|
71
|
-
async updateProgress(progress) {
|
|
72
|
-
this.progress = progress;
|
|
73
|
-
return this;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Set error message
|
|
77
|
-
* @param errorMessage string
|
|
78
|
-
* @returns
|
|
79
|
-
* @example
|
|
80
|
-
* ```
|
|
81
|
-
* const stripeElement = document.createElement('stripe-card-element');
|
|
82
|
-
* customElements
|
|
83
|
-
* .whenDefined('stripe-card-element')
|
|
84
|
-
* .then(() => {
|
|
85
|
-
* // You must set the attributes to stop running default form submit action when you want to listen the 'formSubmit' event.
|
|
86
|
-
* stripeElement.setAttribute('should-use-default-form-submit-action', false)
|
|
87
|
-
* stripeElement.addEventListener('formSubmit', async props => {
|
|
88
|
-
* try {
|
|
89
|
-
* throw new Error('debug')
|
|
90
|
-
* } catch (e) {
|
|
91
|
-
* stripeElement.setErrorMessage(`Error: ${e.message}`)
|
|
92
|
-
* stripeElement.updateProgress('failure')
|
|
93
|
-
* }
|
|
94
|
-
* });
|
|
95
|
-
* })
|
|
96
|
-
*/
|
|
97
|
-
async setErrorMessage(errorMessage) {
|
|
98
|
-
this.cardElementManager.setError(errorMessage);
|
|
99
|
-
return this;
|
|
100
|
-
}
|
|
101
|
-
updatePublishableKey(publishableKey) {
|
|
102
|
-
const options = {};
|
|
103
|
-
if (this.stripeAccount) {
|
|
104
|
-
options.stripeAccount = this.stripeAccount;
|
|
105
|
-
}
|
|
106
|
-
this.initStripe(publishableKey, Object.keys(options).length ? options : undefined);
|
|
107
|
-
}
|
|
108
|
-
updateStripeAccountId(stripeAccount) {
|
|
109
|
-
const publishableKey = this.stripeService.state.publishableKey || this.publishableKey;
|
|
110
|
-
if (!publishableKey) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
this.initStripe(publishableKey, {
|
|
114
|
-
stripeAccount,
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* @param option
|
|
119
|
-
* @private
|
|
120
|
-
*/
|
|
121
|
-
async setPaymentRequestOption(option) {
|
|
122
|
-
this.paymentRequestOption = option;
|
|
123
|
-
this.createPaymentRequestButton();
|
|
124
|
-
return this;
|
|
125
|
-
}
|
|
126
|
-
stripeLoadedEventHandler() {
|
|
127
|
-
const event = {
|
|
128
|
-
stripe: this.stripeService.getStripe(),
|
|
129
|
-
};
|
|
130
|
-
if (this.stripeDidLoaded) {
|
|
131
|
-
this.stripeDidLoaded(event);
|
|
132
|
-
}
|
|
133
|
-
this.stripeLoaded.emit(event);
|
|
134
|
-
}
|
|
135
|
-
async formSubmitEventHandler() {
|
|
136
|
-
const cardElements = this.cardElementManager.getElements();
|
|
137
|
-
const stripe = this.stripeService.getStripe();
|
|
138
|
-
if (!cardElements) {
|
|
139
|
-
console.error('Card elements not initialized');
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
this.formSubmit.emit({
|
|
143
|
-
cardCVCElement: cardElements.cardCVC,
|
|
144
|
-
cardExpiryElement: cardElements.cardExpiry,
|
|
145
|
-
cardNumberElement: cardElements.cardNumber,
|
|
146
|
-
stripe,
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
async defaultFormSubmitResultHandler(result) {
|
|
150
|
-
this.defaultFormSubmitResult.emit(result);
|
|
151
|
-
}
|
|
152
|
-
componentWillRender() {
|
|
153
|
-
if (!this.stripeService.state.publishableKey) {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
if (['success', 'loading'].includes(this.stripeService.state.loadStripeStatus)) {
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
this.initStripe(this.stripeService.state.publishableKey, {
|
|
160
|
-
stripeAccount: this.stripeService.state.stripeAccount,
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Default form submit action (just call a confirmCardPayment).
|
|
165
|
-
* If you don't want use it, please set `should-use-default-form-submit-action="false"`
|
|
166
|
-
* @param event
|
|
167
|
-
* @param param1
|
|
168
|
-
*/
|
|
169
|
-
async defaultFormSubmitAction(event, { stripe, cardNumberElement, intentClientSecret }) {
|
|
170
|
-
event.preventDefault();
|
|
171
|
-
try {
|
|
172
|
-
const { intentType } = this;
|
|
173
|
-
const result = await (() => {
|
|
174
|
-
if (intentType === 'payment') {
|
|
175
|
-
return stripe.confirmCardPayment(intentClientSecret, {
|
|
176
|
-
payment_method: {
|
|
177
|
-
card: cardNumberElement,
|
|
178
|
-
},
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
return stripe.confirmCardSetup(intentClientSecret, {
|
|
182
|
-
payment_method: {
|
|
183
|
-
card: cardNumberElement,
|
|
184
|
-
},
|
|
185
|
-
});
|
|
186
|
-
})();
|
|
187
|
-
if (result.error) {
|
|
188
|
-
throw new StripeAPIError(result.error);
|
|
189
|
-
}
|
|
190
|
-
this.defaultFormSubmitResultHandler(result);
|
|
191
|
-
}
|
|
192
|
-
catch (e) {
|
|
193
|
-
console.error(e);
|
|
194
|
-
this.defaultFormSubmitResultHandler(e);
|
|
195
|
-
throw e;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
constructor(registerHost) {
|
|
199
|
-
super();
|
|
200
|
-
if (registerHost !== false) {
|
|
201
|
-
this.__registerHost();
|
|
202
|
-
}
|
|
203
|
-
this.stripeLoaded = createEvent(this, "stripeLoaded", 7);
|
|
204
|
-
this.formSubmit = createEvent(this, "formSubmit", 7);
|
|
205
|
-
this.defaultFormSubmitResult = createEvent(this, "defaultFormSubmitResult", 7);
|
|
206
|
-
// Track if payment request button has been created to prevent duplicates
|
|
207
|
-
this.paymentRequestButtonCreated = false;
|
|
208
|
-
/**
|
|
209
|
-
* Default submit handle type.
|
|
210
|
-
* If you want to use `setupIntent`, should update this attribute.
|
|
211
|
-
*/
|
|
212
|
-
this.intentType = 'payment';
|
|
213
|
-
/**
|
|
214
|
-
* If true, show zip code field
|
|
215
|
-
*/
|
|
216
|
-
this.zip = true;
|
|
217
|
-
/**
|
|
218
|
-
* Payment sheet title
|
|
219
|
-
* By default we recommended to use these string
|
|
220
|
-
* - 'Add your payment information' -> PaymentSheet / PaymentFlow(Android)
|
|
221
|
-
* - 'Add a card' -> PaymentFlow(iOS)
|
|
222
|
-
* These strings will translated automatically by this library.
|
|
223
|
-
*/
|
|
224
|
-
this.sheetTitle = 'Add your payment information';
|
|
225
|
-
/**
|
|
226
|
-
* Submit button label
|
|
227
|
-
* By default we recommended to use these string
|
|
228
|
-
* - 'Pay' -> PaymentSheet
|
|
229
|
-
* - 'Add' -> PaymentFlow(Android)
|
|
230
|
-
* - 'Add card' -> PaymentFlow(iOS)
|
|
231
|
-
* - 'Add a card' -> PaymentFlow(iOS)
|
|
232
|
-
* These strings will translated automatically by this library.
|
|
233
|
-
*
|
|
234
|
-
*/
|
|
235
|
-
this.buttonLabel = 'Pay';
|
|
236
|
-
/**
|
|
237
|
-
* The progress status of the checkout process
|
|
238
|
-
*/
|
|
239
|
-
this.progress = '';
|
|
240
|
-
/**
|
|
241
|
-
* zip code
|
|
242
|
-
*/
|
|
243
|
-
this.zipCode = '';
|
|
244
|
-
/**
|
|
245
|
-
* Overwrite the application name that registered
|
|
246
|
-
* For wrapper library (like Capacitor)
|
|
247
|
-
*/
|
|
248
|
-
this.applicationName = 'stripe-pwa-elements';
|
|
249
|
-
/**
|
|
250
|
-
* Show the form label
|
|
251
|
-
*/
|
|
252
|
-
this.showLabel = false;
|
|
253
|
-
/**
|
|
254
|
-
* The component will provide a function to call the `stripe.confirmCardPayment`API.
|
|
255
|
-
* If you want to customize the behavior, should set false.
|
|
256
|
-
* And listen the 'formSubmit' event on the element
|
|
257
|
-
*/
|
|
258
|
-
this.shouldUseDefaultFormSubmitAction = true;
|
|
259
|
-
// Dependency Injection via factory
|
|
260
|
-
this.stripeService = serviceFactory.createStripeService();
|
|
261
|
-
this.cardElementManager = serviceFactory.createCardElementManager(this.stripeService);
|
|
262
|
-
if (this.publishableKey) {
|
|
263
|
-
this.initStripe(this.publishableKey, {
|
|
264
|
-
stripeAccount: this.stripeAccount,
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Initialize Component using Stripe Element
|
|
270
|
-
*/
|
|
271
|
-
async initElement() {
|
|
272
|
-
// Initialize card elements
|
|
273
|
-
await this.cardElementManager.initialize(this.el);
|
|
274
|
-
// Add form submit listener scoped to this component instance
|
|
275
|
-
const formElement = this.el.querySelector('#stripe-card-element');
|
|
276
|
-
if (!formElement) {
|
|
277
|
-
console.error('Form element #stripe-card-element not found');
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
formElement.addEventListener('submit', async (e) => {
|
|
281
|
-
const cardElements = this.cardElementManager.getElements();
|
|
282
|
-
const stripe = this.stripeService.getStripe();
|
|
283
|
-
const { intentClientSecret } = this;
|
|
284
|
-
if (!cardElements || !stripe) {
|
|
285
|
-
console.error('Stripe not properly initialized');
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
const submitEventProps = {
|
|
289
|
-
cardCVCElement: cardElements.cardCVC,
|
|
290
|
-
cardExpiryElement: cardElements.cardExpiry,
|
|
291
|
-
cardNumberElement: cardElements.cardNumber,
|
|
292
|
-
stripe,
|
|
293
|
-
intentClientSecret,
|
|
294
|
-
zipCode: this.zipCode,
|
|
295
|
-
};
|
|
296
|
-
this.progress = 'loading';
|
|
297
|
-
try {
|
|
298
|
-
if (this.handleSubmit) {
|
|
299
|
-
await this.handleSubmit(e, submitEventProps);
|
|
300
|
-
}
|
|
301
|
-
else if (this.shouldUseDefaultFormSubmitAction === true && intentClientSecret) {
|
|
302
|
-
await this.defaultFormSubmitAction(e, submitEventProps);
|
|
303
|
-
}
|
|
304
|
-
else {
|
|
305
|
-
e.preventDefault();
|
|
306
|
-
}
|
|
307
|
-
await this.formSubmitEventHandler();
|
|
308
|
-
if (this.handleSubmit || this.shouldUseDefaultFormSubmitAction === true) {
|
|
309
|
-
this.progress = 'success';
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
catch (e) {
|
|
313
|
-
this.cardElementManager.setError(e.message);
|
|
314
|
-
this.progress = 'failure';
|
|
315
|
-
}
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
componentDidLoad() {
|
|
319
|
-
this.el.classList.add(checkPlatform());
|
|
320
|
-
}
|
|
321
|
-
componentDidRender() {
|
|
322
|
-
// Safely create payment request button after DOM is ready
|
|
323
|
-
// Only runs if conditions are met and button hasn't been created yet
|
|
324
|
-
if (this.showPaymentRequestButton && this.paymentRequestOption && !this.paymentRequestButtonCreated) {
|
|
325
|
-
this.createPaymentRequestButton();
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
disconnectedCallback() {
|
|
329
|
-
this.cardElementManager.unmount();
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Create payment request button
|
|
333
|
-
* It's just proxy of stripe-payment-request-button
|
|
334
|
-
*/
|
|
335
|
-
createPaymentRequestButton() {
|
|
336
|
-
const { showPaymentRequestButton, paymentRequestOption } = this;
|
|
337
|
-
// Guard: prevent duplicate creation
|
|
338
|
-
if (this.paymentRequestButtonCreated) {
|
|
339
|
-
return null;
|
|
340
|
-
}
|
|
341
|
-
if (!showPaymentRequestButton || !paymentRequestOption) {
|
|
342
|
-
return null;
|
|
343
|
-
}
|
|
344
|
-
if (!document) {
|
|
345
|
-
return null;
|
|
346
|
-
}
|
|
347
|
-
const targetElement = this.el.querySelector('#stripe-payment-request-button');
|
|
348
|
-
if (!targetElement) {
|
|
349
|
-
console.error('Target element #stripe-payment-request-button not found');
|
|
350
|
-
return null;
|
|
351
|
-
}
|
|
352
|
-
// Check if button already exists in DOM to prevent duplicates
|
|
353
|
-
if (targetElement.querySelector('stripe-payment-request-button')) {
|
|
354
|
-
this.paymentRequestButtonCreated = true;
|
|
355
|
-
return null;
|
|
356
|
-
}
|
|
357
|
-
const stripePaymentRequestElement = document.createElement('stripe-payment-request-button');
|
|
358
|
-
targetElement.appendChild(stripePaymentRequestElement);
|
|
359
|
-
const { paymentRequestPaymentMethodHandler, paymentRequestShippingOptionChangeHandler, paymentRequestShippingAddressChangeHandler } = paymentRequestOption;
|
|
360
|
-
customElements.whenDefined('stripe-payment-request-button').then(() => {
|
|
361
|
-
stripePaymentRequestElement.setPaymentRequestOption(paymentRequestOption);
|
|
362
|
-
if (paymentRequestPaymentMethodHandler) {
|
|
363
|
-
stripePaymentRequestElement.setPaymentMethodEventHandler(paymentRequestPaymentMethodHandler);
|
|
364
|
-
}
|
|
365
|
-
if (paymentRequestShippingOptionChangeHandler) {
|
|
366
|
-
stripePaymentRequestElement.setPaymentRequestShippingOptionEventHandler(paymentRequestShippingOptionChangeHandler);
|
|
367
|
-
}
|
|
368
|
-
if (paymentRequestShippingAddressChangeHandler) {
|
|
369
|
-
stripePaymentRequestElement.setPaymentRequestShippingAddressEventHandler(paymentRequestShippingAddressChangeHandler);
|
|
370
|
-
}
|
|
371
|
-
return stripePaymentRequestElement.initStripe(this.publishableKey);
|
|
372
|
-
});
|
|
373
|
-
// Mark as created
|
|
374
|
-
this.paymentRequestButtonCreated = true;
|
|
375
|
-
}
|
|
376
|
-
render() {
|
|
377
|
-
const { loadStripeStatus } = this.stripeService.state;
|
|
378
|
-
const { errorMessage } = this.cardElementManager.getState();
|
|
379
|
-
if (loadStripeStatus === 'failure') {
|
|
380
|
-
return h("p", null, i18n.t('Failed to load Stripe'));
|
|
381
|
-
}
|
|
382
|
-
const disabled = this.progress === 'loading';
|
|
383
|
-
return (h("div", { class: "stripe-payment-sheet-wrap" }, h("form", { id: "stripe-card-element" }, h("div", { class: "stripe-heading" }, i18n.t(this.sheetTitle)), h("div", { id: "stripe-payment-request-button" }), h("div", null, h("div", { class: "stripe-section-title" }, i18n.t('Card information'))), h("div", { class: "payment-info card visible" }, h("fieldset", { class: "stripe-input-box" }, h("div", null, h("label", null, this.showLabel ? h("lenged", null, i18n.t('Card Number')) : null, h("div", { id: "card-number" }))), h("div", { class: "stripe-input-column", style: { display: 'flex' } }, h("label", { style: { width: '50%' } }, this.showLabel ? h("lenged", null, i18n.t('MM / YY')) : null, h("div", { id: "card-expiry" })), h("label", { style: { width: '50%' } }, this.showLabel ? h("lenged", null, i18n.t('CVC')) : null, h("div", { id: "card-cvc" }))))), h("div", { id: "card-errors", class: "stripe-element-errors" }, errorMessage), this.zip ? (h("div", { style: { marginTop: '1.5rem' } }, h("div", { class: "stripe-section-title" }, i18n.t('Country or region')))) : null, this.zip ? (h("div", { class: "payment-info card visible" }, h("fieldset", { class: "stripe-input-box" }, h("div", null, h("label", null, this.showLabel ? h("lenged", null, i18n.t('Postal Code')) : null, h("input", { id: "zip", name: "zip", type: "text", inputmode: "numeric", class: "StripeElement", style: { width: '100%' }, placeholder: i18n.t('Postal Code'), value: this.zipCode, onInput: e => {
|
|
384
|
-
this.zipCode = e.target.value;
|
|
385
|
-
} })))))) : null, h("div", { style: { marginTop: '32px' } }, h("button", { type: "submit", disabled: disabled }, this.progress === 'loading' ? i18n.t('Loading') : i18n.t(this.buttonLabel))))));
|
|
386
|
-
}
|
|
387
|
-
get el() { return this; }
|
|
388
|
-
static get watchers() { return {
|
|
389
|
-
"publishableKey": ["updatePublishableKey"],
|
|
390
|
-
"stripeAccount": ["updateStripeAccountId"]
|
|
391
|
-
}; }
|
|
392
|
-
static get style() { return stripeCardElementCss; }
|
|
393
|
-
}, [256, "stripe-card-element", {
|
|
394
|
-
"intentType": [1, "intent-type"],
|
|
395
|
-
"zip": [4],
|
|
396
|
-
"sheetTitle": [1, "sheet-title"],
|
|
397
|
-
"buttonLabel": [1, "button-label"],
|
|
398
|
-
"publishableKey": [1, "publishable-key"],
|
|
399
|
-
"stripeAccount": [1, "stripe-account"],
|
|
400
|
-
"applicationName": [1, "application-name"],
|
|
401
|
-
"showLabel": [4, "show-label"],
|
|
402
|
-
"intentClientSecret": [1, "intent-client-secret"],
|
|
403
|
-
"shouldUseDefaultFormSubmitAction": [4, "should-use-default-form-submit-action"],
|
|
404
|
-
"showPaymentRequestButton": [4, "show-payment-request-button"],
|
|
405
|
-
"handleSubmit": [1040],
|
|
406
|
-
"stripeDidLoaded": [1040],
|
|
407
|
-
"progress": [32],
|
|
408
|
-
"zipCode": [32],
|
|
409
|
-
"paymentRequestOption": [32],
|
|
410
|
-
"initStripe": [64],
|
|
411
|
-
"updateProgress": [64],
|
|
412
|
-
"setErrorMessage": [64],
|
|
413
|
-
"setPaymentRequestOption": [64]
|
|
414
|
-
}, undefined, {
|
|
415
|
-
"publishableKey": ["updatePublishableKey"],
|
|
416
|
-
"stripeAccount": ["updateStripeAccountId"]
|
|
417
|
-
}]);
|
|
418
|
-
function defineCustomElement() {
|
|
419
|
-
if (typeof customElements === "undefined") {
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
const components = ["stripe-card-element", "stripe-payment-request-button"];
|
|
423
|
-
components.forEach(tagName => { switch (tagName) {
|
|
424
|
-
case "stripe-card-element":
|
|
425
|
-
if (!customElements.get(tagName)) {
|
|
426
|
-
customElements.define(tagName, StripeCardElement);
|
|
427
|
-
}
|
|
428
|
-
break;
|
|
429
|
-
case "stripe-payment-request-button":
|
|
430
|
-
if (!customElements.get(tagName)) {
|
|
431
|
-
defineCustomElement$1();
|
|
432
|
-
}
|
|
433
|
-
break;
|
|
434
|
-
} });
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
export { StripeCardElement as S, defineCustomElement as d };
|
|
438
|
-
//# sourceMappingURL=stripe-card-element2.js.map
|
|
439
|
-
|
|
440
|
-
//# sourceMappingURL=stripe-card-element2.js.map
|
|
1
|
+
import{transformTag as t,proxyCustomElement as e,HTMLElement as i,createEvent as s,h as n}from"@stencil/core/internal/client";import{c as r}from"./utils.js";import{s as o,i as l}from"./factory.js";import{S as a}from"./error.js";import{d as p}from"./stripe-payment-request-button2.js";const u=t=>{if(null!=t&&""!==t)return{stripeAccount:t}},d=e(class extends i{async initStripe(t,e){if(await this.stripeService.initialize(t,{stripeAccount:null==e?void 0:e.stripeAccount,applicationName:this.applicationName}),"success"===this.stripeService.state.loadStripeStatus)await this.initElement(),this.stripeLoadedEventHandler();else{const t=this.stripeService.onChange("loadStripeStatus",(async e=>{"success"===e&&(await this.initElement(),this.stripeLoadedEventHandler(),t())}))}}async updateProgress(t){return this.progress=t,this}async setErrorMessage(t){return this.cardElementManager.setError(t),this}updatePublishableKey(t){null!=t&&""!==t&&this.initStripe(t,u(this.stripeAccount))}updateStripeAccountId(t){const e=this.stripeService.state.publishableKey||this.publishableKey;null!=e&&""!==e&&this.initStripe(e,{stripeAccount:t})}async setPaymentRequestOption(t){return this.paymentRequestOption=t,this.createPaymentRequestButton(),this}stripeLoadedEventHandler(){const t={stripe:this.stripeService.getStripe()};null!=this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}async formSubmitEventHandler(){const t=this.cardElementManager.getElements(),e=this.stripeService.getStripe();null!=t?this.formSubmit.emit({cardCVCElement:t.cardCVC,cardExpiryElement:t.cardExpiry,cardNumberElement:t.cardNumber,stripe:e}):console.error("Card elements not initialized")}async defaultFormSubmitResultHandler(t){this.defaultFormSubmitResult.emit(t)}componentWillRender(){const{publishableKey:t}=this.stripeService.state;null!=t&&""!==t&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||this.initStripe(t,u(this.stripeService.state.stripeAccount)))}async defaultFormSubmitAction(t,{stripe:e,cardNumberElement:i,intentClientSecret:s}){t.preventDefault();try{const t=await((t,e,i,s)=>"payment"===this.intentType?t.confirmCardPayment(i,{payment_method:{card:s}}):t.confirmCardSetup(i,{payment_method:{card:s}}))(e,0,s,i);if(null!=t.error)throw new a(t.error);this.defaultFormSubmitResultHandler(t)}catch(t){throw console.error(t),this.defaultFormSubmitResultHandler(t),t}}constructor(t){super(),!1!==t&&this.__registerHost(),this.stripeLoaded=s(this,"stripeLoaded",7),this.formSubmit=s(this,"formSubmit",7),this.defaultFormSubmitResult=s(this,"defaultFormSubmitResult",7),this.paymentRequestButtonCreated=!1,this.intentType="payment",this.zip=!0,this.sheetTitle="Add your payment information",this.buttonLabel="Pay",this.progress="",this.zipCode="",this.applicationName="stripe-pwa-elements",this.showLabel=!1,this.shouldUseDefaultFormSubmitAction=!0,this.stripeService=o.createStripeService(),this.cardElementManager=o.createCardElementManager(this.stripeService),null!=this.publishableKey&&""!==this.publishableKey&&this.initStripe(this.publishableKey,u(this.stripeAccount))}async initElement(){await this.cardElementManager.initialize(this.el);const t=this.el.querySelector("#stripe-card-element");null!=t?t.addEventListener("submit",(async t=>{const e=this.cardElementManager.getElements(),i=this.stripeService.getStripe(),{intentClientSecret:s}=this;if(null==e||null==i)return void console.error("Stripe not properly initialized");const n={cardCVCElement:e.cardCVC,cardExpiryElement:e.cardExpiry,cardNumberElement:e.cardNumber,stripe:i,intentClientSecret:s,zipCode:this.zipCode};this.progress="loading";try{null!=this.handleSubmit?await this.handleSubmit(t,n):!0===this.shouldUseDefaultFormSubmitAction&&null!=s&&""!==s?await this.defaultFormSubmitAction(t,n):t.preventDefault(),await this.formSubmitEventHandler(),null==this.handleSubmit&&!0!==this.shouldUseDefaultFormSubmitAction||(this.progress="success")}catch(t){this.cardElementManager.setError(t.message),this.progress="failure"}})):console.error("Form element #stripe-card-element not found")}componentDidLoad(){this.el.classList.add(r())}componentDidRender(){this.showPaymentRequestButton&&this.paymentRequestOption&&!this.paymentRequestButtonCreated&&this.createPaymentRequestButton()}disconnectedCallback(){this.cardElementManager.unmount()}createPaymentRequestButton(){const{showPaymentRequestButton:t,paymentRequestOption:e}=this;if(this.paymentRequestButtonCreated)return null;if(!t||null==e)return null;if(null==document)return null;const i=this.el.querySelector("#stripe-payment-request-button");if(null==i)return console.error("Target element #stripe-payment-request-button not found"),null;if(null!=i.querySelector("stripe-payment-request-button"))return this.paymentRequestButtonCreated=!0,null;const s=document.createElement("stripe-payment-request-button");i.appendChild(s),customElements.whenDefined("stripe-payment-request-button").then((()=>(((t,e)=>{const{paymentRequestPaymentMethodHandler:i,paymentRequestShippingOptionChangeHandler:s,paymentRequestShippingAddressChangeHandler:n}=e;t.setPaymentRequestOption(e),null!=i&&t.setPaymentMethodEventHandler(i),null!=s&&t.setPaymentRequestShippingOptionEventHandler(s),null!=n&&t.setPaymentRequestShippingAddressEventHandler(n)})(s,e),s.initStripe(this.publishableKey)))),this.paymentRequestButtonCreated=!0}render(){const{loadStripeStatus:t}=this.stripeService.state,{errorMessage:e}=this.cardElementManager.getState();if("failure"===t)return n("p",null,l.t("Failed to load Stripe"));const i="loading"===this.progress;return n("div",{class:"stripe-payment-sheet-wrap"},n("form",{id:"stripe-card-element"},n("div",{class:"stripe-heading"},l.t(this.sheetTitle)),n("div",{id:"stripe-payment-request-button"}),n("div",null,n("div",{class:"stripe-section-title"},l.t("Card information"))),n("div",{class:"payment-info card visible"},n("fieldset",{class:"stripe-input-box"},n("div",null,n("label",null,this.showLabel?n("lenged",null,l.t("Card Number")):null,n("div",{id:"card-number"}))),n("div",{class:"stripe-input-column",style:{display:"flex"}},n("label",{style:{width:"50%"}},this.showLabel?n("lenged",null,l.t("MM / YY")):null,n("div",{id:"card-expiry"})),n("label",{style:{width:"50%"}},this.showLabel?n("lenged",null,l.t("CVC")):null,n("div",{id:"card-cvc"}))))),n("div",{id:"card-errors",class:"stripe-element-errors"},e),this.zip?n("div",{style:{marginTop:"1.5rem"}},n("div",{class:"stripe-section-title"},l.t("Country or region"))):null,this.zip?n("div",{class:"payment-info card visible"},n("fieldset",{class:"stripe-input-box"},n("div",null,n("label",null,this.showLabel?n("lenged",null,l.t("Postal Code")):null,n("input",{id:"zip",name:"zip",type:"text",inputmode:"numeric",class:"StripeElement",style:{width:"100%"},placeholder:l.t("Postal Code"),value:this.zipCode,onInput:t=>{this.zipCode=t.target.value}}))))):null,n("div",{style:{marginTop:"32px"}},n("button",{type:"submit",disabled:i},l.t("loading"===this.progress?"Loading":this.buttonLabel)))))}get el(){return this}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}}static get style(){return':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-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 .StripeElement{padding:8px 16px;min-height:64px;display:flex;justify-content:center;align-items:center}.stripe-payment-sheet-wrap .StripeElement>.__PrivateStripeElement{width:100%}.stripe-payment-sheet-wrap .stripe-input-box{background-color:#fff;border-radius:6px;border:1px solid var(--color-input-border);overflow:hidden;filter:drop-shadow(0 0 2px var(--color-input-border-shadow))}.stripe-payment-sheet-wrap .stripe-input-box>*{border-bottom:1px solid var(--color-input-border)}.stripe-payment-sheet-wrap .stripe-input-box>*:last-child{border-bottom:none}.stripe-payment-sheet-wrap .stripe-input-column>*{border-right:1px solid var(--color-input-border)}.stripe-payment-sheet-wrap .stripe-input-column>*:last-child{border-right:none}.stripe-payment-sheet-wrap .stripe-heading{font-size:24px;font-weight:bold;color:var(--color-heading-text);margin-bottom:24px}.stripe-payment-sheet-wrap .stripe-section-title{font-size:14px;font-weight:bold;color:var(--color-label);margin-bottom:8px}.stripe-payment-sheet-wrap .payment-info label{color:var(--color-label)}.stripe-payment-sheet-wrap .stripe-element-errors{margin-top:8px;font-size:14px;color:var(--color-text-error)}.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)}'}},[0,"stripe-card-element",{intentType:[1,"intent-type"],zip:[4],sheetTitle:[1,"sheet-title"],buttonLabel:[1,"button-label"],publishableKey:[1,"publishable-key"],stripeAccount:[1,"stripe-account"],applicationName:[1,"application-name"],showLabel:[4,"show-label"],intentClientSecret:[1,"intent-client-secret"],shouldUseDefaultFormSubmitAction:[4,"should-use-default-form-submit-action"],showPaymentRequestButton:[4,"show-payment-request-button"],handleSubmit:[1040],stripeDidLoaded:[1040],progress:[32],zipCode:[32],paymentRequestOption:[32],initStripe:[64],updateProgress:[64],setErrorMessage:[64],setPaymentRequestOption:[64]},void 0,{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}]);function c(){"undefined"!=typeof customElements&&["stripe-card-element","stripe-payment-request-button"].forEach((e=>{switch(e){case"stripe-card-element":customElements.get(t(e))||customElements.define(t(e),d);break;case"stripe-payment-request-button":customElements.get(t(e))||p()}}))}c();export{d as S,c as d}
|