@stripe/connect-js 3.3.13-beta-1 → 3.3.15-beta-1

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,5 +1,9 @@
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
8
  "payment-details": {
5
9
  setPayment: _payment => {},
@@ -44,6 +48,9 @@ const ConnectElementCustomMethodConfig = {
44
48
  "app-viewport": {
45
49
  setApp: _app => {},
46
50
  setAppData: _appData => {}
51
+ },
52
+ "payment-method-settings": {
53
+ setPaymentMethodConfiguration: _paymentMethodConfiguration => {}
47
54
  }
48
55
  };
49
56
 
@@ -153,15 +160,14 @@ const initStripeConnect = (stripePromise, initParams) => {
153
160
  htmlName = tagName;
154
161
  }
155
162
  const element = document.createElement(htmlName);
156
- if (hasCustomMethod(tagName)) {
157
- const methods = ConnectElementCustomMethodConfig[tagName];
158
- for (const method in methods) {
159
- element[method] = function (value) {
160
- stripeConnectInstance.then(() => {
161
- this[`${method}InternalOnly`](value);
162
- });
163
- };
164
- }
163
+ const customMethods = hasCustomMethod(tagName) ? ConnectElementCustomMethodConfig[tagName] : {};
164
+ const methods = Object.assign(Object.assign({}, customMethods), ConnectElementCommonMethodConfig);
165
+ for (const method in methods) {
166
+ element[method] = function (value) {
167
+ stripeConnectInstance.then(() => {
168
+ this[`${method}InternalOnly`](value);
169
+ });
170
+ };
165
171
  }
166
172
  stripeConnectInstance.then(instance => {
167
173
  if (!element.isConnected && !element.setConnector) {
@@ -211,7 +217,7 @@ const createWrapper = stripeConnect => {
211
217
  sdk: true,
212
218
  sdkOptions: {
213
219
  // This will be replaced by the npm package version when bundling
214
- sdkVersion: "3.3.13-beta-1"
220
+ sdkVersion: "3.3.14-beta-1"
215
221
  }
216
222
  })
217
223
  }));
package/dist/connect.js CHANGED
@@ -4,6 +4,10 @@ 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
12
  "payment-details": {
9
13
  setPayment: _payment => {},
@@ -48,6 +52,9 @@ const ConnectElementCustomMethodConfig = {
48
52
  "app-viewport": {
49
53
  setApp: _app => {},
50
54
  setAppData: _appData => {}
55
+ },
56
+ "payment-method-settings": {
57
+ setPaymentMethodConfiguration: _paymentMethodConfiguration => {}
51
58
  }
52
59
  };
53
60
 
@@ -157,15 +164,14 @@ const initStripeConnect = (stripePromise, initParams) => {
157
164
  htmlName = tagName;
158
165
  }
159
166
  const element = document.createElement(htmlName);
160
- if (hasCustomMethod(tagName)) {
161
- const methods = ConnectElementCustomMethodConfig[tagName];
162
- for (const method in methods) {
163
- element[method] = function (value) {
164
- stripeConnectInstance.then(() => {
165
- this[`${method}InternalOnly`](value);
166
- });
167
- };
168
- }
167
+ const customMethods = hasCustomMethod(tagName) ? ConnectElementCustomMethodConfig[tagName] : {};
168
+ const methods = Object.assign(Object.assign({}, customMethods), ConnectElementCommonMethodConfig);
169
+ for (const method in methods) {
170
+ element[method] = function (value) {
171
+ stripeConnectInstance.then(() => {
172
+ this[`${method}InternalOnly`](value);
173
+ });
174
+ };
169
175
  }
170
176
  stripeConnectInstance.then(instance => {
171
177
  if (!element.isConnected && !element.setConnector) {
@@ -215,7 +221,7 @@ const createWrapper = stripeConnect => {
215
221
  sdk: true,
216
222
  sdkOptions: {
217
223
  // This will be replaced by the npm package version when bundling
218
- sdkVersion: "3.3.13-beta-1"
224
+ sdkVersion: "3.3.14-beta-1"
219
225
  }
220
226
  })
221
227
  }));
package/dist/pure.esm.js CHANGED
@@ -1,5 +1,9 @@
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
8
  "payment-details": {
5
9
  setPayment: _payment => {},
@@ -44,6 +48,9 @@ const ConnectElementCustomMethodConfig = {
44
48
  "app-viewport": {
45
49
  setApp: _app => {},
46
50
  setAppData: _appData => {}
51
+ },
52
+ "payment-method-settings": {
53
+ setPaymentMethodConfiguration: _paymentMethodConfiguration => {}
47
54
  }
48
55
  };
49
56
 
@@ -153,15 +160,14 @@ const initStripeConnect = (stripePromise, initParams) => {
153
160
  htmlName = tagName;
154
161
  }
155
162
  const element = document.createElement(htmlName);
156
- if (hasCustomMethod(tagName)) {
157
- const methods = ConnectElementCustomMethodConfig[tagName];
158
- for (const method in methods) {
159
- element[method] = function (value) {
160
- stripeConnectInstance.then(() => {
161
- this[`${method}InternalOnly`](value);
162
- });
163
- };
164
- }
163
+ const customMethods = hasCustomMethod(tagName) ? ConnectElementCustomMethodConfig[tagName] : {};
164
+ const methods = Object.assign(Object.assign({}, customMethods), ConnectElementCommonMethodConfig);
165
+ for (const method in methods) {
166
+ element[method] = function (value) {
167
+ stripeConnectInstance.then(() => {
168
+ this[`${method}InternalOnly`](value);
169
+ });
170
+ };
165
171
  }
166
172
  stripeConnectInstance.then(instance => {
167
173
  if (!element.isConnected && !element.setConnector) {
@@ -211,7 +217,7 @@ const createWrapper = stripeConnect => {
211
217
  sdk: true,
212
218
  sdkOptions: {
213
219
  // This will be replaced by the npm package version when bundling
214
- sdkVersion: "3.3.13-beta-1"
220
+ sdkVersion: "3.3.14-beta-1"
215
221
  }
216
222
  })
217
223
  }));
package/dist/pure.js CHANGED
@@ -4,6 +4,10 @@ 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
12
  "payment-details": {
9
13
  setPayment: _payment => {},
@@ -48,6 +52,9 @@ const ConnectElementCustomMethodConfig = {
48
52
  "app-viewport": {
49
53
  setApp: _app => {},
50
54
  setAppData: _appData => {}
55
+ },
56
+ "payment-method-settings": {
57
+ setPaymentMethodConfiguration: _paymentMethodConfiguration => {}
51
58
  }
52
59
  };
53
60
 
@@ -157,15 +164,14 @@ const initStripeConnect = (stripePromise, initParams) => {
157
164
  htmlName = tagName;
158
165
  }
159
166
  const element = document.createElement(htmlName);
160
- if (hasCustomMethod(tagName)) {
161
- const methods = ConnectElementCustomMethodConfig[tagName];
162
- for (const method in methods) {
163
- element[method] = function (value) {
164
- stripeConnectInstance.then(() => {
165
- this[`${method}InternalOnly`](value);
166
- });
167
- };
168
- }
167
+ const customMethods = hasCustomMethod(tagName) ? ConnectElementCustomMethodConfig[tagName] : {};
168
+ const methods = Object.assign(Object.assign({}, customMethods), ConnectElementCommonMethodConfig);
169
+ for (const method in methods) {
170
+ element[method] = function (value) {
171
+ stripeConnectInstance.then(() => {
172
+ this[`${method}InternalOnly`](value);
173
+ });
174
+ };
169
175
  }
170
176
  stripeConnectInstance.then(instance => {
171
177
  if (!element.isConnected && !element.setConnector) {
@@ -215,7 +221,7 @@ const createWrapper = stripeConnect => {
215
221
  sdk: true,
216
222
  sdkOptions: {
217
223
  // This will be replaced by the npm package version when bundling
218
- sdkVersion: "3.3.13-beta-1"
224
+ sdkVersion: "3.3.14-beta-1"
219
225
  }
220
226
  })
221
227
  }));
@@ -18,6 +18,46 @@ export type InstallState = {
18
18
  appId: string;
19
19
  state: "INSTALLED" | "UNINSTALLED";
20
20
  };
21
+ export type LoaderStart = {
22
+ elementTagName: string;
23
+ };
24
+ export type LoadError = {
25
+ elementTagName: string;
26
+ error: EmbeddedError;
27
+ };
28
+ export type EmbeddedError = {
29
+ type: EmbeddedErrorType;
30
+ message?: string;
31
+ };
32
+ export type EmbeddedErrorType =
33
+ /**
34
+ * Failure to connect to Stripe's API.
35
+ */
36
+ "api_connection_error"
37
+ /**
38
+ * Failure to perform the authentication flow within Connect Embedded Components
39
+ */
40
+ | "authentication_error"
41
+ /**
42
+ * Account session create failed
43
+ */
44
+ | "account_session_create_error"
45
+ /**
46
+ * Request failed with an 4xx status code, typically caused by platform configuration issues
47
+ */
48
+ | "invalid_request_error"
49
+ /**
50
+ * Too many requests hit the API too quickly.
51
+ */
52
+ | "rate_limit_error"
53
+ /**
54
+ * API errors covering any other type of problem (e.g., a temporary problem with Stripe's servers), and are extremely uncommon.
55
+ */
56
+ | "api_error";
57
+ export declare const ConnectElementCommonMethodConfig: {
58
+ setOnLoadError: (_listener: (({ error, elementTagName }: LoadError) => void) | undefined) => void;
59
+ setOnLoaderStart: (_listener: (({ elementTagName }: LoaderStart) => void) | undefined) => void;
60
+ };
21
61
  export declare const ConnectElementCustomMethodConfig: {
22
62
  "payment-details": {
23
63
  setPayment: (_payment: string | undefined) => void;
@@ -63,4 +103,7 @@ export declare const ConnectElementCustomMethodConfig: {
63
103
  setApp: (_app: string | undefined) => void;
64
104
  setAppData: (_appData: Record<string, string> | undefined) => void;
65
105
  };
106
+ "payment-method-settings": {
107
+ setPaymentMethodConfiguration: (_paymentMethodConfiguration: string | undefined) => void;
108
+ };
66
109
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stripe/connect-js",
3
- "version": "3.3.13-beta-1",
3
+ "version": "3.3.15-beta-1",
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,7 +4,10 @@ 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
@@ -189,15 +192,16 @@ export const initStripeConnect = (
189
192
  }
190
193
  const element = document.createElement(htmlName);
191
194
 
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
- }
195
+ const customMethods = hasCustomMethod(tagName)
196
+ ? ConnectElementCustomMethodConfig[tagName]
197
+ : {};
198
+ const methods = { ...customMethods, ...ConnectElementCommonMethodConfig };
199
+ for (const method in methods) {
200
+ (element as any)[method] = function(value: any) {
201
+ stripeConnectInstance.then(() => {
202
+ this[`${method}InternalOnly`](value);
203
+ });
204
+ };
201
205
  }
202
206
 
203
207
  stripeConnectInstance.then(instance => {
package/types/config.ts CHANGED
@@ -25,6 +25,55 @@ export type InstallState = {
25
25
  state: "INSTALLED" | "UNINSTALLED";
26
26
  };
27
27
 
28
+ export type LoaderStart = {
29
+ elementTagName: string;
30
+ };
31
+
32
+ export type LoadError = {
33
+ elementTagName: string;
34
+ error: EmbeddedError;
35
+ };
36
+
37
+ export type EmbeddedError = {
38
+ type: EmbeddedErrorType;
39
+ message?: string;
40
+ };
41
+
42
+ export type EmbeddedErrorType =
43
+ /**
44
+ * Failure to connect to Stripe's API.
45
+ */
46
+ | "api_connection_error"
47
+ /**
48
+ * Failure to perform the authentication flow within Connect Embedded Components
49
+ */
50
+ | "authentication_error"
51
+ /**
52
+ * Account session create failed
53
+ */
54
+ | "account_session_create_error"
55
+ /**
56
+ * Request failed with an 4xx status code, typically caused by platform configuration issues
57
+ */
58
+ | "invalid_request_error"
59
+ /**
60
+ * Too many requests hit the API too quickly.
61
+ */
62
+ | "rate_limit_error"
63
+ /**
64
+ * API errors covering any other type of problem (e.g., a temporary problem with Stripe's servers), and are extremely uncommon.
65
+ */
66
+ | "api_error";
67
+
68
+ export const ConnectElementCommonMethodConfig = {
69
+ setOnLoadError: (
70
+ _listener: (({ error, elementTagName }: LoadError) => void) | undefined
71
+ ): void => {},
72
+ setOnLoaderStart: (
73
+ _listener: (({ elementTagName }: LoaderStart) => void) | undefined
74
+ ): void => {}
75
+ };
76
+
28
77
  export const ConnectElementCustomMethodConfig = {
29
78
  "payment-details": {
30
79
  setPayment: (_payment: string | undefined): void => {},
@@ -93,5 +142,10 @@ export const ConnectElementCustomMethodConfig = {
93
142
  "app-viewport": {
94
143
  setApp: (_app: string | undefined): void => {},
95
144
  setAppData: (_appData: Record<string, string> | undefined): void => {}
145
+ },
146
+ "payment-method-settings": {
147
+ setPaymentMethodConfiguration: (
148
+ _paymentMethodConfiguration: string | undefined
149
+ ): void => {}
96
150
  }
97
151
  };
package/types/shared.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- import { ConnectElementCustomMethodConfig } from "./config";
2
-
1
+ import {
2
+ ConnectElementCustomMethodConfig,
3
+ ConnectElementCommonMethodConfig
4
+ } from "./config";
3
5
  export declare type LoadConnectAndInitialize = (
4
6
  initParams: IStripeConnectInitParams
5
7
  ) => StripeConnectInstance;
@@ -412,12 +414,14 @@ export interface IStripeConnectInitParams {
412
414
  }
413
415
 
414
416
  type ConnectElementCustomMethods = typeof ConnectElementCustomMethodConfig;
417
+ type ConnectElementCommonMethods = typeof ConnectElementCommonMethodConfig;
415
418
 
416
419
  export type ConnectHTMLElementRecord = {
417
420
  [K in keyof ConnectElementCustomMethods]: HTMLElement &
418
- ConnectElementCustomMethods[K];
421
+ ConnectElementCustomMethods[K] &
422
+ ConnectElementCommonMethods;
419
423
  } & {
420
- [key: string]: HTMLElement;
424
+ [key: string]: HTMLElement & ConnectElementCommonMethods;
421
425
  };
422
426
 
423
427
  export interface StripeConnectInstance {