@stripe/connect-js 3.3.55-preview-1 → 3.4.1-preview-1
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/{types/config.d.ts → components/componentsAndSetters.d.ts} +1 -0
- package/dist/components/componentsAndSettersChecks.d.ts +4 -0
- package/dist/connect.esm.js +11 -49
- package/dist/connect.js +13 -48
- package/dist/exportedTypes/index.d.ts +2 -0
- package/dist/exportedTypes/shared.d.ts +557 -0
- package/dist/index.d.ts +3 -0
- package/dist/init.d.ts +10 -0
- package/dist/pure.d.ts +3 -0
- package/dist/pure.esm.js +11 -49
- package/dist/pure.js +13 -48
- package/dist/utils/scriptUtils.d.ts +3 -0
- package/package.json +3 -3
- package/pure.d.ts +2 -4
- package/{types/config.ts → src/components/componentsAndSetters.ts} +48 -1
- package/{types/checks.ts → src/components/componentsAndSettersChecks.ts} +2 -2
- package/src/exportedTypes/index.ts +4 -0
- package/{types/shared.d.ts → src/exportedTypes/shared.ts} +18 -54
- package/src/index.ts +9 -3
- package/src/{shared.ts → init.ts} +21 -142
- package/src/pure.test.ts +1 -1
- package/src/pure.ts +9 -3
- package/src/utils/scriptUtils.ts +33 -0
- package/dist/src/index.d.ts +0 -2
- package/dist/src/pure.d.ts +0 -2
- package/dist/src/shared.d.ts +0 -15
- package/types/.eslintrc.yml +0 -3
- package/types/index.d.ts +0 -7
- /package/dist/{src/utils → utils}/jestHelpers.d.ts +0 -0
- /package/dist/{src/utils → utils}/jestSetup.d.ts +0 -0
package/dist/pure.esm.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
2
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
// Source of truth for the entire list of components. When you add a new component, it should be added here.
|
|
3
|
+
const connectElementTagNames = ["payments", "payouts", "payment-details", "payment-disputes", "disputes-list", "account-onboarding", "payment-method-settings", "account-management", "notification-banner", "instant-payouts", "instant-payouts-promotion", "issuing-card", "issuing-cards-list", "financial-account", "financial-account-transactions", "recipients", "capital-financing", "capital-financing-application", "capital-financing-promotion", "capital-overview", "documents", "product-tax-code-selector", "export-tax-transactions", "tax-registrations", "tax-settings", "tax-threshold-monitoring", "balances", "payouts-list", "payout-details", "app-install", "app-viewport", "reporting-chart", "check-scanning", "agentic-commerce-settings", "terminal-hardware-orders", "terminal-hardware-shop", "network-cost-passthrough-report", "balance-report", "payout-reconciliation-report", "recipients-list", "financial-accounts", "financial-accounts-transactions"];
|
|
3
4
|
const ConnectElementCommonMethodConfig = {
|
|
4
5
|
setOnLoadError: _listener => {},
|
|
5
6
|
setOnLoaderStart: _listener => {}
|
|
@@ -135,55 +136,11 @@ const ConnectElementCustomMethodConfig = {
|
|
|
135
136
|
}
|
|
136
137
|
};
|
|
137
138
|
|
|
138
|
-
const componentNameMapping = {
|
|
139
|
-
payments: "stripe-connect-payments",
|
|
140
|
-
payouts: "stripe-connect-payouts",
|
|
141
|
-
"payment-details": "stripe-connect-payment-details",
|
|
142
|
-
"payment-disputes": "stripe-connect-payment-disputes",
|
|
143
|
-
"disputes-list": "stripe-connect-disputes-list",
|
|
144
|
-
"account-onboarding": "stripe-connect-account-onboarding",
|
|
145
|
-
"payment-method-settings": "stripe-connect-payment-method-settings",
|
|
146
|
-
"account-management": "stripe-connect-account-management",
|
|
147
|
-
"notification-banner": "stripe-connect-notification-banner",
|
|
148
|
-
"instant-payouts": "stripe-connect-instant-payouts",
|
|
149
|
-
"instant-payouts-promotion": "stripe-connect-instant-payouts-promotion",
|
|
150
|
-
"issuing-card": "stripe-connect-issuing-card",
|
|
151
|
-
"issuing-cards-list": "stripe-connect-issuing-cards-list",
|
|
152
|
-
"financial-account": "stripe-connect-financial-account",
|
|
153
|
-
recipients: "stripe-connect-recipients",
|
|
154
|
-
"financial-account-transactions": "stripe-connect-financial-account-transactions",
|
|
155
|
-
"capital-financing": "stripe-connect-capital-financing",
|
|
156
|
-
"capital-financing-application": "stripe-connect-capital-financing-application",
|
|
157
|
-
"capital-financing-promotion": "stripe-connect-capital-financing-promotion",
|
|
158
|
-
"capital-overview": "stripe-connect-capital-overview",
|
|
159
|
-
documents: "stripe-connect-documents",
|
|
160
|
-
"product-tax-code-selector": "stripe-connect-product-tax-code-selector",
|
|
161
|
-
"export-tax-transactions": "stripe-connect-export-tax-transactions",
|
|
162
|
-
"tax-registrations": "stripe-connect-tax-registrations",
|
|
163
|
-
"tax-settings": "stripe-connect-tax-settings",
|
|
164
|
-
"tax-threshold-monitoring": "stripe-connect-tax-threshold-monitoring",
|
|
165
|
-
balances: "stripe-connect-balances",
|
|
166
|
-
"payouts-list": "stripe-connect-payouts-list",
|
|
167
|
-
"payout-details": "stripe-connect-payout-details",
|
|
168
|
-
"app-install": "stripe-connect-app-install",
|
|
169
|
-
"app-viewport": "stripe-connect-app-viewport",
|
|
170
|
-
"reporting-chart": "stripe-connect-reporting-chart",
|
|
171
|
-
"check-scanning": "stripe-connect-check-scanning",
|
|
172
|
-
"agentic-commerce-settings": "stripe-connect-agentic-commerce-settings",
|
|
173
|
-
"terminal-hardware-orders": "stripe-connect-terminal-hardware-orders",
|
|
174
|
-
"terminal-hardware-shop": "stripe-connect-terminal-hardware-shop",
|
|
175
|
-
"network-cost-passthrough-report": "stripe-connect-network-cost-passthrough-report",
|
|
176
|
-
"balance-report": "stripe-connect-balance-report",
|
|
177
|
-
"payout-reconciliation-report": "stripe-connect-payout-reconciliation-report",
|
|
178
|
-
"recipients-list": "stripe-connect-recipients-list",
|
|
179
|
-
"financial-accounts": "stripe-connect-financial-accounts",
|
|
180
|
-
"financial-accounts-transactions": "stripe-connect-financial-accounts-transactions"
|
|
181
|
-
};
|
|
182
139
|
const EXISTING_SCRIPT_MESSAGE = "loadConnect was called but an existing Connect.js script already exists in the document; existing script parameters will be used";
|
|
183
140
|
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
184
141
|
const V1_URL = "https://connect-js.stripe.com/v1.0/connect.js";
|
|
185
142
|
const findScript = () => {
|
|
186
|
-
return document.querySelectorAll(`script[src="${
|
|
143
|
+
return document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
|
|
187
144
|
};
|
|
188
145
|
const injectScript = () => {
|
|
189
146
|
const script = document.createElement("script");
|
|
@@ -195,6 +152,11 @@ const injectScript = () => {
|
|
|
195
152
|
document.head.appendChild(script);
|
|
196
153
|
return script;
|
|
197
154
|
};
|
|
155
|
+
|
|
156
|
+
const componentNameMapping = connectElementTagNames.reduce((acc, name) => {
|
|
157
|
+
acc[name] = `stripe-connect-${name}`;
|
|
158
|
+
return acc;
|
|
159
|
+
}, {});
|
|
198
160
|
let stripePromise = null;
|
|
199
161
|
const isWindowStripeConnectDefined = stripeConnect => {
|
|
200
162
|
// We only consider `StripeConnect` defined if `init` is a function
|
|
@@ -274,7 +236,7 @@ const initStripeConnect = (stripePromise, initParams) => {
|
|
|
274
236
|
element[method] = function (value) {
|
|
275
237
|
stripeConnectInstance.then(() => {
|
|
276
238
|
if (!this[`${method}InternalOnly`]) {
|
|
277
|
-
throw new Error(`Method ${method} is not available in the ${tagName} HTML element. Are you using a supported version of the "@stripe/connect-js" package? Using version: 3.
|
|
239
|
+
throw new Error(`Method ${method} is not available in the ${tagName} HTML element. Are you using a supported version of the "@stripe/connect-js" package? Using version: 3.4.1-preview-1`);
|
|
278
240
|
}
|
|
279
241
|
this[`${method}InternalOnly`](value);
|
|
280
242
|
});
|
|
@@ -328,7 +290,7 @@ const createWrapper = stripeConnect => {
|
|
|
328
290
|
sdk: true,
|
|
329
291
|
sdkOptions: {
|
|
330
292
|
// This will be replaced by the npm package version when bundling
|
|
331
|
-
sdkVersion: "3.
|
|
293
|
+
sdkVersion: "3.4.1-preview-1"
|
|
332
294
|
}
|
|
333
295
|
})
|
|
334
296
|
}));
|
|
@@ -346,4 +308,4 @@ const loadConnectAndInitialize = initParams => {
|
|
|
346
308
|
return initStripeConnect(maybeConnect, initParams);
|
|
347
309
|
};
|
|
348
310
|
|
|
349
|
-
export { loadConnectAndInitialize };
|
|
311
|
+
export { ConnectElementCommonMethodConfig, ConnectElementCustomMethodConfig, connectElementTagNames, loadConnectAndInitialize };
|
package/dist/pure.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
6
5
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
6
|
+
// Source of truth for the entire list of components. When you add a new component, it should be added here.
|
|
7
|
+
const connectElementTagNames = ["payments", "payouts", "payment-details", "payment-disputes", "disputes-list", "account-onboarding", "payment-method-settings", "account-management", "notification-banner", "instant-payouts", "instant-payouts-promotion", "issuing-card", "issuing-cards-list", "financial-account", "financial-account-transactions", "recipients", "capital-financing", "capital-financing-application", "capital-financing-promotion", "capital-overview", "documents", "product-tax-code-selector", "export-tax-transactions", "tax-registrations", "tax-settings", "tax-threshold-monitoring", "balances", "payouts-list", "payout-details", "app-install", "app-viewport", "reporting-chart", "check-scanning", "agentic-commerce-settings", "terminal-hardware-orders", "terminal-hardware-shop", "network-cost-passthrough-report", "balance-report", "payout-reconciliation-report", "recipients-list", "financial-accounts", "financial-accounts-transactions"];
|
|
7
8
|
const ConnectElementCommonMethodConfig = {
|
|
8
9
|
setOnLoadError: _listener => {},
|
|
9
10
|
setOnLoaderStart: _listener => {}
|
|
@@ -139,55 +140,11 @@ const ConnectElementCustomMethodConfig = {
|
|
|
139
140
|
}
|
|
140
141
|
};
|
|
141
142
|
|
|
142
|
-
const componentNameMapping = {
|
|
143
|
-
payments: "stripe-connect-payments",
|
|
144
|
-
payouts: "stripe-connect-payouts",
|
|
145
|
-
"payment-details": "stripe-connect-payment-details",
|
|
146
|
-
"payment-disputes": "stripe-connect-payment-disputes",
|
|
147
|
-
"disputes-list": "stripe-connect-disputes-list",
|
|
148
|
-
"account-onboarding": "stripe-connect-account-onboarding",
|
|
149
|
-
"payment-method-settings": "stripe-connect-payment-method-settings",
|
|
150
|
-
"account-management": "stripe-connect-account-management",
|
|
151
|
-
"notification-banner": "stripe-connect-notification-banner",
|
|
152
|
-
"instant-payouts": "stripe-connect-instant-payouts",
|
|
153
|
-
"instant-payouts-promotion": "stripe-connect-instant-payouts-promotion",
|
|
154
|
-
"issuing-card": "stripe-connect-issuing-card",
|
|
155
|
-
"issuing-cards-list": "stripe-connect-issuing-cards-list",
|
|
156
|
-
"financial-account": "stripe-connect-financial-account",
|
|
157
|
-
recipients: "stripe-connect-recipients",
|
|
158
|
-
"financial-account-transactions": "stripe-connect-financial-account-transactions",
|
|
159
|
-
"capital-financing": "stripe-connect-capital-financing",
|
|
160
|
-
"capital-financing-application": "stripe-connect-capital-financing-application",
|
|
161
|
-
"capital-financing-promotion": "stripe-connect-capital-financing-promotion",
|
|
162
|
-
"capital-overview": "stripe-connect-capital-overview",
|
|
163
|
-
documents: "stripe-connect-documents",
|
|
164
|
-
"product-tax-code-selector": "stripe-connect-product-tax-code-selector",
|
|
165
|
-
"export-tax-transactions": "stripe-connect-export-tax-transactions",
|
|
166
|
-
"tax-registrations": "stripe-connect-tax-registrations",
|
|
167
|
-
"tax-settings": "stripe-connect-tax-settings",
|
|
168
|
-
"tax-threshold-monitoring": "stripe-connect-tax-threshold-monitoring",
|
|
169
|
-
balances: "stripe-connect-balances",
|
|
170
|
-
"payouts-list": "stripe-connect-payouts-list",
|
|
171
|
-
"payout-details": "stripe-connect-payout-details",
|
|
172
|
-
"app-install": "stripe-connect-app-install",
|
|
173
|
-
"app-viewport": "stripe-connect-app-viewport",
|
|
174
|
-
"reporting-chart": "stripe-connect-reporting-chart",
|
|
175
|
-
"check-scanning": "stripe-connect-check-scanning",
|
|
176
|
-
"agentic-commerce-settings": "stripe-connect-agentic-commerce-settings",
|
|
177
|
-
"terminal-hardware-orders": "stripe-connect-terminal-hardware-orders",
|
|
178
|
-
"terminal-hardware-shop": "stripe-connect-terminal-hardware-shop",
|
|
179
|
-
"network-cost-passthrough-report": "stripe-connect-network-cost-passthrough-report",
|
|
180
|
-
"balance-report": "stripe-connect-balance-report",
|
|
181
|
-
"payout-reconciliation-report": "stripe-connect-payout-reconciliation-report",
|
|
182
|
-
"recipients-list": "stripe-connect-recipients-list",
|
|
183
|
-
"financial-accounts": "stripe-connect-financial-accounts",
|
|
184
|
-
"financial-accounts-transactions": "stripe-connect-financial-accounts-transactions"
|
|
185
|
-
};
|
|
186
143
|
const EXISTING_SCRIPT_MESSAGE = "loadConnect was called but an existing Connect.js script already exists in the document; existing script parameters will be used";
|
|
187
144
|
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
188
145
|
const V1_URL = "https://connect-js.stripe.com/v1.0/connect.js";
|
|
189
146
|
const findScript = () => {
|
|
190
|
-
return document.querySelectorAll(`script[src="${
|
|
147
|
+
return document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
|
|
191
148
|
};
|
|
192
149
|
const injectScript = () => {
|
|
193
150
|
const script = document.createElement("script");
|
|
@@ -199,6 +156,11 @@ const injectScript = () => {
|
|
|
199
156
|
document.head.appendChild(script);
|
|
200
157
|
return script;
|
|
201
158
|
};
|
|
159
|
+
|
|
160
|
+
const componentNameMapping = connectElementTagNames.reduce((acc, name) => {
|
|
161
|
+
acc[name] = `stripe-connect-${name}`;
|
|
162
|
+
return acc;
|
|
163
|
+
}, {});
|
|
202
164
|
let stripePromise = null;
|
|
203
165
|
const isWindowStripeConnectDefined = stripeConnect => {
|
|
204
166
|
// We only consider `StripeConnect` defined if `init` is a function
|
|
@@ -278,7 +240,7 @@ const initStripeConnect = (stripePromise, initParams) => {
|
|
|
278
240
|
element[method] = function (value) {
|
|
279
241
|
stripeConnectInstance.then(() => {
|
|
280
242
|
if (!this[`${method}InternalOnly`]) {
|
|
281
|
-
throw new Error(`Method ${method} is not available in the ${tagName} HTML element. Are you using a supported version of the "@stripe/connect-js" package? Using version: 3.
|
|
243
|
+
throw new Error(`Method ${method} is not available in the ${tagName} HTML element. Are you using a supported version of the "@stripe/connect-js" package? Using version: 3.4.1-preview-1`);
|
|
282
244
|
}
|
|
283
245
|
this[`${method}InternalOnly`](value);
|
|
284
246
|
});
|
|
@@ -332,7 +294,7 @@ const createWrapper = stripeConnect => {
|
|
|
332
294
|
sdk: true,
|
|
333
295
|
sdkOptions: {
|
|
334
296
|
// This will be replaced by the npm package version when bundling
|
|
335
|
-
sdkVersion: "3.
|
|
297
|
+
sdkVersion: "3.4.1-preview-1"
|
|
336
298
|
}
|
|
337
299
|
})
|
|
338
300
|
}));
|
|
@@ -350,4 +312,7 @@ const loadConnectAndInitialize = initParams => {
|
|
|
350
312
|
return initStripeConnect(maybeConnect, initParams);
|
|
351
313
|
};
|
|
352
314
|
|
|
315
|
+
exports.ConnectElementCommonMethodConfig = ConnectElementCommonMethodConfig;
|
|
316
|
+
exports.ConnectElementCustomMethodConfig = ConnectElementCustomMethodConfig;
|
|
317
|
+
exports.connectElementTagNames = connectElementTagNames;
|
|
353
318
|
exports.loadConnectAndInitialize = loadConnectAndInitialize;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const EXISTING_SCRIPT_MESSAGE = "loadConnect was called but an existing Connect.js script already exists in the document; existing script parameters will be used";
|
|
2
|
+
export declare const findScript: () => HTMLScriptElement | null;
|
|
3
|
+
export declare const injectScript: () => HTMLScriptElement;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stripe/connect-js",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.1-preview-1",
|
|
4
4
|
"description": "Connect.js loading utility package (preview version)",
|
|
5
5
|
"main": "dist/connect.js",
|
|
6
6
|
"module": "dist/connect.esm.js",
|
|
7
|
-
"types": "
|
|
8
|
-
"typings": "
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"typings": "dist/index.d.ts",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "yarn lint && yarn test:unit --passWithNoTests && yarn typecheck && yarn build",
|
|
11
11
|
"test:unit": "jest",
|
package/pure.d.ts
CHANGED
|
@@ -1,6 +1,53 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
2
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3
2
|
|
|
3
|
+
// Source of truth for the entire list of components. When you add a new component, it should be added here.
|
|
4
|
+
export const connectElementTagNames = [
|
|
5
|
+
"payments",
|
|
6
|
+
"payouts",
|
|
7
|
+
"payment-details",
|
|
8
|
+
"payment-disputes",
|
|
9
|
+
"disputes-list",
|
|
10
|
+
"account-onboarding",
|
|
11
|
+
"payment-method-settings",
|
|
12
|
+
"account-management",
|
|
13
|
+
"notification-banner",
|
|
14
|
+
"instant-payouts",
|
|
15
|
+
"instant-payouts-promotion",
|
|
16
|
+
"issuing-card",
|
|
17
|
+
"issuing-cards-list",
|
|
18
|
+
"financial-account",
|
|
19
|
+
"financial-account-transactions",
|
|
20
|
+
"recipients",
|
|
21
|
+
"capital-financing",
|
|
22
|
+
"capital-financing-application",
|
|
23
|
+
"capital-financing-promotion",
|
|
24
|
+
"capital-overview",
|
|
25
|
+
"documents",
|
|
26
|
+
"product-tax-code-selector",
|
|
27
|
+
"export-tax-transactions",
|
|
28
|
+
"tax-registrations",
|
|
29
|
+
"tax-settings",
|
|
30
|
+
"tax-threshold-monitoring",
|
|
31
|
+
"balances",
|
|
32
|
+
"payouts-list",
|
|
33
|
+
"payout-details",
|
|
34
|
+
"app-install",
|
|
35
|
+
"app-viewport",
|
|
36
|
+
"reporting-chart",
|
|
37
|
+
"check-scanning",
|
|
38
|
+
"agentic-commerce-settings",
|
|
39
|
+
"terminal-hardware-orders",
|
|
40
|
+
"terminal-hardware-shop",
|
|
41
|
+
"network-cost-passthrough-report",
|
|
42
|
+
"balance-report",
|
|
43
|
+
"payout-reconciliation-report",
|
|
44
|
+
"recipients-list",
|
|
45
|
+
"financial-accounts",
|
|
46
|
+
"financial-accounts-transactions",
|
|
47
|
+
] as const;
|
|
48
|
+
|
|
49
|
+
// BEGIN: Setter definitions. All setters and their associated types are defined here. When adding a new component, if it has setters, they should be added here as well.
|
|
50
|
+
|
|
4
51
|
export type FetchEphemeralKeyFunction = (fetchParams: {
|
|
5
52
|
issuingCard: string;
|
|
6
53
|
nonce: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { ConnectElementTagName } from "../exportedTypes";
|
|
2
|
+
import type { ConnectElementCustomMethodConfig } from "./componentsAndSetters";
|
|
3
3
|
|
|
4
4
|
// ensure that keys of ConnectElementCustomMethodConfig are from ConnectElementTagName
|
|
5
5
|
export type HasType<T, Q extends T> = Q;
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
ConnectElementCustomMethodConfig,
|
|
3
2
|
ConnectElementCommonMethodConfig,
|
|
3
|
+
ConnectElementCustomMethodConfig,
|
|
4
|
+
connectElementTagNames,
|
|
4
5
|
EmbeddedError,
|
|
5
6
|
EmbeddedErrorType,
|
|
6
|
-
} from "
|
|
7
|
-
|
|
7
|
+
} from "../components/componentsAndSetters";
|
|
8
|
+
|
|
9
|
+
export type LoadConnectAndInitialize = (
|
|
8
10
|
initParams: IStripeConnectInitParams
|
|
9
11
|
) => StripeConnectInstance;
|
|
10
12
|
|
|
11
|
-
export
|
|
13
|
+
export interface StripeConnectWrapper {
|
|
14
|
+
initialize: (params: IStripeConnectInitParams) => StripeConnectInstance;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type OverlayOption = "dialog" | "drawer";
|
|
12
18
|
|
|
13
19
|
/*
|
|
14
20
|
* Use a `CssFontSource` to pass custom fonts via a stylesheet URL when initializing a Connect instance.
|
|
15
21
|
*/
|
|
16
|
-
export
|
|
22
|
+
export type CssFontSource = {
|
|
17
23
|
/**
|
|
18
24
|
* A relative or absolute URL pointing to a CSS file with [@font-face](https://developer.mozilla.org/en/docs/Web/CSS/@font-face) definitions, for example:
|
|
19
25
|
*
|
|
@@ -27,7 +33,7 @@ export declare type CssFontSource = {
|
|
|
27
33
|
/*
|
|
28
34
|
* Use a `CustomFontSource` to pass custom fonts when initializing a Connect instance.
|
|
29
35
|
*/
|
|
30
|
-
export
|
|
36
|
+
export type CustomFontSource = {
|
|
31
37
|
/**
|
|
32
38
|
* The name to give the font
|
|
33
39
|
*/
|
|
@@ -63,7 +69,7 @@ export declare type CustomFontSource = {
|
|
|
63
69
|
/**
|
|
64
70
|
* Appearance options for the Connect instance.
|
|
65
71
|
*/
|
|
66
|
-
export
|
|
72
|
+
export type AppearanceOptions = {
|
|
67
73
|
/**
|
|
68
74
|
* The type of overlay used throughout the Connect.js design system. Set this to be either a Dialog or Drawer.
|
|
69
75
|
*/
|
|
@@ -71,7 +77,7 @@ export declare type AppearanceOptions = {
|
|
|
71
77
|
variables?: AppearanceVariables;
|
|
72
78
|
};
|
|
73
79
|
|
|
74
|
-
export
|
|
80
|
+
export type AppearanceVariables = {
|
|
75
81
|
// Commonly used
|
|
76
82
|
|
|
77
83
|
/**
|
|
@@ -510,7 +516,7 @@ export type IStripeConnectUpdateParams = {
|
|
|
510
516
|
/**
|
|
511
517
|
* Reasons why risk signals collection was skipped.
|
|
512
518
|
*/
|
|
513
|
-
export
|
|
519
|
+
export type RiskSignalsCollectionSkippedReason =
|
|
514
520
|
/**
|
|
515
521
|
* Required component (account_onboarding) not enabled.
|
|
516
522
|
*/
|
|
@@ -527,7 +533,7 @@ export declare type RiskSignalsCollectionSkippedReason =
|
|
|
527
533
|
/**
|
|
528
534
|
* Error types that can occur during risk signals collection.
|
|
529
535
|
*/
|
|
530
|
-
export
|
|
536
|
+
export type RiskSignalsCollectionErrorType = Extract<
|
|
531
537
|
EmbeddedErrorType,
|
|
532
538
|
| "api_connection_error"
|
|
533
539
|
| "invalid_request_error"
|
|
@@ -538,7 +544,7 @@ export declare type RiskSignalsCollectionErrorType = Extract<
|
|
|
538
544
|
/**
|
|
539
545
|
* Errors that can occur during risk signals collection.
|
|
540
546
|
*/
|
|
541
|
-
export
|
|
547
|
+
export type RiskSignalsCollectionError =
|
|
542
548
|
/**
|
|
543
549
|
* Error occurred during general Connect.js loading.
|
|
544
550
|
*/
|
|
@@ -643,46 +649,4 @@ export interface StripeConnectInstance {
|
|
|
643
649
|
/**
|
|
644
650
|
* Tagnames to be used with the `create` method of the Connect instance.
|
|
645
651
|
*/
|
|
646
|
-
export type ConnectElementTagName =
|
|
647
|
-
| "payments"
|
|
648
|
-
| "payouts"
|
|
649
|
-
| "payment-details"
|
|
650
|
-
| "payment-disputes"
|
|
651
|
-
| "disputes-list"
|
|
652
|
-
| "account-onboarding"
|
|
653
|
-
| "payment-method-settings"
|
|
654
|
-
| "account-management"
|
|
655
|
-
| "notification-banner"
|
|
656
|
-
| "instant-payouts"
|
|
657
|
-
| "instant-payouts-promotion"
|
|
658
|
-
| "issuing-card"
|
|
659
|
-
| "issuing-cards-list"
|
|
660
|
-
| "financial-account"
|
|
661
|
-
| "financial-account-transactions"
|
|
662
|
-
| "recipients"
|
|
663
|
-
| "capital-financing"
|
|
664
|
-
| "capital-financing-application"
|
|
665
|
-
| "capital-financing-promotion"
|
|
666
|
-
| "capital-overview"
|
|
667
|
-
| "documents"
|
|
668
|
-
| "product-tax-code-selector"
|
|
669
|
-
| "export-tax-transactions"
|
|
670
|
-
| "tax-registrations"
|
|
671
|
-
| "tax-settings"
|
|
672
|
-
| "tax-threshold-monitoring"
|
|
673
|
-
| "balances"
|
|
674
|
-
| "payouts-list"
|
|
675
|
-
| "payout-details"
|
|
676
|
-
| "app-install"
|
|
677
|
-
| "app-viewport"
|
|
678
|
-
| "reporting-chart"
|
|
679
|
-
| "check-scanning"
|
|
680
|
-
| "agentic-commerce-settings"
|
|
681
|
-
| "terminal-hardware-orders"
|
|
682
|
-
| "terminal-hardware-shop"
|
|
683
|
-
| "network-cost-passthrough-report"
|
|
684
|
-
| "balance-report"
|
|
685
|
-
| "payout-reconciliation-report"
|
|
686
|
-
| "recipients-list"
|
|
687
|
-
| "financial-accounts"
|
|
688
|
-
| "financial-accounts-transactions";
|
|
652
|
+
export type ConnectElementTagName = (typeof connectElementTagNames)[number];
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
|
|
1
|
+
import { initStripeConnect, loadScript } from "./init";
|
|
2
|
+
import type {
|
|
3
|
+
IStripeConnectInitParams,
|
|
4
|
+
StripeConnectInstance,
|
|
5
|
+
LoadConnectAndInitialize,
|
|
6
|
+
} from "./exportedTypes/shared";
|
|
4
7
|
|
|
5
8
|
// Execute our own script injection after a tick to give users time to do their
|
|
6
9
|
// own script injection.
|
|
@@ -20,3 +23,6 @@ export const loadConnectAndInitialize: LoadConnectAndInitialize = (
|
|
|
20
23
|
loadCalled = true;
|
|
21
24
|
return initStripeConnect(stripePromise, initParams);
|
|
22
25
|
};
|
|
26
|
+
|
|
27
|
+
// Export all types from the exportedTypes folder
|
|
28
|
+
export * from "./exportedTypes";
|
|
@@ -1,156 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConnectElementCommonMethodConfig,
|
|
3
|
+
ConnectElementCustomMethodConfig,
|
|
4
|
+
connectElementTagNames,
|
|
5
|
+
} from "./components/componentsAndSetters";
|
|
6
|
+
import type { ConnectHTMLElementRecord } from "./exportedTypes/shared";
|
|
1
7
|
import type {
|
|
8
|
+
ConnectElementTagName,
|
|
2
9
|
IStripeConnectInitParams,
|
|
3
10
|
StripeConnectInstance,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "../types";
|
|
11
|
+
StripeConnectWrapper,
|
|
12
|
+
} from "./exportedTypes/shared";
|
|
7
13
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export type LoadConnectAndInitialize = (
|
|
13
|
-
initParams: IStripeConnectInitParams
|
|
14
|
-
) => StripeConnectInstance;
|
|
14
|
+
EXISTING_SCRIPT_MESSAGE,
|
|
15
|
+
findScript,
|
|
16
|
+
injectScript,
|
|
17
|
+
} from "./utils/scriptUtils";
|
|
15
18
|
|
|
16
|
-
export type ConnectElementHTMLName =
|
|
17
|
-
| "stripe-connect-payments"
|
|
18
|
-
| "stripe-connect-payouts"
|
|
19
|
-
| "stripe-connect-payment-details"
|
|
20
|
-
| "stripe-connect-payment-disputes"
|
|
21
|
-
| "stripe-connect-disputes-list"
|
|
22
|
-
| "stripe-connect-account-onboarding"
|
|
23
|
-
| "stripe-connect-payment-method-settings"
|
|
24
|
-
| "stripe-connect-account-management"
|
|
25
|
-
| "stripe-connect-notification-banner"
|
|
26
|
-
| "stripe-connect-instant-payouts"
|
|
27
|
-
| "stripe-connect-instant-payouts-promotion"
|
|
28
|
-
| "stripe-connect-issuing-card"
|
|
29
|
-
| "stripe-connect-issuing-cards-list"
|
|
30
|
-
| "stripe-connect-financial-account"
|
|
31
|
-
| "stripe-connect-financial-account-transactions"
|
|
32
|
-
| "stripe-connect-recipients"
|
|
33
|
-
| "stripe-connect-capital-financing"
|
|
34
|
-
| "stripe-connect-capital-financing-application"
|
|
35
|
-
| "stripe-connect-capital-financing-promotion"
|
|
36
|
-
| "stripe-connect-capital-overview"
|
|
37
|
-
| "stripe-connect-documents"
|
|
38
|
-
| "stripe-connect-product-tax-code-selector"
|
|
39
|
-
| "stripe-connect-export-tax-transactions"
|
|
40
|
-
| "stripe-connect-tax-registrations"
|
|
41
|
-
| "stripe-connect-tax-settings"
|
|
42
|
-
| "stripe-connect-tax-threshold-monitoring"
|
|
43
|
-
| "stripe-connect-balances"
|
|
44
|
-
| "stripe-connect-payouts-list"
|
|
45
|
-
| "stripe-connect-payout-details"
|
|
46
|
-
| "stripe-connect-app-install"
|
|
47
|
-
| "stripe-connect-app-viewport"
|
|
48
|
-
| "stripe-connect-reporting-chart"
|
|
49
|
-
| "stripe-connect-check-scanning"
|
|
50
|
-
| "stripe-connect-agentic-commerce-settings"
|
|
51
|
-
| "stripe-connect-terminal-hardware-orders"
|
|
52
|
-
| "stripe-connect-terminal-hardware-shop"
|
|
53
|
-
| "stripe-connect-network-cost-passthrough-report"
|
|
54
|
-
| "stripe-connect-balance-report"
|
|
55
|
-
| "stripe-connect-payout-reconciliation-report"
|
|
56
|
-
| "stripe-connect-recipients-list"
|
|
57
|
-
| "stripe-connect-financial-accounts"
|
|
58
|
-
| "stripe-connect-financial-accounts-transactions";
|
|
19
|
+
export type ConnectElementHTMLName = `stripe-connect-${ConnectElementTagName}`;
|
|
59
20
|
|
|
60
|
-
export const componentNameMapping
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"payment-disputes": "stripe-connect-payment-disputes",
|
|
68
|
-
"disputes-list": "stripe-connect-disputes-list",
|
|
69
|
-
"account-onboarding": "stripe-connect-account-onboarding",
|
|
70
|
-
"payment-method-settings": "stripe-connect-payment-method-settings",
|
|
71
|
-
"account-management": "stripe-connect-account-management",
|
|
72
|
-
"notification-banner": "stripe-connect-notification-banner",
|
|
73
|
-
"instant-payouts": "stripe-connect-instant-payouts",
|
|
74
|
-
"instant-payouts-promotion": "stripe-connect-instant-payouts-promotion",
|
|
75
|
-
"issuing-card": "stripe-connect-issuing-card",
|
|
76
|
-
"issuing-cards-list": "stripe-connect-issuing-cards-list",
|
|
77
|
-
"financial-account": "stripe-connect-financial-account",
|
|
78
|
-
recipients: "stripe-connect-recipients",
|
|
79
|
-
"financial-account-transactions":
|
|
80
|
-
"stripe-connect-financial-account-transactions",
|
|
81
|
-
"capital-financing": "stripe-connect-capital-financing",
|
|
82
|
-
"capital-financing-application":
|
|
83
|
-
"stripe-connect-capital-financing-application",
|
|
84
|
-
"capital-financing-promotion": "stripe-connect-capital-financing-promotion",
|
|
85
|
-
"capital-overview": "stripe-connect-capital-overview",
|
|
86
|
-
documents: "stripe-connect-documents",
|
|
87
|
-
"product-tax-code-selector": "stripe-connect-product-tax-code-selector",
|
|
88
|
-
"export-tax-transactions": "stripe-connect-export-tax-transactions",
|
|
89
|
-
"tax-registrations": "stripe-connect-tax-registrations",
|
|
90
|
-
"tax-settings": "stripe-connect-tax-settings",
|
|
91
|
-
"tax-threshold-monitoring": "stripe-connect-tax-threshold-monitoring",
|
|
92
|
-
balances: "stripe-connect-balances",
|
|
93
|
-
"payouts-list": "stripe-connect-payouts-list",
|
|
94
|
-
"payout-details": "stripe-connect-payout-details",
|
|
95
|
-
"app-install": "stripe-connect-app-install",
|
|
96
|
-
"app-viewport": "stripe-connect-app-viewport",
|
|
97
|
-
"reporting-chart": "stripe-connect-reporting-chart",
|
|
98
|
-
"check-scanning": "stripe-connect-check-scanning",
|
|
99
|
-
"agentic-commerce-settings": "stripe-connect-agentic-commerce-settings",
|
|
100
|
-
"terminal-hardware-orders": "stripe-connect-terminal-hardware-orders",
|
|
101
|
-
"terminal-hardware-shop": "stripe-connect-terminal-hardware-shop",
|
|
102
|
-
"network-cost-passthrough-report":
|
|
103
|
-
"stripe-connect-network-cost-passthrough-report",
|
|
104
|
-
"balance-report": "stripe-connect-balance-report",
|
|
105
|
-
"payout-reconciliation-report": "stripe-connect-payout-reconciliation-report",
|
|
106
|
-
"recipients-list": "stripe-connect-recipients-list",
|
|
107
|
-
"financial-accounts": "stripe-connect-financial-accounts",
|
|
108
|
-
"financial-accounts-transactions":
|
|
109
|
-
"stripe-connect-financial-accounts-transactions",
|
|
110
|
-
};
|
|
21
|
+
export const componentNameMapping = connectElementTagNames.reduce(
|
|
22
|
+
(acc, name) => {
|
|
23
|
+
acc[name] = `stripe-connect-${name}`;
|
|
24
|
+
return acc;
|
|
25
|
+
},
|
|
26
|
+
{} as Record<ConnectElementTagName, ConnectElementHTMLName>
|
|
27
|
+
);
|
|
111
28
|
|
|
112
29
|
type StripeConnectInstanceExtended = StripeConnectInstance & {
|
|
113
30
|
debugInstance: () => Promise<StripeConnectInstance>;
|
|
114
31
|
};
|
|
115
32
|
|
|
116
|
-
interface StripeConnectWrapper {
|
|
117
|
-
initialize: (params: IStripeConnectInitParams) => StripeConnectInstance;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const EXISTING_SCRIPT_MESSAGE =
|
|
121
|
-
"loadConnect was called but an existing Connect.js script already exists in the document; existing script parameters will be used";
|
|
122
|
-
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
123
|
-
const V1_URL = "https://connect-js.stripe.com/v1.0/connect.js";
|
|
124
|
-
|
|
125
|
-
export const findScript = (): HTMLScriptElement | null => {
|
|
126
|
-
return (
|
|
127
|
-
document.querySelectorAll<HTMLScriptElement>(
|
|
128
|
-
`script[src="${V0_URL}"]`
|
|
129
|
-
)[0] ||
|
|
130
|
-
document.querySelectorAll<HTMLScriptElement>(
|
|
131
|
-
`script[src="${V1_URL}"]`
|
|
132
|
-
)[0] ||
|
|
133
|
-
null
|
|
134
|
-
);
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const injectScript = (): HTMLScriptElement => {
|
|
138
|
-
const script = document.createElement("script");
|
|
139
|
-
script.src = V1_URL;
|
|
140
|
-
|
|
141
|
-
const head = document.head;
|
|
142
|
-
|
|
143
|
-
if (!head) {
|
|
144
|
-
throw new Error(
|
|
145
|
-
"Expected document.head not to be null. Connect.js requires a <head> element."
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
document.head.appendChild(script);
|
|
150
|
-
|
|
151
|
-
return script;
|
|
152
|
-
};
|
|
153
|
-
|
|
154
33
|
let stripePromise: Promise<StripeConnectWrapper> | null = null;
|
|
155
34
|
|
|
156
35
|
export const isWindowStripeConnectDefined = (stripeConnect: unknown) => {
|
package/src/pure.test.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
2
|
|
|
3
|
-
import type { IStripeConnectInitParams } from "
|
|
3
|
+
import type { IStripeConnectInitParams } from "./exportedTypes/shared";
|
|
4
4
|
import { SCRIPT_SELECTOR } from "./utils/jestHelpers";
|
|
5
5
|
|
|
6
6
|
describe("pure module", () => {
|