@stripe/connect-js 3.3.22-preview-1 → 3.3.22

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.
@@ -10,14 +10,38 @@ export type CollectionOptions = {
10
10
  fields: "currently_due" | "eventually_due";
11
11
  futureRequirements?: "omit" | "include";
12
12
  };
13
+ export type Status = "blocked" | "canceled" | "disputed" | "early_fraud_warning" | "failed" | "incomplete" | "partially_refunded" | "pending" | "refund_pending" | "refunded" | "successful" | "uncaptured";
14
+ export type PaymentMethod = "ach_credit_transfer" | "ach_debit" | "acss_debit" | "affirm" | "afterpay_clearpay" | "alipay" | "alma" | "amazon_pay" | "amex_express_checkout" | "android_pay" | "apple_pay" | "au_becs_debit" | "nz_bank_account" | "bancontact" | "bacs_debit" | "bitcoin_source" | "bitcoin" | "blik" | "boleto" | "boleto_pilot" | "card_present" | "card" | "cashapp" | "crypto" | "customer_balance" | "demo_pay" | "dummy_passthrough_card" | "gbp_credit_transfer" | "google_pay" | "eps" | "fpx" | "giropay" | "grabpay" | "ideal" | "id_bank_transfer" | "id_credit_transfer" | "jp_credit_transfer" | "interac_present" | "kakao_pay" | "klarna" | "konbini" | "kr_card" | "kr_market" | "link" | "masterpass" | "mb_way" | "meta_pay" | "multibanco" | "mobilepay" | "naver_pay" | "netbanking" | "ng_bank" | "ng_bank_transfer" | "ng_card" | "ng_market" | "ng_ussd" | "vipps" | "oxxo" | "p24" | "payto" | "pay_by_bank" | "paper_check" | "payco" | "paynow" | "paypal" | "pix" | "promptpay" | "revolut_pay" | "samsung_pay" | "sepa_credit_transfer" | "sepa_debit" | "sofort" | "south_korea_market" | "swish" | "three_d_secure" | "three_d_secure_2" | "three_d_secure_2_eap" | "twint" | "upi" | "us_bank_account" | "visa_checkout" | "wechat" | "wechat_pay" | "zip";
15
+ export type PaymentsListDefaultFilters = {
16
+ amount?: {
17
+ equals: number;
18
+ } | {
19
+ greaterThan: number;
20
+ } | {
21
+ lessThan: number;
22
+ } | {
23
+ between: {
24
+ lowerBound: number;
25
+ upperBound: number;
26
+ };
27
+ };
28
+ date?: {
29
+ before: Date;
30
+ } | {
31
+ after: Date;
32
+ } | {
33
+ between: {
34
+ start: Date;
35
+ end: Date;
36
+ };
37
+ };
38
+ status?: Array<Status>;
39
+ paymentMethod?: PaymentMethod;
40
+ };
13
41
  export type NotificationCount = {
14
42
  total: number;
15
43
  actionRequired: number;
16
44
  };
17
- export type InstallState = {
18
- appId: string;
19
- state: "INSTALLED" | "UNINSTALLED";
20
- };
21
45
  export type LoaderStart = {
22
46
  elementTagName: string;
23
47
  };
@@ -32,13 +56,6 @@ export type EmbeddedError = {
32
56
  type: EmbeddedErrorType;
33
57
  message?: string;
34
58
  };
35
- export type FinancingProductType = {
36
- productType: "standard" | "refill" | "none";
37
- };
38
- export type FinancingPromotionLayoutType = "full" | "banner";
39
- export type IntervalType = "day" | "week" | "month" | "quarter" | "year";
40
- export type ReportName = "gross_volume" | "net_volume";
41
- export type RecipientDataSource = "customers";
42
59
  export type EmbeddedErrorType =
