@stripe/connect-js 3.3.23-preview-1 → 3.3.23

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/README.md CHANGED
@@ -36,7 +36,7 @@ const fetchClientSecret = async () => {
36
36
 
37
37
  const instance = loadConnectAndInitialize({
38
38
  publishableKey: "{{pk test123}}",
39
- fetchClientSecret: fetchClientSecret
39
+ fetchClientSecret: fetchClientSecret,
40
40
  });
41
41
  ```
42
42
 
@@ -47,7 +47,7 @@ test this code through your Connect account.
47
47
  If you have deployed a
48
48
  [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/Security/CSP),
49
49
  make sure to
50
- [include Connect.js in your directives](https://stripe.com/docs/security/guide#content-security-policy).
50
+ [include Connect.js in your directives](https://stripe.com/docs/connect/get-started-connect-embedded-components?platform=web#csp-and-http-header-requirements).
51
51
 
52
52
  ### Import as a side effect
53
53
 
@@ -71,6 +71,6 @@ import { loadConnectAndInitialize } from "@stripe/connect-js/pure";
71
71
  // Connect.js will not be loaded until `loadConnect` is called
72
72
  const instance = loadConnectAndInitialize({
73
73
  publishableKey: "{{pk test123}}",
74
- fetchClientSecret: fetchClientSecret
74
+ fetchClientSecret: fetchClientSecret,
75
75
  });
76
76
  ```
@@ -5,13 +5,6 @@ const ConnectElementCommonMethodConfig = {
5
5
  setOnLoaderStart: _listener => {}
6
6
  };
7
7
  const ConnectElementCustomMethodConfig = {
8
- payments: {
9
- setDefaultFilters: _filters => {}
10
- },
11
- "payment-details": {
12
- setPayment: _payment => {},
13
- setOnClose: _listener => {}
14
- },
15
8
  "account-onboarding": {
16
9
  setFullTermsOfServiceUrl: _termOfServiceUrl => {},
17
10
  setRecipientTermsOfServiceUrl: _recipientTermsOfServiceUrl => {},
@@ -45,46 +38,12 @@ const ConnectElementCustomMethodConfig = {
45
38
  "financial-account-transactions": {
46
39
  setFinancialAccount: _financialAccount => {}
47
40
  },
48
- recipients: {
49
- setDataSource: _dataSource => {}
50
- },
51
- "app-install": {
52
- setApp: _app => {},
53
- setOnAppInstallStateFetched: _listener => {},
54
- setOnAppInstallStateChanged: _listener => {}
55
- },
56
- "app-viewport": {
57
- setApp: _app => {},
58
- setAppData: _appData => {}
59
- },
60
- "payment-method-settings": {
61
- setPaymentMethodConfiguration: _paymentMethodConfiguration => {}
62
- },
63
- "capital-financing": {
64
- setDefaultFinancingOffer: _defaultFinancingOffer => {},
65
- setShowFinancingSelector: _showFinancingSelector => {},
66
- setHowCapitalWorksUrl: _howCapitalWorksUrl => {},
67
- setSupportUrl: _supportUrl => {},
68
- setOnFinancingsLoaded: _listener => {}
69
- },
70
- "capital-financing-application": {
71
- setOnApplicationSubmitted: _listener => {},
72
- setPrivacyPolicyUrl: _privacyPolicyUrl => {},
73
- setHowCapitalWorksUrl: _howCapitalWorksUrl => {}
74
- },
75
- "capital-financing-promotion": {
76
- setLayout: _layout => {},
77
- setOnApplicationSubmitted: _listener => {},
78
- setOnEligibleFinancingOfferLoaded: _listener => {},
79
- setPrivacyPolicyUrl: _privacyPolicyUrl => {},
80
- setHowCapitalWorksUrl: _howCapitalWorksUrl => {},
81
- setEligibilityCriteriaUrl: _eligibilityCriteriaUrl => {}
41
+ payments: {
42
+ setDefaultFilters: _filters => {}
82
43
  },
83
- "reporting-chart": {
84
- setReportName: _reportName => {},
85
- setIntervalStart: _intervalStart => {},
86
- setIntervalEnd: _intervalEnd => {},
87
- setIntervalType: _intervalType => {}
44
+ "payment-details": {
45
+ setPayment: _payment => {},
46
+ setOnClose: _listener => {}
88
47
  },
89
48
  "tax-settings": {
90
49
  setHideProductTaxCodeSelector: _hidden => {},
@@ -98,37 +57,27 @@ const ConnectElementCustomMethodConfig = {
98
57
  };
99
58
 
100
59
  const componentNameMapping = {
60
+ "account-onboarding": "stripe-connect-account-onboarding",
101
61
  payments: "stripe-connect-payments",
102
- payouts: "stripe-connect-payouts",
103
62
  "payment-details": "stripe-connect-payment-details",
104
- "account-onboarding": "stripe-connect-account-onboarding",
105
- "payment-method-settings": "stripe-connect-payment-method-settings",
63
+ payouts: "stripe-connect-payouts",
64
+ "payouts-list": "stripe-connect-payouts-list",
65
+ balances: "stripe-connect-balances",
106
66
  "account-management": "stripe-connect-account-management",
107
67
  "notification-banner": "stripe-connect-notification-banner",
108
- "instant-payouts": "stripe-connect-instant-payouts",
109
68
  "issuing-card": "stripe-connect-issuing-card",
110
69
  "issuing-cards-list": "stripe-connect-issuing-cards-list",
111
70
  "financial-account": "stripe-connect-financial-account",
112
- recipients: "stripe-connect-recipients",
113
71
  "financial-account-transactions": "stripe-connect-financial-account-transactions",
114
- "capital-financing": "stripe-connect-capital-financing",
115
- "capital-financing-application": "stripe-connect-capital-financing-application",
116
- "capital-financing-promotion": "stripe-connect-capital-financing-promotion",
117
- "capital-overview": "stripe-connect-capital-overview",
118
72
  documents: "stripe-connect-documents",
119
73
  "tax-registrations": "stripe-connect-tax-registrations",
120
- "tax-settings": "stripe-connect-tax-settings",
121
- balances: "stripe-connect-balances",
122
- "payouts-list": "stripe-connect-payouts-list",
123
- "app-install": "stripe-connect-app-install",
124
- "app-viewport": "stripe-connect-app-viewport",
125
- "reporting-chart": "stripe-connect-reporting-chart"
74
+ "tax-settings": "stripe-connect-tax-settings"
126
75
  };
127
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";
128
77
  const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
129
78
  const V1_URL = "https://connect-js.stripe.com/v1.0/connect.js";
130
79
  const findScript = () => {
131
- return document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || null;
80
+ return document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
132
81
  };
133
82
  const injectScript = () => {
134
83
  const script = document.createElement("script");
@@ -140,21 +89,26 @@ const injectScript = () => {
140
89
  document.head.appendChild(script);
141
90
  return script;
142
91
  };
143
- let stripePromise = null;
92
+ let stripePromise$1 = null;
93
+ const isWindowStripeConnectDefined = stripeConnect => {
94
+ // We only consider `StripeConnect` defined if `init` is a function
95
+ // Why? HTML markup like:
96
+ // <a id="StripeConnect"><a id="StripeConnect" name="init" href="stripe"></a></a> in the <head> of the page
97
+ // can end up "contaminating" the window.StripeConnect object and cause issues in connect.js initialization
98
+ return !!(stripeConnect && typeof stripeConnect === "object" && "init" in stripeConnect && typeof stripeConnect.init === "function");
99
+ };
144
100
  const loadScript = () => {
145
101
  // Ensure that we only attempt to load Connect.js at most once
146
- if (stripePromise !== null) {
147
- return stripePromise;
102
+ if (stripePromise$1 !== null) {
103
+ return stripePromise$1;
148
104
  }
149
- stripePromise = new Promise((resolve, reject) => {
105
+ stripePromise$1 = new Promise((resolve, reject) => {
150
106
  if (typeof window === "undefined") {
151
107
  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.");
152
108
  return;
153
109
  }
154
- if (window.StripeConnect) {
110
+ if (isWindowStripeConnectDefined(window.StripeConnect)) {
155
111
  console.warn(EXISTING_SCRIPT_MESSAGE);
156
- }
157
- if (window.StripeConnect) {
158
112
  const wrapper = createWrapper(window.StripeConnect);
159
113
  resolve(wrapper);
160
114
  return;
@@ -167,7 +121,7 @@ const loadScript = () => {
167
121
  script = injectScript();
168
122
  }
169
123
  script.addEventListener("load", () => {
170
- if (window.StripeConnect) {
124
+ if (isWindowStripeConnectDefined(window.StripeConnect)) {
171
125
  const wrapper = createWrapper(window.StripeConnect);
172
126
  resolve(wrapper);
173
127
  } else {
@@ -181,7 +135,7 @@ const loadScript = () => {
181
135
  reject(error);
182
136
  }
183
137
  });
184
- return stripePromise;
138
+ return stripePromise$1;
185
139
  };
186
140
  const hasCustomMethod = tagName => {
187
141
  return tagName in ConnectElementCustomMethodConfig;
@@ -265,7 +219,7 @@ const createWrapper = stripeConnect => {
265
219
  sdk: true,
266
220
  sdkOptions: {
267
221
  // This will be replaced by the npm package version when bundling
268
- sdkVersion: "3.3.23-preview-1"
222
+ sdkVersion: "3.3.23"
269
223
  }
270
224
  })
271
225
  }));
@@ -277,16 +231,16 @@ const createWrapper = stripeConnect => {
277
231
 
278
232
  // Execute our own script injection after a tick to give users time to do their
279
233
  // own script injection.
280
- const stripePromise$1 = Promise.resolve().then(() => loadScript());
234
+ const stripePromise = Promise.resolve().then(() => loadScript());
281
235
  let loadCalled = false;
282
- stripePromise$1.catch(err => {
236
+ stripePromise.catch(err => {
283
237
  if (!loadCalled) {
284
238
  console.warn(err);
285
239
  }
286
240
  });
287
241
  const loadConnectAndInitialize = initParams => {
288
242
  loadCalled = true;
289
- return initStripeConnect(stripePromise$1, initParams);
243
+ return initStripeConnect(stripePromise, initParams);
290
244
  };
291
245
 
292
246
  export { loadConnectAndInitialize };
package/dist/connect.js CHANGED
@@ -9,13 +9,6 @@ const ConnectElementCommonMethodConfig = {
9
9
  setOnLoaderStart: _listener => {}
10
10
  };
11
11
  const ConnectElementCustomMethodConfig = {
12
- payments: {
13
- setDefaultFilters: _filters => {}
14
- },
15
- "payment-details": {
16
- setPayment: _payment => {},
17
- setOnClose: _listener => {}
18
- },
19
12
  "account-onboarding": {
20
13
  setFullTermsOfServiceUrl: _termOfServiceUrl => {},
21
14
  setRecipientTermsOfServiceUrl: _recipientTermsOfServiceUrl => {},
@@ -49,46 +42,12 @@ const ConnectElementCustomMethodConfig = {
49
42
  "financial-account-transactions": {
50
43
  setFinancialAccount: _financialAccount => {}
51
44
  },
52
- recipients: {
53
- setDataSource: _dataSource => {}
54
- },
55
- "app-install": {
56
- setApp: _app => {},
57
- setOnAppInstallStateFetched: _listener => {},
58
- setOnAppInstallStateChanged: _listener => {}
59
- },
60
- "app-viewport": {
61
- setApp: _app => {},
62
- setAppData: _appData => {}
63
- },
64
- "payment-method-settings": {
65
- setPaymentMethodConfiguration: _paymentMethodConfiguration => {}
66
- },
67
- "capital-financing": {
68
- setDefaultFinancingOffer: _defaultFinancingOffer => {},
69
- setShowFinancingSelector: _showFinancingSelector => {},
70
- setHowCapitalWorksUrl: _howCapitalWorksUrl => {},
71
- setSupportUrl: _supportUrl => {},
72
- setOnFinancingsLoaded: _listener => {}
73
- },
74
- "capital-financing-application": {
75
- setOnApplicationSubmitted: _listener => {},
76
- setPrivacyPolicyUrl: _privacyPolicyUrl => {},
77
- setHowCapitalWorksUrl: _howCapitalWorksUrl => {}
78
- },
79
- "capital-financing-promotion": {
80
- setLayout: _layout => {},
81
- setOnApplicationSubmitted: _listener => {},
82
- setOnEligibleFinancingOfferLoaded: _listener => {},
83
- setPrivacyPolicyUrl: _privacyPolicyUrl => {},
84
- setHowCapitalWorksUrl: _howCapitalWorksUrl => {},
85
- setEligibilityCriteriaUrl: _eligibilityCriteriaUrl => {}
45
+ payments: {
46
+ setDefaultFilters: _filters => {}
86
47
  },
87
- "reporting-chart": {
88
- setReportName: _reportName => {},
89
- setIntervalStart: _intervalStart => {},
90
- setIntervalEnd: _intervalEnd => {},
91
- setIntervalType: _intervalType => {}
48
+ "payment-details": {
49
+ setPayment: _payment => {},
50
+ setOnClose: _listener => {}
92
51
  },
93
52
  "tax-settings": {
94
53
  setHideProductTaxCodeSelector: _hidden => {},
@@ -102,37 +61,27 @@ const ConnectElementCustomMethodConfig = {
102
61
  };
103
62
 
104
63
  const componentNameMapping = {
64
+ "account-onboarding": "stripe-connect-account-onboarding",
105
65
  payments: "stripe-connect-payments",
106
- payouts: "stripe-connect-payouts",
107
66
  "payment-details": "stripe-connect-payment-details",
108
- "account-onboarding": "stripe-connect-account-onboarding",
109
- "payment-method-settings": "stripe-connect-payment-method-settings",
67
+ payouts: "stripe-connect-payouts",
68
+ "payouts-list": "stripe-connect-payouts-list",
69
+ balances: "stripe-connect-balances",
110
70
  "account-management": "stripe-connect-account-management",
111
71
  "notification-banner": "stripe-connect-notification-banner",
112
- "instant-payouts": "stripe-connect-instant-payouts",
113
72
  "issuing-card": "stripe-connect-issuing-card",
114
73
  "issuing-cards-list": "stripe-connect-issuing-cards-list",
115
74
  "financial-account": "stripe-connect-financial-account",
116
- recipients: "stripe-connect-recipients",
117
75
  "financial-account-transactions": "stripe-connect-financial-account-transactions",
118
- "capital-financing": "stripe-connect-capital-financing",
119
- "capital-financing-application": "stripe-connect-capital-financing-application",
120
- "capital-financing-promotion": "stripe-connect-capital-financing-promotion",
121
- "capital-overview": "stripe-connect-capital-overview",
122
76
  documents: "stripe-connect-documents",
123
77
  "tax-registrations": "stripe-connect-tax-registrations",
124
- "tax-settings": "stripe-connect-tax-settings",
125
- balances: "stripe-connect-balances",
126
- "payouts-list": "stripe-connect-payouts-list",
127
- "app-install": "stripe-connect-app-install",
128
- "app-viewport": "stripe-connect-app-viewport",
129
- "reporting-chart": "stripe-connect-reporting-chart"
78
+ "tax-settings": "stripe-connect-tax-settings"
130
79
  };
131
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";
132
81
  const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
133
82
  const V1_URL = "https://connect-js.stripe.com/v1.0/connect.js";
134
83
  const findScript = () => {
135
- return document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || null;
84
+ return document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
136
85
  };
137
86
  const injectScript = () => {
138
87
  const script = document.createElement("script");
@@ -144,21 +93,26 @@ const injectScript = () => {
144
93
  document.head.appendChild(script);
145
94
  return script;
146
95
  };
147
- let stripePromise = null;
96
+ let stripePromise$1 = null;
97
+ const isWindowStripeConnectDefined = stripeConnect => {
98
+ // We only consider `StripeConnect` defined if `init` is a function
99
+ // Why? HTML markup like:
100
+ // <a id="StripeConnect"><a id="StripeConnect" name="init" href="stripe"></a></a> in the <head> of the page
101
+ // can end up "contaminating" the window.StripeConnect object and cause issues in connect.js initialization
102
+ return !!(stripeConnect && typeof stripeConnect === "object" && "init" in stripeConnect && typeof stripeConnect.init === "function");
103
+ };
148
104
  const loadScript = () => {
149
105
  // Ensure that we only attempt to load Connect.js at most once
150
- if (stripePromise !== null) {
151
- return stripePromise;
106
+ if (stripePromise$1 !== null) {
107
+ return stripePromise$1;
152
108
  }
153
- stripePromise = new Promise((resolve, reject) => {
109
+ stripePromise$1 = new Promise((resolve, reject) => {
154
110
  if (typeof window === "undefined") {
155
111
  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.");
156
112
  return;
157
113
  }
158
- if (window.StripeConnect) {
114
+ if (isWindowStripeConnectDefined(window.StripeConnect)) {
159
115
  console.warn(EXISTING_SCRIPT_MESSAGE);
160
- }
161
- if (window.StripeConnect) {
162
116
  const wrapper = createWrapper(window.StripeConnect);
163
117
  resolve(wrapper);
164
118
  return;
@@ -171,7 +125,7 @@ const loadScript = () => {
171
125
  script = injectScript();
172
126
  }
173
127
  script.addEventListener("load", () => {
174
- if (window.StripeConnect) {
128
+ if (isWindowStripeConnectDefined(window.StripeConnect)) {
175
129
  const wrapper = createWrapper(window.StripeConnect);
176
130
  resolve(wrapper);
177
131
  } else {
@@ -185,7 +139,7 @@ const loadScript = () => {
185
139
  reject(error);
186
140
  }
187
141
  });
188
- return stripePromise;
142
+ return stripePromise$1;
189
143
  };
190
144
  const hasCustomMethod = tagName => {
191
145
  return tagName in ConnectElementCustomMethodConfig;
@@ -269,7 +223,7 @@ const createWrapper = stripeConnect => {
269
223
  sdk: true,
270
224
  sdkOptions: {
271
225
  // This will be replaced by the npm package version when bundling
272
- sdkVersion: "3.3.23-preview-1"
226
+ sdkVersion: "3.3.23"
273
227
  }
274
228
  })
275
229
  }));
@@ -281,16 +235,16 @@ const createWrapper = stripeConnect => {
281
235
 
282
236
  // Execute our own script injection after a tick to give users time to do their
283
237
  // own script injection.
284
- const stripePromise$1 = Promise.resolve().then(() => loadScript());
238
+ const stripePromise = Promise.resolve().then(() => loadScript());
285
239
  let loadCalled = false;
286
- stripePromise$1.catch(err => {
240
+ stripePromise.catch(err => {
287
241
  if (!loadCalled) {
288
242
  console.warn(err);
289
243
  }
290
244
  });
291
245
  const loadConnectAndInitialize = initParams => {
292
246
  loadCalled = true;
293
- return initStripeConnect(stripePromise$1, initParams);
247
+ return initStripeConnect(stripePromise, initParams);
294
248
  };
295
249
 
296
250
  exports.loadConnectAndInitialize = loadConnectAndInitialize;
package/dist/pure.esm.js CHANGED
@@ -5,13 +5,6 @@ const ConnectElementCommonMethodConfig = {
5
5
  setOnLoaderStart: _listener => {}
6
6
  };
7
7
  const ConnectElementCustomMethodConfig = {
8
- payments: {
9
- setDefaultFilters: _filters => {}
10
- },
11
- "payment-details": {
12
- setPayment: _payment => {},
13
- setOnClose: _listener => {}
14
- },
15
8
  "account-onboarding": {
16
9
  setFullTermsOfServiceUrl: _termOfServiceUrl => {},
17
10
  setRecipientTermsOfServiceUrl: _recipientTermsOfServiceUrl => {},
@@ -45,46 +38,12 @@ const ConnectElementCustomMethodConfig = {
45
38
  "financial-account-transactions": {
46
39
  setFinancialAccount: _financialAccount => {}
47
40
  },
48
- recipients: {
49
- setDataSource: _dataSource => {}
50
- },
51
- "app-install": {
52
- setApp: _app => {},
53
- setOnAppInstallStateFetched: _listener => {},
54
- setOnAppInstallStateChanged: _listener => {}
55
- },
56
- "app-viewport": {
57
- setApp: _app => {},
58
- setAppData: _appData => {}
59
- },
60
- "payment-method-settings": {
61
- setPaymentMethodConfiguration: _paymentMethodConfiguration => {}
62
- },
63
- "capital-financing": {
64
- setDefaultFinancingOffer: _defaultFinancingOffer => {},
65
- setShowFinancingSelector: _showFinancingSelector => {},
66
- setHowCapitalWorksUrl: _howCapitalWorksUrl => {},
67
- setSupportUrl: _supportUrl => {},
68
- setOnFinancingsLoaded: _listener => {}
69
- },
70
- "capital-financing-application": {
71
- setOnApplicationSubmitted: _listener => {},
72
- setPrivacyPolicyUrl: _privacyPolicyUrl => {},
73
- setHowCapitalWorksUrl: _howCapitalWorksUrl => {}
74
- },
75
- "capital-financing-promotion": {
76
- setLayout: _layout => {},
77
- setOnApplicationSubmitted: _listener => {},
78
- setOnEligibleFinancingOfferLoaded: _listener => {},
79
- setPrivacyPolicyUrl: _privacyPolicyUrl => {},
80
- setHowCapitalWorksUrl: _howCapitalWorksUrl => {},
81
- setEligibilityCriteriaUrl: _eligibilityCriteriaUrl => {}
41
+ payments: {
42
+ setDefaultFilters: _filters => {}
82
43
  },
83
- "reporting-chart": {
84
- setReportName: _reportName => {},
85
- setIntervalStart: _intervalStart => {},
86
- setIntervalEnd: _intervalEnd => {},
87
- setIntervalType: _intervalType => {}
44
+ "payment-details": {
45
+ setPayment: _payment => {},
46
+ setOnClose: _listener => {}
88
47
  },
89
48
  "tax-settings": {
90
49
  setHideProductTaxCodeSelector: _hidden => {},
@@ -98,37 +57,27 @@ const ConnectElementCustomMethodConfig = {
98
57
  };
99
58
 
100
59
  const componentNameMapping = {
60
+ "account-onboarding": "stripe-connect-account-onboarding",
101
61
  payments: "stripe-connect-payments",
102
- payouts: "stripe-connect-payouts",
103
62
  "payment-details": "stripe-connect-payment-details",
104
- "account-onboarding": "stripe-connect-account-onboarding",
105
- "payment-method-settings": "stripe-connect-payment-method-settings",
63
+ payouts: "stripe-connect-payouts",
64
+ "payouts-list": "stripe-connect-payouts-list",
65
+ balances: "stripe-connect-balances",
106
66
  "account-management": "stripe-connect-account-management",
107
67
  "notification-banner": "stripe-connect-notification-banner",
108
- "instant-payouts": "stripe-connect-instant-payouts",
109
68
  "issuing-card": "stripe-connect-issuing-card",
110
69
  "issuing-cards-list": "stripe-connect-issuing-cards-list",
111
70
  "financial-account": "stripe-connect-financial-account",
112
- recipients: "stripe-connect-recipients",
113
71
  "financial-account-transactions": "stripe-connect-financial-account-transactions",
114
- "capital-financing": "stripe-connect-capital-financing",
115
- "capital-financing-application": "stripe-connect-capital-financing-application",
116
- "capital-financing-promotion": "stripe-connect-capital-financing-promotion",
117
- "capital-overview": "stripe-connect-capital-overview",
118
72
  documents: "stripe-connect-documents",
119
73
  "tax-registrations": "stripe-connect-tax-registrations",
120
- "tax-settings": "stripe-connect-tax-settings",
121
- balances: "stripe-connect-balances",
122
- "payouts-list": "stripe-connect-payouts-list",
123
- "app-install": "stripe-connect-app-install",
124
- "app-viewport": "stripe-connect-app-viewport",
125
- "reporting-chart": "stripe-connect-reporting-chart"
74
+ "tax-settings": "stripe-connect-tax-settings"
126
75
  };
127
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";
128
77
  const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
129
78
  const V1_URL = "https://connect-js.stripe.com/v1.0/connect.js";
130
79
  const findScript = () => {
131
- return document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || null;
80
+ return document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
132
81
  };
133
82
  const injectScript = () => {
134
83
  const script = document.createElement("script");
@@ -141,6 +90,13 @@ const injectScript = () => {
141
90
  return script;
142
91
  };
143
92
  let stripePromise = null;
93
+ const isWindowStripeConnectDefined = stripeConnect => {
94
+ // We only consider `StripeConnect` defined if `init` is a function
95
+ // Why? HTML markup like:
96
+ // <a id="StripeConnect"><a id="StripeConnect" name="init" href="stripe"></a></a> in the <head> of the page
97
+ // can end up "contaminating" the window.StripeConnect object and cause issues in connect.js initialization
98
+ return !!(stripeConnect && typeof stripeConnect === "object" && "init" in stripeConnect && typeof stripeConnect.init === "function");
99
+ };
144
100
  const loadScript = () => {
145
101
  // Ensure that we only attempt to load Connect.js at most once
146
102
  if (stripePromise !== null) {
@@ -151,10 +107,8 @@ const loadScript = () => {
151
107
  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.");
152
108
  return;
153
109
  }
154
- if (window.StripeConnect) {
110
+ if (isWindowStripeConnectDefined(window.StripeConnect)) {
155
111
  console.warn(EXISTING_SCRIPT_MESSAGE);
156
- }
157
- if (window.StripeConnect) {
158
112
  const wrapper = createWrapper(window.StripeConnect);
159
113
  resolve(wrapper);
160
114
  return;
@@ -167,7 +121,7 @@ const loadScript = () => {
167
121
  script = injectScript();
168
122
  }
169
123
  script.addEventListener("load", () => {
170
- if (window.StripeConnect) {
124
+ if (isWindowStripeConnectDefined(window.StripeConnect)) {
171
125
  const wrapper = createWrapper(window.StripeConnect);
172
126
  resolve(wrapper);
173
127
  } else {
@@ -265,7 +219,7 @@ const createWrapper = stripeConnect => {
265
219
  sdk: true,
266
220
  sdkOptions: {
267
221
  // This will be replaced by the npm package version when bundling
268
- sdkVersion: "3.3.23-preview-1"
222
+ sdkVersion: "3.3.23"
269
223
  }
270
224
  })
271
225
  }));