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

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,10 @@
1
1
  /* eslint-disable @typescript-eslint/no-empty-function */
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars */
3
+ const ConnectElementCommonMethodConfig = {
4
+ setOnLoadError: _listener => {},
5
+ setOnLoaderStart: _listener => {}
6
+ };
3
7
  const ConnectElementCustomMethodConfig = {
4
- "payment-details": {
5
- setPayment: _payment => {},
6
- setOnClose: _listener => {}
7
- },
8
8
  "account-onboarding": {
9
9
  setFullTermsOfServiceUrl: _termOfServiceUrl => {},
10
10
  setRecipientTermsOfServiceUrl: _recipientTermsOfServiceUrl => {},
@@ -20,51 +20,30 @@ const ConnectElementCustomMethodConfig = {
20
20
  setCollectionOptions: _collectionOptions => {},
21
21
  setOnNotificationsChange: _listener => {}
22
22
  },
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 => {}
23
+ "payment-details": {
24
+ setPayment: _payment => {},
25
+ setOnClose: _listener => {}
38
26
  }
39
27
  };
40
28
 
41
29
  const componentNameMapping = {
30
+ "account-onboarding": "stripe-connect-account-onboarding",
42
31
  payments: "stripe-connect-payments",
43
- payouts: "stripe-connect-payouts",
44
32
  "payment-details": "stripe-connect-payment-details",
45
- "account-onboarding": "stripe-connect-account-onboarding",
46
- "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",
47
36
  "account-management": "stripe-connect-account-management",
48
37
  "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
38
  documents: "stripe-connect-documents",
56
39
  "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"
40
+ "tax-settings": "stripe-connect-tax-settings"
62
41
  };
63
42
  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
43
  const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
65
44
  const V1_URL = "https://connect-js.stripe.com/v1.0/connect.js";
66
45
  const findScript = () => {
67
- return document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || null;
46
+ return document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
68
47
  };
69
48
  const injectScript = () => {
70
49
  const script = document.createElement("script");
@@ -144,15 +123,14 @@ const initStripeConnect = (stripePromise, initParams) => {
144
123
  htmlName = tagName;
145
124
  }
146
125
  const element = document.createElement(htmlName);
147
- if (hasCustomMethod(tagName)) {
148
- const methods = ConnectElementCustomMethodConfig[tagName];
149
- for (const method in methods) {
150
- element[method] = function (value) {
151
- stripeConnectInstance.then(() => {
152
- this[`${method}InternalOnly`](value);
153
- });
154
- };
155
- }
126
+ const customMethods = hasCustomMethod(tagName) ? ConnectElementCustomMethodConfig[tagName] : {};
127
+ const methods = Object.assign(Object.assign({}, customMethods), ConnectElementCommonMethodConfig);
128
+ for (const method in methods) {
129
+ element[method] = function (value) {
130
+ stripeConnectInstance.then(() => {
131
+ this[`${method}InternalOnly`](value);
132
+ });
133
+ };
156
134
  }
157
135
  stripeConnectInstance.then(instance => {
158
136
  if (!element.isConnected && !element.setConnector) {
@@ -202,7 +180,7 @@ const createWrapper = stripeConnect => {
202
180
  sdk: true,
203
181
  sdkOptions: {
204
182
  // This will be replaced by the npm package version when bundling
205
- sdkVersion: "3.3.12-beta-1"
183
+ sdkVersion: "3.3.12"
206
184
  }
207
185
  })
208
186
  }));
package/dist/connect.js CHANGED
@@ -4,11 +4,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  /* eslint-disable @typescript-eslint/no-empty-function */
6
6
  /* eslint-disable @typescript-eslint/no-unused-vars */
7
+ const ConnectElementCommonMethodConfig = {
8
+ setOnLoadError: _listener => {},
9
+ setOnLoaderStart: _listener => {}
10
+ };
7
11
  const ConnectElementCustomMethodConfig = {
8
- "payment-details": {
9
- setPayment: _payment => {},
10
- setOnClose: _listener => {}
11
- },
12
12
  "account-onboarding": {
13
13
  setFullTermsOfServiceUrl: _termOfServiceUrl => {},
14
14
  setRecipientTermsOfServiceUrl: _recipientTermsOfServiceUrl => {},
@@ -24,51 +24,30 @@ const ConnectElementCustomMethodConfig = {
24
24
  setCollectionOptions: _collectionOptions => {},
25
25
  setOnNotificationsChange: _listener => {}
26
26
  },
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 => {}
27
+ "payment-details": {
28
+ setPayment: _payment => {},
29
+ setOnClose: _listener => {}
42
30
  }
43
31
  };
44
32
 
45
33
  const componentNameMapping = {
34
+ "account-onboarding": "stripe-connect-account-onboarding",
46
35
  payments: "stripe-connect-payments",
47
- payouts: "stripe-connect-payouts",
48
36
  "payment-details": "stripe-connect-payment-details",
49
- "account-onboarding": "stripe-connect-account-onboarding",
50
- "payment-method-settings": "stripe-connect-payment-method-settings",
37
+ payouts: "stripe-connect-payouts",
38
+ "payouts-list": "stripe-connect-payouts-list",
39
+ balances: "stripe-connect-balances",
51
40
  "account-management": "stripe-connect-account-management",
52
41
  "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
42
  documents: "stripe-connect-documents",
60
43
  "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"
44
+ "tax-settings": "stripe-connect-tax-settings"
66
45
  };
67
46
  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
47
  const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
69
48
  const V1_URL = "https://connect-js.stripe.com/v1.0/connect.js";
70
49
  const findScript = () => {
71
- return document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || null;
50
+ return document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
72
51
  };
73
52
  const injectScript = () => {
74
53
  const script = document.createElement("script");
@@ -148,15 +127,14 @@ const initStripeConnect = (stripePromise, initParams) => {
148
127
  htmlName = tagName;
149
128
  }
150
129
  const element = document.createElement(htmlName);
151
- if (hasCustomMethod(tagName)) {
152
- const methods = ConnectElementCustomMethodConfig[tagName];
153
- for (const method in methods) {
154
- element[method] = function (value) {
155
- stripeConnectInstance.then(() => {
156
- this[`${method}InternalOnly`](value);
157
- });
158
- };
159
- }
130
+ const customMethods = hasCustomMethod(tagName) ? ConnectElementCustomMethodConfig[tagName] : {};
131
+ const methods = Object.assign(Object.assign({}, customMethods), ConnectElementCommonMethodConfig);
132
+ for (const method in methods) {
133
+ element[method] = function (value) {
134
+ stripeConnectInstance.then(() => {
135
+ this[`${method}InternalOnly`](value);
136
+ });
137
+ };
160
138
  }
161
139
  stripeConnectInstance.then(instance => {
162
140
  if (!element.isConnected && !element.setConnector) {
@@ -206,7 +184,7 @@ const createWrapper = stripeConnect => {
206
184
  sdk: true,
207
185
  sdkOptions: {
208
186
  // This will be replaced by the npm package version when bundling
209
- sdkVersion: "3.3.12-beta-1"
187
+ sdkVersion: "3.3.12"
210
188
  }
211
189
  })
212
190
  }));
package/dist/pure.esm.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /* eslint-disable @typescript-eslint/no-empty-function */
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars */
3
+ const ConnectElementCommonMethodConfig = {
4
+ setOnLoadError: _listener => {},
5
+ setOnLoaderStart: _listener => {}
6
+ };
3
7
  const ConnectElementCustomMethodConfig = {
4
- "payment-details": {
5
- setPayment: _payment => {},
6
- setOnClose: _listener => {}
7
- },
8
8
  "account-onboarding": {
9
9
  setFullTermsOfServiceUrl: _termOfServiceUrl => {},
10
10
  setRecipientTermsOfServiceUrl: _recipientTermsOfServiceUrl => {},
@@ -20,51 +20,30 @@ const ConnectElementCustomMethodConfig = {
20
20
  setCollectionOptions: _collectionOptions => {},
21
21
  setOnNotificationsChange: _listener => {}
22
22
  },
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 => {}
23
+ "payment-details": {
24
+ setPayment: _payment => {},
25
+ setOnClose: _listener => {}
38
26
  }
39
27
  };
40
28
 
41
29
  const componentNameMapping = {
30
+ "account-onboarding": "stripe-connect-account-onboarding",
42
31
  payments: "stripe-connect-payments",
43
- payouts: "stripe-connect-payouts",
44
32
  "payment-details": "stripe-connect-payment-details",
45
- "account-onboarding": "stripe-connect-account-onboarding",
46
- "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",
47
36
  "account-management": "stripe-connect-account-management",
48
37
  "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
38
  documents: "stripe-connect-documents",
56
39
  "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"
40
+ "tax-settings": "stripe-connect-tax-settings"
62
41
  };
63
42
  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
43
  const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
65
44
  const V1_URL = "https://connect-js.stripe.com/v1.0/connect.js";
66
45
  const findScript = () => {
67
- return document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || null;
46
+ return document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
68
47
  };
69
48
  const injectScript = () => {
70
49
  const script = document.createElement("script");
@@ -144,15 +123,14 @@ const initStripeConnect = (stripePromise, initParams) => {
144
123
  htmlName = tagName;
145
124
  }
146
125
  const element = document.createElement(htmlName);
147
- if (hasCustomMethod(tagName)) {
148
- const methods = ConnectElementCustomMethodConfig[tagName];
149
- for (const method in methods) {
150
- element[method] = function (value) {
151
- stripeConnectInstance.then(() => {
152
- this[`${method}InternalOnly`](value);
153
- });
154
- };
155
- }
126
+ const customMethods = hasCustomMethod(tagName) ? ConnectElementCustomMethodConfig[tagName] : {};
127
+ const methods = Object.assign(Object.assign({}, customMethods), ConnectElementCommonMethodConfig);
128
+ for (const method in methods) {
129
+ element[method] = function (value) {
130
+ stripeConnectInstance.then(() => {
131
+ this[`${method}InternalOnly`](value);
132
+ });
133
+ };
156
134
  }
157
135
  stripeConnectInstance.then(instance => {
158
136
  if (!element.isConnected && !element.setConnector) {
@@ -202,7 +180,7 @@ const createWrapper = stripeConnect => {
202
180
  sdk: true,
203
181
  sdkOptions: {
204
182
  // This will be replaced by the npm package version when bundling
205
- sdkVersion: "3.3.12-beta-1"
183
+ sdkVersion: "3.3.12"
206
184
  }
207
185
  })
208
186
  }));
package/dist/pure.js CHANGED
@@ -4,11 +4,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  /* eslint-disable @typescript-eslint/no-empty-function */
6
6
  /* eslint-disable @typescript-eslint/no-unused-vars */
7
+ const ConnectElementCommonMethodConfig = {
8
+ setOnLoadError: _listener => {},
9
+ setOnLoaderStart: _listener => {}
10
+ };
7
11
  const ConnectElementCustomMethodConfig = {
8
- "payment-details": {
9
- setPayment: _payment => {},
10
- setOnClose: _listener => {}
11
- },
12
12
  "account-onboarding": {
13
13
  setFullTermsOfServiceUrl: _termOfServiceUrl => {},
14
14
  setRecipientTermsOfServiceUrl: _recipientTermsOfServiceUrl => {},
@@ -24,51 +24,30 @@ const ConnectElementCustomMethodConfig = {
24
24
  setCollectionOptions: _collectionOptions => {},
25
25
  setOnNotificationsChange: _listener => {}
26
26
  },
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 => {}
27
+ "payment-details": {
28
+ setPayment: _payment => {},
29
+ setOnClose: _listener => {}
42
30
  }
43
31
  };
44
32
 
45
33
  const componentNameMapping = {
34
+ "account-onboarding": "stripe-connect-account-onboarding",
46
35
  payments: "stripe-connect-payments",
47
- payouts: "stripe-connect-payouts",
48
36
  "payment-details": "stripe-connect-payment-details",
49
- "account-onboarding": "stripe-connect-account-onboarding",
50
- "payment-method-settings": "stripe-connect-payment-method-settings",
37
+ payouts: "stripe-connect-payouts",
38
+ "payouts-list": "stripe-connect-payouts-list",
39
+ balances: "stripe-connect-balances",
51
40
  "account-management": "stripe-connect-account-management",
52
41
  "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
42
  documents: "stripe-connect-documents",
60
43
  "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"
44
+ "tax-settings": "stripe-connect-tax-settings"
66
45
  };
67
46
  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
47
  const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
69
48
  const V1_URL = "https://connect-js.stripe.com/v1.0/connect.js";
70
49
  const findScript = () => {
71
- return document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || null;
50
+ return document.querySelectorAll(`script[src="${V1_URL}"]`)[0] || document.querySelectorAll(`script[src="${V0_URL}"]`)[0] || null;
72
51
  };
73
52
  const injectScript = () => {
74
53
  const script = document.createElement("script");
@@ -148,15 +127,14 @@ const initStripeConnect = (stripePromise, initParams) => {
148
127
  htmlName = tagName;
149
128
  }
150
129
  const element = document.createElement(htmlName);
151
- if (hasCustomMethod(tagName)) {
152
- const methods = ConnectElementCustomMethodConfig[tagName];
153
- for (const method in methods) {
154
- element[method] = function (value) {
155
- stripeConnectInstance.then(() => {
156
- this[`${method}InternalOnly`](value);
157
- });
158
- };
159
- }
130
+ const customMethods = hasCustomMethod(tagName) ? ConnectElementCustomMethodConfig[tagName] : {};
131
+ const methods = Object.assign(Object.assign({}, customMethods), ConnectElementCommonMethodConfig);
132
+ for (const method in methods) {
133
+ element[method] = function (value) {
134
+ stripeConnectInstance.then(() => {
135
+ this[`${method}InternalOnly`](value);
136
+ });
137
+ };
160
138
  }
161
139
  stripeConnectInstance.then(instance => {
162
140
  if (!element.isConnected && !element.setConnector) {
@@ -206,7 +184,7 @@ const createWrapper = stripeConnect => {
206
184
  sdk: true,
207
185
  sdkOptions: {
208
186
  // This will be replaced by the npm package version when bundling
209
- sdkVersion: "3.3.12-beta-1"
187
+ sdkVersion: "3.3.12"
210
188
  }
211
189
  })
212
190
  }));
@@ -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" | "stripe-connect-tax-registrations" | "stripe-connect-tax-settings";
4
4
  export declare const componentNameMapping: Record<ConnectElementTagName, ConnectElementHTMLName>;
5
5
  type StripeConnectInstanceExtended = StripeConnectInstance & {
6
6
  debugInstance: () => Promise<StripeConnectInstance>;
@@ -1,11 +1,3 @@
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";
@@ -14,11 +6,47 @@ export type NotificationCount = {
14
6
  total: number;
15
7
  actionRequired: number;
16
8
  };
9
+ export type LoaderStart = {
10
+ elementTagName: string;
11
+ };
12
+ export type LoadError = {
13
+ elementTagName: string;
14
+ error: EmbeddedError;
15
+ };
16
+ export type EmbeddedError = {
17
+ type: EmbeddedErrorType;
18
+ message?: string;
19
+ };
20
+ export type EmbeddedErrorType =
21
+ /**
22
+ * Failure to connect to Stripe's API.
23
+ */
24
+ "api_connection_error"
25
+ /**
26
+ * Failure to perform the authentication flow within Connect Embedded Components
27
+ */
28
+ | "authentication_error"
29
+ /**
30
+ * Account session create failed
31
+ */
32
+ | "account_session_create_error"
33
+ /**
34
+ * Request failed with an 4xx status code, typically caused by platform configuration issues
35
+ */
36
+ | "invalid_request_error"
37
+ /**
38
+ * Too many requests hit the API too quickly.
39
+ */
40
+ | "rate_limit_error"
41
+ /**
42
+ * API errors covering any other type of problem (e.g., a temporary problem with Stripe's servers), and are extremely uncommon.
43
+ */
44
+ | "api_error";
45
+ export declare const ConnectElementCommonMethodConfig: {
46
+ setOnLoadError: (_listener: (({ error, elementTagName }: LoadError) => void) | undefined) => void;
47
+ setOnLoaderStart: (_listener: (({ elementTagName }: LoaderStart) => void) | undefined) => void;
48
+ };
17
49
  export declare const ConnectElementCustomMethodConfig: {
18
- "payment-details": {
19
- setPayment: (_payment: string | undefined) => void;
20
- setOnClose: (_listener: (() => void) | undefined) => void;
21
- };
22
50
  "account-onboarding": {
23
51
  setFullTermsOfServiceUrl: (_termOfServiceUrl: string | undefined) => void;
24
52
  setRecipientTermsOfServiceUrl: (_recipientTermsOfServiceUrl: string | undefined) => void;
@@ -34,20 +62,8 @@ export declare const ConnectElementCustomMethodConfig: {
34
62
  setCollectionOptions: (_collectionOptions: CollectionOptions | undefined) => void;
35
63
  setOnNotificationsChange: (_listener: (({ total, actionRequired }: NotificationCount) => void) | undefined) => void;
36
64
  };
37
- "issuing-card": {
38
- setDefaultCard: (_defaultCard: string | undefined) => void;
39
- setCardArtFileLink: (_cardArtFileLink: string | undefined) => void;
40
- setCardSwitching: (_cardSwitching: boolean | undefined) => void;
41
- setFetchEphemeralKey: (_fetchEphemeralKey: FetchEphemeralKeyFunction | undefined) => void;
42
- };
43
- "issuing-cards-list": {
44
- setCardArtFileLink: (_cardArtFileLink: string | undefined) => void;
45
- setFetchEphemeralKey: (_fetchEphemeralKey: FetchEphemeralKeyFunction | undefined) => void;
46
- };
47
- "financial-account": {
48
- setFinancialAccount: (_financialAccount: string) => void;
49
- };
50
- "financial-account-transactions": {
51
- setFinancialAccount: (_financialAccount: string) => void;
65
+ "payment-details": {
66
+ setPayment: (_payment: string | undefined) => void;
67
+ setOnClose: (_listener: (() => void) | undefined) => void;
52
68
  };
53
69
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stripe/connect-js",
3
- "version": "3.3.12-beta-1",
3
+ "version": "3.3.12",
4
4
  "description": "Connect.js loading utility package",
5
5
  "main": "dist/connect.js",
6
6
  "module": "dist/connect.esm.js",
package/src/shared.ts CHANGED
@@ -4,59 +4,43 @@ import {
4
4
  ConnectElementTagName,
5
5
  ConnectHTMLElementRecord
6
6
  } from "../types";
7
- import { ConnectElementCustomMethodConfig } from "../types/config";
7
+ import {
8
+ ConnectElementCommonMethodConfig,
9
+ ConnectElementCustomMethodConfig
10
+ } from "../types/config";
8
11
 
9
12
  export type LoadConnectAndInitialize = (
10
13
  initParams: IStripeConnectInitParams
11
14
  ) => StripeConnectInstance;
12
15
 
13
- export type ConnectElementHTMLName =
16
+ type ConnectElementHTMLName =
17
+ | "stripe-connect-account-onboarding"
14
18
  | "stripe-connect-payments"
15
- | "stripe-connect-payouts"
16
19
  | "stripe-connect-payment-details"
17
- | "stripe-connect-account-onboarding"
18
- | "stripe-connect-payment-method-settings"
19
20
  | "stripe-connect-account-management"
20
21
  | "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"
22
+ | "stripe-connect-payouts"
23
+ | "stripe-connect-payouts-list"
24
+ | "stripe-connect-balances"
27
25
  | "stripe-connect-documents"
28
26
  | "stripe-connect-tax-registrations"
29
- | "stripe-connect-tax-settings"
30
- | "stripe-connect-balances"
31
- | "stripe-connect-payouts-list"
32
- | "stripe-connect-app-install"
33
- | "stripe-connect-app-viewport";
27
+ | "stripe-connect-tax-settings";
34
28
 
35
29
  export const componentNameMapping: Record<
36
30
  ConnectElementTagName,
37
31
  ConnectElementHTMLName
38
32
  > = {
33
+ "account-onboarding": "stripe-connect-account-onboarding",
39
34
  payments: "stripe-connect-payments",
40
- payouts: "stripe-connect-payouts",
41
35
  "payment-details": "stripe-connect-payment-details",
42
- "account-onboarding": "stripe-connect-account-onboarding",
43
- "payment-method-settings": "stripe-connect-payment-method-settings",
36
+ payouts: "stripe-connect-payouts",
37
+ "payouts-list": "stripe-connect-payouts-list",
38
+ balances: "stripe-connect-balances",
44
39
  "account-management": "stripe-connect-account-management",
45
40
  "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
41
  documents: "stripe-connect-documents",
54
42
  "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"
43
+ "tax-settings": "stripe-connect-tax-settings"
60
44
  };
61
45
 
62
46
  type StripeConnectInstanceExtended = StripeConnectInstance & {
@@ -75,10 +59,10 @@ const V1_URL = "https://connect-js.stripe.com/v1.0/connect.js";
75
59
  export const findScript = (): HTMLScriptElement | null => {
76
60
  return (
77
61
  document.querySelectorAll<HTMLScriptElement>(
78
- `script[src="${V0_URL}"]`
62
+ `script[src="${V1_URL}"]`
79
63
  )[0] ||
80
64
  document.querySelectorAll<HTMLScriptElement>(
81
- `script[src="${V1_URL}"]`
65
+ `script[src="${V0_URL}"]`
82
66
  )[0] ||
83
67
  null
84
68
  );
@@ -189,15 +173,16 @@ export const initStripeConnect = (
189
173
  }
190
174
  const element = document.createElement(htmlName);
191
175
 
192
- if (hasCustomMethod(tagName)) {
193
- const methods = ConnectElementCustomMethodConfig[tagName];
194
- for (const method in methods) {
195
- (element as any)[method] = function(value: any) {
196
- stripeConnectInstance.then(() => {
197
- this[`${method}InternalOnly`](value);
198
- });
199
- };
200
- }
176
+ const customMethods = hasCustomMethod(tagName)
177
+ ? ConnectElementCustomMethodConfig[tagName]
178
+ : {};
179
+ const methods = { ...customMethods, ...ConnectElementCommonMethodConfig };
180
+ for (const method in methods) {
181
+ (element as any)[method] = function(value: any) {
182
+ stripeConnectInstance.then(() => {
183
+ this[`${method}InternalOnly`](value);
184
+ });
185
+ };
201
186
  }
202
187
 
203
188
  stripeConnectInstance.then(instance => {
package/types/config.ts CHANGED
@@ -1,15 +1,6 @@
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";
@@ -20,11 +11,56 @@ export type NotificationCount = {
20
11
  actionRequired: number;
21
12
  };
22
13
 
14
+ export type LoaderStart = {
15
+ elementTagName: string;
16
+ };
17
+
18
+ export type LoadError = {
19
+ elementTagName: string;
20
+ error: EmbeddedError;
21
+ };
22
+
23
+ export type EmbeddedError = {
24
+ type: EmbeddedErrorType;
25
+ message?: string;
26
+ };
27
+
28
+ export type EmbeddedErrorType =
29
+ /**
30
+ * Failure to connect to Stripe's API.
31
+ */
32
+ | "api_connection_error"
33
+ /**
34
+ * Failure to perform the authentication flow within Connect Embedded Components
35
+ */
36
+ | "authentication_error"
37
+ /**
38
+ * Account session create failed
39
+ */
40
+ | "account_session_create_error"
41
+ /**
42
+ * Request failed with an 4xx status code, typically caused by platform configuration issues
43
+ */
44
+ | "invalid_request_error"
45
+ /**
46
+ * Too many requests hit the API too quickly.
47
+ */
48
+ | "rate_limit_error"
49
+ /**
50
+ * API errors covering any other type of problem (e.g., a temporary problem with Stripe's servers), and are extremely uncommon.
51
+ */
52
+ | "api_error";
53
+
54
+ export const ConnectElementCommonMethodConfig = {
55
+ setOnLoadError: (
56
+ _listener: (({ error, elementTagName }: LoadError) => void) | undefined
57
+ ): void => {},
58
+ setOnLoaderStart: (
59
+ _listener: (({ elementTagName }: LoaderStart) => void) | undefined
60
+ ): void => {}
61
+ };
62
+
23
63
  export const ConnectElementCustomMethodConfig = {
24
- "payment-details": {
25
- setPayment: (_payment: string | undefined): void => {},
26
- setOnClose: (_listener: (() => void) | undefined): void => {}
27
- },
28
64
  "account-onboarding": {
29
65
  setFullTermsOfServiceUrl: (
30
66
  _termOfServiceUrl: string | undefined
@@ -56,24 +92,8 @@ export const ConnectElementCustomMethodConfig = {
56
92
  | undefined
57
93
  ): void => {}
58
94
  },
59
- "issuing-card": {
60
- setDefaultCard: (_defaultCard: string | undefined): void => {},
61
- setCardArtFileLink: (_cardArtFileLink: string | undefined): void => {},
62
- setCardSwitching: (_cardSwitching: boolean | undefined): void => {},
63
- setFetchEphemeralKey: (
64
- _fetchEphemeralKey: FetchEphemeralKeyFunction | undefined
65
- ): void => {}
66
- },
67
- "issuing-cards-list": {
68
- setCardArtFileLink: (_cardArtFileLink: string | undefined): void => {},
69
- setFetchEphemeralKey: (
70
- _fetchEphemeralKey: FetchEphemeralKeyFunction | undefined
71
- ): void => {}
72
- },
73
- "financial-account": {
74
- setFinancialAccount: (_financialAccount: string): void => {}
75
- },
76
- "financial-account-transactions": {
77
- setFinancialAccount: (_financialAccount: string): void => {}
95
+ "payment-details": {
96
+ setPayment: (_payment: string | undefined): void => {},
97
+ setOnClose: (_listener: (() => void) | undefined): void => {}
78
98
  }
79
99
  };
package/types/shared.d.ts CHANGED
@@ -1,4 +1,7 @@
1
- import { ConnectElementCustomMethodConfig } from "./config";
1
+ import {
2
+ ConnectElementCustomMethodConfig,
3
+ ConnectElementCommonMethodConfig
4
+ } from "./config";
2
5
 
3
6
  export declare type LoadConnectAndInitialize = (
4
7
  initParams: IStripeConnectInitParams
@@ -412,12 +415,14 @@ export interface IStripeConnectInitParams {
412
415
  }
413
416
 
414
417
  type ConnectElementCustomMethods = typeof ConnectElementCustomMethodConfig;
418
+ type ConnectElementCommonMethods = typeof ConnectElementCommonMethodConfig;
415
419
 
416
420
  export type ConnectHTMLElementRecord = {
417
421
  [K in keyof ConnectElementCustomMethods]: HTMLElement &
418
- ConnectElementCustomMethods[K];
422
+ ConnectElementCustomMethods[K] &
423
+ ConnectElementCommonMethods;
419
424
  } & {
420
- [key: string]: HTMLElement;
425
+ [key: string]: HTMLElement & ConnectElementCommonMethods;
421
426
  };
422
427
 
423
428
  export interface StripeConnectInstance {
@@ -447,23 +452,14 @@ export interface StripeConnectInstance {
447
452
  * Tagnames to be used with the `create` method of the Connect instance.
448
453
  */
449
454
  export type ConnectElementTagName =
455
+ | "account-onboarding"
450
456
  | "payments"
451
- | "payouts"
452
457
  | "payment-details"
453
- | "account-onboarding"
454
- | "payment-method-settings"
455
458
  | "account-management"
456
459
  | "notification-banner"
457
- | "instant-payouts"
458
- | "issuing-card"
459
- | "issuing-cards-list"
460
- | "financial-account"
461
- | "financial-account-transactions"
462
- | "capital-overview"
460
+ | "payouts"
461
+ | "payouts-list"
462
+ | "balances"
463
463
  | "documents"
464
464
  | "tax-registrations"
465
- | "tax-settings"
466
- | "balances"
467
- | "payouts-list"
468
- | "app-install"
469
- | "app-viewport";
465
+ | "tax-settings";