43
60
  /**
44
61
  * Failure to connect to Stripe's API.
@@ -69,10 +86,6 @@ export declare const ConnectElementCommonMethodConfig: {
69
86
  setOnLoaderStart: (_listener: (({ elementTagName }: LoaderStart) => void) | undefined) => void;
70
87
  };
71
88
  export declare const ConnectElementCustomMethodConfig: {
72
- "payment-details": {
73
- setPayment: (_payment: string | undefined) => void;
74
- setOnClose: (_listener: (() => void) | undefined) => void;
75
- };
76
89
  "account-onboarding": {
77
90
  setFullTermsOfServiceUrl: (_termOfServiceUrl: string | undefined) => void;
78
91
  setRecipientTermsOfServiceUrl: (_recipientTermsOfServiceUrl: string | undefined) => void;
@@ -106,48 +119,12 @@ export declare const ConnectElementCustomMethodConfig: {
106
119
  "financial-account-transactions": {
107
120
  setFinancialAccount: (_financialAccount: string) => void;
108
121
  };
109
- recipients: {
110
- setDataSource: (_dataSource: RecipientDataSource) => void;
111
- };
112
- "app-install": {
113
- setApp: (_app: string | undefined) => void;
114
- setOnAppInstallStateFetched: (_listener: (({ appId, state }: InstallState) => void) | undefined) => void;
115
- setOnAppInstallStateChanged: (_listener: (({ appId, state }: InstallState) => void) | undefined) => void;
116
- };
117
- "app-viewport": {
118
- setApp: (_app: string | undefined) => void;
119
- setAppData: (_appData: Record<string, string> | undefined) => void;
120
- };
121
- "payment-method-settings": {
122
- setPaymentMethodConfiguration: (_paymentMethodConfiguration: string | undefined) => void;
122
+ payments: {
123
+ setDefaultFilters: (_filters: PaymentsListDefaultFilters | undefined) => void;
123
124
  };
124
- "capital-financing": {
125
- setDefaultFinancingOffer: (_defaultFinancingOffer: string | undefined) => void;
126
- setShowFinancingSelector: (_showFinancingSelector: boolean | undefined) => void;
127
- setHowCapitalWorksUrl: (_howCapitalWorksUrl: string | undefined) => void;
128
- setSupportUrl: (_supportUrl: string | undefined) => void;
129
- setOnFinancingsLoaded: (_listener: (({ total }: {
130
- total: number;
131
- }) => void) | undefined) => void;
132
- };
133
- "capital-financing-application": {
134
- setOnApplicationSubmitted: (_listener: (() => void) | undefined) => void;
135
- setPrivacyPolicyUrl: (_privacyPolicyUrl: string | undefined) => void;
136
- setHowCapitalWorksUrl: (_howCapitalWorksUrl: string | undefined) => void;
137
- };
138
- "capital-financing-promotion": {
139
- setLayout: (_layout: FinancingPromotionLayoutType | undefined) => void;
140
- setOnApplicationSubmitted: (_listener: (() => void) | undefined) => void;
141
- setOnEligibleFinancingOfferLoaded: (_listener: (({ productType }: FinancingProductType) => void) | undefined) => void;
142
- setPrivacyPolicyUrl: (_privacyPolicyUrl: string | undefined) => void;
143
- setHowCapitalWorksUrl: (_howCapitalWorksUrl: string | undefined) => void;
144
- setEligibilityCriteriaUrl: (_eligibilityCriteriaUrl: string | undefined) => void;
145
- };
146
- "reporting-chart": {
147
- setReportName: (_reportName: ReportName) => void;
148
- setIntervalStart: (_intervalStart: Date | undefined) => void;
149
- setIntervalEnd: (_intervalEnd: Date | undefined) => void;
150
- setIntervalType: (_intervalType: IntervalType | undefined) => void;
125
+ "payment-details": {
126
+ setPayment: (_payment: string | undefined) => void;
127
+ setOnClose: (_listener: (() => void) | undefined) => void;
151
128
  };
152
129
  "tax-settings": {
153
130
  setHideProductTaxCodeSelector: (_hidden: boolean | undefined) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stripe/connect-js",
3
- "version": "3.3.22-preview-1",
3
+ "version": "3.3.22",
4
4
  "description": "Connect.js loading utility package",
5
5
  "main": "dist/connect.js",
6
6
  "module": "dist/connect.esm.js",
@@ -11,6 +11,7 @@
11
11
  "test:unit": "jest",
12
12
  "test:types": "zx ./tests/types/scripts/test.mjs",
13
13
  "lint": "eslint '{src,types}/**/*.{ts,js}' && yarn prettier-check",
14
+ "lint-fix": "eslint '{src,types}/**/*.{ts,js}' --fix && yarn prettier-check",
14
15
  "typecheck": "tsc --noEmit",
