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

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 => {},
@@ -20,54 +16,31 @@ const ConnectElementCustomMethodConfig = {
20
16
  setCollectionOptions: _collectionOptions => {},
21
17
  setOnNotificationsChange: _listener => {}
22
18
  },
23
- "issuing-card": {
24
- setDefaultCard: _defaultCard => {},
25
- setCardArtFileLink: _cardArtFileLink => {},
26
- setCardSwitching: _cardSwitching => {},
27
- setFetchEphemeralKey: _fetchEphemeralKey => {}
28
- },
29
- "issuing-cards-list": {
30
- setCardArtFileLink: _cardArtFileLink => {},
31
- setFetchEphemeralKey: _fetchEphemeralKey => {}
32
- },
33
- "financial-account": {
34
- setFinancialAccount: _financialAccount => {}
35
- },
36
- "financial-account-transactions": {
37
- setFinancialAccount: _financialAccount => {}
19
+ "payment-details": {
20
+ setPayment: _payment => {},
21
+ setOnClose: _listener => {}
38
22
  }
39
23
  };
40
24
 
41
25
  const componentNameMapping = {
26
+ "account-onboarding": "stripe-connect-account-onboarding",
42
27
  payments: "stripe-connect-payments",
43
- payouts: "stripe-connect-payouts",
44
28
  "payment-details": "stripe-connect-payment-details",
45
- "account-onboarding": "stripe-connect-account-onboarding",
46
- "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",
47
32
  "account-management": "stripe-connect-account-management",
48
33
  "notification-banner": "stripe-connect-notification-banner",
49
- "instant-payouts": "stripe-connect-instant-payouts",
50
- "issuing-card": "stripe-connect-issuing-card",
51
- "issuing-cards-list": "stripe-connect-issuing-cards-list",
52
- "financial-account": "stripe-connect-financial-account",
53
- "financial-account-transactions": "stripe-connect-financial-account-transactions",
54
- "capital-overview": "stripe-connect-capital-overview",
55
- documents: "stripe-connect-documents",
56
- "tax-registrations": "stripe-connect-tax-registrations",
57
- "tax-settings": "stripe-connect-tax-settings",
58
- balances: "stripe-connect-balances",
59
- "payouts-list": "stripe-connect-payouts-list",
60
- "app-install": "stripe-connect-app-install",
61
- "app-viewport": "stripe-connect-app-viewport"
34
+ documents: "stripe-connect-documents"
62
35
  };
63
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";
64
- 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";
65
38
  const findScript = () => {
66
39
  return document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
67
40
  };
