@stripe/connect-js 3.3.24-preview-1 → 3.3.24
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 -74
- package/dist/connect.js +34 -74
- package/dist/pure.esm.js +26 -66
- package/dist/pure.js +26 -66
- 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 -57
- 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 +48 -55
- package/types/checks.ts +2 -2
- package/types/config.ts +20 -102
- package/types/index.d.ts +1 -1
- package/types/shared.d.ts +10 -17
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 => {},
|
|
@@ -98,37 +61,29 @@ const ConnectElementCustomMethodConfig = {
|
|
|
98
61
|
};
|
|
99
62
|
|
|
100
63
|
const componentNameMapping = {
|
|
64
|
+
"account-onboarding": "stripe-connect-account-onboarding",
|
|
65
|
+
"disputes-list": "stripe-connect-disputes-list",
|
|
101
66
|
payments: "stripe-connect-payments",
|
|
102
|
-
payouts: "stripe-connect-payouts",
|
|
103
67
|
"payment-details": "stripe-connect-payment-details",
|
|
104
|
-
"
|
|
105
|
-
|
|
68
|
+
"payment-disputes": "stripe-connect-payment-disputes",
|
|
69
|
+
payouts: "stripe-connect-payouts",
|
|
70
|
+
"payouts-list": "stripe-connect-payouts-list",
|
|
71
|
+
balances: "stripe-connect-balances",
|
|
106
72
|
"account-management": "stripe-connect-account-management",
|
|
107
73
|
"notification-banner": "stripe-connect-notification-banner",
|
|
108
|
-
"instant-payouts": "stripe-connect-instant-payouts",
|
|
109
74
|
"issuing-card": "stripe-connect-issuing-card",
|
|
110
75
|
"issuing-cards-list": "stripe-connect-issuing-cards-list",
|
|
111
76
|
"financial-account": "stripe-connect-financial-account",
|
|
112
|
-
recipients: "stripe-connect-recipients",
|
|
113
77
|
"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
78
|
documents: "stripe-connect-documents",
|
|
119
79
|
"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"
|
|
80
|
+
"tax-settings": "stripe-connect-tax-settings"
|
|
126
81
|
};
|
|
127
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";
|
|
128
83
|
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
129
84
|
const V1_URL = "https://connect-js.stripe.com/v1.0/connect.js";
|
|
130
85
|
const findScript = () => {
|
|
131
|
-
return document.querySelectorAll(`script[src="${
|
|
86
|
+
return document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
|
|
132
87
|
};
|
|
133
88
|
const injectScript = () => {
|
|
134
89
|
const script = document.createElement("script");
|
|
@@ -140,21 +95,26 @@ const injectScript = () => {
|
|
|
140
95
|
document.head.appendChild(script);
|
|
141
96
|
return script;
|
|
142
97
|
};
|
|
143
|
-
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
|
+
};
|
|
144
106
|
const loadScript = () => {
|
|
145
107
|
// Ensure that we only attempt to load Connect.js at most once
|
|
146
|
-
if (stripePromise !== null) {
|
|
147
|
-
return stripePromise;
|
|
108
|
+
if (stripePromise$1 !== null) {
|
|
109
|
+
return stripePromise$1;
|
|
148
110
|
}
|
|
149
|
-
stripePromise = new Promise((resolve, reject) => {
|
|
111
|
+
stripePromise$1 = new Promise((resolve, reject) => {
|
|
150
112
|
if (typeof window === "undefined") {
|
|
151
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.");
|
|
152
114
|
return;
|
|
153
115
|
}
|
|
154
|
-
if (window.StripeConnect) {
|
|
116
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
155
117
|
console.warn(EXISTING_SCRIPT_MESSAGE);
|
|
156
|
-
}
|
|
157
|
-
if (window.StripeConnect) {
|
|
158
118
|
const wrapper = createWrapper(window.StripeConnect);
|
|
159
119
|
resolve(wrapper);
|
|
160
120
|
return;
|
|
@@ -167,7 +127,7 @@ const loadScript = () => {
|
|
|
167
127
|
script = injectScript();
|
|
168
128
|
}
|
|
169
129
|
script.addEventListener("load", () => {
|
|
170
|
-
if (window.StripeConnect) {
|
|
130
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
171
131
|
const wrapper = createWrapper(window.StripeConnect);
|
|
172
132
|
resolve(wrapper);
|
|
173
133
|
} else {
|
|
@@ -181,7 +141,7 @@ const loadScript = () => {
|
|
|
181
141
|
reject(error);
|
|
182
142
|
}
|
|
183
143
|
});
|
|
184
|
-
return stripePromise;
|
|
144
|
+
return stripePromise$1;
|
|
185
145
|
};
|
|
186
146
|
const hasCustomMethod = tagName => {
|
|
187
147
|
return tagName in ConnectElementCustomMethodConfig;
|
|
@@ -265,7 +225,7 @@ const createWrapper = stripeConnect => {
|
|
|
265
225
|
sdk: true,
|
|
266
226
|
sdkOptions: {
|
|
267
227
|
// This will be replaced by the npm package version when bundling
|
|
268
|
-
sdkVersion: "3.3.24
|
|
228
|
+
sdkVersion: "3.3.24"
|
|
269
229
|
}
|
|
270
230
|
})
|
|
271
231
|
}));
|
|
@@ -277,16 +237,16 @@ const createWrapper = stripeConnect => {
|
|
|
277
237
|
|
|
278
238
|
// Execute our own script injection after a tick to give users time to do their
|
|
279
239
|
// own script injection.
|
|
280
|
-
const stripePromise
|
|
240
|
+
const stripePromise = Promise.resolve().then(() => loadScript());
|
|
281
241
|
let loadCalled = false;
|
|
282
|
-
stripePromise
|
|
242
|
+
stripePromise.catch(err => {
|
|
283
243
|
if (!loadCalled) {
|
|
284
244
|
console.warn(err);
|
|
285
245
|
}
|
|
286
246
|
});
|
|
287
247
|
const loadConnectAndInitialize = initParams => {
|
|
288
248
|
loadCalled = true;
|
|
289
|
-
return initStripeConnect(stripePromise
|
|
249
|
+
return initStripeConnect(stripePromise, initParams);
|
|
290
250
|
};
|
|
291
251
|
|
|
292
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 => {},
|
|
@@ -102,37 +65,29 @@ const ConnectElementCustomMethodConfig = {
|
|
|
102
65
|
};
|
|
103
66
|
|
|
104
67
|
const componentNameMapping = {
|
|
68
|
+
"account-onboarding": "stripe-connect-account-onboarding",
|
|
69
|
+
"disputes-list": "stripe-connect-disputes-list",
|
|
105
70
|
payments: "stripe-connect-payments",
|
|
106
|
-
payouts: "stripe-connect-payouts",
|
|
107
71
|
"payment-details": "stripe-connect-payment-details",
|
|
108
|
-
"
|
|
109
|
-
|
|
72
|
+
"payment-disputes": "stripe-connect-payment-disputes",
|
|
73
|
+
payouts: "stripe-connect-payouts",
|
|
74
|
+
"payouts-list": "stripe-connect-payouts-list",
|
|
75
|
+
balances: "stripe-connect-balances",
|
|
110
76
|
"account-management": "stripe-connect-account-management",
|
|
111
77
|
"notification-banner": "stripe-connect-notification-banner",
|
|
112
|
-
"instant-payouts": "stripe-connect-instant-payouts",
|
|
113
78
|
"issuing-card": "stripe-connect-issuing-card",
|
|
114
79
|
"issuing-cards-list": "stripe-connect-issuing-cards-list",
|
|
115
80
|
"financial-account": "stripe-connect-financial-account",
|
|
116
|
-
recipients: "stripe-connect-recipients",
|
|
117
81
|
"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
82
|
documents: "stripe-connect-documents",
|
|
123
83
|
"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"
|
|
84
|
+
"tax-settings": "stripe-connect-tax-settings"
|
|
130
85
|
};
|
|
131
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";
|
|
132
87
|
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
133
88
|
const V1_URL = "https://connect-js.stripe.com/v1.0/connect.js";
|
|
134
89
|
const findScript = () => {
|
|
135
|
-
return document.querySelectorAll(`script[src="${
|
|
90
|
+
return document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
|
|
136
91
|
};
|
|
137
92
|
const injectScript = () => {
|
|
138
93
|
const script = document.createElement("script");
|
|
@@ -144,21 +99,26 @@ const injectScript = () => {
|
|
|
144
99
|
document.head.appendChild(script);
|
|
145
100
|
return script;
|
|
146
101
|
};
|
|
147
|
-
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
|
+
};
|
|
148
110
|
const loadScript = () => {
|
|
149
111
|
// Ensure that we only attempt to load Connect.js at most once
|
|
150
|
-
if (stripePromise !== null) {
|
|
151
|
-
return stripePromise;
|
|
112
|
+
if (stripePromise$1 !== null) {
|
|
113
|
+
return stripePromise$1;
|
|
152
114
|
}
|
|
153
|
-
stripePromise = new Promise((resolve, reject) => {
|
|
115
|
+
stripePromise$1 = new Promise((resolve, reject) => {
|
|
154
116
|
if (typeof window === "undefined") {
|
|
155
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.");
|
|
156
118
|
return;
|
|
157
119
|
}
|
|
158
|
-
if (window.StripeConnect) {
|
|
120
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
159
121
|
console.warn(EXISTING_SCRIPT_MESSAGE);
|
|
160
|
-
}
|
|
161
|
-
if (window.StripeConnect) {
|
|
162
122
|
const wrapper = createWrapper(window.StripeConnect);
|
|
163
123
|
resolve(wrapper);
|
|
164
124
|
return;
|
|
@@ -171,7 +131,7 @@ const loadScript = () => {
|
|
|
171
131
|
script = injectScript();
|
|
172
132
|
}
|
|
173
133
|
script.addEventListener("load", () => {
|
|
174
|
-
if (window.StripeConnect) {
|
|
134
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
175
135
|
const wrapper = createWrapper(window.StripeConnect);
|
|
176
136
|
resolve(wrapper);
|
|
177
137
|
} else {
|
|
@@ -185,7 +145,7 @@ const loadScript = () => {
|
|
|
185
145
|
reject(error);
|
|
186
146
|
}
|
|
187
147
|
});
|
|
188
|
-
return stripePromise;
|
|
148
|
+
return stripePromise$1;
|
|
189
149
|
};
|
|
190
150
|
const hasCustomMethod = tagName => {
|
|
191
151
|
return tagName in ConnectElementCustomMethodConfig;
|
|
@@ -269,7 +229,7 @@ const createWrapper = stripeConnect => {
|
|
|
269
229
|
sdk: true,
|
|
270
230
|
sdkOptions: {
|
|
271
231
|
// This will be replaced by the npm package version when bundling
|
|
272
|
-
sdkVersion: "3.3.24
|
|
232
|
+
sdkVersion: "3.3.24"
|
|
273
233
|
}
|
|
274
234
|
})
|
|
275
235
|
}));
|
|
@@ -281,16 +241,16 @@ const createWrapper = stripeConnect => {
|
|
|
281
241
|
|
|
282
242
|
// Execute our own script injection after a tick to give users time to do their
|
|
283
243
|
// own script injection.
|
|
284
|
-
const stripePromise
|
|
244
|
+
const stripePromise = Promise.resolve().then(() => loadScript());
|
|
285
245
|
let loadCalled = false;
|
|
286
|
-
stripePromise
|
|
246
|
+
stripePromise.catch(err => {
|
|
287
247
|
if (!loadCalled) {
|
|
288
248
|
console.warn(err);
|
|
289
249
|
}
|
|
290
250
|
});
|
|
291
251
|
const loadConnectAndInitialize = initParams => {
|
|
292
252
|
loadCalled = true;
|
|
293
|
-
return initStripeConnect(stripePromise
|
|
253
|
+
return initStripeConnect(stripePromise, initParams);
|
|
294
254
|
};
|
|
295
255
|
|
|
296
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 => {},
|
|
@@ -98,37 +61,29 @@ const ConnectElementCustomMethodConfig = {
|
|
|
98
61
|
};
|
|
99
62
|
|
|
100
63
|
const componentNameMapping = {
|
|
64
|
+
"account-onboarding": "stripe-connect-account-onboarding",
|
|
65
|
+
"disputes-list": "stripe-connect-disputes-list",
|
|
101
66
|
payments: "stripe-connect-payments",
|
|
102
|
-
payouts: "stripe-connect-payouts",
|
|
103
67
|
"payment-details": "stripe-connect-payment-details",
|
|
104
|
-
"
|
|
105
|
-
|
|
68
|
+
"payment-disputes": "stripe-connect-payment-disputes",
|
|
69
|
+
payouts: "stripe-connect-payouts",
|
|
70
|
+
"payouts-list": "stripe-connect-payouts-list",
|
|
71
|
+
balances: "stripe-connect-balances",
|
|
106
72
|
"account-management": "stripe-connect-account-management",
|
|
107
73
|
"notification-banner": "stripe-connect-notification-banner",
|
|
108
|
-
"instant-payouts": "stripe-connect-instant-payouts",
|
|
109
74
|
"issuing-card": "stripe-connect-issuing-card",
|
|
110
75
|
"issuing-cards-list": "stripe-connect-issuing-cards-list",
|
|
111
76
|
"financial-account": "stripe-connect-financial-account",
|
|
112
|
-
recipients: "stripe-connect-recipients",
|
|
113
77
|
"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
78
|
documents: "stripe-connect-documents",
|
|
119
79
|
"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"
|
|
80
|
+
"tax-settings": "stripe-connect-tax-settings"
|
|
126
81
|
};
|
|
127
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";
|
|
128
83
|
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
129
84
|
const V1_URL = "https://connect-js.stripe.com/v1.0/connect.js";
|
|
130
85
|
const findScript = () => {
|
|
131
|
-
return document.querySelectorAll(`script[src="${
|
|
86
|
+
return document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
|
|
132
87
|
};
|
|
133
88
|
const injectScript = () => {
|
|
134
89
|
const script = document.createElement("script");
|
|
@@ -141,6 +96,13 @@ const injectScript = () => {
|
|
|
141
96
|
return script;
|
|
142
97
|
};
|
|
143
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
|
+
};
|
|
144
106
|
const loadScript = () => {
|
|
145
107
|
// Ensure that we only attempt to load Connect.js at most once
|
|
146
108
|
if (stripePromise !== null) {
|
|
@@ -151,10 +113,8 @@ const loadScript = () => {
|
|
|
151
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.");
|
|
152
114
|
return;
|
|
153
115
|
}
|
|
154
|
-
if (window.StripeConnect) {
|
|
116
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
155
117
|
console.warn(EXISTING_SCRIPT_MESSAGE);
|
|
156
|
-
}
|
|
157
|
-
if (window.StripeConnect) {
|
|
158
118
|
const wrapper = createWrapper(window.StripeConnect);
|
|
159
119
|
resolve(wrapper);
|
|
160
120
|
return;
|
|
@@ -167,7 +127,7 @@ const loadScript = () => {
|
|
|
167
127
|
script = injectScript();
|
|
168
128
|
}
|
|
169
129
|
script.addEventListener("load", () => {
|
|
170
|
-
if (window.StripeConnect) {
|
|
130
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
171
131
|
const wrapper = createWrapper(window.StripeConnect);
|
|
172
132
|
resolve(wrapper);
|
|
173
133
|
} else {
|
|
@@ -265,7 +225,7 @@ const createWrapper = stripeConnect => {
|
|
|
265
225
|
sdk: true,
|
|
266
226
|
sdkOptions: {
|
|
267
227
|
// This will be replaced by the npm package version when bundling
|
|
268
|
-
sdkVersion: "3.3.24
|
|
228
|
+
sdkVersion: "3.3.24"
|
|
269
229
|
}
|
|
270
230
|
})
|
|
271
231
|
}));
|