stripe-pwa-elements 3.1.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-Hsw0e7-d.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 +135 -73
- 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.css +2 -2
- package/dist/collection/components/stripe-card-element-modal/stripe-card-element-modal.js +16 -12
- 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.css +36 -2
- package/dist/collection/components/stripe-modal/stripe-modal.js +34 -7
- 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 +5 -0
- 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 -88
- 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-Li_TGt9P.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 +135 -73
- 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-modal/stripe-modal.d.ts +6 -0
- 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/dist/types/utils/test-setup.d.ts +1 -0
- 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-Hsw0e7-d.js.map +0 -1
- package/dist/cjs/index-Ba1pBePA.js.map +0 -1
- package/dist/cjs/index-C1haN5iF.js +0 -1907
- package/dist/cjs/index-C1haN5iF.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/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-Li_TGt9P.js.map +0 -1
- package/dist/esm/index-BHDCxQOb.js.map +0 -1
- package/dist/esm/index-Dkis4t79.js +0 -1895
- package/dist/esm/index-Dkis4t79.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-01d63033.entry.js +0 -2
- package/dist/stripe-elements/p-01d63033.entry.js.map +0 -1
- package/dist/stripe-elements/p-1b8f9c7f.entry.js +0 -2
- package/dist/stripe-elements/p-1b8f9c7f.entry.js.map +0 -1
- package/dist/stripe-elements/p-37008853.entry.js +0 -2
- package/dist/stripe-elements/p-37008853.entry.js.map +0 -1
- package/dist/stripe-elements/p-5d152193.entry.js +0 -2
- package/dist/stripe-elements/p-5d152193.entry.js.map +0 -1
- package/dist/stripe-elements/p-623f13e6.entry.js +0 -2
- package/dist/stripe-elements/p-623f13e6.entry.js.map +0 -1
- package/dist/stripe-elements/p-809c9f2f.entry.js +0 -2
- package/dist/stripe-elements/p-809c9f2f.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-DQuL1Twl.js.map +0 -1
- package/dist/stripe-elements/p-Dkis4t79.js +0 -3
- package/dist/stripe-elements/p-Dkis4t79.js.map +0 -1
- package/dist/stripe-elements/p-WnA32N4v.js +0 -2
- package/dist/stripe-elements/p-WnA32N4v.js.map +0 -1
- package/dist/stripe-elements/p-XRfh5Wrs.js.map +0 -1
- package/dist/stripe-elements/p-ba41e196.entry.js +0 -2
- package/dist/stripe-elements/p-ba41e196.entry.js.map +0 -1
- package/dist/stripe-elements/p-bb1bc49a.entry.js +0 -2
- package/dist/stripe-elements/p-bb1bc49a.entry.js.map +0 -1
- package/dist/stripe-elements/p-f21ea941.entry.js +0 -2
- package/dist/stripe-elements/p-f21ea941.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,224 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { l as loadStripe } from './index2.js';
|
|
3
|
-
|
|
4
|
-
const stripePaymentRequestButtonCss = ":host{display:block}";
|
|
5
|
-
|
|
6
|
-
const StripePaymentRequestButton = /*@__PURE__*/ proxyCustomElement(class StripePaymentRequestButton extends HTMLElement {
|
|
7
|
-
/**
|
|
8
|
-
* Check isAvailable ApplePay or GooglePay.
|
|
9
|
-
* If you run this method, you should run before initStripe.
|
|
10
|
-
*/
|
|
11
|
-
async isAvailable(type) {
|
|
12
|
-
if (this.publishableKey === undefined) {
|
|
13
|
-
throw new Error('You should set publishableKey before calling this method.');
|
|
14
|
-
}
|
|
15
|
-
const stripe = await loadStripe(this.publishableKey, {
|
|
16
|
-
stripeAccount: this.stripeAccount,
|
|
17
|
-
});
|
|
18
|
-
const paymentRequest = stripe.paymentRequest({
|
|
19
|
-
country: 'US',
|
|
20
|
-
currency: 'usd',
|
|
21
|
-
total: {
|
|
22
|
-
label: 'Demo total',
|
|
23
|
-
amount: 1099,
|
|
24
|
-
},
|
|
25
|
-
disableWallets: ['applePay', 'googlePay', 'browserCard'].filter(method => method !== type),
|
|
26
|
-
});
|
|
27
|
-
const paymentRequestSupport = await paymentRequest.canMakePayment();
|
|
28
|
-
if (!paymentRequestSupport || (type === 'applePay' && !paymentRequestSupport[type]) || (type === 'googlePay' && !paymentRequestSupport[type])) {
|
|
29
|
-
throw new Error(`This device cannot use ${type}.`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Register event handler for `paymentRequest.on('paymentmethod'` event.
|
|
34
|
-
*/
|
|
35
|
-
async setPaymentMethodEventHandler(handler) {
|
|
36
|
-
this.paymentMethodEventHandler = handler;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Register event handler for `paymentRequest.on('shippingoptionchange'` event.
|
|
40
|
-
*/
|
|
41
|
-
async setPaymentRequestShippingOptionEventHandler(handler) {
|
|
42
|
-
this.shippingOptionEventHandler = handler;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Register event handler for `paymentRequest.on('shippingaddresschange'` event.
|
|
46
|
-
*/
|
|
47
|
-
async setPaymentRequestShippingAddressEventHandler(handler) {
|
|
48
|
-
this.shippingAddressEventHandler = handler;
|
|
49
|
-
}
|
|
50
|
-
stripeLoadedEventHandler() {
|
|
51
|
-
const event = {
|
|
52
|
-
stripe: this.stripe,
|
|
53
|
-
};
|
|
54
|
-
if (this.stripeDidLoaded) {
|
|
55
|
-
this.stripeDidLoaded(event);
|
|
56
|
-
}
|
|
57
|
-
this.stripeLoaded.emit(event);
|
|
58
|
-
}
|
|
59
|
-
constructor(registerHost) {
|
|
60
|
-
super();
|
|
61
|
-
if (registerHost !== false) {
|
|
62
|
-
this.__registerHost();
|
|
63
|
-
}
|
|
64
|
-
this.stripeLoaded = createEvent(this, "stripeLoaded", 7);
|
|
65
|
-
this.loadStripeStatus = '';
|
|
66
|
-
/**
|
|
67
|
-
* Overwrite the application name that registered
|
|
68
|
-
* For wrapper library (like Capacitor)
|
|
69
|
-
*/
|
|
70
|
-
this.applicationName = 'stripe-pwa-elements';
|
|
71
|
-
if (this.publishableKey !== undefined && this.paymentRequestOption !== undefined) {
|
|
72
|
-
this.initStripe(this.publishableKey, {
|
|
73
|
-
stripeAccount: this.stripeAccount,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
this.loadStripeStatus = 'failure';
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* @param option
|
|
82
|
-
* @private
|
|
83
|
-
*/
|
|
84
|
-
async setPaymentRequestOption(option) {
|
|
85
|
-
this.paymentRequestOption = option;
|
|
86
|
-
return this;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Get Stripe.js, and initialize elements
|
|
90
|
-
* @param publishableKey
|
|
91
|
-
* @param options
|
|
92
|
-
*/
|
|
93
|
-
async initStripe(publishableKey, options = undefined) {
|
|
94
|
-
this.loadStripeStatus = 'loading';
|
|
95
|
-
loadStripe(publishableKey, {
|
|
96
|
-
stripeAccount: options === null || options === void 0 ? void 0 : options.stripeAccount,
|
|
97
|
-
})
|
|
98
|
-
.then(stripe => {
|
|
99
|
-
this.loadStripeStatus = 'success';
|
|
100
|
-
stripe.registerAppInfo({
|
|
101
|
-
name: this.applicationName,
|
|
102
|
-
});
|
|
103
|
-
this.stripe = stripe;
|
|
104
|
-
return;
|
|
105
|
-
})
|
|
106
|
-
.catch(e => {
|
|
107
|
-
console.log(e);
|
|
108
|
-
this.loadStripeStatus = 'failure';
|
|
109
|
-
return;
|
|
110
|
-
})
|
|
111
|
-
.then(() => {
|
|
112
|
-
if (!this.stripe) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
// 後方互換のため、明確にfalseにしていないものはtrue扱い
|
|
116
|
-
return this.initElement(!(options === null || options === void 0 ? void 0 : options.showButton) === false);
|
|
117
|
-
})
|
|
118
|
-
.then(() => {
|
|
119
|
-
if (!this.stripe) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
this.stripeLoadedEventHandler();
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Initialize Component using Stripe Element
|
|
127
|
-
*/
|
|
128
|
-
async initElement(showButton = true) {
|
|
129
|
-
const paymentRequest = this.stripe.paymentRequest(this.paymentRequestOption);
|
|
130
|
-
// Check if the Payment Request is available (or Apple Pay on the Web).
|
|
131
|
-
const paymentRequestSupport = await paymentRequest.canMakePayment();
|
|
132
|
-
if (!paymentRequestSupport) {
|
|
133
|
-
throw new Error('Payment Request is not supported.');
|
|
134
|
-
}
|
|
135
|
-
if (this.paymentMethodEventHandler) {
|
|
136
|
-
paymentRequest.on('paymentmethod', event => {
|
|
137
|
-
this.paymentMethodEventHandler(event, this.stripe);
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
if (this.shippingOptionEventHandler) {
|
|
141
|
-
paymentRequest.on('shippingoptionchange', event => {
|
|
142
|
-
this.shippingOptionEventHandler(event, this.stripe);
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
if (this.shippingAddressEventHandler) {
|
|
146
|
-
paymentRequest.on('shippingaddresschange', event => {
|
|
147
|
-
this.shippingAddressEventHandler(event, this.stripe);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
if (showButton) {
|
|
151
|
-
// Cleanup previous element if exists
|
|
152
|
-
if (this.paymentRequestElement) {
|
|
153
|
-
this.paymentRequestElement.unmount();
|
|
154
|
-
}
|
|
155
|
-
// Display the Pay button by mounting the Element in the DOM.
|
|
156
|
-
const elements = this.stripe.elements();
|
|
157
|
-
const paymentRequestButton = elements.create('paymentRequestButton', {
|
|
158
|
-
paymentRequest,
|
|
159
|
-
});
|
|
160
|
-
// Store reference for cleanup
|
|
161
|
-
this.paymentRequestElement = paymentRequestButton;
|
|
162
|
-
const paymentRequestButtonElement = this.el.querySelector('#payment-request-button');
|
|
163
|
-
paymentRequestButton.mount(paymentRequestButtonElement);
|
|
164
|
-
// Show the payment request section.
|
|
165
|
-
this.el.querySelector('#payment-request').classList.add('visible');
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
/**
|
|
169
|
-
* This method must be called as the result of a user interaction (for example, in a click handler).
|
|
170
|
-
* https://stripe.com/docs/js/payment_request/show
|
|
171
|
-
*/
|
|
172
|
-
paymentRequest.show();
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
disconnectedCallback() {
|
|
176
|
-
// Cleanup payment request element
|
|
177
|
-
if (this.paymentRequestElement) {
|
|
178
|
-
this.paymentRequestElement.unmount();
|
|
179
|
-
this.paymentRequestElement = undefined;
|
|
180
|
-
}
|
|
181
|
-
// Clear stripe reference
|
|
182
|
-
this.stripe = undefined;
|
|
183
|
-
}
|
|
184
|
-
render() {
|
|
185
|
-
return (h(Host, { key: '5f7f2504c49e31edfb57ba22603fb350a5a9cf03' }, h("div", { key: '4f1c95d4c6d52e873cfed3ac8661bfacdf4703dc', id: "payment-request" }, h("div", { key: '621875745ffd2e144164e8b942eb6de304d09697', id: "payment-request-button" })), h("slot", { key: '28eda00bc50dddb57bfe925b73295c963c89d29a' })));
|
|
186
|
-
}
|
|
187
|
-
get el() { return this; }
|
|
188
|
-
static get style() { return stripePaymentRequestButtonCss; }
|
|
189
|
-
}, [260, "stripe-payment-request-button", {
|
|
190
|
-
"paymentMethodEventHandler": [16],
|
|
191
|
-
"shippingOptionEventHandler": [16],
|
|
192
|
-
"shippingAddressEventHandler": [16],
|
|
193
|
-
"publishableKey": [1, "publishable-key"],
|
|
194
|
-
"stripeAccount": [1, "stripe-account"],
|
|
195
|
-
"applicationName": [1, "application-name"],
|
|
196
|
-
"stripeDidLoaded": [1040],
|
|
197
|
-
"loadStripeStatus": [32],
|
|
198
|
-
"stripe": [32],
|
|
199
|
-
"paymentRequestOption": [32],
|
|
200
|
-
"isAvailable": [64],
|
|
201
|
-
"setPaymentMethodEventHandler": [64],
|
|
202
|
-
"setPaymentRequestShippingOptionEventHandler": [64],
|
|
203
|
-
"setPaymentRequestShippingAddressEventHandler": [64],
|
|
204
|
-
"setPaymentRequestOption": [64],
|
|
205
|
-
"initStripe": [64]
|
|
206
|
-
}]);
|
|
207
|
-
function defineCustomElement() {
|
|
208
|
-
if (typeof customElements === "undefined") {
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
const components = ["stripe-payment-request-button"];
|
|
212
|
-
components.forEach(tagName => { switch (tagName) {
|
|
213
|
-
case "stripe-payment-request-button":
|
|
214
|
-
if (!customElements.get(tagName)) {
|
|
215
|
-
customElements.define(tagName, StripePaymentRequestButton);
|
|
216
|
-
}
|
|
217
|
-
break;
|
|
218
|
-
} });
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
export { StripePaymentRequestButton as S, defineCustomElement as d };
|
|
222
|
-
//# sourceMappingURL=stripe-payment-request-button2.js.map
|
|
223
|
-
|
|
224
|
-
//# sourceMappingURL=stripe-payment-request-button2.js.map
|
|
1
|
+
import{transformTag as e,proxyCustomElement as t,HTMLElement as s,createEvent as i,h as n,Host as a}from"@stencil/core/internal/client";import{l as o}from"./index2.js";const r=t(class extends s{async isAvailable(e){if(void 0===this.publishableKey)throw new Error("You should set publishableKey before calling this method.");const t=(await o(this.publishableKey,{stripeAccount:this.stripeAccount})).paymentRequest({country:"US",currency:"usd",total:{label:"Demo total",amount:1099},disableWallets:["applePay","googlePay","browserCard"].filter((t=>t!==e))}),s=await t.canMakePayment();if(!s||"applePay"===e&&!s[e]||"googlePay"===e&&!s[e])throw new Error(`This device cannot use ${e}.`)}async setPaymentMethodEventHandler(e){this.paymentMethodEventHandler=e}async setPaymentRequestShippingOptionEventHandler(e){this.shippingOptionEventHandler=e}async setPaymentRequestShippingAddressEventHandler(e){this.shippingAddressEventHandler=e}stripeLoadedEventHandler(){const e={stripe:this.stripe};this.stripeDidLoaded&&this.stripeDidLoaded(e),this.stripeLoaded.emit(e)}constructor(e){super(),!1!==e&&this.__registerHost(),this.stripeLoaded=i(this,"stripeLoaded",7),this.loadStripeStatus="",this.applicationName="stripe-pwa-elements",void 0!==this.publishableKey&&void 0!==this.paymentRequestOption?this.initStripe(this.publishableKey,{stripeAccount:this.stripeAccount}):this.loadStripeStatus="failure"}connectedCallback(){console.warn("[stripe-pwa-elements] <stripe-payment-request-button> is deprecated. stripe.paymentRequest() is being removed in Stripe.js 9.x (deprecated 2025-09-30 / removed 2026-03-25). Please migrate to <stripe-express-checkout-element>, which supports Apple Pay, Google Pay, Link, PayPal, and more. Migration guide: https://hideokamoto.github.io/stripe-pwa-elements/guides/migrate-payment-request-button-to-express-checkout/")}async setPaymentRequestOption(e){return this.paymentRequestOption=e,this}async initStripe(e,t){this.loadStripeStatus="loading",o(e,{stripeAccount:null==t?void 0:t.stripeAccount}).then((e=>{this.loadStripeStatus="success",e.registerAppInfo({name:this.applicationName}),this.stripe=e})).catch((e=>{console.log(e),this.loadStripeStatus="failure"})).then((()=>{if(this.stripe)return this.initElement(0==!(null==t?void 0:t.showButton))})).then((()=>{this.stripe&&this.stripeLoadedEventHandler()}))}async initElement(e=!0){const t=this.stripe.paymentRequest(this.paymentRequestOption);if(!await t.canMakePayment())throw new Error("Payment Request is not supported.");if(this.paymentMethodEventHandler&&t.on("paymentmethod",(e=>{this.paymentMethodEventHandler(e,this.stripe)})),this.shippingOptionEventHandler&&t.on("shippingoptionchange",(e=>{this.shippingOptionEventHandler(e,this.stripe)})),this.shippingAddressEventHandler&&t.on("shippingaddresschange",(e=>{this.shippingAddressEventHandler(e,this.stripe)})),e){this.paymentRequestElement&&this.paymentRequestElement.unmount();const e=this.stripe.elements().create("paymentRequestButton",{paymentRequest:t});this.paymentRequestElement=e;const s=this.el.querySelector("#payment-request-button");e.mount(s),this.el.querySelector("#payment-request").classList.add("visible")}else t.show()}disconnectedCallback(){this.paymentRequestElement&&(this.paymentRequestElement.unmount(),this.paymentRequestElement=void 0),this.stripe=void 0}render(){return n(a,{key:"6340656e6d6f7ac25db9c42e8cd82be9e342640d"},n("div",{key:"2c83b290ee0fc7663b15d6e5ee7a76380f54875b",id:"payment-request"},n("div",{key:"bff7ac4d9f5cba737fa7addbc594c275164ff04a",id:"payment-request-button"})),n("slot",{key:"de55b77ffa140ba83a6de8592f95bc75f4ffabf5"}))}get el(){return this}static get style(){return":host{display:block}"}},[260,"stripe-payment-request-button",{paymentMethodEventHandler:[16],shippingOptionEventHandler:[16],shippingAddressEventHandler:[16],publishableKey:[1,"publishable-key"],stripeAccount:[1,"stripe-account"],applicationName:[1,"application-name"],stripeDidLoaded:[1040],loadStripeStatus:[32],stripe:[32],paymentRequestOption:[32],isAvailable:[64],setPaymentMethodEventHandler:[64],setPaymentRequestShippingOptionEventHandler:[64],setPaymentRequestShippingAddressEventHandler:[64],setPaymentRequestOption:[64],initStripe:[64]}]);function p(){"undefined"!=typeof customElements&&["stripe-payment-request-button"].forEach((t=>{"stripe-payment-request-button"===t&&(customElements.get(e(t))||customElements.define(e(t),r))}))}p();export{r as S,p as d}
|
package/dist/components/utils.js
CHANGED
|
@@ -1,89 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
const setupPlatforms = (win = window) => {
|
|
3
|
-
if (typeof win === 'undefined') {
|
|
4
|
-
return [];
|
|
5
|
-
}
|
|
6
|
-
win.Ionic = win.Ionic || {};
|
|
7
|
-
let platforms = win.Ionic.platforms;
|
|
8
|
-
if (platforms == null) {
|
|
9
|
-
platforms = win.Ionic.platforms = detectPlatforms(win);
|
|
10
|
-
platforms.forEach(p => win.document.documentElement.classList.add(`plt-${p}`));
|
|
11
|
-
}
|
|
12
|
-
return platforms;
|
|
13
|
-
};
|
|
14
|
-
const detectPlatforms = (win) => Object.keys(PLATFORMS_MAP).filter(p => PLATFORMS_MAP[p](win));
|
|
15
|
-
const isMobileWeb = (win) => isMobile(win) && !isHybrid(win);
|
|
16
|
-
const isIpad = (win) => {
|
|
17
|
-
// iOS 12 and below
|
|
18
|
-
if (testUserAgent(win, /iPad/i)) {
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
// iOS 13+
|
|
22
|
-
if (testUserAgent(win, /Macintosh/i) && isMobile(win)) {
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
return false;
|
|
26
|
-
};
|
|
27
|
-
const isIphone = (win) => testUserAgent(win, /iPhone/i);
|
|
28
|
-
const isIOS = (win) => testUserAgent(win, /iPhone|iPod/i) || isIpad(win);
|
|
29
|
-
const isAndroid = (win) => testUserAgent(win, /android|sink/i);
|
|
30
|
-
const isAndroidTablet = (win) => {
|
|
31
|
-
return isAndroid(win) && !testUserAgent(win, /mobile/i);
|
|
32
|
-
};
|
|
33
|
-
const isPhablet = (win) => {
|
|
34
|
-
const width = win.innerWidth;
|
|
35
|
-
const height = win.innerHeight;
|
|
36
|
-
const smallest = Math.min(width, height);
|
|
37
|
-
const largest = Math.max(width, height);
|
|
38
|
-
return smallest > 390 && smallest < 520 && largest > 620 && largest < 800;
|
|
39
|
-
};
|
|
40
|
-
const isTablet = (win) => {
|
|
41
|
-
const width = win.innerWidth;
|
|
42
|
-
const height = win.innerHeight;
|
|
43
|
-
const smallest = Math.min(width, height);
|
|
44
|
-
const largest = Math.max(width, height);
|
|
45
|
-
return isIpad(win) || isAndroidTablet(win) || (smallest > 460 && smallest < 820 && largest > 780 && largest < 1400);
|
|
46
|
-
};
|
|
47
|
-
const isMobile = (win) => matchMedia(win, '(any-pointer:coarse)');
|
|
48
|
-
const isDesktop = (win) => !isMobile(win);
|
|
49
|
-
const isHybrid = (win) => isCordova(win) || isCapacitorNative(win);
|
|
50
|
-
const isCordova = (win) => !!(win['cordova'] || win['phonegap'] || win['PhoneGap']);
|
|
51
|
-
const isCapacitorNative = (win) => {
|
|
52
|
-
const capacitor = win['Capacitor'];
|
|
53
|
-
return !!(capacitor && capacitor.isNative);
|
|
54
|
-
};
|
|
55
|
-
const isElectron = (win) => testUserAgent(win, /electron/i);
|
|
56
|
-
const isPWA = (win) => !!(win.matchMedia('(display-mode: standalone)').matches || win.navigator.standalone);
|
|
57
|
-
const testUserAgent = (win, expr) => expr.test(win.navigator.userAgent);
|
|
58
|
-
const matchMedia = (win, query) => win.matchMedia(query).matches;
|
|
59
|
-
const PLATFORMS_MAP = {
|
|
60
|
-
ipad: isIpad,
|
|
61
|
-
iphone: isIphone,
|
|
62
|
-
ios: isIOS,
|
|
63
|
-
android: isAndroid,
|
|
64
|
-
phablet: isPhablet,
|
|
65
|
-
tablet: isTablet,
|
|
66
|
-
cordova: isCordova,
|
|
67
|
-
capacitor: isCapacitorNative,
|
|
68
|
-
electron: isElectron,
|
|
69
|
-
pwa: isPWA,
|
|
70
|
-
mobile: isMobile,
|
|
71
|
-
mobileweb: isMobileWeb,
|
|
72
|
-
desktop: isDesktop,
|
|
73
|
-
hybrid: isHybrid,
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const checkPlatform = () => {
|
|
77
|
-
const device = getPlatforms();
|
|
78
|
-
if (device.includes('ios')) {
|
|
79
|
-
return 'ios';
|
|
80
|
-
}
|
|
81
|
-
if (device.includes('android')) {
|
|
82
|
-
return 'android';
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export { checkPlatform as c };
|
|
87
|
-
//# sourceMappingURL=utils.js.map
|
|
88
|
-
|
|
89
|
-
//# sourceMappingURL=utils.js.map
|
|
1
|
+
const i=i=>Object.keys(c).filter((o=>c[o](i))),o=i=>!!d(i,/iPad/i)||!(!d(i,/Macintosh/i)||!e(i)),n=i=>d(i,/android|sink/i),e=i=>s(i,"(any-pointer:coarse)"),t=i=>r(i)||a(i),r=i=>!!(i.cordova||i.phonegap||i.PhoneGap),a=i=>{const o=i.Capacitor;return!(!o||!o.isNative)},d=(i,o)=>o.test(i.navigator.userAgent),s=(i,o)=>i.matchMedia(o).matches,c={ipad:o,iphone:i=>d(i,/iPhone/i),ios:i=>d(i,/iPhone|iPod/i)||o(i),android:n,phablet:i=>{const o=i.innerWidth,n=i.innerHeight,e=Math.min(o,n),t=Math.max(o,n);return e>390&&e<520&&t>620&&t<800},tablet:i=>{const e=i.innerWidth,t=i.innerHeight,r=Math.min(e,t),a=Math.max(e,t);return o(i)||(i=>n(i)&&!d(i,/mobile/i))(i)||r>460&&r<820&&a>780&&a<1400},cordova:r,capacitor:a,electron:i=>d(i,/electron/i),pwa:i=>!(!i.matchMedia("(display-mode: standalone)").matches&&!i.navigator.standalone),mobile:e,mobileweb:i=>e(i)&&!t(i),desktop:i=>!e(i),hybrid:t},l=()=>{const o=((o=window)=>{if(void 0===o)return[];o.Ionic=o.Ionic||{};let n=o.Ionic.platforms;return null==n&&(n=o.Ionic.platforms=i(o),n.forEach((i=>o.document.documentElement.classList.add(`plt-${i}`)))),n})(undefined);return o.includes("ios")?"ios":o.includes("android")?"android":void 0};export{l as c}
|