68
41
  const injectScript = () => {
69
42
  const script = document.createElement("script");
70
- script.src = "https://connect-js.stripe.com/v0.1/connect.js";
43
+ script.src = "https://connect-js.stripe.com/v1.0/connect.js";
71
44
  const head = document.head;
72
45
  if (!head) {
73
46
  throw new Error("Expected document.head not to be null. Connect.js requires a <head> element.");
@@ -122,7 +95,20 @@ const hasCustomMethod = tagName => {
122
95
  return tagName in ConnectElementCustomMethodConfig;
123
96
  };
124
97
  const initStripeConnect = (stripePromise, initParams) => {
125
- 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
+ })));
126
112
  return {
127
113
  create: tagName => {
128
114
  let htmlName = componentNameMapping[tagName];
@@ -188,7 +174,7 @@ const createWrapper = stripeConnect => {
188
174
  sdk: true,
189
175
  sdkOptions: {
190
176
  // This will be replaced by the npm package version when bundling
191
- sdkVersion: "3.3.7-beta-1"
177
+ sdkVersion: "3.3.9"
192
178
  }
193
179
  })
194
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 => {},
@@ -24,54 +20,31 @@ const ConnectElementCustomMethodConfig = {
24
20
  setCollectionOptions: _collectionOptions => {},
25
21
  setOnNotificationsChange: _listener => {}
26
22
  },
27
- "issuing-card": {
28
- setDefaultCard: _defaultCard => {},
29
- setCardArtFileLink: _cardArtFileLink => {},
30
- setCardSwitching: _cardSwitching => {},
31
- setFetchEphemeralKey: _fetchEphemeralKey => {}
32
- },
33
- "issuing-cards-list": {
34
- setCardArtFileLink: _cardArtFileLink => {},
35
- setFetchEphemeralKey: _fetchEphemeralKey => {}
36
- },
37
- "financial-account": {
38
- setFinancialAccount: _financialAccount => {}
39
- },
40
- "financial-account-transactions": {
41
- setFinancialAccount: _financialAccount => {}
23
+ "payment-details": {
24
+ setPayment: _payment => {},
25
+ setOnClose: _listener => {}
42
26
  }
43
27
  };
44
28
 
45
29
  const componentNameMapping = {
30
+ "account-onboarding": "stripe-connect-account-onboarding",
46
31
  payments: "stripe-connect-payments",
47
- payouts: "stripe-connect-payouts",
48
32
  "payment-details": "stripe-connect-payment-details",
49
- "account-onboarding": "stripe-connect-account-onboarding",
50
- "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",
51
36
  "account-management": "stripe-connect-account-management",
52
37
  "notification-banner": "stripe-connect-notification-banner",
53
- "instant-payouts": "stripe-connect-instant-payouts",
54
- "issuing-card": "stripe-connect-issuing-card",
55
- "issuing-cards-list": "stripe-connect-issuing-cards-list",
56
- "financial-account": "stripe-connect-financial-account",
57
- "financial-account-transactions": "stripe-connect-financial-account-transactions",
58
- "capital-overview": "stripe-connect-capital-overview",
59
- documents: "stripe-connect-documents",
60
- "tax-registrations": "stripe-connect-tax-registrations",
61
- "tax-settings": "stripe-connect-tax-settings",
62
- balances: "stripe-connect-balances",
63
- "payouts-list": "stripe-connect-payouts-list",
64
- "app-install": "stripe-connect-app-install",
65
- "app-viewport": "stripe-connect-app-viewport"
38
+ documents: "stripe-connect-documents"
66
39
  };
67
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";
68
- 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";
69
42
  const findScript = () => {
70
43
  return document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
71
44
  };
72
45
  const injectScript = () => {
73
46
  const script = document.createElement("script");
74
- script.src = "https://connect-js.stripe.com/v0.1/connect.js";
47
+ script.src = "https://connect-js.stripe.com/v1.0/connect.js";
75
48
  const head = document.head;
76
49
  if (!head) {
77
50
  throw new Error("Expected document.head not to be null. Connect.js requires a <head> element.");
@@ -126,7 +99,20 @@ const hasCustomMethod = tagName => {
126
99
  return tagName in ConnectElementCustomMethodConfig;
127
100
  };
128
101
  const initStripeConnect = (stripePromise, initParams) => {
129
- 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
+ })));
130
116
  return {
131
117
  create: tagName => {
132
118
  let htmlName = componentNameMapping[tagName];
@@ -192,7 +178,7 @@ const createWrapper = stripeConnect => {
192
178
  sdk: true,
193
179
  sdkOptions: {
194
180
  // This will be replaced by the npm package version when bundling
195
- sdkVersion: "3.3.7-beta-1"
181
+ sdkVersion: "3.3.9"
196
182
  }
197
183
  })
198
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 => {},
@@ -20,54 +16,31 @@ const ConnectElementCustomMethodConfig = {
20
16
  setCollectionOptions: _collectionOptions => {},
21
17
  setOnNotificationsChange: _listener => {}
22
18
  },
23
- "issuing-card": {
24
- setDefaultCard: _defaultCard => {},
25
- setCardArtFileLink: _cardArtFileLink => {},
26
- setCardSwitching: _cardSwitching => {},
27
- setFetchEphemeralKey: _fetchEphemeralKey => {}
28
- },
29
- "issuing-cards-list": {
30
- setCardArtFileLink: _cardArtFileLink => {},
31
- setFetchEphemeralKey: _fetchEphemeralKey => {}
32
- },
33
- "financial-account": {
34
- setFinancialAccount: _financialAccount => {}
35
- },
36
- "financial-account-transactions": {
37
- setFinancialAccount: _financialAccount => {}
19
+ "payment-details": {
20
+ setPayment: _payment => {},
21
+ setOnClose: _listener => {}
38
22
  }
39
23
  };
40
24
 
41
25
  const componentNameMapping = {
26
+ "account-onboarding": "stripe-connect-account-onboarding",
42
27
  payments: "stripe-connect-payments",
43
- payouts: "stripe-connect-payouts",
44
28
  "payment-details": "stripe-connect-payment-details",
45
- "account-onboarding": "stripe-connect-account-onboarding",
46
- "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",
47
32
  "account-management": "stripe-connect-account-management",
48
33
  "notification-banner": "stripe-connect-notification-banner",
49
- "instant-payouts": "stripe-connect-instant-payouts",
50
- "issuing-card": "stripe-connect-issuing-card",
51
- "issuing-cards-list": "stripe-connect-issuing-cards-list",
52
- "financial-account": "stripe-connect-financial-account",
53
- "financial-account-transactions": "stripe-connect-financial-account-transactions",
54
- "capital-overview": "stripe-connect-capital-overview",
55
- documents: "stripe-connect-documents",
56
- "tax-registrations": "stripe-connect-tax-registrations",
57
- "tax-settings": "stripe-connect-tax-settings",
58
- balances: "stripe-connect-balances",
59
- "payouts-list": "stripe-connect-payouts-list",
60
- "app-install": "stripe-connect-app-install",
61
- "app-viewport": "stripe-connect-app-viewport"
34
+ documents: "stripe-connect-documents"
62
35
  };
63
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";
64
- 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";
65
38
  const findScript = () => {
66
39
  return document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
67
40
  };
68
41
  const injectScript = () => {
69
42
  const script = document.createElement("script");
70
- script.src = "https://connect-js.stripe.com/v0.1/connect.js";
43
+ script.src = "https://connect-js.stripe.com/v1.0/connect.js";
71
44
  const head = document.head;
72
45
  if (!head) {
73
46
  throw new Error("Expected document.head not to be null. Connect.js requires a <head> element.");
@@ -122,7 +95,20 @@ const hasCustomMethod = tagName => {
122
95
  return tagName in ConnectElementCustomMethodConfig;
123
96
  };
124
97
  const initStripeConnect = (stripePromise, initParams) => {
125
- 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
+ })));
126
112
  return {
127
113
  create: tagName => {
128
114
  let htmlName = componentNameMapping[tagName];
@@ -188,7 +174,7 @@ const createWrapper = stripeConnect => {
188
174
  sdk: true,
189
175
  sdkOptions: {
190
176
  // This will be replaced by the npm package version when bundling
191
- sdkVersion: "3.3.7-beta-1"
177
+ sdkVersion: "3.3.9"
192
178
  }
193
179
  })
194
180
  }));
