@stripe/connect-js 2.0.1-beta.3 → 2.0.1-beta.5

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,4 +1,30 @@
1
- var version = "2.0.1-beta.3";
1
+ import { useQuery } from 'react-query';
2
+
3
+ /*! *****************************************************************************
4
+ Copyright (c) Microsoft Corporation. All rights reserved.
5
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
6
+ this file except in compliance with the License. You may obtain a copy of the
7
+ License at http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
10
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
11
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
12
+ MERCHANTABLITY OR NON-INFRINGEMENT.
13
+
14
+ See the Apache Version 2.0 License for specific language governing permissions
15
+ and limitations under the License.
16
+ ***************************************************************************** */
17
+
18
+ function __awaiter(thisArg, _arguments, P, generator) {
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ }
26
+
27
+ var version = "2.0.1-beta.1";
2
28
 
3
29
  const componentNameMapping = {
4
30
  payments: "stripe-connect-payments",
@@ -13,7 +39,7 @@ const findScript = () => {
13
39
  };
14
40
  const injectScript = () => {
15
41
  const script = document.createElement("script");
16
- script.src = "https://connect-js.stripe.com/v0.1/connect.js";
42
+ script.src = "http://localhost:3001/v0.1/connect.js";
17
43
  const head = document.head;
18
44
  if (!head) {
19
45
  throw new Error("Expected document.head not to be null. Connect.js requires a <head> element.");
@@ -111,5 +137,19 @@ const loadConnect = () => {
111
137
  loadCalled = true;
112
138
  return stripePromise$1.then(maybeConnect => initStripeConnect(maybeConnect));
113
139
  };
140
+ const loadConnectAndInitialize = initParams => {
141
+ loadCalled = true;
142
+ console.log("loading connect and initializing");
143
+ const {
144
+ data
145
+ } = useQuery([initParams], () => __awaiter(void 0, void 0, void 0, function* () {
146
+ const stripeConnectWrapper = yield stripePromise$1.then(maybeConnect => initStripeConnect(maybeConnect));
147
+ if (stripeConnectWrapper === null) {
148
+ throw new Error("Stripe Connect has not loaded correctly");
149
+ }
150
+ return stripeConnectWrapper.initialize(initParams);
151
+ }));
152
+ return data;
153
+ };
114
154
 
115
- export { loadConnect };
155
+ export { loadConnect, loadConnectAndInitialize };
package/dist/connect.js CHANGED
@@ -2,7 +2,33 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = "2.0.1-beta.3";
5
+ var reactQuery = require('react-query');
6
+
7
+ /*! *****************************************************************************
8
+ Copyright (c) Microsoft Corporation. All rights reserved.
9
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
10
+ this file except in compliance with the License. You may obtain a copy of the
11
+ License at http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
15
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
16
+ MERCHANTABLITY OR NON-INFRINGEMENT.
17
+
18
+ See the Apache Version 2.0 License for specific language governing permissions
19
+ and limitations under the License.
20
+ ***************************************************************************** */
21
+
22
+ function __awaiter(thisArg, _arguments, P, generator) {
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ }
30
+
31
+ var version = "2.0.1-beta.1";
6
32
 
7
33
  const componentNameMapping = {
8
34
  payments: "stripe-connect-payments",
@@ -17,7 +43,7 @@ const findScript = () => {
17
43
  };
18
44
  const injectScript = () => {
19
45
  const script = document.createElement("script");
20
- script.src = "https://connect-js.stripe.com/v0.1/connect.js";
46
+ script.src = "http://localhost:3001/v0.1/connect.js";
21
47
  const head = document.head;
22
48
  if (!head) {
23
49
  throw new Error("Expected document.head not to be null. Connect.js requires a <head> element.");
@@ -115,5 +141,20 @@ const loadConnect = () => {
115
141
  loadCalled = true;
116
142
  return stripePromise$1.then(maybeConnect => initStripeConnect(maybeConnect));
117
143
  };
144
+ const loadConnectAndInitialize = initParams => {
145
+ loadCalled = true;
146
+ console.log("loading connect and initializing");
147
+ const {
148
+ data
149
+ } = reactQuery.useQuery([initParams], () => __awaiter(void 0, void 0, void 0, function* () {
150
+ const stripeConnectWrapper = yield stripePromise$1.then(maybeConnect => initStripeConnect(maybeConnect));
151
+ if (stripeConnectWrapper === null) {
152
+ throw new Error("Stripe Connect has not loaded correctly");
153
+ }
154
+ return stripeConnectWrapper.initialize(initParams);
155
+ }));
156
+ return data;
157
+ };
118
158
 
119
159
  exports.loadConnect = loadConnect;
160
+ exports.loadConnectAndInitialize = loadConnectAndInitialize;
package/dist/pure.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- var version = "2.0.1-beta.3";
1
+ var version = "2.0.1-beta.1";
2
2
 
3
3
  const componentNameMapping = {
4
4
  payments: "stripe-connect-payments",
@@ -13,7 +13,7 @@ const findScript = () => {
13
13
  };
14
14
  const injectScript = () => {
15
15
  const script = document.createElement("script");
16
- script.src = "https://connect-js.stripe.com/v0.1/connect.js";
16
+ script.src = "http://localhost:3001/v0.1/connect.js";
17
17
  const head = document.head;
18
18
  if (!head) {
19
19
  throw new Error("Expected document.head not to be null. Connect.js requires a <head> element.");
package/dist/pure.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = "2.0.1-beta.3";
5
+ var version = "2.0.1-beta.1";
6
6
 
7
7
  const componentNameMapping = {
8
8
  payments: "stripe-connect-payments",
@@ -17,7 +17,7 @@ const findScript = () => {
17
17
  };
18
18
  const injectScript = () => {
19
19
  const script = document.createElement("script");
20
- script.src = "https://connect-js.stripe.com/v0.1/connect.js";
20
+ script.src = "http://localhost:3001/v0.1/connect.js";
21
21
  const head = document.head;
22
22
  if (!head) {
23
23
  throw new Error("Expected document.head not to be null. Connect.js requires a <head> element.");
@@ -1,3 +1,5 @@
1
+ import { IStripeConnectInitParams, StripeConnectInstance } from "../types";
1
2
  import { LoadConnect } from "./shared";
2
3
  export declare const loadConnect: LoadConnect;
4
+ export declare const loadConnectAndInitialize: (initParams: IStripeConnectInitParams) => StripeConnectInstance;
3
5
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stripe/connect-js",
3
- "version": "2.0.1-beta.3",
3
+ "version": "2.0.1-beta.5",
4
4
  "description": "Connect.js loading utility package",
5
5
  "main": "dist/connect.js",
6
6
  "module": "dist/connect.esm.js",
@@ -13,7 +13,7 @@
13
13
  "lint": "eslint '{src,types}/**/*.{ts,js}' && yarn prettier-check",
14
14
  "typecheck": "tsc --noEmit",
15
15
  "build": "yarn clean && rollup -c",
16
- "validate-change": "yarn run typescript && yarn run lint && yarn run test",
16
+ "validate-change": "yarn run test",
17
17
  "clean": "rimraf dist",
18
18
  "prettier": "prettier './**/*.{js,ts,md,html,css}' --write",
19
19
  "prettier-check": "prettier './**/*.{js,ts,md,html,css}' --check"
package/src/shared.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { version } from ".././package.json";
2
1
  import {
3
2
  StripeConnectWrapper,
4
3
  IStripeConnectInitParams,
@@ -11,7 +10,8 @@ type ConnectElementHTMLName =
11
10
  | "stripe-connect-payments"
12
11
  | "stripe-connect-payouts"
13
12
  | "stripe-connect-payment-details"
14
- | "stripe-connect-account-onboarding";
13
+ | "stripe-connect-account-onboarding"
14
+ | "stripe-connect-payment-method-settings";
15
15
 
16
16
  const componentNameMapping: Record<
17
17
  ConnectElementTagName,
@@ -20,7 +20,8 @@ const componentNameMapping: Record<
20
20
  payments: "stripe-connect-payments",
21
21
  payouts: "stripe-connect-payouts",
22
22
  "payment-details": "stripe-connect-payment-details",
23
- "account-onboarding": "stripe-connect-account-onboarding"
23
+ "account-onboarding": "stripe-connect-account-onboarding",
24
+ "payment-method-settings": "stripe-connect-payment-method-settings"
24
25
  };
25
26
 
26
27
  const EXISTING_SCRIPT_MESSAGE =
@@ -125,7 +126,8 @@ const createWrapper = (stripeConnect: any) => {
125
126
  ...metaOptions,
126
127
  sdk: true,
127
128
  sdkOptions: {
128
- sdkVersion: version
129
+ // This will be replaced by the npm package version when bundling
130
+ sdkVersion: "_NPM_PACKAGE_VERSION_"
129
131
  }
130
132
  }
131
133
  });
package/types/shared.d.ts CHANGED
@@ -185,7 +185,8 @@ export type ConnectElementTagName =
185
185
  | "payments"
186
186
  | "payouts"
187
187
  | "payment-details"
188
- | "account-onboarding";
188
+ | "account-onboarding"
189
+ | "payment-method-settings";
189
190
 
190
191
  export declare const findScript: () => HTMLScriptElement | null;
191
192