@stripe/connect-js 3.3.25-preview-1 → 3.3.25
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 +3 -3
- package/dist/connect.esm.js +34 -78
- package/dist/connect.js +34 -78
- package/dist/pure.esm.js +26 -70
- package/dist/pure.js +26 -70
- package/dist/src/index.d.ts +1 -1
- package/dist/src/pure.d.ts +1 -1
- package/dist/src/shared.d.ts +3 -2
- package/dist/types/config.d.ts +8 -60
- package/package.json +14 -10
- package/src/index.ts +3 -6
- package/src/pure.test.ts +2 -2
- package/src/pure.ts +3 -6
- package/src/shared.ts +49 -57
- package/types/checks.ts +2 -2
- package/types/config.ts +19 -104
- package/types/index.d.ts +1 -1
- package/types/shared.d.ts +10 -18
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/
|
|
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
|
```
|
package/dist/connect.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,16 @@ const ConnectElementCustomMethodConfig = {
|
|
|
45
38
|
"financial-account-transactions": {
|
|
46
39
|
setFinancialAccount: _financialAccount => {}
|
|
47
40
|
},
|
|
48
|
-
|
|
49
|
-
|
|
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 => {}
|
|
41
|
+
payments: {
|
|
42
|
+
setDefaultFilters: _filters => {}
|
|
74
43
|
},
|
|
75
|
-
"
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
setOnEligibleFinancingOfferLoaded: _listener => {},
|
|
79
|
-
setPrivacyPolicyUrl: _privacyPolicyUrl => {},
|
|
80
|
-
setHowCapitalWorksUrl: _howCapitalWorksUrl => {},
|
|
81
|
-
setEligibilityCriteriaUrl: _eligibilityCriteriaUrl => {}
|
|
44
|
+
"payment-details": {
|
|
45
|
+
setPayment: _payment => {},
|
|
46
|
+
setOnClose: _listener => {}
|
|
82
47
|
},
|
|
83
|
-
"
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
setIntervalEnd: _intervalEnd => {},
|
|
87
|
-
setIntervalType: _intervalType => {}
|
|
48
|
+
"payment-disputes": {
|
|
49
|
+
setPayment: _payment => {},
|
|
50
|
+
setOnDisputesLoaded: _listener => {}
|
|
88
51
|
},
|
|
89
52
|
"tax-settings": {
|
|
90
53
|
setHideProductTaxCodeSelector: _hidden => {},
|
|
@@ -94,45 +57,33 @@ const ConnectElementCustomMethodConfig = {
|
|
|
94
57
|
"tax-registrations": {
|
|
95
58
|
setOnAfterTaxRegistrationAdded: _listener => {},
|
|
96
59
|
setDisplayCountries: _countries => {}
|
|
97
|
-
},
|
|
98
|
-
"tax-threshold-monitoring": {
|
|
99
|
-
setDisplayCountries: _countries => {}
|
|
100
60
|
}
|
|
101
61
|
};
|
|
102
62
|
|
|
103
63
|
const componentNameMapping = {
|
|
64
|
+
"account-onboarding": "stripe-connect-account-onboarding",
|
|
65
|
+
"disputes-list": "stripe-connect-disputes-list",
|
|
104
66
|
payments: "stripe-connect-payments",
|
|
105
|
-
payouts: "stripe-connect-payouts",
|
|
106
67
|
"payment-details": "stripe-connect-payment-details",
|
|
107
|
-
"
|
|
108
|
-
|
|
68
|
+
"payment-disputes": "stripe-connect-payment-disputes",
|
|
69
|
+
payouts: "stripe-connect-payouts",
|
|
70
|
+
"payouts-list": "stripe-connect-payouts-list",
|
|
71
|
+
balances: "stripe-connect-balances",
|
|
109
72
|
"account-management": "stripe-connect-account-management",
|
|
110
73
|
"notification-banner": "stripe-connect-notification-banner",
|
|
111
|
-
"instant-payouts": "stripe-connect-instant-payouts",
|
|
112
74
|
"issuing-card": "stripe-connect-issuing-card",
|
|
113
75
|
"issuing-cards-list": "stripe-connect-issuing-cards-list",
|
|
114
76
|
"financial-account": "stripe-connect-financial-account",
|
|
115
|
-
recipients: "stripe-connect-recipients",
|
|
116
77
|
"financial-account-transactions": "stripe-connect-financial-account-transactions",
|
|
117
|
-
"capital-financing": "stripe-connect-capital-financing",
|
|
118
|
-
"capital-financing-application": "stripe-connect-capital-financing-application",
|
|
119
|
-
"capital-financing-promotion": "stripe-connect-capital-financing-promotion",
|
|
120
|
-
"capital-overview": "stripe-connect-capital-overview",
|
|
121
78
|
documents: "stripe-connect-documents",
|
|
122
79
|
"tax-registrations": "stripe-connect-tax-registrations",
|
|
123
|
-
"tax-settings": "stripe-connect-tax-settings"
|
|
124
|
-
"tax-threshold-monitoring": "stripe-connect-tax-threshold-monitoring",
|
|
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"
|
|
80
|
+
"tax-settings": "stripe-connect-tax-settings"
|
|
130
81
|
};
|
|
131
82
|
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
83
|
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
133
84
|
const V1_URL = "https://connect-js.stripe.com/v1.0/connect.js";
|
|
134
85
|
const findScript = () => {
|
|
135
|
-
return document.querySelectorAll(`script[src="${
|
|
86
|
+
return document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
|
|
136
87
|
};
|
|
137
88
|
const injectScript = () => {
|
|
138
89
|
const script = document.createElement("script");
|
|
@@ -144,21 +95,26 @@ const injectScript = () => {
|
|
|
144
95
|
document.head.appendChild(script);
|
|
145
96
|
return script;
|
|
146
97
|
};
|
|
147
|
-
let stripePromise = null;
|
|
98
|
+
let stripePromise$1 = null;
|
|
99
|
+
const isWindowStripeConnectDefined = stripeConnect => {
|
|
100
|
+
// We only consider `StripeConnect` defined if `init` is a function
|
|
101
|
+
// Why? HTML markup like:
|
|
102
|
+
// <a id="StripeConnect"><a id="StripeConnect" name="init" href="stripe"></a></a> in the <head> of the page
|
|
103
|
+
// can end up "contaminating" the window.StripeConnect object and cause issues in connect.js initialization
|
|
104
|
+
return !!(stripeConnect && typeof stripeConnect === "object" && "init" in stripeConnect && typeof stripeConnect.init === "function");
|
|
105
|
+
};
|
|
148
106
|
const loadScript = () => {
|
|
149
107
|
// Ensure that we only attempt to load Connect.js at most once
|
|
150
|
-
if (stripePromise !== null) {
|
|
151
|
-
return stripePromise;
|
|
108
|
+
if (stripePromise$1 !== null) {
|
|
109
|
+
return stripePromise$1;
|
|
152
110
|
}
|
|
153
|
-
stripePromise = new Promise((resolve, reject) => {
|
|
111
|
+
stripePromise$1 = new Promise((resolve, reject) => {
|
|
154
112
|
if (typeof window === "undefined") {
|
|
155
113
|
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
114
|
return;
|
|
157
115
|
}
|
|
158
|
-
if (window.StripeConnect) {
|
|
116
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
159
117
|
console.warn(EXISTING_SCRIPT_MESSAGE);
|
|
160
|
-
}
|
|
161
|
-
if (window.StripeConnect) {
|
|
162
118
|
const wrapper = createWrapper(window.StripeConnect);
|
|
163
119
|
resolve(wrapper);
|
|
164
120
|
return;
|
|
@@ -171,7 +127,7 @@ const loadScript = () => {
|
|
|
171
127
|
script = injectScript();
|
|
172
128
|
}
|
|
173
129
|
script.addEventListener("load", () => {
|
|
174
|
-
if (window.StripeConnect) {
|
|
130
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
175
131
|
const wrapper = createWrapper(window.StripeConnect);
|
|
176
132
|
resolve(wrapper);
|
|
177
133
|
} else {
|
|
@@ -185,7 +141,7 @@ const loadScript = () => {
|
|
|
185
141
|
reject(error);
|
|
186
142
|
}
|
|
187
143
|
});
|
|
188
|
-
return stripePromise;
|
|
144
|
+
return stripePromise$1;
|
|
189
145
|
};
|
|
190
146
|
const hasCustomMethod = tagName => {
|
|
191
147
|
return tagName in ConnectElementCustomMethodConfig;
|
|
@@ -269,7 +225,7 @@ const createWrapper = stripeConnect => {
|
|
|
269
225
|
sdk: true,
|
|
270
226
|
sdkOptions: {
|
|
271
227
|
// This will be replaced by the npm package version when bundling
|
|
272
|
-
sdkVersion: "3.3.
|
|
228
|
+
sdkVersion: "3.3.25"
|
|
273
229
|
}
|
|
274
230
|
})
|
|
275
231
|
}));
|
|
@@ -281,16 +237,16 @@ const createWrapper = stripeConnect => {
|
|
|
281
237
|
|
|
282
238
|
// Execute our own script injection after a tick to give users time to do their
|
|
283
239
|
// own script injection.
|
|
284
|
-
const stripePromise
|
|
240
|
+
const stripePromise = Promise.resolve().then(() => loadScript());
|
|
285
241
|
let loadCalled = false;
|
|
286
|
-
stripePromise
|
|
242
|
+
stripePromise.catch(err => {
|
|
287
243
|
if (!loadCalled) {
|
|
288
244
|
console.warn(err);
|
|
289
245
|
}
|
|
290
246
|
});
|
|
291
247
|
const loadConnectAndInitialize = initParams => {
|
|
292
248
|
loadCalled = true;
|
|
293
|
-
return initStripeConnect(stripePromise
|
|
249
|
+
return initStripeConnect(stripePromise, initParams);
|
|
294
250
|
};
|
|
295
251
|
|
|
296
252
|
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,16 @@ const ConnectElementCustomMethodConfig = {
|
|
|
49
42
|
"financial-account-transactions": {
|
|
50
43
|
setFinancialAccount: _financialAccount => {}
|
|
51
44
|
},
|
|
52
|
-
|
|
53
|
-
|
|
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 => {}
|
|
45
|
+
payments: {
|
|
46
|
+
setDefaultFilters: _filters => {}
|
|
78
47
|
},
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
setOnEligibleFinancingOfferLoaded: _listener => {},
|
|
83
|
-
setPrivacyPolicyUrl: _privacyPolicyUrl => {},
|
|
84
|
-
setHowCapitalWorksUrl: _howCapitalWorksUrl => {},
|
|
85
|
-
setEligibilityCriteriaUrl: _eligibilityCriteriaUrl => {}
|
|
48
|
+
"payment-details": {
|
|
49
|
+
setPayment: _payment => {},
|
|
50
|
+
setOnClose: _listener => {}
|
|
86
51
|
},
|
|
87
|
-
"
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
setIntervalEnd: _intervalEnd => {},
|
|
91
|
-
setIntervalType: _intervalType => {}
|
|
52
|
+
"payment-disputes": {
|
|
53
|
+
setPayment: _payment => {},
|
|
54
|
+
setOnDisputesLoaded: _listener => {}
|
|
92
55
|
},
|
|
93
56
|
"tax-settings": {
|
|
94
57
|
setHideProductTaxCodeSelector: _hidden => {},
|
|
@@ -98,45 +61,33 @@ const ConnectElementCustomMethodConfig = {
|
|
|
98
61
|
"tax-registrations": {
|
|
99
62
|
setOnAfterTaxRegistrationAdded: _listener => {},
|
|
100
63
|
setDisplayCountries: _countries => {}
|
|
101
|
-
},
|
|
102
|
-
"tax-threshold-monitoring": {
|
|
103
|
-
setDisplayCountries: _countries => {}
|
|
104
64
|
}
|
|
105
65
|
};
|
|
106
66
|
|
|
107
67
|
const componentNameMapping = {
|
|
68
|
+
"account-onboarding": "stripe-connect-account-onboarding",
|
|
69
|
+
"disputes-list": "stripe-connect-disputes-list",
|
|
108
70
|
payments: "stripe-connect-payments",
|
|
109
|
-
payouts: "stripe-connect-payouts",
|
|
110
71
|
"payment-details": "stripe-connect-payment-details",
|
|
111
|
-
"
|
|
112
|
-
|
|
72
|
+
"payment-disputes": "stripe-connect-payment-disputes",
|
|
73
|
+
payouts: "stripe-connect-payouts",
|
|
74
|
+
"payouts-list": "stripe-connect-payouts-list",
|
|
75
|
+
balances: "stripe-connect-balances",
|
|
113
76
|
"account-management": "stripe-connect-account-management",
|
|
114
77
|
"notification-banner": "stripe-connect-notification-banner",
|
|
115
|
-
"instant-payouts": "stripe-connect-instant-payouts",
|
|
116
78
|
"issuing-card": "stripe-connect-issuing-card",
|
|
117
79
|
"issuing-cards-list": "stripe-connect-issuing-cards-list",
|
|
118
80
|
"financial-account": "stripe-connect-financial-account",
|
|
119
|
-
recipients: "stripe-connect-recipients",
|
|
120
81
|
"financial-account-transactions": "stripe-connect-financial-account-transactions",
|
|
121
|
-
"capital-financing": "stripe-connect-capital-financing",
|
|
122
|
-
"capital-financing-application": "stripe-connect-capital-financing-application",
|
|
123
|
-
"capital-financing-promotion": "stripe-connect-capital-financing-promotion",
|
|
124
|
-
"capital-overview": "stripe-connect-capital-overview",
|
|
125
82
|
documents: "stripe-connect-documents",
|
|
126
83
|
"tax-registrations": "stripe-connect-tax-registrations",
|
|
127
|
-
"tax-settings": "stripe-connect-tax-settings"
|
|
128
|
-
"tax-threshold-monitoring": "stripe-connect-tax-threshold-monitoring",
|
|
129
|
-
balances: "stripe-connect-balances",
|
|
130
|
-
"payouts-list": "stripe-connect-payouts-list",
|
|
131
|
-
"app-install": "stripe-connect-app-install",
|
|
132
|
-
"app-viewport": "stripe-connect-app-viewport",
|
|
133
|
-
"reporting-chart": "stripe-connect-reporting-chart"
|
|
84
|
+
"tax-settings": "stripe-connect-tax-settings"
|
|
134
85
|
};
|
|
135
86
|
const EXISTING_SCRIPT_MESSAGE = "loadConnect was called but an existing Connect.js script already exists in the document; existing script parameters will be used";
|
|
136
87
|
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
137
88
|
const V1_URL = "https://connect-js.stripe.com/v1.0/connect.js";
|
|
138
89
|
const findScript = () => {
|
|
139
|
-
return document.querySelectorAll(`script[src="${
|
|
90
|
+
return document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
|
|
140
91
|
};
|
|
141
92
|
const injectScript = () => {
|
|
142
93
|
const script = document.createElement("script");
|
|
@@ -148,21 +99,26 @@ const injectScript = () => {
|
|
|
148
99
|
document.head.appendChild(script);
|
|
149
100
|
return script;
|
|
150
101
|
};
|
|
151
|
-
let stripePromise = null;
|
|
102
|
+
let stripePromise$1 = null;
|
|
103
|
+
const isWindowStripeConnectDefined = stripeConnect => {
|
|
104
|
+
// We only consider `StripeConnect` defined if `init` is a function
|
|
105
|
+
// Why? HTML markup like:
|
|
106
|
+
// <a id="StripeConnect"><a id="StripeConnect" name="init" href="stripe"></a></a> in the <head> of the page
|
|
107
|
+
// can end up "contaminating" the window.StripeConnect object and cause issues in connect.js initialization
|
|
108
|
+
return !!(stripeConnect && typeof stripeConnect === "object" && "init" in stripeConnect && typeof stripeConnect.init === "function");
|
|
109
|
+
};
|
|
152
110
|
const loadScript = () => {
|
|
153
111
|
// Ensure that we only attempt to load Connect.js at most once
|
|
154
|
-
if (stripePromise !== null) {
|
|
155
|
-
return stripePromise;
|
|
112
|
+
if (stripePromise$1 !== null) {
|
|
113
|
+
return stripePromise$1;
|
|
156
114
|
}
|
|
157
|
-
stripePromise = new Promise((resolve, reject) => {
|
|
115
|
+
stripePromise$1 = new Promise((resolve, reject) => {
|
|
158
116
|
if (typeof window === "undefined") {
|
|
159
117
|
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.");
|
|
160
118
|
return;
|
|
161
119
|
}
|
|
162
|
-
if (window.StripeConnect) {
|
|
120
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
163
121
|
console.warn(EXISTING_SCRIPT_MESSAGE);
|
|
164
|
-
}
|
|
165
|
-
if (window.StripeConnect) {
|
|
166
122
|
const wrapper = createWrapper(window.StripeConnect);
|
|
167
123
|
resolve(wrapper);
|
|
168
124
|
return;
|
|
@@ -175,7 +131,7 @@ const loadScript = () => {
|
|
|
175
131
|
script = injectScript();
|
|
176
132
|
}
|
|
177
133
|
script.addEventListener("load", () => {
|
|
178
|
-
if (window.StripeConnect) {
|
|
134
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
179
135
|
const wrapper = createWrapper(window.StripeConnect);
|
|
180
136
|
resolve(wrapper);
|
|
181
137
|
} else {
|
|
@@ -189,7 +145,7 @@ const loadScript = () => {
|
|
|
189
145
|
reject(error);
|
|
190
146
|
}
|
|
191
147
|
});
|
|
192
|
-
return stripePromise;
|
|
148
|
+
return stripePromise$1;
|
|
193
149
|
};
|
|
194
150
|
const hasCustomMethod = tagName => {
|
|
195
151
|
return tagName in ConnectElementCustomMethodConfig;
|
|
@@ -273,7 +229,7 @@ const createWrapper = stripeConnect => {
|
|
|
273
229
|
sdk: true,
|
|
274
230
|
sdkOptions: {
|
|
275
231
|
// This will be replaced by the npm package version when bundling
|
|
276
|
-
sdkVersion: "3.3.
|
|
232
|
+
sdkVersion: "3.3.25"
|
|
277
233
|
}
|
|
278
234
|
})
|
|
279
235
|
}));
|
|
@@ -285,16 +241,16 @@ const createWrapper = stripeConnect => {
|
|
|
285
241
|
|
|
286
242
|
// Execute our own script injection after a tick to give users time to do their
|
|
287
243
|
// own script injection.
|
|
288
|
-
const stripePromise
|
|
244
|
+
const stripePromise = Promise.resolve().then(() => loadScript());
|
|
289
245
|
let loadCalled = false;
|
|
290
|
-
stripePromise
|
|
246
|
+
stripePromise.catch(err => {
|
|
291
247
|
if (!loadCalled) {
|
|
292
248
|
console.warn(err);
|
|
293
249
|
}
|
|
294
250
|
});
|
|
295
251
|
const loadConnectAndInitialize = initParams => {
|
|
296
252
|
loadCalled = true;
|
|
297
|
-
return initStripeConnect(stripePromise
|
|
253
|
+
return initStripeConnect(stripePromise, initParams);
|
|
298
254
|
};
|
|
299
255
|
|
|
300
256
|
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,16 @@ const ConnectElementCustomMethodConfig = {
|
|
|
45
38
|
"financial-account-transactions": {
|
|
46
39
|
setFinancialAccount: _financialAccount => {}
|
|
47
40
|
},
|
|
48
|
-
|
|
49
|
-
|
|
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 => {}
|
|
41
|
+
payments: {
|
|
42
|
+
setDefaultFilters: _filters => {}
|
|
74
43
|
},
|
|
75
|
-
"
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
setOnEligibleFinancingOfferLoaded: _listener => {},
|
|
79
|
-
setPrivacyPolicyUrl: _privacyPolicyUrl => {},
|
|
80
|
-
setHowCapitalWorksUrl: _howCapitalWorksUrl => {},
|
|
81
|
-
setEligibilityCriteriaUrl: _eligibilityCriteriaUrl => {}
|
|
44
|
+
"payment-details": {
|
|
45
|
+
setPayment: _payment => {},
|
|
46
|
+
setOnClose: _listener => {}
|
|
82
47
|
},
|
|
83
|
-
"
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
setIntervalEnd: _intervalEnd => {},
|
|
87
|
-
setIntervalType: _intervalType => {}
|
|
48
|
+
"payment-disputes": {
|
|
49
|
+
setPayment: _payment => {},
|
|
50
|
+
setOnDisputesLoaded: _listener => {}
|
|
88
51
|
},
|
|
89
52
|
"tax-settings": {
|
|
90
53
|
setHideProductTaxCodeSelector: _hidden => {},
|
|
@@ -94,45 +57,33 @@ const ConnectElementCustomMethodConfig = {
|
|
|
94
57
|
"tax-registrations": {
|
|
95
58
|
setOnAfterTaxRegistrationAdded: _listener => {},
|
|
96
59
|
setDisplayCountries: _countries => {}
|
|
97
|
-
},
|
|
98
|
-
"tax-threshold-monitoring": {
|
|
99
|
-
setDisplayCountries: _countries => {}
|
|
100
60
|
}
|
|
101
61
|
};
|
|
102
62
|
|
|
103
63
|
const componentNameMapping = {
|
|
64
|
+
"account-onboarding": "stripe-connect-account-onboarding",
|
|
65
|
+
"disputes-list": "stripe-connect-disputes-list",
|
|
104
66
|
payments: "stripe-connect-payments",
|
|
105
|
-
payouts: "stripe-connect-payouts",
|
|
106
67
|
"payment-details": "stripe-connect-payment-details",
|
|
107
|
-
"
|
|
108
|
-
|
|
68
|
+
"payment-disputes": "stripe-connect-payment-disputes",
|
|
69
|
+
payouts: "stripe-connect-payouts",
|
|
70
|
+
"payouts-list": "stripe-connect-payouts-list",
|
|
71
|
+
balances: "stripe-connect-balances",
|
|
109
72
|
"account-management": "stripe-connect-account-management",
|
|
110
73
|
"notification-banner": "stripe-connect-notification-banner",
|
|
111
|
-
"instant-payouts": "stripe-connect-instant-payouts",
|
|
112
74
|
"issuing-card": "stripe-connect-issuing-card",
|
|
113
75
|
"issuing-cards-list": "stripe-connect-issuing-cards-list",
|
|
114
76
|
"financial-account": "stripe-connect-financial-account",
|
|
115
|
-
recipients: "stripe-connect-recipients",
|
|
116
77
|
"financial-account-transactions": "stripe-connect-financial-account-transactions",
|
|
117
|
-
"capital-financing": "stripe-connect-capital-financing",
|
|
118
|
-
"capital-financing-application": "stripe-connect-capital-financing-application",
|
|
119
|
-
"capital-financing-promotion": "stripe-connect-capital-financing-promotion",
|
|
120
|
-
"capital-overview": "stripe-connect-capital-overview",
|
|
121
78
|
documents: "stripe-connect-documents",
|
|
122
79
|
"tax-registrations": "stripe-connect-tax-registrations",
|
|
123
|
-
"tax-settings": "stripe-connect-tax-settings"
|
|
124
|
-
"tax-threshold-monitoring": "stripe-connect-tax-threshold-monitoring",
|
|
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"
|
|
80
|
+
"tax-settings": "stripe-connect-tax-settings"
|
|
130
81
|
};
|
|
131
82
|
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
83
|
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
133
84
|
const V1_URL = "https://connect-js.stripe.com/v1.0/connect.js";
|
|
134
85
|
const findScript = () => {
|
|
135
|
-
return document.querySelectorAll(`script[src="${
|
|
86
|
+
return document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
|
|
136
87
|
};
|
|
137
88
|
const injectScript = () => {
|
|
138
89
|
const script = document.createElement("script");
|
|
@@ -145,6 +96,13 @@ const injectScript = () => {
|
|
|
145
96
|
return script;
|
|
146
97
|
};
|
|
147
98
|
let stripePromise = null;
|
|
99
|
+
const isWindowStripeConnectDefined = stripeConnect => {
|
|
100
|
+
// We only consider `StripeConnect` defined if `init` is a function
|
|
101
|
+
// Why? HTML markup like:
|
|
102
|
+
// <a id="StripeConnect"><a id="StripeConnect" name="init" href="stripe"></a></a> in the <head> of the page
|
|
103
|
+
// can end up "contaminating" the window.StripeConnect object and cause issues in connect.js initialization
|
|
104
|
+
return !!(stripeConnect && typeof stripeConnect === "object" && "init" in stripeConnect && typeof stripeConnect.init === "function");
|
|
105
|
+
};
|
|
148
106
|
const loadScript = () => {
|
|
149
107
|
// Ensure that we only attempt to load Connect.js at most once
|
|
150
108
|
if (stripePromise !== null) {
|
|
@@ -155,10 +113,8 @@ const loadScript = () => {
|
|
|
155
113
|
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
114
|
return;
|
|
157
115
|
}
|
|
158
|
-
if (window.StripeConnect) {
|
|
116
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
159
117
|
console.warn(EXISTING_SCRIPT_MESSAGE);
|
|
160
|
-
}
|
|
161
|
-
if (window.StripeConnect) {
|
|
162
118
|
const wrapper = createWrapper(window.StripeConnect);
|
|
163
119
|
resolve(wrapper);
|
|
164
120
|
return;
|
|
@@ -171,7 +127,7 @@ const loadScript = () => {
|
|
|
171
127
|
script = injectScript();
|
|
172
128
|
}
|
|
173
129
|
script.addEventListener("load", () => {
|
|
174
|
-
if (window.StripeConnect) {
|
|
130
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
175
131
|
const wrapper = createWrapper(window.StripeConnect);
|
|
176
132
|
resolve(wrapper);
|
|
177
133
|
} else {
|
|
@@ -269,7 +225,7 @@ const createWrapper = stripeConnect => {
|
|
|
269
225
|
sdk: true,
|
|
270
226
|
sdkOptions: {
|
|
271
227
|
// This will be replaced by the npm package version when bundling
|
|
272
|
-
sdkVersion: "3.3.
|
|
228
|
+
sdkVersion: "3.3.25"
|
|
273
229
|
}
|
|
274
230
|
})
|
|
275
231
|
}));
|