@stripe/connect-js 3.3.8-beta-1 → 3.3.8

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.
@@ -1,10 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-empty-function */
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars */
3
3
  const ConnectElementCustomMethodConfig = {
4
- "payment-details": {
5
- setPayment: _payment => {},
6
- setOnClose: _listener => {}
7
- },
8
4
  "account-onboarding": {
9
5
  setFullTermsOfServiceUrl: _termOfServiceUrl => {},
10
6
  setRecipientTermsOfServiceUrl: _recipientTermsOfServiceUrl => {},
@@ -17,56 +13,34 @@ const ConnectElementCustomMethodConfig = {
17
13
  setCollectionOptions: _collectionOptions => {}
18
14
  },
19
15
  "notification-banner": {
20
- setCollectionOptions: _collectionOptions => {}
21
- },
22
- "issuing-card": {
23
- setDefaultCard: _defaultCard => {},
24
- setCardArtFileLink: _cardArtFileLink => {},
25
- setCardSwitching: _cardSwitching => {},
26
- setFetchEphemeralKey: _fetchEphemeralKey => {}
27
- },
28
- "issuing-cards-list": {
29
- setCardArtFileLink: _cardArtFileLink => {},
30
- setFetchEphemeralKey: _fetchEphemeralKey => {}
31
- },
32
- "financial-account": {
33
- setFinancialAccount: _financialAccount => {}
16
+ setCollectionOptions: _collectionOptions => {},
17
+ setOnNotificationsChange: _listener => {}
34
18
  },
35
- "financial-account-transactions": {
36
- setFinancialAccount: _financialAccount => {}
19
+ "payment-details": {
20
+ setPayment: _payment => {},
21
+ setOnClose: _listener => {}
37
22
  }
38
23
  };
39
24
 
40
25
  const componentNameMapping = {
26
+ "account-onboarding": "stripe-connect-account-onboarding",
41
27
  payments: "stripe-connect-payments",
42
- payouts: "stripe-connect-payouts",
43
28
  "payment-details": "stripe-connect-payment-details",
44
- "account-onboarding": "stripe-connect-account-onboarding",
45
- "payment-method-settings": "stripe-connect-payment-method-settings",
29
+ payouts: "stripe-connect-payouts",
30
+ "payouts-list": "stripe-connect-payouts-list",
31
+ balances: "stripe-connect-balances",
46
32
  "account-management": "stripe-connect-account-management",
47
33
  "notification-banner": "stripe-connect-notification-banner",
48
- "instant-payouts": "stripe-connect-instant-payouts",
49
- "issuing-card": "stripe-connect-issuing-card",
50
- "issuing-cards-list": "stripe-connect-issuing-cards-list",
51
- "financial-account": "stripe-connect-financial-account",
52
- "financial-account-transactions": "stripe-connect-financial-account-transactions",
53
- "capital-overview": "stripe-connect-capital-overview",
54
- documents: "stripe-connect-documents",
55
- "tax-registrations": "stripe-connect-tax-registrations",
56
- "tax-settings": "stripe-connect-tax-settings",
57
- balances: "stripe-connect-balances",
58
- "payouts-list": "stripe-connect-payouts-list",
59
- "app-install": "stripe-connect-app-install",
60
- "app-viewport": "stripe-connect-app-viewport"
34
+ documents: "stripe-connect-documents"
61
35
  };
62
36
  const EXISTING_SCRIPT_MESSAGE = "loadConnect was called but an existing Connect.js script already exists in the document; existing script parameters will be used";
63
- const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
37
+ const V0_URL = "https://connect-js.stripe.com/v1.0/connect.js";
64
38
  const findScript = () => {
65
39
  return document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
66
40
  };
67
41
  const injectScript = () => {
68
42
  const script = document.createElement("script");
69
- script.src = "https://connect-js.stripe.com/v0.1/connect.js";
43
+ script.src = "https://connect-js.stripe.com/v1.0/connect.js";
70
44
  const head = document.head;
71
45
  if (!head) {
72
46
  throw new Error("Expected document.head not to be null. Connect.js requires a <head> element.");
@@ -121,7 +95,20 @@ const hasCustomMethod = tagName => {
121
95
  return tagName in ConnectElementCustomMethodConfig;
122
96
  };
123
97
  const initStripeConnect = (stripePromise, initParams) => {
124
- const stripeConnectInstance = stripePromise.then(wrapper => wrapper.initialize(initParams));
98
+ var _a;
99
+ const eagerClientSecretPromise = (() => {
100
+ try {
101
+ return initParams.fetchClientSecret();
102
+ } catch (error) {
103
+ return Promise.reject(error);
104
+ }
105
+ })();
106
+ const metaOptions = (_a = initParams.metaOptions) !== null && _a !== void 0 ? _a : {};
107
+ const stripeConnectInstance = stripePromise.then(wrapper => wrapper.initialize(Object.assign(Object.assign({}, initParams), {
108
+ metaOptions: Object.assign(Object.assign({}, metaOptions), {
109
+ eagerClientSecretPromise
110
+ })
111
+ })));
125
112
  return {
126
113
  create: tagName => {
127
114
  let htmlName = componentNameMapping[tagName];
@@ -187,7 +174,7 @@ const createWrapper = stripeConnect => {
187
174
  sdk: true,
188
175
  sdkOptions: {
189
176
  // This will be replaced by the npm package version when bundling
190
- sdkVersion: "3.3.8-beta-1"
177
+ sdkVersion: "3.3.8"
191
178
  }
192
179
  })
193
180
  }));
package/dist/connect.js CHANGED
@@ -5,10 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  /* eslint-disable @typescript-eslint/no-empty-function */
6
6
  /* eslint-disable @typescript-eslint/no-unused-vars */
7
7
  const ConnectElementCustomMethodConfig = {
8
- "payment-details": {
9
- setPayment: _payment => {},
10
- setOnClose: _listener => {}
11
- },
12
8
  "account-onboarding": {
13
9
  setFullTermsOfServiceUrl: _termOfServiceUrl => {},
14
10
  setRecipientTermsOfServiceUrl: _recipientTermsOfServiceUrl => {},
@@ -21,56 +17,34 @@ const ConnectElementCustomMethodConfig = {
21
17
  setCollectionOptions: _collectionOptions => {}
22
18
  },
23
19
  "notification-banner": {
24
- setCollectionOptions: _collectionOptions => {}
25
- },
26
- "issuing-card": {
27
- setDefaultCard: _defaultCard => {},
28
- setCardArtFileLink: _cardArtFileLink => {},
29
- setCardSwitching: _cardSwitching => {},
30
- setFetchEphemeralKey: _fetchEphemeralKey => {}
31
- },
32
- "issuing-cards-list": {
33
- setCardArtFileLink: _cardArtFileLink => {},
34
- setFetchEphemeralKey: _fetchEphemeralKey => {}
35
- },
36
- "financial-account": {
37
- setFinancialAccount: _financialAccount => {}
20
+ setCollectionOptions: _collectionOptions => {},
21
+ setOnNotificationsChange: _listener => {}
38
22
  },
39
- "financial-account-transactions": {
40
- setFinancialAccount: _financialAccount => {}
23
+ "payment-details": {
24
+ setPayment: _payment => {},
25
+ setOnClose: _listener => {}
41
26
  }
42
27
  };
43
28
 
44
29
  const componentNameMapping = {
30
+ "account-onboarding": "stripe-connect-account-onboarding",
45
31
  payments: "stripe-connect-payments",
46
- payouts: "stripe-connect-payouts",
47
32
  "payment-details": "stripe-connect-payment-details",
48
- "account-onboarding": "stripe-connect-account-onboarding",
49
- "payment-method-settings": "stripe-connect-payment-method-settings",
33
+ payouts: "stripe-connect-payouts",
34
+ "payouts-list": "stripe-connect-payouts-list",
35
+ balances: "stripe-connect-balances",
50
36
  "account-management": "stripe-connect-account-management",
51
37
  "notification-banner": "stripe-connect-notification-banner",
52
- "instant-payouts": "stripe-connect-instant-payouts",
53
- "issuing-card": "stripe-connect-issuing-card",
54
- "issuing-cards-list": "stripe-connect-issuing-cards-list",
55
- "financial-account": "stripe-connect-financial-account",
56
- "financial-account-transactions": "stripe-connect-financial-account-transactions",
57
- "capital-overview": "stripe-connect-capital-overview",
58
- documents: "stripe-connect-documents",
59
- "tax-registrations": "stripe-connect-tax-registrations",
60
- "tax-settings": "stripe-connect-tax-settings",
61
- balances: "stripe-connect-balances",
62
- "payouts-list": "stripe-connect-payouts-list",
63
- "app-install": "stripe-connect-app-install",
64
- "app-viewport": "stripe-connect-app-viewport"
38
+ documents: "stripe-connect-documents"
65
39
  };
66
40
  const EXISTING_SCRIPT_MESSAGE = "loadConnect was called but an existing Connect.js script already exists in the document; existing script parameters will be used";
67
- const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
41
+ const V0_URL = "https://connect-js.stripe.com/v1.0/connect.js";
68
42
  const findScript = () => {
69
43
  return document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
70
44
  };
71
45
  const injectScript = () => {
72
46
  const script = document.createElement("script");
73
- script.src = "https://connect-js.stripe.com/v0.1/connect.js";
47
+ script.src = "https://connect-js.stripe.com/v1.0/connect.js";
74
48
  const head = document.head;
75
49
  if (!head) {
76
50
  throw new Error("Expected document.head not to be null. Connect.js requires a <head> element.");
@@ -125,7 +99,20 @@ const hasCustomMethod = tagName => {
125
99
  return tagName in ConnectElementCustomMethodConfig;
126
100
  };
127
101
  const initStripeConnect = (stripePromise, initParams) => {
128
- const stripeConnectInstance = stripePromise.then(wrapper => wrapper.initialize(initParams));
102
+ var _a;
103
+ const eagerClientSecretPromise = (() => {
104
+ try {
105
+ return initParams.fetchClientSecret();
106
+ } catch (error) {
107
+ return Promise.reject(error);
108
+ }
109
+ })();
110
+ const metaOptions = (_a = initParams.metaOptions) !== null && _a !== void 0 ? _a : {};
111
+ const stripeConnectInstance = stripePromise.then(wrapper => wrapper.initialize(Object.assign(Object.assign({}, initParams), {
112
+ metaOptions: Object.assign(Object.assign({}, metaOptions), {
113
+ eagerClientSecretPromise
114
+ })
115
+ })));
129
116
  return {
130
117
  create: tagName => {
131
118
  let htmlName = componentNameMapping[tagName];
@@ -191,7 +178,7 @@ const createWrapper = stripeConnect => {
191
178
  sdk: true,
192
179
  sdkOptions: {
193
180
  // This will be replaced by the npm package version when bundling
194
- sdkVersion: "3.3.8-beta-1"
181
+ sdkVersion: "3.3.8"
195
182
  }
196
183
  })
197
184
  }));
package/dist/pure.esm.js CHANGED
@@ -1,10 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-empty-function */
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars */
3
3
  const ConnectElementCustomMethodConfig = {
4
- "payment-details": {
5
- setPayment: _payment => {},
6
- setOnClose: _listener => {}
7
- },
8
4
  "account-onboarding": {
9
5
  setFullTermsOfServiceUrl: _termOfServiceUrl => {},
10
6
  setRecipientTermsOfServiceUrl: _recipientTermsOfServiceUrl => {},
@@ -17,56 +13,34 @@ const ConnectElementCustomMethodConfig = {
17
13
  setCollectionOptions: _collectionOptions => {}
18
14
  },
19
15
  "notification-banner": {
20
- setCollectionOptions: _collectionOptions => {}
21
- },
22
- "issuing-card": {
23
- setDefaultCard: _defaultCard => {},
24
- setCardArtFileLink: _cardArtFileLink => {},
25
- setCardSwitching: _cardSwitching => {},
26
- setFetchEphemeralKey: _fetchEphemeralKey => {}
27
- },
28
- "issuing-cards-list": {
29
- setCardArtFileLink: _cardArtFileLink => {},
30
- setFetchEphemeralKey: _fetchEphemeralKey => {}
31
- },
32
- "financial-account": {
33
- setFinancialAccount: _financialAccount => {}
16
+ setCollectionOptions: _collectionOptions => {},
17
+ setOnNotificationsChange: _listener => {}
34
18
  },
35
- "financial-account-transactions": {
36
- setFinancialAccount: _financialAccount => {}
19
+ "payment-details": {
20
+ setPayment: _payment => {},
21
+ setOnClose: _listener => {}
37
22
  }
38
23
  };
39
24
 
40
25
  const componentNameMapping = {
26
+ "account-onboarding": "stripe-connect-account-onboarding",
41
27
  payments: "stripe-connect-payments",
42
- payouts: "stripe-connect-payouts",
43
28
  "payment-details": "stripe-connect-payment-details",
44
- "account-onboarding": "stripe-connect-account-onboarding",
45
- "payment-method-settings": "stripe-connect-payment-method-settings",
29
+ payouts: "stripe-connect-payouts",
30
+ "payouts-list": "stripe-connect-payouts-list",
31
+ balances: "stripe-connect-balances",
46
32
  "account-management": "stripe-connect-account-management",
47
33
  "notification-banner": "stripe-connect-notification-banner",
48
- "instant-payouts": "stripe-connect-instant-payouts",
49
- "issuing-card": "stripe-connect-issuing-card",
50
- "issuing-cards-list": "stripe-connect-issuing-cards-list",
51
- "financial-account": "stripe-connect-financial-account",
52
- "financial-account-transactions": "stripe-connect-financial-account-transactions",
53
- "capital-overview": "stripe-connect-capital-overview",
54
- documents: "stripe-connect-documents",
55
- "tax-registrations": "stripe-connect-tax-registrations",
56
- "tax-settings": "stripe-connect-tax-settings",
57
- balances: "stripe-connect-balances",
58
- "payouts-list": "stripe-connect-payouts-list",
59
- "app-install": "stripe-connect-app-install",
60
- "app-viewport": "stripe-connect-app-viewport"
34
+ documents: "stripe-connect-documents"
61
35
  };
62
36
  const EXISTING_SCRIPT_MESSAGE = "loadConnect was called but an existing Connect.js script already exists in the document; existing script parameters will be used";
63
- const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
37
+ const V0_URL = "https://connect-js.stripe.com/v1.0/connect.js";
64
38
  const findScript = () => {
65
39
  return document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
66
40
  };
67
41
  const injectScript = () => {
68
42
  const script = document.createElement("script");
69
- script.src = "https://connect-js.stripe.com/v0.1/connect.js";
43
+ script.src = "https://connect-js.stripe.com/v1.0/connect.js";
70
44
  const head = document.head;
71
45
  if (!head) {
72
46
  throw new Error("Expected document.head not to be null. Connect.js requires a <head> element.");
@@ -121,7 +95,20 @@ const hasCustomMethod = tagName => {
121
95
  return tagName in ConnectElementCustomMethodConfig;
122
96
  };
123
97
  const initStripeConnect = (stripePromise, initParams) => {
124
- const stripeConnectInstance = stripePromise.then(wrapper => wrapper.initialize(initParams));
98
+ var _a;
99
+ const eagerClientSecretPromise = (() => {
100
+ try {
101
+ return initParams.fetchClientSecret();
102
+ } catch (error) {
103
+ return Promise.reject(error);
104
+ }
105
+ })();
106
+ const metaOptions = (_a = initParams.metaOptions) !== null && _a !== void 0 ? _a : {};
107
+ const stripeConnectInstance = stripePromise.then(wrapper => wrapper.initialize(Object.assign(Object.assign({}, initParams), {
108
+ metaOptions: Object.assign(Object.assign({}, metaOptions), {
109
+ eagerClientSecretPromise
110
+ })
111
+ })));
125
112
  return {
126
113
  create: tagName => {
127
114
  let htmlName = componentNameMapping[tagName];
@@ -187,7 +174,7 @@ const createWrapper = stripeConnect => {
187
174
  sdk: true,
188
175
  sdkOptions: {
189
176
  // This will be replaced by the npm package version when bundling
190
- sdkVersion: "3.3.8-beta-1"
177
+ sdkVersion: "3.3.8"
191
178
  }
192
179
  })
193
180
  }));
@@ -199,6 +186,9 @@ const createWrapper = stripeConnect => {
199
186
 
200
187
  const loadConnectAndInitialize = initParams => {
201
188
  const maybeConnect = loadScript();
189
+ if (initParams == null) {
190
+ throw new Error("You must provide required parameters to initialize Connect");
191
+ }
202
192
  return initStripeConnect(maybeConnect, initParams);
203
193
  };
204
194
 
package/dist/pure.js CHANGED
@@ -5,10 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  /* eslint-disable @typescript-eslint/no-empty-function */
6
6
  /* eslint-disable @typescript-eslint/no-unused-vars */
7
7
  const ConnectElementCustomMethodConfig = {
8
- "payment-details": {
9
- setPayment: _payment => {},
10
- setOnClose: _listener => {}
11
- },
12
8
  "account-onboarding": {
13
9
  setFullTermsOfServiceUrl: _termOfServiceUrl => {},
14
10
  setRecipientTermsOfServiceUrl: _recipientTermsOfServiceUrl => {},
@@ -21,56 +17,34 @@ const ConnectElementCustomMethodConfig = {
21
17
  setCollectionOptions: _collectionOptions => {}
22
18
  },
23
19
  "notification-banner": {
24
- setCollectionOptions: _collectionOptions => {}
25
- },
26
- "issuing-card": {
27
- setDefaultCard: _defaultCard => {},
28
- setCardArtFileLink: _cardArtFileLink => {},
29
- setCardSwitching: _cardSwitching => {},
30
- setFetchEphemeralKey: _fetchEphemeralKey => {}
31
- },
32
- "issuing-cards-list": {
33
- setCardArtFileLink: _cardArtFileLink => {},
34
- setFetchEphemeralKey: _fetchEphemeralKey => {}
35
- },
36
- "financial-account": {
37
- setFinancialAccount: _financialAccount => {}
20
+ setCollectionOptions: _collectionOptions => {},
21
+ setOnNotificationsChange: _listener => {}
38
22
  },
39
- "financial-account-transactions": {
40
- setFinancialAccount: _financialAccount => {}
23
+ "payment-details": {
24
+ setPayment: _payment => {},
25
+ setOnClose: _listener => {}
41
26
  }
42
27
  };
43
28
 
44
29
  const componentNameMapping = {
30
+ "account-onboarding": "stripe-connect-account-onboarding",
45
31
  payments: "stripe-connect-payments",
46
- payouts: "stripe-connect-payouts",
47
32
  "payment-details": "stripe-connect-payment-details",
48
- "account-onboarding": "stripe-connect-account-onboarding",
49
- "payment-method-settings": "stripe-connect-payment-method-settings",
33
+ payouts: "stripe-connect-payouts",
34
+ "payouts-list": "stripe-connect-payouts-list",
35
+ balances: "stripe-connect-balances",
50
36
  "account-management": "stripe-connect-account-management",
51
37
  "notification-banner": "stripe-connect-notification-banner",
52
- "instant-payouts": "stripe-connect-instant-payouts",
53
- "issuing-card": "stripe-connect-issuing-card",
54
- "issuing-cards-list": "stripe-connect-issuing-cards-list",
55
- "financial-account": "stripe-connect-financial-account",
56
- "financial-account-transactions": "stripe-connect-financial-account-transactions",
57
- "capital-overview": "stripe-connect-capital-overview",
58
- documents: "stripe-connect-documents",
59
- "tax-registrations": "stripe-connect-tax-registrations",
60
- "tax-settings": "stripe-connect-tax-settings",
61
- balances: "stripe-connect-balances",
62
- "payouts-list": "stripe-connect-payouts-list",
63
- "app-install": "stripe-connect-app-install",
64
- "app-viewport": "stripe-connect-app-viewport"
38
+ documents: "stripe-connect-documents"
65
39
  };
66
40
  const EXISTING_SCRIPT_MESSAGE = "loadConnect was called but an existing Connect.js script already exists in the document; existing script parameters will be used";
67
- const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
41
+ const V0_URL = "https://connect-js.stripe.com/v1.0/connect.js";
68
42
  const findScript = () => {
69
43
  return document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
70
44
  };
71
45
  const injectScript = () => {
72
46
  const script = document.createElement("script");
73
- script.src = "https://connect-js.stripe.com/v0.1/connect.js";
47
+ script.src = "https://connect-js.stripe.com/v1.0/connect.js";
74
48
  const head = document.head;
75
49
  if (!head) {
76
50
  throw new Error("Expected document.head not to be null. Connect.js requires a <head> element.");
@@ -125,7 +99,20 @@ const hasCustomMethod = tagName => {
125
99
  return tagName in ConnectElementCustomMethodConfig;
126
100
  };
127
101
  const initStripeConnect = (stripePromise, initParams) => {
128
- const stripeConnectInstance = stripePromise.then(wrapper => wrapper.initialize(initParams));
102
+ var _a;
103
+ const eagerClientSecretPromise = (() => {
104
+ try {
105
+ return initParams.fetchClientSecret();
106
+ } catch (error) {
107
+ return Promise.reject(error);
108
+ }
109
+ })();
110
+ const metaOptions = (_a = initParams.metaOptions) !== null && _a !== void 0 ? _a : {};
111
+ const stripeConnectInstance = stripePromise.then(wrapper => wrapper.initialize(Object.assign(Object.assign({}, initParams), {
112
+ metaOptions: Object.assign(Object.assign({}, metaOptions), {
113
+ eagerClientSecretPromise
114
+ })
115
+ })));
129
116
  return {
130
117
  create: tagName => {
131
118
  let htmlName = componentNameMapping[tagName];
@@ -191,7 +178,7 @@ const createWrapper = stripeConnect => {
191
178
  sdk: true,
192
179
  sdkOptions: {
193
180
  // This will be replaced by the npm package version when bundling
194
- sdkVersion: "3.3.8-beta-1"
181
+ sdkVersion: "3.3.8"
195
182
  }
196
183
  })
197
184
  }));
@@ -203,6 +190,9 @@ const createWrapper = stripeConnect => {
203
190
 
204
191
  const loadConnectAndInitialize = initParams => {
205
192
  const maybeConnect = loadScript();
193
+ if (initParams == null) {
194
+ throw new Error("You must provide required parameters to initialize Connect");
195
+ }
206
196
  return initStripeConnect(maybeConnect, initParams);
207
197
  };
208
198
 
@@ -1,6 +1,6 @@
1
1
  import { IStripeConnectInitParams, StripeConnectInstance, ConnectElementTagName } from "../types";
2
2
  export type LoadConnectAndInitialize = (initParams: IStripeConnectInitParams) => StripeConnectInstance;
3
- export type ConnectElementHTMLName = "stripe-connect-payments" | "stripe-connect-payouts" | "stripe-connect-payment-details" | "stripe-connect-account-onboarding" | "stripe-connect-payment-method-settings" | "stripe-connect-account-management" | "stripe-connect-notification-banner" | "stripe-connect-instant-payouts" | "stripe-connect-issuing-card" | "stripe-connect-issuing-cards-list" | "stripe-connect-financial-account" | "stripe-connect-financial-account-transactions" | "stripe-connect-capital-overview" | "stripe-connect-documents" | "stripe-connect-tax-registrations" | "stripe-connect-tax-settings" | "stripe-connect-balances" | "stripe-connect-payouts-list" | "stripe-connect-app-install" | "stripe-connect-app-viewport";
3
+ type ConnectElementHTMLName = "stripe-connect-account-onboarding" | "stripe-connect-payments" | "stripe-connect-payment-details" | "stripe-connect-account-management" | "stripe-connect-notification-banner" | "stripe-connect-payouts" | "stripe-connect-payouts-list" | "stripe-connect-balances" | "stripe-connect-documents";
4
4
  export declare const componentNameMapping: Record<ConnectElementTagName, ConnectElementHTMLName>;
5
5
  type StripeConnectInstanceExtended = StripeConnectInstance & {
6
6
  debugInstance: () => Promise<StripeConnectInstance>;
@@ -1,2 +1,2 @@
1
- export declare const SCRIPT_SELECTOR = "script[src^=\"https://connect-js.stripe.com/v0.1/connect.js\"]";
1
+ export declare const SCRIPT_SELECTOR = "script[src^=\"https://connect-js.stripe.com/v1.0/connect.js\"]";
2
2
  export {};
@@ -1,20 +1,8 @@
1
- export type FetchEphemeralKeyFunction = (fetchParams: {
2
- issuingCard: string;
3
- nonce: string;
4
- }) => Promise<{
5
- issuingCard: string;
6
- nonce: string;
7
- ephemeralKeySecret: string;
8
- }>;
9
1
  export type CollectionOptions = {
10
2
  fields: "currently_due" | "eventually_due";
11
3
  futureRequirements?: "omit" | "include";
12
4
  };
13
5
  export declare const ConnectElementCustomMethodConfig: {
14
- "payment-details": {
15
- setPayment: (_payment: string | undefined) => void;
16
- setOnClose: (_listener: (() => void) | undefined) => void;
17
- };
18
6
  "account-onboarding": {
19
7
  setFullTermsOfServiceUrl: (_termOfServiceUrl: string | undefined) => void;
20
8
  setRecipientTermsOfServiceUrl: (_recipientTermsOfServiceUrl: string | undefined) => void;
@@ -28,21 +16,10 @@ export declare const ConnectElementCustomMethodConfig: {
28
16
  };
29
17
  "notification-banner": {
30
18
  setCollectionOptions: (_collectionOptions: CollectionOptions | undefined) => void;
19
+ setOnNotificationsChange: (_listener: (() => void) | undefined) => void;
31
20
  };
32
- "issuing-card": {
33
- setDefaultCard: (_defaultCard: string | undefined) => void;
34
- setCardArtFileLink: (_cardArtFileLink: string | undefined) => void;
35
- setCardSwitching: (_cardSwitching: boolean | undefined) => void;
36
- setFetchEphemeralKey: (_fetchEphemeralKey: FetchEphemeralKeyFunction | undefined) => void;
37
- };
38
- "issuing-cards-list": {
39
- setCardArtFileLink: (_cardArtFileLink: string | undefined) => void;
40
- setFetchEphemeralKey: (_fetchEphemeralKey: FetchEphemeralKeyFunction | undefined) => void;
41
- };
42
- "financial-account": {
43
- setFinancialAccount: (_financialAccount: string) => void;
44
- };
45
- "financial-account-transactions": {
46
- setFinancialAccount: (_financialAccount: string) => void;
21
+ "payment-details": {
22
+ setPayment: (_payment: string | undefined) => void;
23
+ setOnClose: (_listener: (() => void) | undefined) => void;
47
24
  };
48
25
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stripe/connect-js",
3
- "version": "3.3.8-beta-1",
3
+ "version": "3.3.8",
4
4
  "description": "Connect.js loading utility package",
5
5
  "main": "dist/connect.js",
6
6
  "module": "dist/connect.esm.js",
package/src/pure.ts CHANGED
@@ -9,5 +9,10 @@ export const loadConnectAndInitialize: LoadConnectAndInitialize = (
9
9
  initParams: IStripeConnectInitParams
10
10
  ): StripeConnectInstance => {
11
11
  const maybeConnect = loadScript();
12
+ if (initParams == null) {
13
+ throw new Error(
14
+ "You must provide required parameters to initialize Connect"
15
+ );
16
+ }
12
17
  return initStripeConnect(maybeConnect, initParams);
13
18
  };
package/src/shared.ts CHANGED
@@ -10,53 +10,30 @@ export type LoadConnectAndInitialize = (
10
10
  initParams: IStripeConnectInitParams
11
11
  ) => StripeConnectInstance;
12
12
 
13
- export type ConnectElementHTMLName =
13
+ type ConnectElementHTMLName =
14
+ | "stripe-connect-account-onboarding"
14
15
  | "stripe-connect-payments"
15
- | "stripe-connect-payouts"
16
16
  | "stripe-connect-payment-details"
17
- | "stripe-connect-account-onboarding"
18
- | "stripe-connect-payment-method-settings"
19
17
  | "stripe-connect-account-management"
20
18
  | "stripe-connect-notification-banner"
21
- | "stripe-connect-instant-payouts"
22
- | "stripe-connect-issuing-card"
23
- | "stripe-connect-issuing-cards-list"
24
- | "stripe-connect-financial-account"
25
- | "stripe-connect-financial-account-transactions"
26
- | "stripe-connect-capital-overview"
27
- | "stripe-connect-documents"
28
- | "stripe-connect-tax-registrations"
29
- | "stripe-connect-tax-settings"
30
- | "stripe-connect-balances"
19
+ | "stripe-connect-payouts"
31
20
  | "stripe-connect-payouts-list"
32
- | "stripe-connect-app-install"
33
- | "stripe-connect-app-viewport";
21
+ | "stripe-connect-balances"
22
+ | "stripe-connect-documents";
34
23
 
35
24
  export const componentNameMapping: Record<
36
25
  ConnectElementTagName,
37
26
  ConnectElementHTMLName
38
27
  > = {
28
+ "account-onboarding": "stripe-connect-account-onboarding",
39
29
  payments: "stripe-connect-payments",
40
- payouts: "stripe-connect-payouts",
41
30
  "payment-details": "stripe-connect-payment-details",
42
- "account-onboarding": "stripe-connect-account-onboarding",
43
- "payment-method-settings": "stripe-connect-payment-method-settings",
31
+ payouts: "stripe-connect-payouts",
32
+ "payouts-list": "stripe-connect-payouts-list",
33
+ balances: "stripe-connect-balances",
44
34
  "account-management": "stripe-connect-account-management",
45
35
  "notification-banner": "stripe-connect-notification-banner",
46
- "instant-payouts": "stripe-connect-instant-payouts",
47
- "issuing-card": "stripe-connect-issuing-card",
48
- "issuing-cards-list": "stripe-connect-issuing-cards-list",
49
- "financial-account": "stripe-connect-financial-account",
50
- "financial-account-transactions":
51
- "stripe-connect-financial-account-transactions",
52
- "capital-overview": "stripe-connect-capital-overview",
53
- documents: "stripe-connect-documents",
54
- "tax-registrations": "stripe-connect-tax-registrations",
55
- "tax-settings": "stripe-connect-tax-settings",
56
- balances: "stripe-connect-balances",
57
- "payouts-list": "stripe-connect-payouts-list",
58
- "app-install": "stripe-connect-app-install",
59
- "app-viewport": "stripe-connect-app-viewport"
36
+ documents: "stripe-connect-documents"
60
37
  };
61
38
 
62
39
  type StripeConnectInstanceExtended = StripeConnectInstance & {
@@ -69,7 +46,7 @@ interface StripeConnectWrapper {
69
46
 
70
47
  const EXISTING_SCRIPT_MESSAGE =
71
48
  "loadConnect was called but an existing Connect.js script already exists in the document; existing script parameters will be used";
72
- const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
49
+ const V0_URL = "https://connect-js.stripe.com/v1.0/connect.js";
73
50
 
74
51
  export const findScript = (): HTMLScriptElement | null => {
75
52
  return (
@@ -81,7 +58,7 @@ export const findScript = (): HTMLScriptElement | null => {
81
58
 
82
59
  const injectScript = (): HTMLScriptElement => {
83
60
  const script = document.createElement("script");
84
- script.src = "https://connect-js.stripe.com/v0.1/connect.js";
61
+ script.src = "https://connect-js.stripe.com/v1.0/connect.js";
85
62
 
86
63
  const head = document.head;
87
64
 
@@ -161,8 +138,19 @@ export const initStripeConnect = (
161
138
  stripePromise: Promise<StripeConnectWrapper>,
162
139
  initParams: IStripeConnectInitParams
163
140
  ): StripeConnectInstanceExtended => {
141
+ const eagerClientSecretPromise = (() => {
142
+ try {
143
+ return initParams.fetchClientSecret();
144
+ } catch (error) {
145
+ return Promise.reject(error);
146
+ }
147
+ })();
148
+ const metaOptions = (initParams as any).metaOptions ?? {};
164
149
  const stripeConnectInstance = stripePromise.then(wrapper =>
165
- wrapper.initialize(initParams)
150
+ wrapper.initialize({
151
+ ...initParams,
152
+ metaOptions: { ...metaOptions, eagerClientSecretPromise }
153
+ } as any)
166
154
  );
167
155
 
168
156
  return {
@@ -1,4 +1,4 @@
1
1
  export const SCRIPT_SELECTOR =
2
- 'script[src^="https://connect-js.stripe.com/v0.1/connect.js"]';
2
+ 'script[src^="https://connect-js.stripe.com/v1.0/connect.js"]';
3
3
 
4
4
  export {};
package/types/config.ts CHANGED
@@ -1,25 +1,12 @@
1
1
  /* eslint-disable @typescript-eslint/no-empty-function */
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars */
3
3
 
4
- export type FetchEphemeralKeyFunction = (fetchParams: {
5
- issuingCard: string;
6
- nonce: string;
7
- }) => Promise<{
8
- issuingCard: string;
9
- nonce: string;
10
- ephemeralKeySecret: string;
11
- }>;
12
-
13
4
  export type CollectionOptions = {
14
5
  fields: "currently_due" | "eventually_due";
15
6
  futureRequirements?: "omit" | "include";
16
7
  };
17
8
 
18
9
  export const ConnectElementCustomMethodConfig = {
19
- "payment-details": {
20
- setPayment: (_payment: string | undefined): void => {},
21
- setOnClose: (_listener: (() => void) | undefined): void => {}
22
- },
23
10
  "account-onboarding": {
24
11
  setFullTermsOfServiceUrl: (
25
12
  _termOfServiceUrl: string | undefined
@@ -44,26 +31,11 @@ export const ConnectElementCustomMethodConfig = {
44
31
  "notification-banner": {
45
32
  setCollectionOptions: (
46
33
  _collectionOptions: CollectionOptions | undefined
47
- ): void => {}
48
- },
49
- "issuing-card": {
50
- setDefaultCard: (_defaultCard: string | undefined): void => {},
51
- setCardArtFileLink: (_cardArtFileLink: string | undefined): void => {},
52
- setCardSwitching: (_cardSwitching: boolean | undefined): void => {},
53
- setFetchEphemeralKey: (
54
- _fetchEphemeralKey: FetchEphemeralKeyFunction | undefined
55
- ): void => {}
56
- },
57
- "issuing-cards-list": {
58
- setCardArtFileLink: (_cardArtFileLink: string | undefined): void => {},
59
- setFetchEphemeralKey: (
60
- _fetchEphemeralKey: FetchEphemeralKeyFunction | undefined
61
- ): void => {}
62
- },
63
- "financial-account": {
64
- setFinancialAccount: (_financialAccount: string): void => {}
34
+ ): void => {},
35
+ setOnNotificationsChange: (_listener: (() => void) | undefined): void => {}
65
36
  },
66
- "financial-account-transactions": {
67
- setFinancialAccount: (_financialAccount: string): void => {}
37
+ "payment-details": {
38
+ setPayment: (_payment: string | undefined): void => {},
39
+ setOnClose: (_listener: (() => void) | undefined): void => {}
68
40
  }
69
41
  };
package/types/shared.d.ts CHANGED
@@ -447,23 +447,12 @@ export interface StripeConnectInstance {
447
447
  * Tagnames to be used with the `create` method of the Connect instance.
448
448
  */
449
449
  export type ConnectElementTagName =
450
+ | "account-onboarding"
450
451
  | "payments"
451
- | "payouts"
452
452
  | "payment-details"
453
- | "account-onboarding"
454
- | "payment-method-settings"
455
453
  | "account-management"
456
454
  | "notification-banner"
457
- | "instant-payouts"
458
- | "issuing-card"
459
- | "issuing-cards-list"
460
- | "financial-account"
461
- | "financial-account-transactions"
462
- | "capital-overview"
463
- | "documents"
464
- | "tax-registrations"
465
- | "tax-settings"
466
- | "balances"
455
+ | "payouts"
467
456
  | "payouts-list"
468
- | "app-install"
469
- | "app-viewport";
457
+ | "balances"
458
+ | "documents";