@stripe/connect-js 3.3.29-preview-1 → 3.3.29
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 +44 -87
- package/dist/connect.js +44 -87
- package/dist/pure.esm.js +36 -79
- package/dist/pure.js +36 -79
- 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 +24 -68
- 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 +53 -61
- package/types/checks.ts +2 -2
- package/types/config.ts +39 -112
- package/types/index.d.ts +1 -1
- package/types/shared.d.ts +12 -20
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 => {},
|
|
@@ -95,53 +62,38 @@ const ConnectElementCustomMethodConfig = {
|
|
|
95
62
|
setOnAfterTaxRegistrationAdded: _listener => {},
|
|
96
63
|
setDisplayCountries: _countries => {}
|
|
97
64
|
},
|
|
98
|
-
"
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
setOnTaxCodeSelect: _listener => {},
|
|
103
|
-
setHideDescription: _hideDescription => {},
|
|
104
|
-
setDisabled: _disabled => {},
|
|
105
|
-
setInitialTaxCode: _initialTaxCode => {}
|
|
106
|
-
},
|
|
107
|
-
"export-tax-transactions": {}
|
|
65
|
+
"payout-details": {
|
|
66
|
+
setPayout: _payout => {},
|
|
67
|
+
setOnClose: _listener => {}
|
|
68
|
+
}
|
|
108
69
|
};
|
|
109
70
|
|
|
110
71
|
const componentNameMapping = {
|
|
72
|
+
"account-onboarding": "stripe-connect-account-onboarding",
|
|
73
|
+
"disputes-list": "stripe-connect-disputes-list",
|
|
111
74
|
payments: "stripe-connect-payments",
|
|
112
|
-
payouts: "stripe-connect-payouts",
|
|
113
75
|
"payment-details": "stripe-connect-payment-details",
|
|
114
|
-
"
|
|
115
|
-
|
|
76
|
+
"payment-disputes": "stripe-connect-payment-disputes",
|
|
77
|
+
payouts: "stripe-connect-payouts",
|
|
78
|
+
"payouts-list": "stripe-connect-payouts-list",
|
|
79
|
+
"payout-details": "stripe-connect-payout-details",
|
|
80
|
+
balances: "stripe-connect-balances",
|
|
116
81
|
"account-management": "stripe-connect-account-management",
|
|
117
82
|
"notification-banner": "stripe-connect-notification-banner",
|
|
118
|
-
"instant-payouts": "stripe-connect-instant-payouts",
|
|
83
|
+
"instant-payouts-promotion": "stripe-connect-instant-payouts-promotion",
|
|
119
84
|
"issuing-card": "stripe-connect-issuing-card",
|
|
120
85
|
"issuing-cards-list": "stripe-connect-issuing-cards-list",
|
|
121
86
|
"financial-account": "stripe-connect-financial-account",
|
|
122
|
-
recipients: "stripe-connect-recipients",
|
|
123
87
|
"financial-account-transactions": "stripe-connect-financial-account-transactions",
|
|
124
|
-
"capital-financing": "stripe-connect-capital-financing",
|
|
125
|
-
"capital-financing-application": "stripe-connect-capital-financing-application",
|
|
126
|
-
"capital-financing-promotion": "stripe-connect-capital-financing-promotion",
|
|
127
|
-
"capital-overview": "stripe-connect-capital-overview",
|
|
128
88
|
documents: "stripe-connect-documents",
|
|
129
|
-
"product-tax-code-selector": "stripe-connect-product-tax-code-selector",
|
|
130
|
-
"export-tax-transactions": "stripe-connect-export-tax-transactions",
|
|
131
89
|
"tax-registrations": "stripe-connect-tax-registrations",
|
|
132
|
-
"tax-settings": "stripe-connect-tax-settings"
|
|
133
|
-
"tax-threshold-monitoring": "stripe-connect-tax-threshold-monitoring",
|
|
134
|
-
balances: "stripe-connect-balances",
|
|
135
|
-
"payouts-list": "stripe-connect-payouts-list",
|
|
136
|
-
"app-install": "stripe-connect-app-install",
|
|
137
|
-
"app-viewport": "stripe-connect-app-viewport",
|
|
138
|
-
"reporting-chart": "stripe-connect-reporting-chart"
|
|
90
|
+
"tax-settings": "stripe-connect-tax-settings"
|
|
139
91
|
};
|
|
140
92
|
const EXISTING_SCRIPT_MESSAGE = "loadConnect was called but an existing Connect.js script already exists in the document; existing script parameters will be used";
|
|
141
93
|
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
142
94
|
const V1_URL = "https://connect-js.stripe.com/v1.0/connect.js";
|
|
143
95
|
const findScript = () => {
|
|
144
|
-
return document.querySelectorAll(`script[src="${
|
|
96
|
+
return document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
|
|
145
97
|
};
|
|
146
98
|
const injectScript = () => {
|
|
147
99
|
const script = document.createElement("script");
|
|
@@ -153,21 +105,26 @@ const injectScript = () => {
|
|
|
153
105
|
document.head.appendChild(script);
|
|
154
106
|
return script;
|
|
155
107
|
};
|
|
156
|
-
let stripePromise = null;
|
|
108
|
+
let stripePromise$1 = null;
|
|
109
|
+
const isWindowStripeConnectDefined = stripeConnect => {
|
|
110
|
+
// We only consider `StripeConnect` defined if `init` is a function
|
|
111
|
+
// Why? HTML markup like:
|
|
112
|
+
// <a id="StripeConnect"><a id="StripeConnect" name="init" href="stripe"></a></a> in the <head> of the page
|
|
113
|
+
// can end up "contaminating" the window.StripeConnect object and cause issues in connect.js initialization
|
|
114
|
+
return !!(stripeConnect && typeof stripeConnect === "object" && "init" in stripeConnect && typeof stripeConnect.init === "function");
|
|
115
|
+
};
|
|
157
116
|
const loadScript = () => {
|
|
158
117
|
// Ensure that we only attempt to load Connect.js at most once
|
|
159
|
-
if (stripePromise !== null) {
|
|
160
|
-
return stripePromise;
|
|
118
|
+
if (stripePromise$1 !== null) {
|
|
119
|
+
return stripePromise$1;
|
|
161
120
|
}
|
|
162
|
-
stripePromise = new Promise((resolve, reject) => {
|
|
121
|
+
stripePromise$1 = new Promise((resolve, reject) => {
|
|
163
122
|
if (typeof window === "undefined") {
|
|
164
123
|
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.");
|
|
165
124
|
return;
|
|
166
125
|
}
|
|
167
|
-
if (window.StripeConnect) {
|
|
126
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
168
127
|
console.warn(EXISTING_SCRIPT_MESSAGE);
|
|
169
|
-
}
|
|
170
|
-
if (window.StripeConnect) {
|
|
171
128
|
const wrapper = createWrapper(window.StripeConnect);
|
|
172
129
|
resolve(wrapper);
|
|
173
130
|
return;
|
|
@@ -180,7 +137,7 @@ const loadScript = () => {
|
|
|
180
137
|
script = injectScript();
|
|
181
138
|
}
|
|
182
139
|
script.addEventListener("load", () => {
|
|
183
|
-
if (window.StripeConnect) {
|
|
140
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
184
141
|
const wrapper = createWrapper(window.StripeConnect);
|
|
185
142
|
resolve(wrapper);
|
|
186
143
|
} else {
|
|
@@ -194,7 +151,7 @@ const loadScript = () => {
|
|
|
194
151
|
reject(error);
|
|
195
152
|
}
|
|
196
153
|
});
|
|
197
|
-
return stripePromise;
|
|
154
|
+
return stripePromise$1;
|
|
198
155
|
};
|
|
199
156
|
const hasCustomMethod = tagName => {
|
|
200
157
|
return tagName in ConnectElementCustomMethodConfig;
|
|
@@ -278,7 +235,7 @@ const createWrapper = stripeConnect => {
|
|
|
278
235
|
sdk: true,
|
|
279
236
|
sdkOptions: {
|
|
280
237
|
// This will be replaced by the npm package version when bundling
|
|
281
|
-
sdkVersion: "3.3.29
|
|
238
|
+
sdkVersion: "3.3.29"
|
|
282
239
|
}
|
|
283
240
|
})
|
|
284
241
|
}));
|
|
@@ -290,16 +247,16 @@ const createWrapper = stripeConnect => {
|
|
|
290
247
|
|
|
291
248
|
// Execute our own script injection after a tick to give users time to do their
|
|
292
249
|
// own script injection.
|
|
293
|
-
const stripePromise
|
|
250
|
+
const stripePromise = Promise.resolve().then(() => loadScript());
|
|
294
251
|
let loadCalled = false;
|
|
295
|
-
stripePromise
|
|
252
|
+
stripePromise.catch(err => {
|
|
296
253
|
if (!loadCalled) {
|
|
297
254
|
console.warn(err);
|
|
298
255
|
}
|
|
299
256
|
});
|
|
300
257
|
const loadConnectAndInitialize = initParams => {
|
|
301
258
|
loadCalled = true;
|
|
302
|
-
return initStripeConnect(stripePromise
|
|
259
|
+
return initStripeConnect(stripePromise, initParams);
|
|
303
260
|
};
|
|
304
261
|
|
|
305
262
|
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 => {},
|
|
@@ -99,53 +66,38 @@ const ConnectElementCustomMethodConfig = {
|
|
|
99
66
|
setOnAfterTaxRegistrationAdded: _listener => {},
|
|
100
67
|
setDisplayCountries: _countries => {}
|
|
101
68
|
},
|
|
102
|
-
"
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
setOnTaxCodeSelect: _listener => {},
|
|
107
|
-
setHideDescription: _hideDescription => {},
|
|
108
|
-
setDisabled: _disabled => {},
|
|
109
|
-
setInitialTaxCode: _initialTaxCode => {}
|
|
110
|
-
},
|
|
111
|
-
"export-tax-transactions": {}
|
|
69
|
+
"payout-details": {
|
|
70
|
+
setPayout: _payout => {},
|
|
71
|
+
setOnClose: _listener => {}
|
|
72
|
+
}
|
|
112
73
|
};
|
|
113
74
|
|
|
114
75
|
const componentNameMapping = {
|
|
76
|
+
"account-onboarding": "stripe-connect-account-onboarding",
|
|
77
|
+
"disputes-list": "stripe-connect-disputes-list",
|
|
115
78
|
payments: "stripe-connect-payments",
|
|
116
|
-
payouts: "stripe-connect-payouts",
|
|
117
79
|
"payment-details": "stripe-connect-payment-details",
|
|
118
|
-
"
|
|
119
|
-
|
|
80
|
+
"payment-disputes": "stripe-connect-payment-disputes",
|
|
81
|
+
payouts: "stripe-connect-payouts",
|
|
82
|
+
"payouts-list": "stripe-connect-payouts-list",
|
|
83
|
+
"payout-details": "stripe-connect-payout-details",
|
|
84
|
+
balances: "stripe-connect-balances",
|
|
120
85
|
"account-management": "stripe-connect-account-management",
|
|
121
86
|
"notification-banner": "stripe-connect-notification-banner",
|
|
122
|
-
"instant-payouts": "stripe-connect-instant-payouts",
|
|
87
|
+
"instant-payouts-promotion": "stripe-connect-instant-payouts-promotion",
|
|
123
88
|
"issuing-card": "stripe-connect-issuing-card",
|
|
124
89
|
"issuing-cards-list": "stripe-connect-issuing-cards-list",
|
|
125
90
|
"financial-account": "stripe-connect-financial-account",
|
|
126
|
-
recipients: "stripe-connect-recipients",
|
|
127
91
|
"financial-account-transactions": "stripe-connect-financial-account-transactions",
|
|
128
|
-
"capital-financing": "stripe-connect-capital-financing",
|
|
129
|
-
"capital-financing-application": "stripe-connect-capital-financing-application",
|
|
130
|
-
"capital-financing-promotion": "stripe-connect-capital-financing-promotion",
|
|
131
|
-
"capital-overview": "stripe-connect-capital-overview",
|
|
132
92
|
documents: "stripe-connect-documents",
|
|
133
|
-
"product-tax-code-selector": "stripe-connect-product-tax-code-selector",
|
|
134
|
-
"export-tax-transactions": "stripe-connect-export-tax-transactions",
|
|
135
93
|
"tax-registrations": "stripe-connect-tax-registrations",
|
|
136
|
-
"tax-settings": "stripe-connect-tax-settings"
|
|
137
|
-
"tax-threshold-monitoring": "stripe-connect-tax-threshold-monitoring",
|
|
138
|
-
balances: "stripe-connect-balances",
|
|
139
|
-
"payouts-list": "stripe-connect-payouts-list",
|
|
140
|
-
"app-install": "stripe-connect-app-install",
|
|
141
|
-
"app-viewport": "stripe-connect-app-viewport",
|
|
142
|
-
"reporting-chart": "stripe-connect-reporting-chart"
|
|
94
|
+
"tax-settings": "stripe-connect-tax-settings"
|
|
143
95
|
};
|
|
144
96
|
const EXISTING_SCRIPT_MESSAGE = "loadConnect was called but an existing Connect.js script already exists in the document; existing script parameters will be used";
|
|
145
97
|
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
146
98
|
const V1_URL = "https://connect-js.stripe.com/v1.0/connect.js";
|
|
147
99
|
const findScript = () => {
|
|
148
|
-
return document.querySelectorAll(`script[src="${
|
|
100
|
+
return document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
|
|
149
101
|
};
|
|
150
102
|
const injectScript = () => {
|
|
151
103
|
const script = document.createElement("script");
|
|
@@ -157,21 +109,26 @@ const injectScript = () => {
|
|
|
157
109
|
document.head.appendChild(script);
|
|
158
110
|
return script;
|
|
159
111
|
};
|
|
160
|
-
let stripePromise = null;
|
|
112
|
+
let stripePromise$1 = null;
|
|
113
|
+
const isWindowStripeConnectDefined = stripeConnect => {
|
|
114
|
+
// We only consider `StripeConnect` defined if `init` is a function
|
|
115
|
+
// Why? HTML markup like:
|
|
116
|
+
// <a id="StripeConnect"><a id="StripeConnect" name="init" href="stripe"></a></a> in the <head> of the page
|
|
117
|
+
// can end up "contaminating" the window.StripeConnect object and cause issues in connect.js initialization
|
|
118
|
+
return !!(stripeConnect && typeof stripeConnect === "object" && "init" in stripeConnect && typeof stripeConnect.init === "function");
|
|
119
|
+
};
|
|
161
120
|
const loadScript = () => {
|
|
162
121
|
// Ensure that we only attempt to load Connect.js at most once
|
|
163
|
-
if (stripePromise !== null) {
|
|
164
|
-
return stripePromise;
|
|
122
|
+
if (stripePromise$1 !== null) {
|
|
123
|
+
return stripePromise$1;
|
|
165
124
|
}
|
|
166
|
-
stripePromise = new Promise((resolve, reject) => {
|
|
125
|
+
stripePromise$1 = new Promise((resolve, reject) => {
|
|
167
126
|
if (typeof window === "undefined") {
|
|
168
127
|
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.");
|
|
169
128
|
return;
|
|
170
129
|
}
|
|
171
|
-
if (window.StripeConnect) {
|
|
130
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
172
131
|
console.warn(EXISTING_SCRIPT_MESSAGE);
|
|
173
|
-
}
|
|
174
|
-
if (window.StripeConnect) {
|
|
175
132
|
const wrapper = createWrapper(window.StripeConnect);
|
|
176
133
|
resolve(wrapper);
|
|
177
134
|
return;
|
|
@@ -184,7 +141,7 @@ const loadScript = () => {
|
|
|
184
141
|
script = injectScript();
|
|
185
142
|
}
|
|
186
143
|
script.addEventListener("load", () => {
|
|
187
|
-
if (window.StripeConnect) {
|
|
144
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
188
145
|
const wrapper = createWrapper(window.StripeConnect);
|
|
189
146
|
resolve(wrapper);
|
|
190
147
|
} else {
|
|
@@ -198,7 +155,7 @@ const loadScript = () => {
|
|
|
198
155
|
reject(error);
|
|
199
156
|
}
|
|
200
157
|
});
|
|
201
|
-
return stripePromise;
|
|
158
|
+
return stripePromise$1;
|
|
202
159
|
};
|
|
203
160
|
const hasCustomMethod = tagName => {
|
|
204
161
|
return tagName in ConnectElementCustomMethodConfig;
|
|
@@ -282,7 +239,7 @@ const createWrapper = stripeConnect => {
|
|
|
282
239
|
sdk: true,
|
|
283
240
|
sdkOptions: {
|
|
284
241
|
// This will be replaced by the npm package version when bundling
|
|
285
|
-
sdkVersion: "3.3.29
|
|
242
|
+
sdkVersion: "3.3.29"
|
|
286
243
|
}
|
|
287
244
|
})
|
|
288
245
|
}));
|
|
@@ -294,16 +251,16 @@ const createWrapper = stripeConnect => {
|
|
|
294
251
|
|
|
295
252
|
// Execute our own script injection after a tick to give users time to do their
|
|
296
253
|
// own script injection.
|
|
297
|
-
const stripePromise
|
|
254
|
+
const stripePromise = Promise.resolve().then(() => loadScript());
|
|
298
255
|
let loadCalled = false;
|
|
299
|
-
stripePromise
|
|
256
|
+
stripePromise.catch(err => {
|
|
300
257
|
if (!loadCalled) {
|
|
301
258
|
console.warn(err);
|
|
302
259
|
}
|
|
303
260
|
});
|
|
304
261
|
const loadConnectAndInitialize = initParams => {
|
|
305
262
|
loadCalled = true;
|
|
306
|
-
return initStripeConnect(stripePromise
|
|
263
|
+
return initStripeConnect(stripePromise, initParams);
|
|
307
264
|
};
|
|
308
265
|
|
|
309
266
|
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 => {},
|
|
@@ -95,53 +62,38 @@ const ConnectElementCustomMethodConfig = {
|
|
|
95
62
|
setOnAfterTaxRegistrationAdded: _listener => {},
|
|
96
63
|
setDisplayCountries: _countries => {}
|
|
97
64
|
},
|
|
98
|
-
"
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
setOnTaxCodeSelect: _listener => {},
|
|
103
|
-
setHideDescription: _hideDescription => {},
|
|
104
|
-
setDisabled: _disabled => {},
|
|
105
|
-
setInitialTaxCode: _initialTaxCode => {}
|
|
106
|
-
},
|
|
107
|
-
"export-tax-transactions": {}
|
|
65
|
+
"payout-details": {
|
|
66
|
+
setPayout: _payout => {},
|
|
67
|
+
setOnClose: _listener => {}
|
|
68
|
+
}
|
|
108
69
|
};
|
|
109
70
|
|
|
110
71
|
const componentNameMapping = {
|
|
72
|
+
"account-onboarding": "stripe-connect-account-onboarding",
|
|
73
|
+
"disputes-list": "stripe-connect-disputes-list",
|
|
111
74
|
payments: "stripe-connect-payments",
|
|
112
|
-
payouts: "stripe-connect-payouts",
|
|
113
75
|
"payment-details": "stripe-connect-payment-details",
|
|
114
|
-
"
|
|
115
|
-
|
|
76
|
+
"payment-disputes": "stripe-connect-payment-disputes",
|
|
77
|
+
payouts: "stripe-connect-payouts",
|
|
78
|
+
"payouts-list": "stripe-connect-payouts-list",
|
|
79
|
+
"payout-details": "stripe-connect-payout-details",
|
|
80
|
+
balances: "stripe-connect-balances",
|
|
116
81
|
"account-management": "stripe-connect-account-management",
|
|
117
82
|
"notification-banner": "stripe-connect-notification-banner",
|
|
118
|
-
"instant-payouts": "stripe-connect-instant-payouts",
|
|
83
|
+
"instant-payouts-promotion": "stripe-connect-instant-payouts-promotion",
|
|
119
84
|
"issuing-card": "stripe-connect-issuing-card",
|
|
120
85
|
"issuing-cards-list": "stripe-connect-issuing-cards-list",
|
|
121
86
|
"financial-account": "stripe-connect-financial-account",
|
|
122
|
-
recipients: "stripe-connect-recipients",
|
|
123
87
|
"financial-account-transactions": "stripe-connect-financial-account-transactions",
|
|
124
|
-
"capital-financing": "stripe-connect-capital-financing",
|
|
125
|
-
"capital-financing-application": "stripe-connect-capital-financing-application",
|
|
126
|
-
"capital-financing-promotion": "stripe-connect-capital-financing-promotion",
|
|
127
|
-
"capital-overview": "stripe-connect-capital-overview",
|
|
128
88
|
documents: "stripe-connect-documents",
|
|
129
|
-
"product-tax-code-selector": "stripe-connect-product-tax-code-selector",
|
|
130
|
-
"export-tax-transactions": "stripe-connect-export-tax-transactions",
|
|
131
89
|
"tax-registrations": "stripe-connect-tax-registrations",
|
|
132
|
-
"tax-settings": "stripe-connect-tax-settings"
|
|
133
|
-
"tax-threshold-monitoring": "stripe-connect-tax-threshold-monitoring",
|
|
134
|
-
balances: "stripe-connect-balances",
|
|
135
|
-
"payouts-list": "stripe-connect-payouts-list",
|
|
136
|
-
"app-install": "stripe-connect-app-install",
|
|
137
|
-
"app-viewport": "stripe-connect-app-viewport",
|
|
138
|
-
"reporting-chart": "stripe-connect-reporting-chart"
|
|
90
|
+
"tax-settings": "stripe-connect-tax-settings"
|
|
139
91
|
};
|
|
140
92
|
const EXISTING_SCRIPT_MESSAGE = "loadConnect was called but an existing Connect.js script already exists in the document; existing script parameters will be used";
|
|
141
93
|
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
142
94
|
const V1_URL = "https://connect-js.stripe.com/v1.0/connect.js";
|
|
143
95
|
const findScript = () => {
|
|
144
|
-
return document.querySelectorAll(`script[src="${
|
|
96
|
+
return document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
|
|
145
97
|
};
|
|
146
98
|
const injectScript = () => {
|
|
147
99
|
const script = document.createElement("script");
|
|
@@ -154,6 +106,13 @@ const injectScript = () => {
|
|
|
154
106
|
return script;
|
|
155
107
|
};
|
|
156
108
|
let stripePromise = null;
|
|
109
|
+
const isWindowStripeConnectDefined = stripeConnect => {
|
|
110
|
+
// We only consider `StripeConnect` defined if `init` is a function
|
|
111
|
+
// Why? HTML markup like:
|
|
112
|
+
// <a id="StripeConnect"><a id="StripeConnect" name="init" href="stripe"></a></a> in the <head> of the page
|
|
113
|
+
// can end up "contaminating" the window.StripeConnect object and cause issues in connect.js initialization
|
|
114
|
+
return !!(stripeConnect && typeof stripeConnect === "object" && "init" in stripeConnect && typeof stripeConnect.init === "function");
|
|
115
|
+
};
|
|
157
116
|
const loadScript = () => {
|
|
158
117
|
// Ensure that we only attempt to load Connect.js at most once
|
|
159
118
|
if (stripePromise !== null) {
|
|
@@ -164,10 +123,8 @@ const loadScript = () => {
|
|
|
164
123
|
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.");
|
|
165
124
|
return;
|
|
166
125
|
}
|
|
167
|
-
if (window.StripeConnect) {
|
|
126
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
168
127
|
console.warn(EXISTING_SCRIPT_MESSAGE);
|
|
169
|
-
}
|
|
170
|
-
if (window.StripeConnect) {
|
|
171
128
|
const wrapper = createWrapper(window.StripeConnect);
|
|
172
129
|
resolve(wrapper);
|
|
173
130
|
return;
|
|
@@ -180,7 +137,7 @@ const loadScript = () => {
|
|
|
180
137
|
script = injectScript();
|
|
181
138
|
}
|
|
182
139
|
script.addEventListener("load", () => {
|
|
183
|
-
if (window.StripeConnect) {
|
|
140
|
+
if (isWindowStripeConnectDefined(window.StripeConnect)) {
|
|
184
141
|
const wrapper = createWrapper(window.StripeConnect);
|
|
185
142
|
resolve(wrapper);
|
|
186
143
|
} else {
|
|
@@ -278,7 +235,7 @@ const createWrapper = stripeConnect => {
|
|
|
278
235
|
sdk: true,
|
|
279
236
|
sdkOptions: {
|
|
280
237
|
// This will be replaced by the npm package version when bundling
|
|
281
|
-
sdkVersion: "3.3.29
|
|
238
|
+
sdkVersion: "3.3.29"
|
|
282
239
|
}
|
|
283
240
|
})
|
|
284
241
|
}));
|