@@ -200,6 +186,9 @@ const createWrapper = stripeConnect => {
200
186
 
201
187
  const loadConnectAndInitialize = initParams => {
202
188
  const maybeConnect = loadScript();
189
+ if (initParams == null) {
190
+ throw new Error("You must provide required parameters to initialize Connect");
191
+ }
203
192
  return initStripeConnect(maybeConnect, initParams);
204
193
  };
205
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 => {},
@@ -24,54 +20,31 @@ const ConnectElementCustomMethodConfig = {
24
20
  setCollectionOptions: _collectionOptions => {},
25
21
  setOnNotificationsChange: _listener => {}
26
22
  },
27
- "issuing-card": {
28
- setDefaultCard: _defaultCard => {},
29
- setCardArtFileLink: _cardArtFileLink => {},
30
- setCardSwitching: _cardSwitching => {},
31
- setFetchEphemeralKey: _fetchEphemeralKey => {}
32
- },
33
- "issuing-cards-list": {
34
- setCardArtFileLink: _cardArtFileLink => {},
35
- setFetchEphemeralKey: _fetchEphemeralKey => {}
36
- },
37
- "financial-account": {
38
- setFinancialAccount: _financialAccount => {}
39
- },
40
- "financial-account-transactions": {
41
- setFinancialAccount: _financialAccount => {}
23
+ "payment-details": {
24
+ setPayment: _payment => {},
25
+ setOnClose: _listener => {}
42
26
  }
43
27
  };
44
28
 
45
29
  const componentNameMapping = {
30
+ "account-onboarding": "stripe-connect-account-onboarding",
46
31
  payments: "stripe-connect-payments",
47
- payouts: "stripe-connect-payouts",
48
32
  "payment-details": "stripe-connect-payment-details",
49
- "account-onboarding": "stripe-connect-account-onboarding",
50
- "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",
51
36
  "account-management": "stripe-connect-account-management",
52
37
  "notification-banner": "stripe-connect-notification-banner",
53
- "instant-payouts": "stripe-connect-instant-payouts",
54
- "issuing-card": "stripe-connect-issuing-card",
55
- "issuing-cards-list": "stripe-connect-issuing-cards-list",
56
- "financial-account": "stripe-connect-financial-account",
57
- "financial-account-transactions": "stripe-connect-financial-account-transactions",
58
- "capital-overview": "stripe-connect-capital-overview",
59
- documents: "stripe-connect-documents",
60
- "tax-registrations": "stripe-connect-tax-registrations",
61
- "tax-settings": "stripe-connect-tax-settings",
62
- balances: "stripe-connect-balances",
63
- "payouts-list": "stripe-connect-payouts-list",
64
- "app-install": "stripe-connect-app-install",
65
- "app-viewport": "stripe-connect-app-viewport"
38
+ documents: "stripe-connect-documents"
66
39
  };
67
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";
68
- 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";
69
42
  const findScript = () => {
70
43
  return document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
71
44
  };
72
45
  const injectScript = () => {
73
46
  const script = document.createElement("script");
74
- script.src = "https://connect-js.stripe.com/v0.1/connect.js";
47
+ script.src = "https://connect-js.stripe.com/v1.0/connect.js";
75
48
  const head = document.head;
76
49
  if (!head) {
77
50
  throw new Error("Expected document.head not to be null. Connect.js requires a <head> element.");
@@ -126,7 +99,20 @@ const hasCustomMethod = tagName => {
126
99
  return tagName in ConnectElementCustomMethodConfig;
127
100
  };
128
101
  const initStripeConnect = (stripePromise, initParams) => {
129
- 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
+ })));
130
116
  return {
131
117
  create: tagName => {
132
118
  let htmlName = componentNameMapping[tagName];
@@ -192,7 +178,7 @@ const createWrapper = stripeConnect => {
192
178
  sdk: true,
193
179
  sdkOptions: {
194
180
  // This will be replaced by the npm package version when bundling
195
- sdkVersion: "3.3.7-beta-1"
181
+ sdkVersion: "3.3.9"
196
182
  }
197
183
  })
198
184
  }));
