@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,3 +1,4 @@
|
|
|
1
|
+
export declare const connectElementTagNames: readonly ["account-onboarding", "disputes-list", "payments", "payment-details", "payment-disputes", "payouts", "payouts-list", "payout-details", "balances", "account-management", "notification-banner", "instant-payouts-promotion", "issuing-card", "issuing-cards-list", "financial-account", "financial-account-transactions", "documents", "tax-registrations", "tax-settings", "balance-report", "payout-reconciliation-report"];
|
|
1
2
|
export type FetchEphemeralKeyFunction = (fetchParams: {
|
|
2
3
|
issuingCard: string;
|
|
3
4
|
nonce: string;
|
|
@@ -47,10 +48,6 @@ export type NotificationCount = {
|
|
|
47
48
|
total: number;
|
|
48
49
|
actionRequired: number;
|
|
49
50
|
};
|
|
50
|
-
export type InstallState = {
|
|
51
|
-
appId: string;
|
|
52
|
-
state: "INSTALLED" | "UNINSTALLED";
|
|
53
|
-
};
|
|
54
51
|
export type LoaderStart = {
|
|
55
52
|
elementTagName: string;
|
|
56
53
|
};
|
|
@@ -65,14 +62,6 @@ export type EmbeddedError = {
|
|
|
65
62
|
type: EmbeddedErrorType;
|
|
66
63
|
message?: string;
|
|
67
64
|
};
|
|
68
|
-
export type FinancingProductType = {
|
|
69
|
-
productType: "standard" | "refill" | "none";
|
|
70
|
-
activeFinancingCount: number;
|
|
71
|
-
};
|
|
72
|
-
export type FinancingPromotionLayoutType = "full" | "banner";
|
|
73
|
-
export type IntervalType = "day" | "week" | "month" | "quarter" | "year";
|
|
74
|
-
export type ReportName = "gross_volume" | "net_volume";
|
|
75
|
-
export type RecipientDataSource = "customers";
|
|
76
65
|
export type EmbeddedErrorType =
|
|
77
66
|
/**
|
|
78
67
|
* Failure to connect to Stripe's API.
|
|
@@ -107,19 +96,6 @@ export declare const ConnectElementCommonMethodConfig: {
|
|
|
107
96
|
setOnLoaderStart: (_listener: (({ elementTagName }: LoaderStart) => void) | undefined) => void;
|
|
108
97
|
};
|
|
109
98
|
export declare const ConnectElementCustomMethodConfig: {
|
|
110
|
-
payments: {
|
|
111
|
-
setDefaultFilters: (_filters: PaymentsListDefaultFilters | undefined) => void;
|
|
112
|
-
};
|
|
113
|
-
"payment-details": {
|
|
114
|
-
setPayment: (_payment: string | undefined) => void;
|
|
115
|
-
setOnClose: (_listener: (() => void) | undefined) => void;
|
|
116
|
-
};
|
|
117
|
-
"payment-disputes": {
|
|
118
|
-
setPayment: (_payment: string | undefined) => void;
|
|
119
|
-
setOnDisputesLoaded: (_listener: (({ total }: {
|
|
120
|
-
total: number;
|
|
121
|
-
}) => void) | undefined) => void;
|
|
122
|
-
};
|
|
123
99
|
"account-onboarding": {
|
|
124
100
|
setFullTermsOfServiceUrl: (_termOfServiceUrl: string | undefined) => void;
|
|
125
101
|
setRecipientTermsOfServiceUrl: (_recipientTermsOfServiceUrl: string | undefined) => void;
|
|
@@ -161,52 +137,19 @@ export declare const ConnectElementCustomMethodConfig: {
|
|
|
161
137
|
"financial-account-transactions": {
|
|
162
138
|
setFinancialAccount: (_financialAccount: string) => void;
|
|
163
139
|
};
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
};
|
|
167
|
-
"app-install": {
|
|
168
|
-
setApp: (_app: string | undefined) => void;
|
|
169
|
-
setOnAppInstallStateFetched: (_listener: (({ appId, state }: InstallState) => void) | undefined) => void;
|
|
170
|
-
setOnAppInstallStateChanged: (_listener: (({ appId, state }: InstallState) => void) | undefined) => void;
|
|
171
|
-
};
|
|
172
|
-
"app-viewport": {
|
|
173
|
-
setApp: (_app: string | undefined) => void;
|
|
174
|
-
setAppData: (_appData: Record<string, string> | undefined) => void;
|
|
140
|
+
payments: {
|
|
141
|
+
setDefaultFilters: (_filters: PaymentsListDefaultFilters | undefined) => void;
|
|
175
142
|
};
|
|
176
|
-
"payment-
|
|
177
|
-
|
|
143
|
+
"payment-details": {
|
|
144
|
+
setPayment: (_payment: string | undefined) => void;
|
|
145
|
+
setOnClose: (_listener: (() => void) | undefined) => void;
|
|
178
146
|
};
|
|
179
|
-
"
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
setHowCapitalWorksUrl: (_howCapitalWorksUrl: string | undefined) => void;
|
|
183
|
-
setSupportUrl: (_supportUrl: string | undefined) => void;
|
|
184
|
-
setOnFinancingsLoaded: (_listener: (({ total }: {
|
|
147
|
+
"payment-disputes": {
|
|
148
|
+
setPayment: (_payment: string | undefined) => void;
|
|
149
|
+
setOnDisputesLoaded: (_listener: (({ total }: {
|
|
185
150
|
total: number;
|
|
186
151
|
}) => void) | undefined) => void;
|
|
187
152
|
};
|
|
188
|
-
"capital-financing-application": {
|
|
189
|
-
setOnApplicationSubmitted: (_listener: (() => void) | undefined) => void;
|
|
190
|
-
setPrivacyPolicyUrl: (_privacyPolicyUrl: string | undefined) => void;
|
|
191
|
-
setHowCapitalWorksUrl: (_howCapitalWorksUrl: string | undefined) => void;
|
|
192
|
-
setOnApplicationStepChange: (_listener: (({ step }: StepChange) => void) | undefined) => void;
|
|
193
|
-
setDefaultFinancingOffer: (_defaultFinancingOffer: string | undefined) => void;
|
|
194
|
-
};
|
|
195
|
-
"capital-financing-promotion": {
|
|
196
|
-
setLayout: (_layout: FinancingPromotionLayoutType | undefined) => void;
|
|
197
|
-
setOnApplicationSubmitted: (_listener: (() => void) | undefined) => void;
|
|
198
|
-
setOnEligibleFinancingOfferLoaded: (_listener: (({ productType, activeFinancingCount, }: FinancingProductType) => void) | undefined) => void;
|
|
199
|
-
setPrivacyPolicyUrl: (_privacyPolicyUrl: string | undefined) => void;
|
|
200
|
-
setHowCapitalWorksUrl: (_howCapitalWorksUrl: string | undefined) => void;
|
|
201
|
-
setEligibilityCriteriaUrl: (_eligibilityCriteriaUrl: string | undefined) => void;
|
|
202
|
-
setOnApplicationStepChange: (_listener: (({ step }: StepChange) => void) | undefined) => void;
|
|
203
|
-
};
|
|
204
|
-
"reporting-chart": {
|
|
205
|
-
setReportName: (_reportName: ReportName) => void;
|
|
206
|
-
setIntervalStart: (_intervalStart: Date | undefined) => void;
|
|
207
|
-
setIntervalEnd: (_intervalEnd: Date | undefined) => void;
|
|
208
|
-
setIntervalType: (_intervalType: IntervalType | undefined) => void;
|
|
209
|
-
};
|
|
210
153
|
"tax-settings": {
|
|
211
154
|
setHideProductTaxCodeSelector: (_hidden: boolean | undefined) => void;
|
|
212
155
|
setDisplayHeadOfficeCountries: (_countries: string[] | undefined) => void;
|
|
@@ -223,35 +166,10 @@ export declare const ConnectElementCustomMethodConfig: {
|
|
|
223
166
|
id: string;
|
|
224
167
|
}) => void) | undefined) => void;
|
|
225
168
|
};
|
|
226
|
-
"tax-threshold-monitoring": {
|
|
227
|
-
setDisplayCountries: (_countries: string[] | undefined) => void;
|
|
228
|
-
};
|
|
229
|
-
"product-tax-code-selector": {
|
|
230
|
-
setOnTaxCodeSelect: (_listener: ((taxCode: string | null, _: {
|
|
231
|
-
analyticsName: string;
|
|
232
|
-
} | null) => void) | undefined) => void;
|
|
233
|
-
setHideDescription: (_hideDescription: boolean | undefined) => void;
|
|
234
|
-
setDisabled: (_disabled: boolean | undefined) => void;
|
|
235
|
-
setInitialTaxCode: (_initialTaxCode: string | undefined) => void;
|
|
236
|
-
};
|
|
237
|
-
"export-tax-transactions": {};
|
|
238
169
|
"payout-details": {
|
|
239
170
|
setPayout: (_payout: string | undefined) => void;
|
|
240
171
|
setOnClose: (_listener: (() => void) | undefined) => void;
|
|
241
172
|
};
|
|
242
|
-
"check-scanning": {
|
|
243
|
-
setHandleCheckScanSubmitted: (_handleCheckScanSubmitted: ({ checkScanToken, }: {
|
|
244
|
-
checkScanToken: string;
|
|
245
|
-
}) => Promise<void>) => void;
|
|
246
|
-
};
|
|
247
|
-
"agentic-commerce-settings": {
|
|
248
|
-
setOnAgreementUpdated: (_listener: (({ agreementId }: {
|
|
249
|
-
agreementId: string;
|
|
250
|
-
}) => void) | undefined) => void;
|
|
251
|
-
};
|
|
252
|
-
"terminal-hardware-shop": {
|
|
253
|
-
setOnCheckoutFinished: (_listener: (() => void) | undefined) => void;
|
|
254
|
-
};
|
|
255
173
|
"payout-reconciliation-report": {
|
|
256
174
|
setOnReportAvailabilityLoaded: (_listener: (({ isReportAvailable }: {
|
|
257
175
|
isReportAvailable: boolean;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ConnectElementTagName } from "../exportedTypes";
|
|
2
|
+
import type { ConnectElementCustomMethodConfig } from "./componentsAndSetters";
|
|
3
|
+
export type HasType<T, Q extends T> = Q;
|
|
4
|
+
export type CustomMethodConfigValidation = HasType<ConnectElementTagName, keyof typeof ConnectElementCustomMethodConfig>;
|
package/dist/connect.esm.js
CHANGED
|
@@ -1,21 +1,11 @@
|
|
|
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 = ["account-onboarding", "disputes-list", "payments", "payment-details", "payment-disputes", "payouts", "payouts-list", "payout-details", "balances", "account-management", "notification-banner", "instant-payouts-promotion", "issuing-card", "issuing-cards-list", "financial-account", "financial-account-transactions", "documents", "tax-registrations", "tax-settings", "balance-report", "payout-reconciliation-report"];
|
|
3
4
|
const ConnectElementCommonMethodConfig = {
|
|
4
5
|
setOnLoadError: _listener => {},
|
|
5
6
|
setOnLoaderStart: _listener => {}
|
|
6
7
|
};
|
|
7
8
|
const ConnectElementCustomMethodConfig = {
|
|
8
|
-
payments: {
|
|
9
|
-
setDefaultFilters: _filters => {}
|
|
10
|
-
},
|
|
11
|
-
"payment-details": {
|
|
12
|
-
setPayment: _payment => {},
|
|
13
|
-
setOnClose: _listener => {}
|
|
14
|
-
},
|
|
15
|
-
"payment-disputes": {
|
|
16
|
-
setPayment: _payment => {},
|
|
17
|
-
setOnDisputesLoaded: _listener => {}
|
|
18
|
-
},
|
|
19
9
|
"account-onboarding": {
|
|
20
10
|
setFullTermsOfServiceUrl: _termOfServiceUrl => {},
|
|
21
11
|
setRecipientTermsOfServiceUrl: _recipientTermsOfServiceUrl => {},
|
|
@@ -53,49 +43,16 @@ const ConnectElementCustomMethodConfig = {
|
|
|
53
43
|
"financial-account-transactions": {
|
|
54
44
|
setFinancialAccount: _financialAccount => {}
|
|
55
45
|
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
},
|
|
59
|
-
"app-install": {
|
|
60
|
-
setApp: _app => {},
|
|
61
|
-
setOnAppInstallStateFetched: _listener => {},
|
|
62
|
-
setOnAppInstallStateChanged: _listener => {}
|
|
63
|
-
},
|
|
64
|
-
"app-viewport": {
|
|
65
|
-
setApp: _app => {},
|
|
66
|
-
setAppData: _appData => {}
|
|
67
|
-
},
|
|
68
|
-
"payment-method-settings": {
|
|
69
|
-
setPaymentMethodConfiguration: _paymentMethodConfiguration => {}
|
|
70
|
-
},
|
|
71
|
-
"capital-financing": {
|
|
72
|
-
setDefaultFinancingOffer: _defaultFinancingOffer => {},
|
|
73
|
-
setShowFinancingSelector: _showFinancingSelector => {},
|
|
74
|
-
setHowCapitalWorksUrl: _howCapitalWorksUrl => {},
|
|
75
|
-
setSupportUrl: _supportUrl => {},
|
|
76
|
-
setOnFinancingsLoaded: _listener => {}
|
|
77
|
-
},
|
|
78
|
-
"capital-financing-application": {
|
|
79
|
-
setOnApplicationSubmitted: _listener => {},
|
|
80
|
-
setPrivacyPolicyUrl: _privacyPolicyUrl => {},
|
|
81
|
-
setHowCapitalWorksUrl: _howCapitalWorksUrl => {},
|
|
82
|
-
setOnApplicationStepChange: _listener => {},
|
|
83
|
-
setDefaultFinancingOffer: _defaultFinancingOffer => {}
|
|
46
|
+
payments: {
|
|
47
|
+
setDefaultFilters: _filters => {}
|
|
84
48
|
},
|
|
85
|
-
"
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
setOnEligibleFinancingOfferLoaded: _listener => {},
|
|
89
|
-
setPrivacyPolicyUrl: _privacyPolicyUrl => {},
|
|
90
|
-
setHowCapitalWorksUrl: _howCapitalWorksUrl => {},
|
|
91
|
-
setEligibilityCriteriaUrl: _eligibilityCriteriaUrl => {},
|
|
92
|
-
setOnApplicationStepChange: _listener => {}
|
|
49
|
+
"payment-details": {
|
|
50
|
+
setPayment: _payment => {},
|
|
51
|
+
setOnClose: _listener => {}
|
|
93
52
|
},
|
|
94
|
-
"
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
setIntervalEnd: _intervalEnd => {},
|
|
98
|
-
setIntervalType: _intervalType => {}
|
|
53
|
+
"payment-disputes": {
|
|
54
|
+
setPayment: _payment => {},
|
|
55
|
+
setOnDisputesLoaded: _listener => {}
|
|
99
56
|
},
|
|
100
57
|
"tax-settings": {
|
|
101
58
|
setHideProductTaxCodeSelector: _hidden => {},
|
|
@@ -107,83 +64,20 @@ const ConnectElementCustomMethodConfig = {
|
|
|
107
64
|
setDisplayCountries: _countries => {},
|
|
108
65
|
setOnAfterTaxRegistrationExpired: _listener => {}
|
|
109
66
|
},
|
|
110
|
-
"tax-threshold-monitoring": {
|
|
111
|
-
setDisplayCountries: _countries => {}
|
|
112
|
-
},
|
|
113
|
-
"product-tax-code-selector": {
|
|
114
|
-
setOnTaxCodeSelect: _listener => {},
|
|
115
|
-
setHideDescription: _hideDescription => {},
|
|
116
|
-
setDisabled: _disabled => {},
|
|
117
|
-
setInitialTaxCode: _initialTaxCode => {}
|
|
118
|
-
},
|
|
119
|
-
"export-tax-transactions": {},
|
|
120
67
|
"payout-details": {
|
|
121
68
|
setPayout: _payout => {},
|
|
122
69
|
setOnClose: _listener => {}
|
|
123
70
|
},
|
|
124
|
-
"check-scanning": {
|
|
125
|
-
setHandleCheckScanSubmitted: _handleCheckScanSubmitted => {}
|
|
126
|
-
},
|
|
127
|
-
"agentic-commerce-settings": {
|
|
128
|
-
setOnAgreementUpdated: _listener => {}
|
|
129
|
-
},
|
|
130
|
-
"terminal-hardware-shop": {
|
|
131
|
-
setOnCheckoutFinished: _listener => {}
|
|
132
|
-
},
|
|
133
71
|
"payout-reconciliation-report": {
|
|
134
72
|
setOnReportAvailabilityLoaded: _listener => {}
|
|
135
73
|
}
|
|
136
74
|
};
|
|
137
75
|
|
|
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
76
|
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
77
|
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
184
78
|
const V1_URL = "https://connect-js.stripe.com/v1.0/connect.js";
|
|
185
79
|
const findScript = () => {
|
|
186
|
-
return document.querySelectorAll(`script[src="${
|
|
80
|
+
return document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
|
|
187
81
|
};
|
|
188
82
|
const injectScript = () => {
|
|
189
83
|
const script = document.createElement("script");
|
|
@@ -195,7 +89,12 @@ const injectScript = () => {
|
|
|
195
89
|
document.head.appendChild(script);
|
|
196
90
|
return script;
|
|
197
91
|
};
|
|
198
|
-
|
|
92
|
+
|
|
93
|
+
const componentNameMapping = connectElementTagNames.reduce((acc, name) => {
|
|
94
|
+
acc[name] = `stripe-connect-${name}`;
|
|
95
|
+
return acc;
|
|
96
|
+
}, {});
|
|
97
|
+
let stripePromise$1 = null;
|
|
199
98
|
const isWindowStripeConnectDefined = stripeConnect => {
|
|
200
99
|
// We only consider `StripeConnect` defined if `init` is a function
|
|
201
100
|
// Why? HTML markup like:
|
|
@@ -205,10 +104,10 @@ const isWindowStripeConnectDefined = stripeConnect => {
|
|
|
205
104
|
};
|
|
206
105
|
const loadScript = () => {
|
|
207
106
|
// Ensure that we only attempt to load Connect.js at most once
|
|
208
|
-
if (stripePromise !== null) {
|
|
209
|
-
return stripePromise;
|
|
107
|
+
if (stripePromise$1 !== null) {
|
|
108
|
+
return stripePromise$1;
|
|
210
109
|
}
|
|
211
|
-
stripePromise = new Promise((resolve, reject) => {
|
|
110
|
+
stripePromise$1 = new Promise((resolve, reject) => {
|
|
212
111
|
if (typeof window === "undefined") {
|
|
213
112
|
reject("ConnectJS won't load when rendering code in the server - it can only be loaded on a browser. This error is expected when loading ConnectJS in SSR environments, like NextJS. It will have no impact in the UI, however if you wish to avoid it, you can switch to the `pure` version of the connect.js loader: https://github.com/stripe/connect-js#importing-loadconnect-without-side-effects.");
|
|
214
113
|
return;
|
|
@@ -241,7 +140,7 @@ const loadScript = () => {
|
|
|
241
140
|
reject(error);
|
|
242
141
|
}
|
|
243
142
|
});
|
|
244
|
-
return stripePromise;
|
|
143
|
+
return stripePromise$1;
|
|
245
144
|
};
|
|
246
145
|
const hasCustomMethod = tagName => {
|
|
247
146
|
return tagName in ConnectElementCustomMethodConfig;
|
|
@@ -274,7 +173,7 @@ const initStripeConnect = (stripePromise, initParams) => {
|
|
|
274
173
|
element[method] = function (value) {
|
|
275
174
|
stripeConnectInstance.then(() => {
|
|
276
175
|
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.
|
|
176
|
+
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`);
|
|
278
177
|
}
|
|
279
178
|
this[`${method}InternalOnly`](value);
|
|
280
179
|
});
|
|
@@ -328,7 +227,7 @@ const createWrapper = stripeConnect => {
|
|
|
328
227
|
sdk: true,
|
|
329
228
|
sdkOptions: {
|
|
330
229
|
// This will be replaced by the npm package version when bundling
|
|
331
|
-
sdkVersion: "3.
|
|
230
|
+
sdkVersion: "3.4.1"
|
|
332
231
|
}
|
|
333
232
|
})
|
|
334
233
|
}));
|
|
@@ -340,16 +239,16 @@ const createWrapper = stripeConnect => {
|
|
|
340
239
|
|
|
341
240
|
// Execute our own script injection after a tick to give users time to do their
|
|
342
241
|
// own script injection.
|
|
343
|
-
const stripePromise
|
|
242
|
+
const stripePromise = Promise.resolve().then(() => loadScript());
|
|
344
243
|
let loadCalled = false;
|
|
345
|
-
stripePromise
|
|
244
|
+
stripePromise.catch(err => {
|
|
346
245
|
if (!loadCalled) {
|
|
347
246
|
console.warn(err);
|
|
348
247
|
}
|
|
349
248
|
});
|
|
350
249
|
const loadConnectAndInitialize = initParams => {
|
|
351
250
|
loadCalled = true;
|
|
352
|
-
return initStripeConnect(stripePromise
|
|
251
|
+
return initStripeConnect(stripePromise, initParams);
|
|
353
252
|
};
|
|
354
253
|
|
|
355
|
-
export { loadConnectAndInitialize };
|
|
254
|
+
export { ConnectElementCommonMethodConfig, ConnectElementCustomMethodConfig, connectElementTagNames, loadConnectAndInitialize };
|
package/dist/connect.js
CHANGED
|
@@ -2,24 +2,14 @@
|
|
|
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 = ["account-onboarding", "disputes-list", "payments", "payment-details", "payment-disputes", "payouts", "payouts-list", "payout-details", "balances", "account-management", "notification-banner", "instant-payouts-promotion", "issuing-card", "issuing-cards-list", "financial-account", "financial-account-transactions", "documents", "tax-registrations", "tax-settings", "balance-report", "payout-reconciliation-report"];
|
|
7
8
|
const ConnectElementCommonMethodConfig = {
|
|
8
9
|
setOnLoadError: _listener => {},
|
|
9
10
|
setOnLoaderStart: _listener => {}
|
|
10
11
|
};
|
|
11
12
|
const ConnectElementCustomMethodConfig = {
|
|
12
|
-
payments: {
|
|
13
|
-
setDefaultFilters: _filters => {}
|
|
14
|
-
},
|
|
15
|
-
"payment-details": {
|
|
16
|
-
setPayment: _payment => {},
|
|
17
|
-
setOnClose: _listener => {}
|
|
18
|
-
},
|
|
19
|
-
"payment-disputes": {
|
|
20
|
-
setPayment: _payment => {},
|
|
21
|
-
setOnDisputesLoaded: _listener => {}
|
|
22
|
-
},
|
|
23
13
|
"account-onboarding": {
|
|
24
14
|
setFullTermsOfServiceUrl: _termOfServiceUrl => {},
|
|
25
15
|
setRecipientTermsOfServiceUrl: _recipientTermsOfServiceUrl => {},
|
|
@@ -57,49 +47,16 @@ const ConnectElementCustomMethodConfig = {
|
|
|
57
47
|
"financial-account-transactions": {
|
|
58
48
|
setFinancialAccount: _financialAccount => {}
|
|
59
49
|
},
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
"app-install": {
|
|
64
|
-
setApp: _app => {},
|
|
65
|
-
setOnAppInstallStateFetched: _listener => {},
|
|
66
|
-
setOnAppInstallStateChanged: _listener => {}
|
|
67
|
-
},
|
|
68
|
-
"app-viewport": {
|
|
69
|
-
setApp: _app => {},
|
|
70
|
-
setAppData: _appData => {}
|
|
71
|
-
},
|
|
72
|
-
"payment-method-settings": {
|
|
73
|
-
setPaymentMethodConfiguration: _paymentMethodConfiguration => {}
|
|
74
|
-
},
|
|
75
|
-
"capital-financing": {
|
|
76
|
-
setDefaultFinancingOffer: _defaultFinancingOffer => {},
|
|
77
|
-
setShowFinancingSelector: _showFinancingSelector => {},
|
|
78
|
-
setHowCapitalWorksUrl: _howCapitalWorksUrl => {},
|
|
79
|
-
setSupportUrl: _supportUrl => {},
|
|
80
|
-
setOnFinancingsLoaded: _listener => {}
|
|
81
|
-
},
|
|
82
|
-
"capital-financing-application": {
|
|
83
|
-
setOnApplicationSubmitted: _listener => {},
|
|
84
|
-
setPrivacyPolicyUrl: _privacyPolicyUrl => {},
|
|
85
|
-
setHowCapitalWorksUrl: _howCapitalWorksUrl => {},
|
|
86
|
-
setOnApplicationStepChange: _listener => {},
|
|
87
|
-
setDefaultFinancingOffer: _defaultFinancingOffer => {}
|
|
50
|
+
payments: {
|
|
51
|
+
setDefaultFilters: _filters => {}
|
|
88
52
|
},
|
|
89
|
-
"
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
setOnEligibleFinancingOfferLoaded: _listener => {},
|
|
93
|
-
setPrivacyPolicyUrl: _privacyPolicyUrl => {},
|
|
94
|
-
setHowCapitalWorksUrl: _howCapitalWorksUrl => {},
|
|
95
|
-
setEligibilityCriteriaUrl: _eligibilityCriteriaUrl => {},
|
|
96
|
-
setOnApplicationStepChange: _listener => {}
|
|
53
|
+
"payment-details": {
|
|
54
|
+
setPayment: _payment => {},
|
|
55
|
+
setOnClose: _listener => {}
|
|
97
56
|
},
|
|
98
|
-
"
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
setIntervalEnd: _intervalEnd => {},
|
|
102
|
-
setIntervalType: _intervalType => {}
|
|
57
|
+
"payment-disputes": {
|
|
58
|
+
setPayment: _payment => {},
|
|
59
|
+
setOnDisputesLoaded: _listener => {}
|
|
103
60
|
},
|
|
104
61
|
"tax-settings": {
|
|
105
62
|
setHideProductTaxCodeSelector: _hidden => {},
|
|
@@ -111,83 +68,20 @@ const ConnectElementCustomMethodConfig = {
|
|
|
111
68
|
setDisplayCountries: _countries => {},
|
|
112
69
|
setOnAfterTaxRegistrationExpired: _listener => {}
|
|
113
70
|
},
|
|
114
|
-
"tax-threshold-monitoring": {
|
|
115
|
-
setDisplayCountries: _countries => {}
|
|
116
|
-
},
|
|
117
|
-
"product-tax-code-selector": {
|
|
118
|
-
setOnTaxCodeSelect: _listener => {},
|
|
119
|
-
setHideDescription: _hideDescription => {},
|
|
120
|
-
setDisabled: _disabled => {},
|
|
121
|
-
setInitialTaxCode: _initialTaxCode => {}
|
|
122
|
-
},
|
|
123
|
-
"export-tax-transactions": {},
|
|
124
71
|
"payout-details": {
|
|
125
72
|
setPayout: _payout => {},
|
|
126
73
|
setOnClose: _listener => {}
|
|
127
74
|
},
|
|
128
|
-
"check-scanning": {
|
|
129
|
-
setHandleCheckScanSubmitted: _handleCheckScanSubmitted => {}
|
|
130
|
-
},
|
|
131
|
-
"agentic-commerce-settings": {
|
|
132
|
-
setOnAgreementUpdated: _listener => {}
|
|
133
|
-
},
|
|
134
|
-
"terminal-hardware-shop": {
|
|
135
|
-
setOnCheckoutFinished: _listener => {}
|
|
136
|
-
},
|
|
137
75
|
"payout-reconciliation-report": {
|
|
138
76
|
setOnReportAvailabilityLoaded: _listener => {}
|
|
139
77
|
}
|
|
140
78
|
};
|
|
141
79
|
|
|
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
80
|
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
81
|
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
188
82
|
const V1_URL = "https://connect-js.stripe.com/v1.0/connect.js";
|
|
189
83
|
const findScript = () => {
|
|
190
|
-
return document.querySelectorAll(`script[src="${
|
|
84
|
+
return document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
|
|
191
85
|
};
|
|
192
86
|
const injectScript = () => {
|
|
193
87
|
const script = document.createElement("script");
|
|
@@ -199,7 +93,12 @@ const injectScript = () => {
|
|
|
199
93
|
document.head.appendChild(script);
|
|
200
94
|
return script;
|
|
201
95
|
};
|
|
202
|
-
|
|
96
|
+
|
|
97
|
+
const componentNameMapping = connectElementTagNames.reduce((acc, name) => {
|
|
98
|
+
acc[name] = `stripe-connect-${name}`;
|
|
99
|
+
return acc;
|
|
100
|
+
}, {});
|
|
101
|
+
let stripePromise$1 = null;
|
|
203
102
|
const isWindowStripeConnectDefined = stripeConnect => {
|
|
204
103
|
// We only consider `StripeConnect` defined if `init` is a function
|
|
205
104
|
// Why? HTML markup like:
|
|
@@ -209,10 +108,10 @@ const isWindowStripeConnectDefined = stripeConnect => {
|
|
|
209
108
|
};
|
|
210
109
|
const loadScript = () => {
|
|
211
110
|
// Ensure that we only attempt to load Connect.js at most once
|
|
212
|
-
if (stripePromise !== null) {
|
|
213
|
-
return stripePromise;
|
|
111
|
+
if (stripePromise$1 !== null) {
|
|
112
|
+
return stripePromise$1;
|
|
214
113
|
}
|
|
215
|
-
stripePromise = new Promise((resolve, reject) => {
|
|
114
|
+
stripePromise$1 = new Promise((resolve, reject) => {
|
|
216
115
|
if (typeof window === "undefined") {
|
|
217
116
|
reject("ConnectJS won't load when rendering code in the server - it can only be loaded on a browser. This error is expected when loading ConnectJS in SSR environments, like NextJS. It will have no impact in the UI, however if you wish to avoid it, you can switch to the `pure` version of the connect.js loader: https://github.com/stripe/connect-js#importing-loadconnect-without-side-effects.");
|
|
218
117
|
return;
|
|
@@ -245,7 +144,7 @@ const loadScript = () => {
|
|
|
245
144
|
reject(error);
|
|
246
145
|
}
|
|
247
146
|
});
|
|
248
|
-
return stripePromise;
|
|
147
|
+
return stripePromise$1;
|
|
249
148
|
};
|
|
250
149
|
const hasCustomMethod = tagName => {
|
|
251
150
|
return tagName in ConnectElementCustomMethodConfig;
|
|
@@ -278,7 +177,7 @@ const initStripeConnect = (stripePromise, initParams) => {
|
|
|
278
177
|
element[method] = function (value) {
|
|
279
178
|
stripeConnectInstance.then(() => {
|
|
280
179
|
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.
|
|
180
|
+
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`);
|
|
282
181
|
}
|
|
283
182
|
this[`${method}InternalOnly`](value);
|
|
284
183
|
});
|
|
@@ -332,7 +231,7 @@ const createWrapper = stripeConnect => {
|
|
|
332
231
|
sdk: true,
|
|
333
232
|
sdkOptions: {
|
|
334
233
|
// This will be replaced by the npm package version when bundling
|
|
335
|
-
sdkVersion: "3.
|
|
234
|
+
sdkVersion: "3.4.1"
|
|
336
235
|
}
|
|
337
236
|
})
|
|
338
237
|
}));
|
|
@@ -344,16 +243,19 @@ const createWrapper = stripeConnect => {
|
|
|
344
243
|
|
|
345
244
|
// Execute our own script injection after a tick to give users time to do their
|
|
346
245
|
// own script injection.
|
|
347
|
-
const stripePromise
|
|
246
|
+
const stripePromise = Promise.resolve().then(() => loadScript());
|
|
348
247
|
let loadCalled = false;
|
|
349
|
-
stripePromise
|
|
248
|
+
stripePromise.catch(err => {
|
|
350
249
|
if (!loadCalled) {
|
|
351
250
|
console.warn(err);
|
|
352
251
|
}
|
|
353
252
|
});
|
|
354
253
|
const loadConnectAndInitialize = initParams => {
|
|
355
254
|
loadCalled = true;
|
|
356
|
-
return initStripeConnect(stripePromise
|
|
255
|
+
return initStripeConnect(stripePromise, initParams);
|
|
357
256
|
};
|
|
358
257
|
|
|
258
|
+
exports.ConnectElementCommonMethodConfig = ConnectElementCommonMethodConfig;
|
|
259
|
+
exports.ConnectElementCustomMethodConfig = ConnectElementCustomMethodConfig;
|
|
260
|
+
exports.connectElementTagNames = connectElementTagNames;
|
|
359
261
|
exports.loadConnectAndInitialize = loadConnectAndInitialize;
|