@stripe/stripe-js 8.6.1 → 8.6.4
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/index.js +23 -2
- package/dist/index.mjs +23 -2
- package/dist/pure.js +7 -2
- package/dist/pure.mjs +7 -2
- package/dist/stripe-js/checkout.d.mts +38 -1
- package/dist/stripe-js/checkout.d.ts +38 -1
- package/dist/stripe-js/elements/index.d.mts +0 -1
- package/dist/stripe-js/elements/index.d.ts +0 -1
- package/dist/stripe-js/elements/payment-form.d.mts +204 -0
- package/dist/stripe-js/elements/payment-form.d.ts +204 -0
- package/dist/stripe-js/elements-group.d.mts +7 -5
- package/dist/stripe-js/elements-group.d.ts +7 -5
- package/package.json +1 -1
- package/src/shared.ts +7 -0
package/dist/index.js
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
function _typeof(obj) {
|
|
6
|
+
"@babel/helpers - typeof";
|
|
7
|
+
|
|
8
|
+
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
9
|
+
_typeof = function (obj) {
|
|
10
|
+
return typeof obj;
|
|
11
|
+
};
|
|
12
|
+
} else {
|
|
13
|
+
_typeof = function (obj) {
|
|
14
|
+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return _typeof(obj);
|
|
19
|
+
}
|
|
20
|
+
|
|
5
21
|
var RELEASE_TRAIN = 'clover';
|
|
6
22
|
|
|
7
23
|
var runtimeVersionToUrlVersion = function runtimeVersionToUrlVersion(version) {
|
|
@@ -55,7 +71,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
|
|
|
55
71
|
|
|
56
72
|
stripe._registerWrapper({
|
|
57
73
|
name: 'stripe-js',
|
|
58
|
-
version: "8.6.
|
|
74
|
+
version: "8.6.4",
|
|
59
75
|
startTime: startTime
|
|
60
76
|
});
|
|
61
77
|
};
|
|
@@ -145,13 +161,18 @@ var initStripe = function initStripe(maybeStripe, args, startTime) {
|
|
|
145
161
|
}
|
|
146
162
|
|
|
147
163
|
var pk = args[0];
|
|
164
|
+
|
|
165
|
+
if (typeof pk !== 'string') {
|
|
166
|
+
throw new Error("Expected publishable key to be of type string, got type ".concat(_typeof(pk), " instead."));
|
|
167
|
+
}
|
|
168
|
+
|
|
148
169
|
var isTestKey = pk.match(/^pk_test/); // @ts-expect-error this is not publicly typed
|
|
149
170
|
|
|
150
171
|
var version = runtimeVersionToUrlVersion(maybeStripe.version);
|
|
151
172
|
var expectedVersion = RELEASE_TRAIN;
|
|
152
173
|
|
|
153
174
|
if (isTestKey && version !== expectedVersion) {
|
|
154
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("8.6.
|
|
175
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("8.6.4", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
155
176
|
}
|
|
156
177
|
|
|
157
178
|
var stripe = maybeStripe.apply(undefined, args);
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
function _typeof(obj) {
|
|
2
|
+
"@babel/helpers - typeof";
|
|
3
|
+
|
|
4
|
+
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
5
|
+
_typeof = function (obj) {
|
|
6
|
+
return typeof obj;
|
|
7
|
+
};
|
|
8
|
+
} else {
|
|
9
|
+
_typeof = function (obj) {
|
|
10
|
+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return _typeof(obj);
|
|
15
|
+
}
|
|
16
|
+
|
|
1
17
|
var RELEASE_TRAIN = 'clover';
|
|
2
18
|
|
|
3
19
|
var runtimeVersionToUrlVersion = function runtimeVersionToUrlVersion(version) {
|
|
@@ -51,7 +67,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
|
|
|
51
67
|
|
|
52
68
|
stripe._registerWrapper({
|
|
53
69
|
name: 'stripe-js',
|
|
54
|
-
version: "8.6.
|
|
70
|
+
version: "8.6.4",
|
|
55
71
|
startTime: startTime
|
|
56
72
|
});
|
|
57
73
|
};
|
|
@@ -141,13 +157,18 @@ var initStripe = function initStripe(maybeStripe, args, startTime) {
|
|
|
141
157
|
}
|
|
142
158
|
|
|
143
159
|
var pk = args[0];
|
|
160
|
+
|
|
161
|
+
if (typeof pk !== 'string') {
|
|
162
|
+
throw new Error("Expected publishable key to be of type string, got type ".concat(_typeof(pk), " instead."));
|
|
163
|
+
}
|
|
164
|
+
|
|
144
165
|
var isTestKey = pk.match(/^pk_test/); // @ts-expect-error this is not publicly typed
|
|
145
166
|
|
|
146
167
|
var version = runtimeVersionToUrlVersion(maybeStripe.version);
|
|
147
168
|
var expectedVersion = RELEASE_TRAIN;
|
|
148
169
|
|
|
149
170
|
if (isTestKey && version !== expectedVersion) {
|
|
150
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("8.6.
|
|
171
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("8.6.4", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
151
172
|
}
|
|
152
173
|
|
|
153
174
|
var stripe = maybeStripe.apply(undefined, args);
|
package/dist/pure.js
CHANGED
|
@@ -71,7 +71,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
|
|
|
71
71
|
|
|
72
72
|
stripe._registerWrapper({
|
|
73
73
|
name: 'stripe-js',
|
|
74
|
-
version: "8.6.
|
|
74
|
+
version: "8.6.4",
|
|
75
75
|
startTime: startTime
|
|
76
76
|
});
|
|
77
77
|
};
|
|
@@ -161,13 +161,18 @@ var initStripe = function initStripe(maybeStripe, args, startTime) {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
var pk = args[0];
|
|
164
|
+
|
|
165
|
+
if (typeof pk !== 'string') {
|
|
166
|
+
throw new Error("Expected publishable key to be of type string, got type ".concat(_typeof(pk), " instead."));
|
|
167
|
+
}
|
|
168
|
+
|
|
164
169
|
var isTestKey = pk.match(/^pk_test/); // @ts-expect-error this is not publicly typed
|
|
165
170
|
|
|
166
171
|
var version = runtimeVersionToUrlVersion(maybeStripe.version);
|
|
167
172
|
var expectedVersion = RELEASE_TRAIN;
|
|
168
173
|
|
|
169
174
|
if (isTestKey && version !== expectedVersion) {
|
|
170
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("8.6.
|
|
175
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("8.6.4", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
171
176
|
}
|
|
172
177
|
|
|
173
178
|
var stripe = maybeStripe.apply(undefined, args);
|
package/dist/pure.mjs
CHANGED
|
@@ -67,7 +67,7 @@ var registerWrapper = function registerWrapper(stripe, startTime) {
|
|
|
67
67
|
|
|
68
68
|
stripe._registerWrapper({
|
|
69
69
|
name: 'stripe-js',
|
|
70
|
-
version: "8.6.
|
|
70
|
+
version: "8.6.4",
|
|
71
71
|
startTime: startTime
|
|
72
72
|
});
|
|
73
73
|
};
|
|
@@ -157,13 +157,18 @@ var initStripe = function initStripe(maybeStripe, args, startTime) {
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
var pk = args[0];
|
|
160
|
+
|
|
161
|
+
if (typeof pk !== 'string') {
|
|
162
|
+
throw new Error("Expected publishable key to be of type string, got type ".concat(_typeof(pk), " instead."));
|
|
163
|
+
}
|
|
164
|
+
|
|
160
165
|
var isTestKey = pk.match(/^pk_test/); // @ts-expect-error this is not publicly typed
|
|
161
166
|
|
|
162
167
|
var version = runtimeVersionToUrlVersion(maybeStripe.version);
|
|
163
168
|
var expectedVersion = RELEASE_TRAIN;
|
|
164
169
|
|
|
165
170
|
if (isTestKey && version !== expectedVersion) {
|
|
166
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("8.6.
|
|
171
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("8.6.4", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
167
172
|
}
|
|
168
173
|
|
|
169
174
|
var stripe = maybeStripe.apply(undefined, args);
|
|
@@ -36,9 +36,12 @@ export interface StripeCheckoutElementsOptions {
|
|
|
36
36
|
export interface StripeCheckoutOptions {
|
|
37
37
|
clientSecret: Promise<string> | string;
|
|
38
38
|
elementsOptions?: StripeCheckoutElementsOptions;
|
|
39
|
+
adaptivePricing?: {allowed?: boolean};
|
|
39
40
|
defaultValues?: {
|
|
40
41
|
billingAddress?: StripeCheckoutContact;
|
|
41
42
|
shippingAddress?: StripeCheckoutContact;
|
|
43
|
+
email?: string;
|
|
44
|
+
phoneNumber?: string;
|
|
42
45
|
};
|
|
43
46
|
}
|
|
44
47
|
|
|
@@ -361,6 +364,38 @@ export type StripeCheckoutAddressElementOptions = {
|
|
|
361
364
|
};
|
|
362
365
|
};
|
|
363
366
|
|
|
367
|
+
/**
|
|
368
|
+
* Wallet button theme options for PaymentFormElement.
|
|
369
|
+
*/
|
|
370
|
+
export type PaymentFormWalletButtonTheme = {
|
|
371
|
+
applePay?: 'black' | 'white' | 'white-outline';
|
|
372
|
+
googlePay?: 'black' | 'white';
|
|
373
|
+
paypal?: 'gold' | 'blue' | 'silver' | 'white' | 'black';
|
|
374
|
+
klarna?: 'dark' | 'light' | 'outlined';
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
export type StripeCheckoutPaymentFormElementOptions = {
|
|
378
|
+
/**
|
|
379
|
+
* The layout of the PaymentFormElement.
|
|
380
|
+
*/
|
|
381
|
+
layout?: 'expanded' | 'compact';
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* An array of saved addresses to display in the PaymentFormElement.
|
|
385
|
+
*/
|
|
386
|
+
contacts?: ContactOption[];
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Wallet configuration options.
|
|
390
|
+
*/
|
|
391
|
+
wallets?: {
|
|
392
|
+
/**
|
|
393
|
+
* Button theme options for wallet payment methods.
|
|
394
|
+
*/
|
|
395
|
+
buttonTheme?: PaymentFormWalletButtonTheme;
|
|
396
|
+
};
|
|
397
|
+
};
|
|
398
|
+
|
|
364
399
|
export type StripeCheckoutExpressCheckoutElementOptions = {
|
|
365
400
|
buttonHeight: StripeExpressCheckoutElementOptions['buttonHeight'];
|
|
366
401
|
buttonTheme: StripeExpressCheckoutElementOptions['buttonTheme'];
|
|
@@ -634,7 +669,9 @@ export interface StripeCheckout {
|
|
|
634
669
|
options?: StripeCheckoutPaymentElementOptions
|
|
635
670
|
): StripePaymentElement;
|
|
636
671
|
/* Requires beta access: Contact [Stripe support](https://support.stripe.com/) for more information. */
|
|
637
|
-
createPaymentFormElement(
|
|
672
|
+
createPaymentFormElement(
|
|
673
|
+
options?: StripeCheckoutPaymentFormElementOptions
|
|
674
|
+
): StripePaymentFormElement;
|
|
638
675
|
createBillingAddressElement(
|
|
639
676
|
options?: StripeCheckoutAddressElementOptions
|
|
640
677
|
): StripeAddressElement;
|
|
@@ -36,9 +36,12 @@ export interface StripeCheckoutElementsOptions {
|
|
|
36
36
|
export interface StripeCheckoutOptions {
|
|
37
37
|
clientSecret: Promise<string> | string;
|
|
38
38
|
elementsOptions?: StripeCheckoutElementsOptions;
|
|
39
|
+
adaptivePricing?: {allowed?: boolean};
|
|
39
40
|
defaultValues?: {
|
|
40
41
|
billingAddress?: StripeCheckoutContact;
|
|
41
42
|
shippingAddress?: StripeCheckoutContact;
|
|
43
|
+
email?: string;
|
|
44
|
+
phoneNumber?: string;
|
|
42
45
|
};
|
|
43
46
|
}
|
|
44
47
|
|
|
@@ -361,6 +364,38 @@ export type StripeCheckoutAddressElementOptions = {
|
|
|
361
364
|
};
|
|
362
365
|
};
|
|
363
366
|
|
|
367
|
+
/**
|
|
368
|
+
* Wallet button theme options for PaymentFormElement.
|
|
369
|
+
*/
|
|
370
|
+
export type PaymentFormWalletButtonTheme = {
|
|
371
|
+
applePay?: 'black' | 'white' | 'white-outline';
|
|
372
|
+
googlePay?: 'black' | 'white';
|
|
373
|
+
paypal?: 'gold' | 'blue' | 'silver' | 'white' | 'black';
|
|
374
|
+
klarna?: 'dark' | 'light' | 'outlined';
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
export type StripeCheckoutPaymentFormElementOptions = {
|
|
378
|
+
/**
|
|
379
|
+
* The layout of the PaymentFormElement.
|
|
380
|
+
*/
|
|
381
|
+
layout?: 'expanded' | 'compact';
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* An array of saved addresses to display in the PaymentFormElement.
|
|
385
|
+
*/
|
|
386
|
+
contacts?: ContactOption[];
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Wallet configuration options.
|
|
390
|
+
*/
|
|
391
|
+
wallets?: {
|
|
392
|
+
/**
|
|
393
|
+
* Button theme options for wallet payment methods.
|
|
394
|
+
*/
|
|
395
|
+
buttonTheme?: PaymentFormWalletButtonTheme;
|
|
396
|
+
};
|
|
397
|
+
};
|
|
398
|
+
|
|
364
399
|
export type StripeCheckoutExpressCheckoutElementOptions = {
|
|
365
400
|
buttonHeight: StripeExpressCheckoutElementOptions['buttonHeight'];
|
|
366
401
|
buttonTheme: StripeExpressCheckoutElementOptions['buttonTheme'];
|
|
@@ -634,7 +669,9 @@ export interface StripeCheckout {
|
|
|
634
669
|
options?: StripeCheckoutPaymentElementOptions
|
|
635
670
|
): StripePaymentElement;
|
|
636
671
|
/* Requires beta access: Contact [Stripe support](https://support.stripe.com/) for more information. */
|
|
637
|
-
createPaymentFormElement(
|
|
672
|
+
createPaymentFormElement(
|
|
673
|
+
options?: StripeCheckoutPaymentFormElementOptions
|
|
674
|
+
): StripePaymentFormElement;
|
|
638
675
|
createBillingAddressElement(
|
|
639
676
|
options?: StripeCheckoutAddressElementOptions
|
|
640
677
|
): StripeAddressElement;
|
|
@@ -1,5 +1,108 @@
|
|
|
1
1
|
import {StripeError} from '../stripe';
|
|
2
2
|
import {StripeElementBase} from './base';
|
|
3
|
+
import {StripeExpressCheckoutElementConfirmEvent} from './express-checkout';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Address type used in PaymentFormElement change events.
|
|
7
|
+
*/
|
|
8
|
+
export type PaymentFormAddress = {
|
|
9
|
+
line1?: string | null;
|
|
10
|
+
line2?: string | null;
|
|
11
|
+
city?: string | null;
|
|
12
|
+
state?: string | null;
|
|
13
|
+
postal_code?: string | null;
|
|
14
|
+
country?: string | null;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The change event payload for the PaymentFormElement.
|
|
19
|
+
*/
|
|
20
|
+
export interface StripePaymentFormElementChangeEvent {
|
|
21
|
+
/**
|
|
22
|
+
* The type of element that emitted this event.
|
|
23
|
+
*/
|
|
24
|
+
elementType: 'paymentForm';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Whether all required fields in the PaymentFormElement are complete.
|
|
28
|
+
*/
|
|
29
|
+
complete: boolean;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Whether the PaymentFormElement is currently empty.
|
|
33
|
+
*/
|
|
34
|
+
empty: boolean;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* An object containing the current form values.
|
|
38
|
+
*/
|
|
39
|
+
value: {
|
|
40
|
+
customerDetails: {
|
|
41
|
+
email: string;
|
|
42
|
+
};
|
|
43
|
+
shippingOption?: {
|
|
44
|
+
id: string;
|
|
45
|
+
displayName: string;
|
|
46
|
+
amount: string;
|
|
47
|
+
};
|
|
48
|
+
shippingAddress?: PaymentFormAddress;
|
|
49
|
+
billingAddress?: PaymentFormAddress;
|
|
50
|
+
tax?: {
|
|
51
|
+
businessName: string;
|
|
52
|
+
taxId: string;
|
|
53
|
+
taxIdType: string;
|
|
54
|
+
externalTaxIdType: string;
|
|
55
|
+
};
|
|
56
|
+
customFields?: Record<string, string | number>;
|
|
57
|
+
payment?: {
|
|
58
|
+
collapsed: boolean;
|
|
59
|
+
type: string;
|
|
60
|
+
country?: string | null;
|
|
61
|
+
billingDetails?: {
|
|
62
|
+
address?: {
|
|
63
|
+
country?: string;
|
|
64
|
+
postal_code?: string;
|
|
65
|
+
};
|
|
66
|
+
} | null;
|
|
67
|
+
payment_method?: {
|
|
68
|
+
id: string;
|
|
69
|
+
type: string;
|
|
70
|
+
billing_details: {
|
|
71
|
+
address: PaymentFormAddress;
|
|
72
|
+
name: string | null;
|
|
73
|
+
email: string | null;
|
|
74
|
+
phone: string | null;
|
|
75
|
+
};
|
|
76
|
+
} | null;
|
|
77
|
+
savePaymentMethod?: boolean;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Confirm event when user completes via Express Checkout (Apple Pay, Google Pay, etc.)
|
|
84
|
+
*/
|
|
85
|
+
interface StripePaymentFormExpressCheckoutConfirmEvent
|
|
86
|
+
extends StripeExpressCheckoutElementConfirmEvent {
|
|
87
|
+
source: 'payment-form-ece';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Confirm event when user clicks the Pay button.
|
|
92
|
+
* paymentMethodType is the selected payment method (e.g., 'card', 'sepa_debit')
|
|
93
|
+
* or null if payment collection is not needed.
|
|
94
|
+
*/
|
|
95
|
+
interface StripePaymentFormPayButtonConfirmEvent {
|
|
96
|
+
source: 'payment-form-pay-button';
|
|
97
|
+
paymentMethodType: string | null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The confirm event payload for the PaymentFormElement.
|
|
102
|
+
*/
|
|
103
|
+
export type StripePaymentFormElementConfirmEvent =
|
|
104
|
+
| StripePaymentFormExpressCheckoutConfirmEvent
|
|
105
|
+
| StripePaymentFormPayButtonConfirmEvent;
|
|
3
106
|
|
|
4
107
|
export type StripePaymentFormElement = StripeElementBase & {
|
|
5
108
|
/**
|
|
@@ -18,6 +121,54 @@ export type StripePaymentFormElement = StripeElementBase & {
|
|
|
18
121
|
handler?: (event: {elementType: 'paymentForm'}) => any
|
|
19
122
|
): StripePaymentFormElement;
|
|
20
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Triggered when the element gains focus.
|
|
126
|
+
*/
|
|
127
|
+
on(
|
|
128
|
+
eventType: 'focus',
|
|
129
|
+
handler: (event: {elementType: 'paymentForm'}) => any
|
|
130
|
+
): StripePaymentFormElement;
|
|
131
|
+
once(
|
|
132
|
+
eventType: 'focus',
|
|
133
|
+
handler: (event: {elementType: 'paymentForm'}) => any
|
|
134
|
+
): StripePaymentFormElement;
|
|
135
|
+
off(
|
|
136
|
+
eventType: 'focus',
|
|
137
|
+
handler?: (event: {elementType: 'paymentForm'}) => any
|
|
138
|
+
): StripePaymentFormElement;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Triggered when the element loses focus.
|
|
142
|
+
*/
|
|
143
|
+
on(
|
|
144
|
+
eventType: 'blur',
|
|
145
|
+
handler: (event: {elementType: 'paymentForm'}) => any
|
|
146
|
+
): StripePaymentFormElement;
|
|
147
|
+
once(
|
|
148
|
+
eventType: 'blur',
|
|
149
|
+
handler: (event: {elementType: 'paymentForm'}) => any
|
|
150
|
+
): StripePaymentFormElement;
|
|
151
|
+
off(
|
|
152
|
+
eventType: 'blur',
|
|
153
|
+
handler?: (event: {elementType: 'paymentForm'}) => any
|
|
154
|
+
): StripePaymentFormElement;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Triggered when the escape key is pressed within the element.
|
|
158
|
+
*/
|
|
159
|
+
on(
|
|
160
|
+
eventType: 'escape',
|
|
161
|
+
handler: (event: {elementType: 'paymentForm'}) => any
|
|
162
|
+
): StripePaymentFormElement;
|
|
163
|
+
once(
|
|
164
|
+
eventType: 'escape',
|
|
165
|
+
handler: (event: {elementType: 'paymentForm'}) => any
|
|
166
|
+
): StripePaymentFormElement;
|
|
167
|
+
off(
|
|
168
|
+
eventType: 'escape',
|
|
169
|
+
handler?: (event: {elementType: 'paymentForm'}) => any
|
|
170
|
+
): StripePaymentFormElement;
|
|
171
|
+
|
|
21
172
|
/**
|
|
22
173
|
* Triggered when the element fails to load.
|
|
23
174
|
*/
|
|
@@ -33,4 +184,57 @@ export type StripePaymentFormElement = StripeElementBase & {
|
|
|
33
184
|
eventType: 'loaderror',
|
|
34
185
|
handler?: (event: {elementType: 'paymentForm'; error: StripeError}) => any
|
|
35
186
|
): StripePaymentFormElement;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Triggered when the element's value changes.
|
|
190
|
+
*/
|
|
191
|
+
on(
|
|
192
|
+
eventType: 'change',
|
|
193
|
+
handler: (event: StripePaymentFormElementChangeEvent) => any
|
|
194
|
+
): StripePaymentFormElement;
|
|
195
|
+
once(
|
|
196
|
+
eventType: 'change',
|
|
197
|
+
handler: (event: StripePaymentFormElementChangeEvent) => any
|
|
198
|
+
): StripePaymentFormElement;
|
|
199
|
+
off(
|
|
200
|
+
eventType: 'change',
|
|
201
|
+
handler?: (event: StripePaymentFormElementChangeEvent) => any
|
|
202
|
+
): StripePaymentFormElement;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Triggered when a buyer authorizes a payment within a supported payment method.
|
|
206
|
+
*/
|
|
207
|
+
on(
|
|
208
|
+
eventType: 'confirm',
|
|
209
|
+
handler: (event: StripePaymentFormElementConfirmEvent) => any
|
|
210
|
+
): StripePaymentFormElement;
|
|
211
|
+
once(
|
|
212
|
+
eventType: 'confirm',
|
|
213
|
+
handler: (event: StripePaymentFormElementConfirmEvent) => any
|
|
214
|
+
): StripePaymentFormElement;
|
|
215
|
+
off(
|
|
216
|
+
eventType: 'confirm',
|
|
217
|
+
handler?: (event: StripePaymentFormElementConfirmEvent) => any
|
|
218
|
+
): StripePaymentFormElement;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Triggered when the payment interface is dismissed (e.g., a buyer closes the payment interface).
|
|
222
|
+
*/
|
|
223
|
+
on(
|
|
224
|
+
eventType: 'cancel',
|
|
225
|
+
handler: (event: {elementType: 'paymentForm'}) => any
|
|
226
|
+
): StripePaymentFormElement;
|
|
227
|
+
once(
|
|
228
|
+
eventType: 'cancel',
|
|
229
|
+
handler: (event: {elementType: 'paymentForm'}) => any
|
|
230
|
+
): StripePaymentFormElement;
|
|
231
|
+
off(
|
|
232
|
+
eventType: 'cancel',
|
|
233
|
+
handler?: (event: {elementType: 'paymentForm'}) => any
|
|
234
|
+
): StripePaymentFormElement;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Retrieves the current form values from the PaymentFormElement.
|
|
238
|
+
*/
|
|
239
|
+
getValue(): Promise<StripePaymentFormElementChangeEvent>;
|
|
36
240
|
};
|
|
@@ -1,5 +1,108 @@
|
|
|
1
1
|
import {StripeError} from '../stripe';
|
|
2
2
|
import {StripeElementBase} from './base';
|
|
3
|
+
import {StripeExpressCheckoutElementConfirmEvent} from './express-checkout';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Address type used in PaymentFormElement change events.
|
|
7
|
+
*/
|
|
8
|
+
export type PaymentFormAddress = {
|
|
9
|
+
line1?: string | null;
|
|
10
|
+
line2?: string | null;
|
|
11
|
+
city?: string | null;
|
|
12
|
+
state?: string | null;
|
|
13
|
+
postal_code?: string | null;
|
|
14
|
+
country?: string | null;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The change event payload for the PaymentFormElement.
|
|
19
|
+
*/
|
|
20
|
+
export interface StripePaymentFormElementChangeEvent {
|
|
21
|
+
/**
|
|
22
|
+
* The type of element that emitted this event.
|
|
23
|
+
*/
|
|
24
|
+
elementType: 'paymentForm';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Whether all required fields in the PaymentFormElement are complete.
|
|
28
|
+
*/
|
|
29
|
+
complete: boolean;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Whether the PaymentFormElement is currently empty.
|
|
33
|
+
*/
|
|
34
|
+
empty: boolean;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* An object containing the current form values.
|
|
38
|
+
*/
|
|
39
|
+
value: {
|
|
40
|
+
customerDetails: {
|
|
41
|
+
email: string;
|
|
42
|
+
};
|
|
43
|
+
shippingOption?: {
|
|
44
|
+
id: string;
|
|
45
|
+
displayName: string;
|
|
46
|
+
amount: string;
|
|
47
|
+
};
|
|
48
|
+
shippingAddress?: PaymentFormAddress;
|
|
49
|
+
billingAddress?: PaymentFormAddress;
|
|
50
|
+
tax?: {
|
|
51
|
+
businessName: string;
|
|
52
|
+
taxId: string;
|
|
53
|
+
taxIdType: string;
|
|
54
|
+
externalTaxIdType: string;
|
|
55
|
+
};
|
|
56
|
+
customFields?: Record<string, string | number>;
|
|
57
|
+
payment?: {
|
|
58
|
+
collapsed: boolean;
|
|
59
|
+
type: string;
|
|
60
|
+
country?: string | null;
|
|
61
|
+
billingDetails?: {
|
|
62
|
+
address?: {
|
|
63
|
+
country?: string;
|
|
64
|
+
postal_code?: string;
|
|
65
|
+
};
|
|
66
|
+
} | null;
|
|
67
|
+
payment_method?: {
|
|
68
|
+
id: string;
|
|
69
|
+
type: string;
|
|
70
|
+
billing_details: {
|
|
71
|
+
address: PaymentFormAddress;
|
|
72
|
+
name: string | null;
|
|
73
|
+
email: string | null;
|
|
74
|
+
phone: string | null;
|
|
75
|
+
};
|
|
76
|
+
} | null;
|
|
77
|
+
savePaymentMethod?: boolean;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Confirm event when user completes via Express Checkout (Apple Pay, Google Pay, etc.)
|
|
84
|
+
*/
|
|
85
|
+
interface StripePaymentFormExpressCheckoutConfirmEvent
|
|
86
|
+
extends StripeExpressCheckoutElementConfirmEvent {
|
|
87
|
+
source: 'payment-form-ece';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Confirm event when user clicks the Pay button.
|
|
92
|
+
* paymentMethodType is the selected payment method (e.g., 'card', 'sepa_debit')
|
|
93
|
+
* or null if payment collection is not needed.
|
|
94
|
+
*/
|
|
95
|
+
interface StripePaymentFormPayButtonConfirmEvent {
|
|
96
|
+
source: 'payment-form-pay-button';
|
|
97
|
+
paymentMethodType: string | null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The confirm event payload for the PaymentFormElement.
|
|
102
|
+
*/
|
|
103
|
+
export type StripePaymentFormElementConfirmEvent =
|
|
104
|
+
| StripePaymentFormExpressCheckoutConfirmEvent
|
|
105
|
+
| StripePaymentFormPayButtonConfirmEvent;
|
|
3
106
|
|
|
4
107
|
export type StripePaymentFormElement = StripeElementBase & {
|
|
5
108
|
/**
|
|
@@ -18,6 +121,54 @@ export type StripePaymentFormElement = StripeElementBase & {
|
|
|
18
121
|
handler?: (event: {elementType: 'paymentForm'}) => any
|
|
19
122
|
): StripePaymentFormElement;
|
|
20
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Triggered when the element gains focus.
|
|
126
|
+
*/
|
|
127
|
+
on(
|
|
128
|
+
eventType: 'focus',
|
|
129
|
+
handler: (event: {elementType: 'paymentForm'}) => any
|
|
130
|
+
): StripePaymentFormElement;
|
|
131
|
+
once(
|
|
132
|
+
eventType: 'focus',
|
|
133
|
+
handler: (event: {elementType: 'paymentForm'}) => any
|
|
134
|
+
): StripePaymentFormElement;
|
|
135
|
+
off(
|
|
136
|
+
eventType: 'focus',
|
|
137
|
+
handler?: (event: {elementType: 'paymentForm'}) => any
|
|
138
|
+
): StripePaymentFormElement;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Triggered when the element loses focus.
|
|
142
|
+
*/
|
|
143
|
+
on(
|
|
144
|
+
eventType: 'blur',
|
|
145
|
+
handler: (event: {elementType: 'paymentForm'}) => any
|
|
146
|
+
): StripePaymentFormElement;
|
|
147
|
+
once(
|
|
148
|
+
eventType: 'blur',
|
|
149
|
+
handler: (event: {elementType: 'paymentForm'}) => any
|
|
150
|
+
): StripePaymentFormElement;
|
|
151
|
+
off(
|
|
152
|
+
eventType: 'blur',
|
|
153
|
+
handler?: (event: {elementType: 'paymentForm'}) => any
|
|
154
|
+
): StripePaymentFormElement;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Triggered when the escape key is pressed within the element.
|
|
158
|
+
*/
|
|
159
|
+
on(
|
|
160
|
+
eventType: 'escape',
|
|
161
|
+
handler: (event: {elementType: 'paymentForm'}) => any
|
|
162
|
+
): StripePaymentFormElement;
|
|
163
|
+
once(
|
|
164
|
+
eventType: 'escape',
|
|
165
|
+
handler: (event: {elementType: 'paymentForm'}) => any
|
|
166
|
+
): StripePaymentFormElement;
|
|
167
|
+
off(
|
|
168
|
+
eventType: 'escape',
|
|
169
|
+
handler?: (event: {elementType: 'paymentForm'}) => any
|
|
170
|
+
): StripePaymentFormElement;
|
|
171
|
+
|
|
21
172
|
/**
|
|
22
173
|
* Triggered when the element fails to load.
|
|
23
174
|
*/
|
|
@@ -33,4 +184,57 @@ export type StripePaymentFormElement = StripeElementBase & {
|
|
|
33
184
|
eventType: 'loaderror',
|
|
34
185
|
handler?: (event: {elementType: 'paymentForm'; error: StripeError}) => any
|
|
35
186
|
): StripePaymentFormElement;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Triggered when the element's value changes.
|
|
190
|
+
*/
|
|
191
|
+
on(
|
|
192
|
+
eventType: 'change',
|
|
193
|
+
handler: (event: StripePaymentFormElementChangeEvent) => any
|
|
194
|
+
): StripePaymentFormElement;
|
|
195
|
+
once(
|
|
196
|
+
eventType: 'change',
|
|
197
|
+
handler: (event: StripePaymentFormElementChangeEvent) => any
|
|
198
|
+
): StripePaymentFormElement;
|
|
199
|
+
off(
|
|
200
|
+
eventType: 'change',
|
|
201
|
+
handler?: (event: StripePaymentFormElementChangeEvent) => any
|
|
202
|
+
): StripePaymentFormElement;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Triggered when a buyer authorizes a payment within a supported payment method.
|
|
206
|
+
*/
|
|
207
|
+
on(
|
|
208
|
+
eventType: 'confirm',
|
|
209
|
+
handler: (event: StripePaymentFormElementConfirmEvent) => any
|
|
210
|
+
): StripePaymentFormElement;
|
|
211
|
+
once(
|
|
212
|
+
eventType: 'confirm',
|
|
213
|
+
handler: (event: StripePaymentFormElementConfirmEvent) => any
|
|
214
|
+
): StripePaymentFormElement;
|
|
215
|
+
off(
|
|
216
|
+
eventType: 'confirm',
|
|
217
|
+
handler?: (event: StripePaymentFormElementConfirmEvent) => any
|
|
218
|
+
): StripePaymentFormElement;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Triggered when the payment interface is dismissed (e.g., a buyer closes the payment interface).
|
|
222
|
+
*/
|
|
223
|
+
on(
|
|
224
|
+
eventType: 'cancel',
|
|
225
|
+
handler: (event: {elementType: 'paymentForm'}) => any
|
|
226
|
+
): StripePaymentFormElement;
|
|
227
|
+
once(
|
|
228
|
+
eventType: 'cancel',
|
|
229
|
+
handler: (event: {elementType: 'paymentForm'}) => any
|
|
230
|
+
): StripePaymentFormElement;
|
|
231
|
+
off(
|
|
232
|
+
eventType: 'cancel',
|
|
233
|
+
handler?: (event: {elementType: 'paymentForm'}) => any
|
|
234
|
+
): StripePaymentFormElement;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Retrieves the current form values from the PaymentFormElement.
|
|
238
|
+
*/
|
|
239
|
+
getValue(): Promise<StripePaymentFormElementChangeEvent>;
|
|
36
240
|
};
|
|
@@ -715,6 +715,13 @@ interface BaseStripeElementsOptions {
|
|
|
715
715
|
* @docs https://docs.stripe.com/js/elements_object/create#stripe_elements-options-syncAddressCheckbox
|
|
716
716
|
*/
|
|
717
717
|
syncAddressCheckbox?: 'billing' | 'shipping' | 'none';
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* Allows PaymentMethods to be created from the Elements instance.
|
|
721
|
+
*
|
|
722
|
+
* @docs https://docs.stripe.com/js/elements_object/create#stripe_elements-options-paymentMethodCreation
|
|
723
|
+
*/
|
|
724
|
+
paymentMethodCreation?: 'manual';
|
|
718
725
|
}
|
|
719
726
|
|
|
720
727
|
export interface StripeElementsOptionsClientSecret
|
|
@@ -827,11 +834,6 @@ interface StripeElementsOptionsModeBase extends BaseStripeElementsOptions {
|
|
|
827
834
|
*/
|
|
828
835
|
payment_method_configuration?: string;
|
|
829
836
|
|
|
830
|
-
/**
|
|
831
|
-
* Allows PaymentMethods to be created from the Elements instance.
|
|
832
|
-
*/
|
|
833
|
-
paymentMethodCreation?: 'manual';
|
|
834
|
-
|
|
835
837
|
/**
|
|
836
838
|
* Additional payment-method-specific options for configuring Payment Element behavior.
|
|
837
839
|
*
|
|
@@ -715,6 +715,13 @@ interface BaseStripeElementsOptions {
|
|
|
715
715
|
* @docs https://docs.stripe.com/js/elements_object/create#stripe_elements-options-syncAddressCheckbox
|
|
716
716
|
*/
|
|
717
717
|
syncAddressCheckbox?: 'billing' | 'shipping' | 'none';
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* Allows PaymentMethods to be created from the Elements instance.
|
|
721
|
+
*
|
|
722
|
+
* @docs https://docs.stripe.com/js/elements_object/create#stripe_elements-options-paymentMethodCreation
|
|
723
|
+
*/
|
|
724
|
+
paymentMethodCreation?: 'manual';
|
|
718
725
|
}
|
|
719
726
|
|
|
720
727
|
export interface StripeElementsOptionsClientSecret
|
|
@@ -827,11 +834,6 @@ interface StripeElementsOptionsModeBase extends BaseStripeElementsOptions {
|
|
|
827
834
|
*/
|
|
828
835
|
payment_method_configuration?: string;
|
|
829
836
|
|
|
830
|
-
/**
|
|
831
|
-
* Allows PaymentMethods to be created from the Elements instance.
|
|
832
|
-
*/
|
|
833
|
-
paymentMethodCreation?: 'manual';
|
|
834
|
-
|
|
835
837
|
/**
|
|
836
838
|
* Additional payment-method-specific options for configuring Payment Element behavior.
|
|
837
839
|
*
|
package/package.json
CHANGED
package/src/shared.ts
CHANGED
|
@@ -169,6 +169,13 @@ export const initStripe = (
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
const pk = args[0];
|
|
172
|
+
|
|
173
|
+
if (typeof pk !== 'string') {
|
|
174
|
+
throw new Error(
|
|
175
|
+
`Expected publishable key to be of type string, got type ${typeof pk} instead.`
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
172
179
|
const isTestKey = pk.match(/^pk_test/);
|
|
173
180
|
|
|
174
181
|
// @ts-expect-error this is not publicly typed
|