15
16
  "build": "yarn clean && rollup -c",
16
17
  "validate-change": "yarn run test",
@@ -45,21 +46,24 @@
45
46
  "@rollup/plugin-json": "^6.0.0",
46
47
  "@rollup/plugin-replace": "^2.3.1",
47
48
  "@types/jest": "^24.0.25",
48
- "@typescript-eslint/eslint-plugin": "^4.15.2",
49
- "@typescript-eslint/parser": "^4.15.2",
49
+ "@typescript-eslint/eslint-plugin": "^7",
50
+ "@typescript-eslint/parser": "^7",
51
+ "@typescript-eslint/rule-tester": "^7",
52
+ "@typescript-eslint/scope-manager": "^7",
53
+ "@typescript-eslint/utils": "^7",
50
54
  "babel-eslint": "^10.0.3",
51
55
  "babel-jest": "^24.9.0",
52
56
  "conditional-type-checks": "^1.0.5",
53
- "eslint": "^6.8.0",
54
- "eslint-config-prettier": "^6.8.0",
55
- "eslint-plugin-import": "^2.18.2",
56
- "eslint-plugin-jest": "^22.6.3",
57
- "eslint-plugin-prettier": "^3.1.1",
57
+ "eslint": "8.56.0",
58
+ "eslint-config-prettier": "^8.3.0",
59
+ "eslint-plugin-import": "^2.20.1",
60
+ "eslint-plugin-jest": "^26.6.0",
61
+ "eslint-plugin-prettier": "^4.2.1",
58
62
  "jest": "^29.5.0",
59
63
  "jest-environment-jsdom": "^29.5.0",
60
- "prettier": "^1.19.1",
64
+ "prettier": "2.8.8",
61
65
  "rimraf": "^2.6.2",
62
- "rollup": "^1.29.0",
66
+ "rollup": "^2.79.2",
63
67
  "rollup-plugin-babel": "^4.4.0",
64
68
  "rollup-plugin-typescript2": "^0.25.3",
65
69
  "ts-jest": "^29.1.0",
package/src/index.ts CHANGED
@@ -1,9 +1,6 @@
1
- import { IStripeConnectInitParams, StripeConnectInstance } from "../types";
2
- import {
3
- loadScript,
4
- initStripeConnect,
5
- LoadConnectAndInitialize
6
- } from "./shared";
1
+ import type { IStripeConnectInitParams, StripeConnectInstance } from "../types";
2
+ import type { LoadConnectAndInitialize } from "./shared";
3
+ import { loadScript, initStripeConnect } from "./shared";
7
4
 
8
5
  // Execute our own script injection after a tick to give users time to do their
9
6
  // own script injection.
package/src/pure.test.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-var-requires */
2
2
 
3
- import { IStripeConnectInitParams } from "../types";
3
+ import type { IStripeConnectInitParams } from "../types";
4
4
  import { SCRIPT_SELECTOR } from "./utils/jestHelpers";
5
5
 