@@ -204,6 +190,9 @@ const createWrapper = stripeConnect => {
204
190
 
205
191
  const loadConnectAndInitialize = initParams => {
206
192
  const maybeConnect = loadScript();
193
+ if (initParams == null) {
194
+ throw new Error("You must provide required parameters to initialize Connect");
195
+ }
207
196
  return initStripeConnect(maybeConnect, initParams);
208
197
  };
209
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,12 @@
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
  };
5
+ export type NotificationCount = {
6
+ total: number;
7
+ actionRequired: number;
8
+ };
13
9
  export declare const ConnectElementCustomMethodConfig: {
14
- "payment-details": {
15
- setPayment: (_payment: string | undefined) => void;
16
- setOnClose: (_listener: (() => void) | undefined) => void;
17
- };
18
10
  "account-onboarding": {
19
11
  setFullTermsOfServiceUrl: (_termOfServiceUrl: string | undefined) => void;
20
12
  setRecipientTermsOfServiceUrl: (_recipientTermsOfServiceUrl: string | undefined) => void;
@@ -28,22 +20,10 @@ export declare const ConnectElementCustomMethodConfig: {
28
20
  };
29
21
  "notification-banner": {
30
22
  setCollectionOptions: (_collectionOptions: CollectionOptions | undefined) => void;
31
- setOnNotificationsChange: (_listener: (() => void) | undefined) => void;
32
- };
33
- "issuing-card": {
34
- setDefaultCard: (_defaultCard: string | undefined) => void;
35
- setCardArtFileLink: (_cardArtFileLink: string | undefined) => void;
36
- setCardSwitching: (_cardSwitching: boolean | undefined) => void;
37
- setFetchEphemeralKey: (_fetchEphemeralKey: FetchEphemeralKeyFunction | undefined) => void;
23
+ setOnNotificationsChange: (_listener: (({ total, actionRequired }: NotificationCount) => void) | undefined) => void;
38
24
  };
39
- "issuing-cards-list": {
40
- setCardArtFileLink: (_cardArtFileLink: string | undefined) => void;
41
- setFetchEphemeralKey: (_fetchEphemeralKey: FetchEphemeralKeyFunction | undefined) => void;
42
- };
43
- "financial-account": {
44
- setFinancialAccount: (_financialAccount: string) => void;
45
- };
46
- "financial-account-transactions": {
47
- setFinancialAccount: (_financialAccount: string) => void;
25
+ "payment-details": {
26
+ setPayment: (_payment: string | undefined) => void;
27
+ setOnClose: (_listener: (() => void) | undefined) => void;
48
28
  };
49
29
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stripe/connect-js",
3
- "version": "3.3.9-beta-1",
3
+ "version": "3.3.9",
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,17 @@
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
 
9
+ export type NotificationCount = {
10
+ total: number;
11
+ actionRequired: number;
12
+ };
13
+
18
14
  export const ConnectElementCustomMethodConfig = {
19
- "payment-details": {
20
- setPayment: (_payment: string | undefined): void => {},
21
- setOnClose: (_listener: (() => void) | undefined): void => {}
22
- },
23
15
  "account-onboarding": {
24
16
  setFullTermsOfServiceUrl: (
25
17
  _termOfServiceUrl: string | undefined
@@ -45,26 +37,14 @@ export const ConnectElementCustomMethodConfig = {
45
37
  setCollectionOptions: (
46
38
  _collectionOptions: CollectionOptions | undefined
47
39
  ): void => {},
48
- setOnNotificationsChange: (_listener: (() => void) | undefined): void => {}
49
- },
50
- "issuing-card": {
51
- setDefaultCard: (_defaultCard: string | undefined): void => {},
52
- setCardArtFileLink: (_cardArtFileLink: string | undefined): void => {},
53
- setCardSwitching: (_cardSwitching: boolean | undefined): void => {},
54
- setFetchEphemeralKey: (
55
- _fetchEphemeralKey: FetchEphemeralKeyFunction | undefined
56
- ): void => {}
57
- },
58
- "issuing-cards-list": {
59
- setCardArtFileLink: (_cardArtFileLink: string | undefined): void => {},
60
- setFetchEphemeralKey: (
61
- _fetchEphemeralKey: FetchEphemeralKeyFunction | undefined
40
+ setOnNotificationsChange: (
41
+ _listener:
42
+ | (({ total, actionRequired }: NotificationCount) => void)
43
+ | undefined
62
44
  ): void => {}
63
45
  },
64
- "financial-account": {
65
- setFinancialAccount: (_financialAccount: string): void => {}
66
- },
67
- "financial-account-transactions": {
68
- setFinancialAccount: (_financialAccount: string): void => {}
46
+ "payment-details": {
47
+ setPayment: (_payment: string | undefined): void => {},
48
+ setOnClose: (_listener: (() => void) | undefined): void => {}
69
49
  }
70
50
  };
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";