@stripe/connect-js 3.3.55-preview-1 → 3.4.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} +9 -91
- package/dist/components/componentsAndSettersChecks.d.ts +4 -0
- package/dist/connect.esm.js +27 -128
- package/dist/connect.js +29 -127
- package/dist/exportedTypes/index.d.ts +2 -0
- package/dist/exportedTypes/shared.d.ts +490 -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 +19 -120
- package/dist/pure.js +21 -119
- 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} +35 -145
- 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} +15 -120
- 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
|
@@ -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,23 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
ConnectElementCustomMethodConfig,
|
|
3
2
|
ConnectElementCommonMethodConfig,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "
|
|
7
|
-
|
|
3
|
+
ConnectElementCustomMethodConfig,
|
|
4
|
+
connectElementTagNames,
|
|
5
|
+
} from "../components/componentsAndSetters";
|
|
6
|
+
|
|
7
|
+
export type LoadConnectAndInitialize = (
|
|
8
8
|
initParams: IStripeConnectInitParams
|
|
9
9
|
) => StripeConnectInstance;
|
|
10
10
|
|
|
11
|
-
export
|
|
11
|
+
export interface StripeConnectWrapper {
|
|
12
|
+
initialize: (params: IStripeConnectInitParams) => StripeConnectInstance;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type OverlayOption = "dialog" | "drawer";
|
|
12
16
|
|
|
13
17
|
/*
|
|
14
18
|
* Use a `CssFontSource` to pass custom fonts via a stylesheet URL when initializing a Connect instance.
|
|
15
19
|
*/
|
|
16
|
-
export
|
|
20
|
+
export type CssFontSource = {
|
|
17
21
|
/**
|
|
18
22
|
* 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
23
|
*
|
|
@@ -27,7 +31,7 @@ export declare type CssFontSource = {
|
|
|
27
31
|
/*
|
|
28
32
|
* Use a `CustomFontSource` to pass custom fonts when initializing a Connect instance.
|
|
29
33
|
*/
|
|
30
|
-
export
|
|
34
|
+
export type CustomFontSource = {
|
|
31
35
|
/**
|
|
32
36
|
* The name to give the font
|
|
33
37
|
*/
|
|
@@ -63,7 +67,7 @@ export declare type CustomFontSource = {
|
|
|
63
67
|
/**
|
|
64
68
|
* Appearance options for the Connect instance.
|
|
65
69
|
*/
|
|
66
|
-
export
|
|
70
|
+
export type AppearanceOptions = {
|
|
67
71
|
/**
|
|
68
72
|
* The type of overlay used throughout the Connect.js design system. Set this to be either a Dialog or Drawer.
|
|
69
73
|
*/
|
|
@@ -71,7 +75,7 @@ export declare type AppearanceOptions = {
|
|
|
71
75
|
variables?: AppearanceVariables;
|
|
72
76
|
};
|
|
73
77
|
|
|
74
|
-
export
|
|
78
|
+
export type AppearanceVariables = {
|
|
75
79
|
// Commonly used
|
|
76
80
|
|
|
77
81
|
/**
|
|
@@ -507,67 +511,6 @@ export type IStripeConnectUpdateParams = {
|
|
|
507
511
|
locale?: string;
|
|
508
512
|
};
|
|
509
513
|
|
|
510
|
-
/**
|
|
511
|
-
* Reasons why risk signals collection was skipped.
|
|
512
|
-
*/
|
|
513
|
-
export declare type RiskSignalsCollectionSkippedReason =
|
|
514
|
-
/**
|
|
515
|
-
* Required component (account_onboarding) not enabled.
|
|
516
|
-
*/
|
|
517
|
-
| "required_component_not_enabled"
|
|
518
|
-
/**
|
|
519
|
-
* The account doesn't have a risk signals collection requirement.
|
|
520
|
-
*/
|
|
521
|
-
| "not_required"
|
|
522
|
-
/**
|
|
523
|
-
* The risk signals collection requirement has already been fulfilled.
|
|
524
|
-
*/
|
|
525
|
-
| "requirement_fulfilled";
|
|
526
|
-
|
|
527
|
-
/**
|
|
528
|
-
* Error types that can occur during risk signals collection.
|
|
529
|
-
*/
|
|
530
|
-
export declare type RiskSignalsCollectionErrorType = Extract<
|
|
531
|
-
EmbeddedErrorType,
|
|
532
|
-
| "api_connection_error"
|
|
533
|
-
| "invalid_request_error"
|
|
534
|
-
| "rate_limit_error"
|
|
535
|
-
| "api_error"
|
|
536
|
-
>;
|
|
537
|
-
|
|
538
|
-
/**
|
|
539
|
-
* Errors that can occur during risk signals collection.
|
|
540
|
-
*/
|
|
541
|
-
export declare type RiskSignalsCollectionError =
|
|
542
|
-
/**
|
|
543
|
-
* Error occurred during general Connect.js loading.
|
|
544
|
-
*/
|
|
545
|
-
| { type: "load_error"; loadError: EmbeddedError }
|
|
546
|
-
|
|
547
|
-
/**
|
|
548
|
-
* Error occurred during risk signals collection.
|
|
549
|
-
*/
|
|
550
|
-
| { type: RiskSignalsCollectionErrorType; message?: string };
|
|
551
|
-
|
|
552
|
-
/**
|
|
553
|
-
* Event emitted during risk signals collection.
|
|
554
|
-
*/
|
|
555
|
-
export declare type RiskSignalsCollectionEvent =
|
|
556
|
-
/**
|
|
557
|
-
* Risk signals collection completed and successfully received by Stripe.
|
|
558
|
-
*/
|
|
559
|
-
| { status: "completed" }
|
|
560
|
-
|
|
561
|
-
/**
|
|
562
|
-
* Risk signals collection skipped with reason.
|
|
563
|
-
*/
|
|
564
|
-
| { status: "skipped"; skippedReason: RiskSignalsCollectionSkippedReason }
|
|
565
|
-
|
|
566
|
-
/**
|
|
567
|
-
* Risk signals collection failed due to error and was not sent to Stripe server.
|
|
568
|
-
*/
|
|
569
|
-
| { status: "failed"; error: RiskSignalsCollectionError };
|
|
570
|
-
|
|
571
514
|
/**
|
|
572
515
|
* Initialization parameters for Connect JS. See https://stripe.com/docs/connect/get-started-connect-embedded-components#configuring-connect-js for more details.
|
|
573
516
|
*/
|
|
@@ -598,12 +541,6 @@ export interface IStripeConnectInitParams {
|
|
|
598
541
|
* An array of custom fonts, which embedded components created from a ConnectInstance can use.
|
|
599
542
|
*/
|
|
600
543
|
fonts?: Array<CssFontSource | CustomFontSource>;
|
|
601
|
-
|
|
602
|
-
/**
|
|
603
|
-
* Callback for risk signals collection event
|
|
604
|
-
* @param {RiskSignalsCollectionEvent} event - The risk signals collection event containing status and additional details.
|
|
605
|
-
*/
|
|
606
|
-
onRiskSignalsCollection?: (event: RiskSignalsCollectionEvent) => void;
|
|
607
544
|
}
|
|
608
545
|
|
|
609
546
|
type ConnectElementCustomMethods = typeof ConnectElementCustomMethodConfig;
|
|
@@ -643,46 +580,4 @@ export interface StripeConnectInstance {
|
|
|
643
580
|
/**
|
|
644
581
|
* Tagnames to be used with the `create` method of the Connect instance.
|
|
645
582
|
*/
|
|
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";
|
|
583
|
+
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", () => {
|
package/src/pure.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
|
|
1
|
+
import { initStripeConnect, loadScript } from "./init";
|
|
2
|
+
import type {
|
|
3
|
+
IStripeConnectInitParams,
|
|
4
|
+
LoadConnectAndInitialize,
|
|
5
|
+
StripeConnectInstance,
|
|
6
|
+
} from "./exportedTypes/shared";
|
|
4
7
|
|
|
5
8
|
export const loadConnectAndInitialize: LoadConnectAndInitialize = (
|
|
6
9
|
initParams: IStripeConnectInitParams
|
|
@@ -13,3 +16,6 @@ export const loadConnectAndInitialize: LoadConnectAndInitialize = (
|
|
|
13
16
|
}
|
|
14
17
|
return initStripeConnect(maybeConnect, initParams);
|
|
15
18
|
};
|
|
19
|
+
|
|
20
|
+
// Export all types from the exportedTypes folder
|
|
21
|
+
export * from "./exportedTypes";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const EXISTING_SCRIPT_MESSAGE =
|
|
2
|
+
"loadConnect was called but an existing Connect.js script already exists in the document; existing script parameters will be used";
|
|
3
|
+
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
4
|
+
const V1_URL = "https://connect-js.stripe.com/v1.0/connect.js";
|
|
5
|
+
|
|
6
|
+
export const findScript = (): HTMLScriptElement | null => {
|
|
7
|
+
return (
|
|
8
|
+
document.querySelectorAll<HTMLScriptElement>(
|
|
9
|
+
`script[src="${V1_URL}"]`
|
|
10
|
+
)[0] ||
|
|
11
|
+
document.querySelectorAll<HTMLScriptElement>(
|
|
12
|
+
`script[src="${V0_URL}"]`
|
|
13
|
+
)[0] ||
|
|
14
|
+
null
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const injectScript = (): HTMLScriptElement => {
|
|
19
|
+
const script = document.createElement("script");
|
|
20
|
+
script.src = V1_URL;
|
|
21
|
+
|
|
22
|
+
const head = document.head;
|
|
23
|
+
|
|
24
|
+
if (!head) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
"Expected document.head not to be null. Connect.js requires a <head> element."
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
document.head.appendChild(script);
|
|
31
|
+
|
|
32
|
+
return script;
|
|
33
|
+
};
|
package/dist/src/index.d.ts
DELETED
package/dist/src/pure.d.ts
DELETED
package/dist/src/shared.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { IStripeConnectInitParams, StripeConnectInstance, ConnectElementTagName } from "../types";
|
|
2
|
-
export type LoadConnectAndInitialize = (initParams: IStripeConnectInitParams) => StripeConnectInstance;
|
|
3
|
-
export type ConnectElementHTMLName = "stripe-connect-payments" | "stripe-connect-payouts" | "stripe-connect-payment-details" | "stripe-connect-payment-disputes" | "stripe-connect-disputes-list" | "stripe-connect-account-onboarding" | "stripe-connect-payment-method-settings" | "stripe-connect-account-management" | "stripe-connect-notification-banner" | "stripe-connect-instant-payouts" | "stripe-connect-instant-payouts-promotion" | "stripe-connect-issuing-card" | "stripe-connect-issuing-cards-list" | "stripe-connect-financial-account" | "stripe-connect-financial-account-transactions" | "stripe-connect-recipients" | "stripe-connect-capital-financing" | "stripe-connect-capital-financing-application" | "stripe-connect-capital-financing-promotion" | "stripe-connect-capital-overview" | "stripe-connect-documents" | "stripe-connect-product-tax-code-selector" | "stripe-connect-export-tax-transactions" | "stripe-connect-tax-registrations" | "stripe-connect-tax-settings" | "stripe-connect-tax-threshold-monitoring" | "stripe-connect-balances" | "stripe-connect-payouts-list" | "stripe-connect-payout-details" | "stripe-connect-app-install" | "stripe-connect-app-viewport" | "stripe-connect-reporting-chart" | "stripe-connect-check-scanning" | "stripe-connect-agentic-commerce-settings" | "stripe-connect-terminal-hardware-orders" | "stripe-connect-terminal-hardware-shop" | "stripe-connect-network-cost-passthrough-report" | "stripe-connect-balance-report" | "stripe-connect-payout-reconciliation-report" | "stripe-connect-recipients-list" | "stripe-connect-financial-accounts" | "stripe-connect-financial-accounts-transactions";
|
|
4
|
-
export declare const componentNameMapping: Record<ConnectElementTagName, ConnectElementHTMLName>;
|
|
5
|
-
type StripeConnectInstanceExtended = StripeConnectInstance & {
|
|
6
|
-
debugInstance: () => Promise<StripeConnectInstance>;
|
|
7
|
-
};
|
|
8
|
-
interface StripeConnectWrapper {
|
|
9
|
-
initialize: (params: IStripeConnectInitParams) => StripeConnectInstance;
|
|
10
|
-
}
|
|
11
|
-
export declare const findScript: () => HTMLScriptElement | null;
|
|
12
|
-
export declare const isWindowStripeConnectDefined: (stripeConnect: unknown) => boolean;
|
|
13
|
-
export declare const loadScript: () => Promise<StripeConnectWrapper>;
|
|
14
|
-
export declare const initStripeConnect: (stripePromise: Promise<StripeConnectWrapper>, initParams: IStripeConnectInitParams) => StripeConnectInstanceExtended;
|
|
15
|
-
export {};
|
package/types/.eslintrc.yml
DELETED
package/types/index.d.ts
DELETED
|
File without changes
|
|
File without changes
|