@stripe/stripe-js 2.1.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pure.esm.js +1 -1
- package/dist/pure.js +1 -1
- package/dist/stripe.esm.js +1 -1
- package/dist/stripe.js +1 -1
- package/package.json +1 -1
- package/types/stripe-js/custom-checkout.d.ts +216 -0
- package/types/stripe-js/elements-group.d.ts +1 -7
- package/types/stripe-js/embedded-checkout.d.ts +30 -0
- package/types/stripe-js/index.d.ts +2 -0
- package/types/stripe-js/stripe.d.ts +24 -0
package/dist/pure.esm.js
CHANGED
package/dist/pure.js
CHANGED
package/dist/stripe.esm.js
CHANGED
package/dist/stripe.js
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LayoutObject,
|
|
3
|
+
Layout,
|
|
4
|
+
TermsOption,
|
|
5
|
+
StripePaymentElement,
|
|
6
|
+
} from './elements/payment';
|
|
7
|
+
import {
|
|
8
|
+
AddressMode,
|
|
9
|
+
ContactOption,
|
|
10
|
+
StripeAddressElement,
|
|
11
|
+
} from './elements/address';
|
|
12
|
+
import {Appearance, CssFontSource, CustomFontSource} from './elements-group';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Requires beta access:
|
|
16
|
+
* Contact [Stripe support](https://support.stripe.com/) for more information.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* StripeCustomCheckoutInitOptions
|
|
21
|
+
*/
|
|
22
|
+
export interface StripeCustomCheckoutElementsOptions {
|
|
23
|
+
appearance?: Appearance;
|
|
24
|
+
loader?: 'auto' | 'always' | 'never';
|
|
25
|
+
fonts?: Array<CssFontSource | CustomFontSource>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface StripeCustomCheckoutOptions {
|
|
29
|
+
clientSecret: string;
|
|
30
|
+
elementsOptions?: StripeCustomCheckoutElementsOptions;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* StripeCustomCheckoutActions
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
export type StripeCustomCheckoutAddress = {
|
|
38
|
+
country: string | null;
|
|
39
|
+
line1: string | null;
|
|
40
|
+
line2?: string | null;
|
|
41
|
+
city: string | null;
|
|
42
|
+
postal_code: string | null;
|
|
43
|
+
state: string | null;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type StripeCustomCheckoutShippingAddress = {
|
|
47
|
+
name?: string | null;
|
|
48
|
+
address: StripeCustomCheckoutAddress;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type StripeCustomCheckoutBillingAddress = StripeCustomCheckoutShippingAddress;
|
|
52
|
+
|
|
53
|
+
export interface StripeCustomCheckoutActions {
|
|
54
|
+
applyPromotionCode: (promotionCode: string) => Promise<void>;
|
|
55
|
+
removePromotionCode: () => Promise<void>;
|
|
56
|
+
updateShippingAddress: (
|
|
57
|
+
shippingAddress: StripeCustomCheckoutShippingAddress
|
|
58
|
+
) => Promise<void>;
|
|
59
|
+
updateBillingAddress: (
|
|
60
|
+
billingAddress: StripeCustomCheckoutBillingAddress
|
|
61
|
+
) => Promise<void>;
|
|
62
|
+
updatePhoneNumber: (phoneNumber: string) => void;
|
|
63
|
+
updateEmail: (email: string) => void;
|
|
64
|
+
updateLineItemQuantity: (args: {
|
|
65
|
+
lineItem: string;
|
|
66
|
+
quantity: number;
|
|
67
|
+
}) => Promise<void>;
|
|
68
|
+
updateShippingOption: (shippingOption: string) => Promise<void>;
|
|
69
|
+
confirm: (args?: {return_url?: string}) => Promise<void>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* StripeCustomCheckoutSession
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
export type StripeCustomCheckoutTaxAmount = {
|
|
77
|
+
amount: number;
|
|
78
|
+
inclusive: boolean;
|
|
79
|
+
displayName: string;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export type StripeCustomCheckoutDiscountAmount = {
|
|
83
|
+
amount: number;
|
|
84
|
+
displayName: string;
|
|
85
|
+
promotionCode?: string | null;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export type StripeCustomCheckoutShipping = {
|
|
89
|
+
shippingOption: StripeCustomCheckoutShippingOption;
|
|
90
|
+
taxAmounts?: Array<StripeCustomCheckoutTaxAmount> | null;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export type StripeCustomCheckoutShippingOption = {
|
|
94
|
+
id: string;
|
|
95
|
+
amount: number;
|
|
96
|
+
currency: string;
|
|
97
|
+
displayName?: string | null;
|
|
98
|
+
deliveryEstimate?: StripeCustomCheckoutDeliveryEstimate | null;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export type StripeCustomCheckoutDeliveryEstimate = {
|
|
102
|
+
maximum?: StripeCustomCheckoutEstimate | null;
|
|
103
|
+
minimum?: StripeCustomCheckoutEstimate | null;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export type StripeCustomCheckoutEstimate = {
|
|
107
|
+
unit: 'business_day' | 'day' | 'hour' | 'week' | 'month';
|
|
108
|
+
value: number;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export type StripeCustomCheckoutLineItemDiscountAmount = {
|
|
112
|
+
amount: number;
|
|
113
|
+
promotionCode?: string | null;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export type StripeCustomCheckoutBillingInterval =
|
|
117
|
+
| 'day'
|
|
118
|
+
| 'month'
|
|
119
|
+
| 'week'
|
|
120
|
+
| 'year';
|
|
121
|
+
|
|
122
|
+
export type StripeCustomCheckoutLineItem = {
|
|
123
|
+
id: string;
|
|
124
|
+
name: string;
|
|
125
|
+
amount: number;
|
|
126
|
+
unitAmount: number;
|
|
127
|
+
description?: string | null;
|
|
128
|
+
quantity: number;
|
|
129
|
+
discountAmounts?: Array<StripeCustomCheckoutLineItemDiscountAmount> | null;
|
|
130
|
+
recurring?: {
|
|
131
|
+
interval: StripeCustomCheckoutBillingInterval;
|
|
132
|
+
interval_count: number;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export type StripeCustomCheckoutTotalSummary = {
|
|
137
|
+
subtotal: number;
|
|
138
|
+
taxExclusive: number;
|
|
139
|
+
taxInclusive: number;
|
|
140
|
+
shippingRate: number;
|
|
141
|
+
discount: number;
|
|
142
|
+
total: number;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export type StripeCustomCheckoutConfirmationRequirement =
|
|
146
|
+
| 'phoneNumber'
|
|
147
|
+
| 'shippingAddress'
|
|
148
|
+
| 'billingAddress'
|
|
149
|
+
| 'paymentDetails'
|
|
150
|
+
| 'email';
|
|
151
|
+
|
|
152
|
+
export interface StripeCustomCheckoutSession {
|
|
153
|
+
lineItems: Array<StripeCustomCheckoutLineItem>;
|
|
154
|
+
taxAmounts?: Array<StripeCustomCheckoutTaxAmount> | null;
|
|
155
|
+
discountAmounts?: Array<StripeCustomCheckoutDiscountAmount> | null;
|
|
156
|
+
currency: string;
|
|
157
|
+
shipping?: StripeCustomCheckoutShipping | null;
|
|
158
|
+
shippingOptions: Array<StripeCustomCheckoutShippingOption>;
|
|
159
|
+
shippingAddress?: StripeCustomCheckoutShippingAddress | null;
|
|
160
|
+
billingAddress?: StripeCustomCheckoutBillingAddress | null;
|
|
161
|
+
phoneNumber?: string | null;
|
|
162
|
+
email?: string | null;
|
|
163
|
+
total: StripeCustomCheckoutTotalSummary;
|
|
164
|
+
confirmationRequirements: StripeCustomCheckoutConfirmationRequirement[];
|
|
165
|
+
canConfirm: boolean;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* StripeCustomCheckoutElements
|
|
170
|
+
*/
|
|
171
|
+
export type StripeCustomCheckoutPaymentElementOptions = {
|
|
172
|
+
layout?: Layout | LayoutObject;
|
|
173
|
+
paymentMethodOrder?: Array<string>;
|
|
174
|
+
readonly?: boolean;
|
|
175
|
+
terms?: TermsOption;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export type StripeCustomCheckoutAddressElementOptions = {
|
|
179
|
+
mode: AddressMode;
|
|
180
|
+
contacts?: ContactOption[];
|
|
181
|
+
display?: {
|
|
182
|
+
name?: 'full' | 'split' | 'organization';
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export interface StripeCustomCheckoutElementsActions {
|
|
187
|
+
changeAppearance: (appearance: Appearance) => void;
|
|
188
|
+
getElement(elementType: 'payment'): StripePaymentElement | null;
|
|
189
|
+
getElement(
|
|
190
|
+
elementType: 'address',
|
|
191
|
+
mode: AddressMode
|
|
192
|
+
): StripeAddressElement | null;
|
|
193
|
+
createElement(
|
|
194
|
+
elementType: 'payment',
|
|
195
|
+
options?: StripeCustomCheckoutPaymentElementOptions
|
|
196
|
+
): StripePaymentElement;
|
|
197
|
+
createElement(
|
|
198
|
+
elementType: 'address',
|
|
199
|
+
options: StripeCustomCheckoutAddressElementOptions
|
|
200
|
+
): StripeAddressElement;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* StripeCustomCheckout
|
|
205
|
+
*/
|
|
206
|
+
export type StripeCustomCheckoutUpdateHandler = (
|
|
207
|
+
session: StripeCustomCheckoutSession
|
|
208
|
+
) => void;
|
|
209
|
+
|
|
210
|
+
export interface StripeCustomCheckout
|
|
211
|
+
extends StripeCustomCheckoutActions,
|
|
212
|
+
StripeCustomCheckoutSession,
|
|
213
|
+
StripeCustomCheckoutElementsActions {
|
|
214
|
+
session: () => StripeCustomCheckoutSession;
|
|
215
|
+
on: (event: 'change', handler: StripeCustomCheckoutUpdateHandler) => void;
|
|
216
|
+
}
|
|
@@ -378,10 +378,7 @@ export interface StripeElements {
|
|
|
378
378
|
/////////////////////////////
|
|
379
379
|
|
|
380
380
|
/**
|
|
381
|
-
*
|
|
382
|
-
* Contact [Stripe support](https://support.stripe.com/) for more information.
|
|
383
|
-
*
|
|
384
|
-
* Creates a `ExpressCheckoutElement`.
|
|
381
|
+
* Creates an `ExpressCheckoutElement`.
|
|
385
382
|
*/
|
|
386
383
|
create(
|
|
387
384
|
elementType: 'expressCheckout',
|
|
@@ -389,9 +386,6 @@ export interface StripeElements {
|
|
|
389
386
|
): StripeExpressCheckoutElement;
|
|
390
387
|
|
|
391
388
|
/**
|
|
392
|
-
* Requires beta access:
|
|
393
|
-
* Contact [Stripe support](https://support.stripe.com/) for more information.
|
|
394
|
-
*
|
|
395
389
|
* Looks up a previously created `Element` by its type.
|
|
396
390
|
*/
|
|
397
391
|
getElement(
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface StripeEmbeddedCheckoutOptions {
|
|
2
|
+
/**
|
|
3
|
+
* The client secret of the [Checkout Session](https://stripe.com/docs/api/checkout/sessions).
|
|
4
|
+
*/
|
|
5
|
+
clientSecret: string;
|
|
6
|
+
/**
|
|
7
|
+
* onComplete is called when the Checkout Session completes successfully.
|
|
8
|
+
* You can use it to unmount Embedded Checkout and render a custom success UI.
|
|
9
|
+
*/
|
|
10
|
+
onComplete?: () => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface StripeEmbeddedCheckout {
|
|
14
|
+
/**
|
|
15
|
+
* The `embeddedCheckout.mount` method attaches your Embedded Checkout to the DOM.
|
|
16
|
+
* `mount` accepts either a CSS Selector (e.g., `'#checkout'`) or a DOM element.
|
|
17
|
+
*/
|
|
18
|
+
mount(location: string | HTMLElement): void;
|
|
19
|
+
/**
|
|
20
|
+
* Unmounts Embedded Checkout from the DOM.
|
|
21
|
+
* Call `embeddedCheckout.mount` to re-attach it to the DOM.
|
|
22
|
+
*/
|
|
23
|
+
unmount(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Removes Embedded Checkout from the DOM and destroys it.
|
|
26
|
+
* Once destroyed it not be re-mounted to the DOM.
|
|
27
|
+
* Use this if you want to create a new Embedded Checkout instance.
|
|
28
|
+
*/
|
|
29
|
+
destroy(): void;
|
|
30
|
+
}
|
|
@@ -15,6 +15,14 @@ import {
|
|
|
15
15
|
import {CheckoutLocale, RedirectToCheckoutOptions} from './checkout';
|
|
16
16
|
import {PaymentRequestOptions, PaymentRequest} from './payment-request';
|
|
17
17
|
import {StripeElement, StripeElementLocale} from './elements-group';
|
|
18
|
+
import {
|
|
19
|
+
StripeCustomCheckoutOptions,
|
|
20
|
+
StripeCustomCheckout,
|
|
21
|
+
} from './custom-checkout';
|
|
22
|
+
import {
|
|
23
|
+
StripeEmbeddedCheckoutOptions,
|
|
24
|
+
StripeEmbeddedCheckout,
|
|
25
|
+
} from './embedded-checkout';
|
|
18
26
|
|
|
19
27
|
export interface Stripe {
|
|
20
28
|
/////////////////////////////
|
|
@@ -1193,6 +1201,22 @@ export interface Stripe {
|
|
|
1193
1201
|
createEphemeralKeyNonce(
|
|
1194
1202
|
options: ephemeralKeys.EphemeralKeyNonceOptions
|
|
1195
1203
|
): Promise<EphemeralKeyNonceResult>;
|
|
1204
|
+
|
|
1205
|
+
/**
|
|
1206
|
+
* Requires beta access:
|
|
1207
|
+
* Contact [Stripe support](https://support.stripe.com/) for more information.
|
|
1208
|
+
*/
|
|
1209
|
+
initCustomCheckout(
|
|
1210
|
+
options: StripeCustomCheckoutOptions
|
|
1211
|
+
): Promise<StripeCustomCheckout>;
|
|
1212
|
+
|
|
1213
|
+
/**
|
|
1214
|
+
* Requires beta access:
|
|
1215
|
+
* Contact [Stripe support](https://support.stripe.com/) for more information.
|
|
1216
|
+
*/
|
|
1217
|
+
initEmbeddedCheckout(
|
|
1218
|
+
options: StripeEmbeddedCheckoutOptions
|
|
1219
|
+
): Promise<StripeEmbeddedCheckout>;
|
|
1196
1220
|
}
|
|
1197
1221
|
|
|
1198
1222
|
export type PaymentIntentResult =
|