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