6
6
  describe("pure module", () => {
@@ -16,7 +16,7 @@ describe("pure module", () => {
16
16
  publishableKey: "pk_123",
17
17
  fetchClientSecret: async () => {
18
18
  return "secret_123";
19
- }
19
+ },
20
20
  };
21
21
  loadConnectAndInitialize(mockInitParams);
22
22
 
package/src/pure.ts CHANGED
@@ -1,9 +1,6 @@
1
- import { IStripeConnectInitParams, StripeConnectInstance } from "../types";
2
- import {
3
- loadScript,
4
- initStripeConnect,
5
- LoadConnectAndInitialize
6
- } from "./shared";
1
+ import type { IStripeConnectInitParams, StripeConnectInstance } from "../types";
2
+ import type { LoadConnectAndInitialize } from "./shared";
3
+ import { loadScript, initStripeConnect } from "./shared";
7
4
 
8
5
  export const loadConnectAndInitialize: LoadConnectAndInitialize = (
9
6
  initParams: IStripeConnectInitParams
package/src/shared.ts CHANGED
@@ -1,76 +1,55 @@
1
- import {
1
+ import type {
2
2
  IStripeConnectInitParams,
3
3
  StripeConnectInstance,
4
4
  ConnectElementTagName,
5
- ConnectHTMLElementRecord
5
+ ConnectHTMLElementRecord,
6
6
  } from "../types";
7
7
  import {
8
8
  ConnectElementCommonMethodConfig,
9
- ConnectElementCustomMethodConfig
9
+ ConnectElementCustomMethodConfig,
10
10
  } from "../types/config";
11
11
 
12
12
  export type LoadConnectAndInitialize = (
13
13
  initParams: IStripeConnectInitParams
14
14
  ) => StripeConnectInstance;
15
15
 
16
- export type ConnectElementHTMLName =
16
+ type ConnectElementHTMLName =
17
+ | "stripe-connect-account-onboarding"
17
18
  | "stripe-connect-payments"
18
- | "stripe-connect-payouts"
19
19
  | "stripe-connect-payment-details"
20
- | "stripe-connect-account-onboarding"
21
- | "stripe-connect-payment-method-settings"
22
20
  | "stripe-connect-account-management"
23
21
  | "stripe-connect-notification-banner"
24
- | "stripe-connect-instant-payouts"
25
22
  | "stripe-connect-issuing-card"
26
23
  | "stripe-connect-issuing-cards-list"
27
24
  | "stripe-connect-financial-account"
28
25
  | "stripe-connect-financial-account-transactions"
29
- | "stripe-connect-recipients"
30
- | "stripe-connect-capital-financing"
31
- | "stripe-connect-capital-financing-application"
32
- | "stripe-connect-capital-financing-promotion"
33
- | "stripe-connect-capital-overview"
26
+ | "stripe-connect-payouts"
27
+ | "stripe-connect-payouts-list"
28
+ | "stripe-connect-balances"
34
29
  | "stripe-connect-documents"
35
30
  | "stripe-connect-tax-registrations"
36
- | "stripe-connect-tax-settings"
37
- | "stripe-connect-balances"
38
- | "stripe-connect-payouts-list"
39
- | "stripe-connect-app-install"
40
- | "stripe-connect-app-viewport"
41
- | "stripe-connect-reporting-chart";
31
+ | "stripe-connect-tax-settings";
42
32
 
43
33
  export const componentNameMapping: Record<
44
34
  ConnectElementTagName,
45
35
  ConnectElementHTMLName
46
36
  > = {
37
+ "account-onboarding": "stripe-connect-account-onboarding",
47
38
  payments: "stripe-connect-payments",
48
- payouts: "stripe-connect-payouts",
49
39
  "payment-details": "stripe-connect-payment-details",
50
- "account-onboarding": "stripe-connect-account-onboarding",
51
- "payment-method-settings": "stripe-connect-payment-method-settings",
40
+ payouts: "stripe-connect-payouts",
41
+ "payouts-list": "stripe-connect-payouts-list",
42
+ balances: "stripe-connect-balances",
52
43
  "account-management": "stripe-connect-account-management",
53
44
  "notification-banner": "stripe-connect-notification-banner",
54
- "instant-payouts": "stripe-connect-instant-payouts",
55
45
  "issuing-card": "stripe-connect-issuing-card",
56
46
  "issuing-cards-list": "stripe-connect-issuing-cards-list",
57
47
  "financial-account": "stripe-connect-financial-account",
58
- recipients: "stripe-connect-recipients",
59
48
  "financial-account-transactions":
60
49
  "stripe-connect-financial-account-transactions",
61
- "capital-financing": "stripe-connect-capital-financing",
62
- "capital-financing-application":
63
- "stripe-connect-capital-financing-application",
64
- "capital-financing-promotion": "stripe-connect-capital-financing-promotion",
65
- "capital-overview": "stripe-connect-capital-overview",
66
50
  documents: "stripe-connect-documents",
67
51
  "tax-registrations": "stripe-connect-tax-registrations",
68
52
  "tax-settings": "stripe-connect-tax-settings",
69
- balances: "stripe-connect-balances",
70
- "payouts-list": "stripe-connect-payouts-list",
71
- "app-install": "stripe-connect-app-install",
72
- "app-viewport": "stripe-connect-app-viewport",
73
- "reporting-chart": "stripe-connect-reporting-chart"
74
53
  };
75
54
 
76
55
  type StripeConnectInstanceExtended = StripeConnectInstance & {
@@ -89,10 +68,10 @@ const V1_URL = "https://connect-js.stripe.com/v1.0/connect.js";
89
68
  export const findScript = (): HTMLScriptElement | null => {
90
69
  return (
91
70
  document.querySelectorAll<HTMLScriptElement>(
92
- `script[src="${V0_URL}"]`
71
+ `script[src="${V1_URL}"]`
93
72
  )[0] ||
94
73
  document.querySelectorAll<HTMLScriptElement>(
95
- `script[src="${V1_URL}"]`
74
+ `script[src="${V0_URL}"]`
96
75
  )[0] ||
97
76
  null
98
77
  );
@@ -188,18 +167,18 @@ export const initStripeConnect = (
188
167
  }
189
168
  })();
190
169
  const metaOptions = (initParams as any).metaOptions ?? {};
191
- const stripeConnectInstance = stripePromise.then(wrapper =>
170
+ const stripeConnectInstance = stripePromise.then((wrapper) =>
192
171
  wrapper.initialize({
193
172
  ...initParams,
194
- metaOptions: { ...metaOptions, eagerClientSecretPromise }
173
+ metaOptions: { ...metaOptions, eagerClientSecretPromise },
195
174
  } as any)
196
175
  );
197
176
 
198
177
  return {
199
- create: tagName => {
178
+ create: (tagName) => {
200
179
  let htmlName = componentNameMapping[tagName];
201
180
  if (!htmlName) {
202
- htmlName = (tagName as unknown) as ConnectElementHTMLName;
181
+ htmlName = tagName as unknown as ConnectElementHTMLName;
203
182
  }
204
183
  const element = document.createElement(htmlName);
205
184
 
@@ -208,14 +187,14 @@ export const initStripeConnect = (
208
187
  : {};
209
188
  const methods = { ...customMethods, ...ConnectElementCommonMethodConfig };
210
189
  for (const method in methods) {
211
- (element as any)[method] = function(value: any) {
190
+ (element as any)[method] = function (value: any) {
212
191
  stripeConnectInstance.then(() => {
213
192
  this[`${method}InternalOnly`](value);
214
193
  });
215
194
  };
216
195
  }
217
196
 
218
- stripeConnectInstance.then(instance => {
197
+ stripeConnectInstance.then((instance) => {
219
198
  if (!element.isConnected && !(element as any).setConnector) {
220
199
  // If the element is not connected to the DOM and the `setConnector` method is not
221
200
  // defined, this indicates the element was created before connect.js was loaded, and has
@@ -243,8 +222,8 @@ export const initStripeConnect = (
243
222
 
244
223
  return element as ConnectHTMLElementRecord[typeof tagName];
245
224
  },
246
- update: updateOptions => {
247
- stripeConnectInstance.then(instance => {
225
+ update: (updateOptions) => {
226
+ stripeConnectInstance.then((instance) => {
248
227
  instance.update(updateOptions);
249
228
  });
250
229
  },
@@ -252,10 +231,10 @@ export const initStripeConnect = (
252
231
  return stripeConnectInstance;
253
232
  },
254
233
  logout: () => {
255
- return stripeConnectInstance.then(instance => {
234
+ return stripeConnectInstance.then((instance) => {
256
235
  return instance.logout();
257
236
  });
258
- }
237
+ },
259
238
  };
260
239
  };
261
240
 
@@ -272,12 +251,12 @@ const createWrapper = (stripeConnect: any) => {
272
251
  sdk: true,
273
252
  sdkOptions: {
274
253
  // This will be replaced by the npm package version when bundling
275
- sdkVersion: "_NPM_PACKAGE_VERSION_"
276
- }
277
- }
254
+ sdkVersion: "_NPM_PACKAGE_VERSION_",
255
+ },
256
+ },
278
257
  });
279
258
  return stripeConnectInstance;
280
- }
259
+ },
281
260
  };
282
261
  return wrapper;
283
262
  };
package/types/checks.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ConnectElementCustomMethodConfig } from "./config";
2
- import { ConnectElementTagName } from "./shared.d";
1
+ import type { ConnectElementCustomMethodConfig } from "./config";
2
+ import type { ConnectElementTagName } from "./shared.d";
3
3
 
4
4
  // ensure that keys of ConnectElementCustomMethodConfig are from ConnectElementTagName
5
5
  export type HasType<T, Q extends T> = Q;