@stripe/connect-js 3.0.0 → 3.1.0-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.
- package/dist/connect.esm.js +49 -3
- package/dist/connect.js +49 -3
- package/dist/pure.esm.js +49 -3
- package/dist/pure.js +49 -3
- package/dist/{shared.d.ts → src/shared.d.ts} +1 -1
- package/dist/types/config.d.ts +21 -0
- package/package.json +1 -1
- package/src/shared.ts +41 -3
- package/types/config.ts +39 -0
- package/types/shared.d.ts +40 -22
- /package/dist/{pure.d.ts → src/pure.d.ts} +0 -0
- /package/dist/{utils → src/utils}/jestHelpers.d.ts +0 -0
- /package/dist/{utils → src/utils}/jestSetup.d.ts +0 -0
package/dist/connect.esm.js
CHANGED
|
@@ -1,8 +1,41 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3
|
+
const ConnectElementCustomMethodConfig = {
|
|
4
|
+
"payment-details": {
|
|
5
|
+
setPayment: payment => {},
|
|
6
|
+
setOnClose: listener => {}
|
|
7
|
+
},
|
|
8
|
+
"account-onboarding": {
|
|
9
|
+
setFullTermsOfServiceUrl: termOfServiceUrl => {},
|
|
10
|
+
setRecipientTermsOfServiceUrl: recipientTermsOfServiceUrl => {},
|
|
11
|
+
setPrivacyPolicyUrl: privacyPolicyUrl => {},
|
|
12
|
+
setSkipTermsOfServiceCollection: skipTermsOfServiceCollection => {},
|
|
13
|
+
setOnExit: listener => {}
|
|
14
|
+
},
|
|
15
|
+
"issuing-card": {
|
|
16
|
+
setDefaultCard: defaultCard => {},
|
|
17
|
+
setCardArtFileLink: cardArtFileLink => {},
|
|
18
|
+
setCardSwitching: cardSwitching => {}
|
|
19
|
+
},
|
|
20
|
+
"issuing-cards-list": {
|
|
21
|
+
setCardArtFileLink: cardArtFileLink => {}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
1
25
|
const componentNameMapping = {
|
|
2
|
-
|
|
26
|
+
payments: "stripe-connect-payments",
|
|
27
|
+
payouts: "stripe-connect-payouts",
|
|
28
|
+
"payment-details": "stripe-connect-payment-details",
|
|
29
|
+
"account-onboarding": "stripe-connect-account-onboarding",
|
|
30
|
+
"payment-method-settings": "stripe-connect-payment-method-settings",
|
|
31
|
+
"account-management": "stripe-connect-account-management",
|
|
32
|
+
"notification-banner": "stripe-connect-notification-banner",
|
|
33
|
+
"instant-payouts": "stripe-connect-instant-payouts",
|
|
34
|
+
"issuing-card": "stripe-connect-issuing-card",
|
|
35
|
+
"issuing-cards-list": "stripe-connect-issuing-cards-list"
|
|
3
36
|
};
|
|
4
37
|
const EXISTING_SCRIPT_MESSAGE = "loadConnect was called but an existing Connect.js script already exists in the document; existing script parameters will be used";
|
|
5
|
-
const V0_URL = "https://connect-js.stripe.com/
|
|
38
|
+
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
6
39
|
const findScript = () => {
|
|
7
40
|
return document.querySelectorAll(`script[src="${V0_URL}"]`)[0];
|
|
8
41
|
};
|
|
@@ -59,6 +92,9 @@ const loadScript = () => {
|
|
|
59
92
|
});
|
|
60
93
|
return stripePromise;
|
|
61
94
|
};
|
|
95
|
+
const hasCustomMethod = tagName => {
|
|
96
|
+
return tagName in ConnectElementCustomMethodConfig;
|
|
97
|
+
};
|
|
62
98
|
const initStripeConnect = (stripePromise, initParams) => {
|
|
63
99
|
const stripeConnectInstance = stripePromise.then(wrapper => wrapper.initialize(initParams));
|
|
64
100
|
return {
|
|
@@ -68,6 +104,16 @@ const initStripeConnect = (stripePromise, initParams) => {
|
|
|
68
104
|
htmlName = tagName;
|
|
69
105
|
}
|
|
70
106
|
const element = document.createElement(htmlName);
|
|
107
|
+
if (hasCustomMethod(tagName)) {
|
|
108
|
+
const methods = ConnectElementCustomMethodConfig[tagName];
|
|
109
|
+
for (const method in methods) {
|
|
110
|
+
element[method] = function (value) {
|
|
111
|
+
stripeConnectInstance.then(() => {
|
|
112
|
+
this[`${method}InternalOnly`](value);
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
71
117
|
stripeConnectInstance.then(instance => {
|
|
72
118
|
element.setConnector(instance.connect);
|
|
73
119
|
});
|
|
@@ -100,7 +146,7 @@ const createWrapper = stripeConnect => {
|
|
|
100
146
|
sdk: true,
|
|
101
147
|
sdkOptions: {
|
|
102
148
|
// This will be replaced by the npm package version when bundling
|
|
103
|
-
sdkVersion: "3.0.
|
|
149
|
+
sdkVersion: "3.1.0-beta.1"
|
|
104
150
|
}
|
|
105
151
|
})
|
|
106
152
|
}));
|
package/dist/connect.js
CHANGED
|
@@ -2,11 +2,44 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
7
|
+
const ConnectElementCustomMethodConfig = {
|
|
8
|
+
"payment-details": {
|
|
9
|
+
setPayment: payment => {},
|
|
10
|
+
setOnClose: listener => {}
|
|
11
|
+
},
|
|
12
|
+
"account-onboarding": {
|
|
13
|
+
setFullTermsOfServiceUrl: termOfServiceUrl => {},
|
|
14
|
+
setRecipientTermsOfServiceUrl: recipientTermsOfServiceUrl => {},
|
|
15
|
+
setPrivacyPolicyUrl: privacyPolicyUrl => {},
|
|
16
|
+
setSkipTermsOfServiceCollection: skipTermsOfServiceCollection => {},
|
|
17
|
+
setOnExit: listener => {}
|
|
18
|
+
},
|
|
19
|
+
"issuing-card": {
|
|
20
|
+
setDefaultCard: defaultCard => {},
|
|
21
|
+
setCardArtFileLink: cardArtFileLink => {},
|
|
22
|
+
setCardSwitching: cardSwitching => {}
|
|
23
|
+
},
|
|
24
|
+
"issuing-cards-list": {
|
|
25
|
+
setCardArtFileLink: cardArtFileLink => {}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
5
29
|
const componentNameMapping = {
|
|
6
|
-
|
|
30
|
+
payments: "stripe-connect-payments",
|
|
31
|
+
payouts: "stripe-connect-payouts",
|
|
32
|
+
"payment-details": "stripe-connect-payment-details",
|
|
33
|
+
"account-onboarding": "stripe-connect-account-onboarding",
|
|
34
|
+
"payment-method-settings": "stripe-connect-payment-method-settings",
|
|
35
|
+
"account-management": "stripe-connect-account-management",
|
|
36
|
+
"notification-banner": "stripe-connect-notification-banner",
|
|
37
|
+
"instant-payouts": "stripe-connect-instant-payouts",
|
|
38
|
+
"issuing-card": "stripe-connect-issuing-card",
|
|
39
|
+
"issuing-cards-list": "stripe-connect-issuing-cards-list"
|
|
7
40
|
};
|
|
8
41
|
const EXISTING_SCRIPT_MESSAGE = "loadConnect was called but an existing Connect.js script already exists in the document; existing script parameters will be used";
|
|
9
|
-
const V0_URL = "https://connect-js.stripe.com/
|
|
42
|
+
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
10
43
|
const findScript = () => {
|
|
11
44
|
return document.querySelectorAll(`script[src="${V0_URL}"]`)[0];
|
|
12
45
|
};
|
|
@@ -63,6 +96,9 @@ const loadScript = () => {
|
|
|
63
96
|
});
|
|
64
97
|
return stripePromise;
|
|
65
98
|
};
|
|
99
|
+
const hasCustomMethod = tagName => {
|
|
100
|
+
return tagName in ConnectElementCustomMethodConfig;
|
|
101
|
+
};
|
|
66
102
|
const initStripeConnect = (stripePromise, initParams) => {
|
|
67
103
|
const stripeConnectInstance = stripePromise.then(wrapper => wrapper.initialize(initParams));
|
|
68
104
|
return {
|
|
@@ -72,6 +108,16 @@ const initStripeConnect = (stripePromise, initParams) => {
|
|
|
72
108
|
htmlName = tagName;
|
|
73
109
|
}
|
|
74
110
|
const element = document.createElement(htmlName);
|
|
111
|
+
if (hasCustomMethod(tagName)) {
|
|
112
|
+
const methods = ConnectElementCustomMethodConfig[tagName];
|
|
113
|
+
for (const method in methods) {
|
|
114
|
+
element[method] = function (value) {
|
|
115
|
+
stripeConnectInstance.then(() => {
|
|
116
|
+
this[`${method}InternalOnly`](value);
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
75
121
|
stripeConnectInstance.then(instance => {
|
|
76
122
|
element.setConnector(instance.connect);
|
|
77
123
|
});
|
|
@@ -104,7 +150,7 @@ const createWrapper = stripeConnect => {
|
|
|
104
150
|
sdk: true,
|
|
105
151
|
sdkOptions: {
|
|
106
152
|
// This will be replaced by the npm package version when bundling
|
|
107
|
-
sdkVersion: "3.0.
|
|
153
|
+
sdkVersion: "3.1.0-beta.1"
|
|
108
154
|
}
|
|
109
155
|
})
|
|
110
156
|
}));
|
package/dist/pure.esm.js
CHANGED
|
@@ -1,8 +1,41 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3
|
+
const ConnectElementCustomMethodConfig = {
|
|
4
|
+
"payment-details": {
|
|
5
|
+
setPayment: payment => {},
|
|
6
|
+
setOnClose: listener => {}
|
|
7
|
+
},
|
|
8
|
+
"account-onboarding": {
|
|
9
|
+
setFullTermsOfServiceUrl: termOfServiceUrl => {},
|
|
10
|
+
setRecipientTermsOfServiceUrl: recipientTermsOfServiceUrl => {},
|
|
11
|
+
setPrivacyPolicyUrl: privacyPolicyUrl => {},
|
|
12
|
+
setSkipTermsOfServiceCollection: skipTermsOfServiceCollection => {},
|
|
13
|
+
setOnExit: listener => {}
|
|
14
|
+
},
|
|
15
|
+
"issuing-card": {
|
|
16
|
+
setDefaultCard: defaultCard => {},
|
|
17
|
+
setCardArtFileLink: cardArtFileLink => {},
|
|
18
|
+
setCardSwitching: cardSwitching => {}
|
|
19
|
+
},
|
|
20
|
+
"issuing-cards-list": {
|
|
21
|
+
setCardArtFileLink: cardArtFileLink => {}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
1
25
|
const componentNameMapping = {
|
|
2
|
-
|
|
26
|
+
payments: "stripe-connect-payments",
|
|
27
|
+
payouts: "stripe-connect-payouts",
|
|
28
|
+
"payment-details": "stripe-connect-payment-details",
|
|
29
|
+
"account-onboarding": "stripe-connect-account-onboarding",
|
|
30
|
+
"payment-method-settings": "stripe-connect-payment-method-settings",
|
|
31
|
+
"account-management": "stripe-connect-account-management",
|
|
32
|
+
"notification-banner": "stripe-connect-notification-banner",
|
|
33
|
+
"instant-payouts": "stripe-connect-instant-payouts",
|
|
34
|
+
"issuing-card": "stripe-connect-issuing-card",
|
|
35
|
+
"issuing-cards-list": "stripe-connect-issuing-cards-list"
|
|
3
36
|
};
|
|
4
37
|
const EXISTING_SCRIPT_MESSAGE = "loadConnect was called but an existing Connect.js script already exists in the document; existing script parameters will be used";
|
|
5
|
-
const V0_URL = "https://connect-js.stripe.com/
|
|
38
|
+
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
6
39
|
const findScript = () => {
|
|
7
40
|
return document.querySelectorAll(`script[src="${V0_URL}"]`)[0];
|
|
8
41
|
};
|
|
@@ -59,6 +92,9 @@ const loadScript = () => {
|
|
|
59
92
|
});
|
|
60
93
|
return stripePromise;
|
|
61
94
|
};
|
|
95
|
+
const hasCustomMethod = tagName => {
|
|
96
|
+
return tagName in ConnectElementCustomMethodConfig;
|
|
97
|
+
};
|
|
62
98
|
const initStripeConnect = (stripePromise, initParams) => {
|
|
63
99
|
const stripeConnectInstance = stripePromise.then(wrapper => wrapper.initialize(initParams));
|
|
64
100
|
return {
|
|
@@ -68,6 +104,16 @@ const initStripeConnect = (stripePromise, initParams) => {
|
|
|
68
104
|
htmlName = tagName;
|
|
69
105
|
}
|
|
70
106
|
const element = document.createElement(htmlName);
|
|
107
|
+
if (hasCustomMethod(tagName)) {
|
|
108
|
+
const methods = ConnectElementCustomMethodConfig[tagName];
|
|
109
|
+
for (const method in methods) {
|
|
110
|
+
element[method] = function (value) {
|
|
111
|
+
stripeConnectInstance.then(() => {
|
|
112
|
+
this[`${method}InternalOnly`](value);
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
71
117
|
stripeConnectInstance.then(instance => {
|
|
72
118
|
element.setConnector(instance.connect);
|
|
73
119
|
});
|
|
@@ -100,7 +146,7 @@ const createWrapper = stripeConnect => {
|
|
|
100
146
|
sdk: true,
|
|
101
147
|
sdkOptions: {
|
|
102
148
|
// This will be replaced by the npm package version when bundling
|
|
103
|
-
sdkVersion: "3.0.
|
|
149
|
+
sdkVersion: "3.1.0-beta.1"
|
|
104
150
|
}
|
|
105
151
|
})
|
|
106
152
|
}));
|
package/dist/pure.js
CHANGED
|
@@ -2,11 +2,44 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
7
|
+
const ConnectElementCustomMethodConfig = {
|
|
8
|
+
"payment-details": {
|
|
9
|
+
setPayment: payment => {},
|
|
10
|
+
setOnClose: listener => {}
|
|
11
|
+
},
|
|
12
|
+
"account-onboarding": {
|
|
13
|
+
setFullTermsOfServiceUrl: termOfServiceUrl => {},
|
|
14
|
+
setRecipientTermsOfServiceUrl: recipientTermsOfServiceUrl => {},
|
|
15
|
+
setPrivacyPolicyUrl: privacyPolicyUrl => {},
|
|
16
|
+
setSkipTermsOfServiceCollection: skipTermsOfServiceCollection => {},
|
|
17
|
+
setOnExit: listener => {}
|
|
18
|
+
},
|
|
19
|
+
"issuing-card": {
|
|
20
|
+
setDefaultCard: defaultCard => {},
|
|
21
|
+
setCardArtFileLink: cardArtFileLink => {},
|
|
22
|
+
setCardSwitching: cardSwitching => {}
|
|
23
|
+
},
|
|
24
|
+
"issuing-cards-list": {
|
|
25
|
+
setCardArtFileLink: cardArtFileLink => {}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
5
29
|
const componentNameMapping = {
|
|
6
|
-
|
|
30
|
+
payments: "stripe-connect-payments",
|
|
31
|
+
payouts: "stripe-connect-payouts",
|
|
32
|
+
"payment-details": "stripe-connect-payment-details",
|
|
33
|
+
"account-onboarding": "stripe-connect-account-onboarding",
|
|
34
|
+
"payment-method-settings": "stripe-connect-payment-method-settings",
|
|
35
|
+
"account-management": "stripe-connect-account-management",
|
|
36
|
+
"notification-banner": "stripe-connect-notification-banner",
|
|
37
|
+
"instant-payouts": "stripe-connect-instant-payouts",
|
|
38
|
+
"issuing-card": "stripe-connect-issuing-card",
|
|
39
|
+
"issuing-cards-list": "stripe-connect-issuing-cards-list"
|
|
7
40
|
};
|
|
8
41
|
const EXISTING_SCRIPT_MESSAGE = "loadConnect was called but an existing Connect.js script already exists in the document; existing script parameters will be used";
|
|
9
|
-
const V0_URL = "https://connect-js.stripe.com/
|
|
42
|
+
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
10
43
|
const findScript = () => {
|
|
11
44
|
return document.querySelectorAll(`script[src="${V0_URL}"]`)[0];
|
|
12
45
|
};
|
|
@@ -63,6 +96,9 @@ const loadScript = () => {
|
|
|
63
96
|
});
|
|
64
97
|
return stripePromise;
|
|
65
98
|
};
|
|
99
|
+
const hasCustomMethod = tagName => {
|
|
100
|
+
return tagName in ConnectElementCustomMethodConfig;
|
|
101
|
+
};
|
|
66
102
|
const initStripeConnect = (stripePromise, initParams) => {
|
|
67
103
|
const stripeConnectInstance = stripePromise.then(wrapper => wrapper.initialize(initParams));
|
|
68
104
|
return {
|
|
@@ -72,6 +108,16 @@ const initStripeConnect = (stripePromise, initParams) => {
|
|
|
72
108
|
htmlName = tagName;
|
|
73
109
|
}
|
|
74
110
|
const element = document.createElement(htmlName);
|
|
111
|
+
if (hasCustomMethod(tagName)) {
|
|
112
|
+
const methods = ConnectElementCustomMethodConfig[tagName];
|
|
113
|
+
for (const method in methods) {
|
|
114
|
+
element[method] = function (value) {
|
|
115
|
+
stripeConnectInstance.then(() => {
|
|
116
|
+
this[`${method}InternalOnly`](value);
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
75
121
|
stripeConnectInstance.then(instance => {
|
|
76
122
|
element.setConnector(instance.connect);
|
|
77
123
|
});
|
|
@@ -104,7 +150,7 @@ const createWrapper = stripeConnect => {
|
|
|
104
150
|
sdk: true,
|
|
105
151
|
sdkOptions: {
|
|
106
152
|
// This will be replaced by the npm package version when bundling
|
|
107
|
-
sdkVersion: "3.0.
|
|
153
|
+
sdkVersion: "3.1.0-beta.1"
|
|
108
154
|
}
|
|
109
155
|
})
|
|
110
156
|
}));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IStripeConnectInitParams, StripeConnectInstance, ConnectElementTagName } from "../types";
|
|
2
2
|
export type LoadConnectAndInitialize = (initParams: IStripeConnectInitParams) => StripeConnectInstance;
|
|
3
|
-
type ConnectElementHTMLName = "stripe-connect-account-onboarding";
|
|
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";
|
|
4
4
|
export declare const componentNameMapping: Record<ConnectElementTagName, ConnectElementHTMLName>;
|
|
5
5
|
type StripeConnectInstanceExtended = StripeConnectInstance & {
|
|
6
6
|
debugInstance: () => Promise<StripeConnectInstance>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const ConnectElementCustomMethodConfig: {
|
|
2
|
+
"payment-details": {
|
|
3
|
+
setPayment: (payment: string | undefined) => void;
|
|
4
|
+
setOnClose: (listener: (() => void) | undefined) => void;
|
|
5
|
+
};
|
|
6
|
+
"account-onboarding": {
|
|
7
|
+
setFullTermsOfServiceUrl: (termOfServiceUrl: string | undefined) => void;
|
|
8
|
+
setRecipientTermsOfServiceUrl: (recipientTermsOfServiceUrl: string | undefined) => void;
|
|
9
|
+
setPrivacyPolicyUrl: (privacyPolicyUrl: string | undefined) => void;
|
|
10
|
+
setSkipTermsOfServiceCollection: (skipTermsOfServiceCollection: boolean | undefined) => void;
|
|
11
|
+
setOnExit: (listener: (() => void) | undefined) => void;
|
|
12
|
+
};
|
|
13
|
+
"issuing-card": {
|
|
14
|
+
setDefaultCard: (defaultCard: string | undefined) => void;
|
|
15
|
+
setCardArtFileLink: (cardArtFileLink: string | undefined) => void;
|
|
16
|
+
setCardSwitching: (cardSwitching: boolean | undefined) => void;
|
|
17
|
+
};
|
|
18
|
+
"issuing-cards-list": {
|
|
19
|
+
setCardArtFileLink: (cardArtFileLink: string | undefined) => void;
|
|
20
|
+
};
|
|
21
|
+
};
|
package/package.json
CHANGED
package/src/shared.ts
CHANGED
|
@@ -4,18 +4,38 @@ import {
|
|
|
4
4
|
ConnectElementTagName,
|
|
5
5
|
ConnectHTMLElementRecord
|
|
6
6
|
} from "../types";
|
|
7
|
+
import { ConnectElementCustomMethodConfig } from "../types/config";
|
|
7
8
|
|
|
8
9
|
export type LoadConnectAndInitialize = (
|
|
9
10
|
initParams: IStripeConnectInitParams
|
|
10
11
|
) => StripeConnectInstance;
|
|
11
12
|
|
|
12
|
-
type ConnectElementHTMLName =
|
|
13
|
+
export type ConnectElementHTMLName =
|
|
14
|
+
| "stripe-connect-payments"
|
|
15
|
+
| "stripe-connect-payouts"
|
|
16
|
+
| "stripe-connect-payment-details"
|
|
17
|
+
| "stripe-connect-account-onboarding"
|
|
18
|
+
| "stripe-connect-payment-method-settings"
|
|
19
|
+
| "stripe-connect-account-management"
|
|
20
|
+
| "stripe-connect-notification-banner"
|
|
21
|
+
| "stripe-connect-instant-payouts"
|
|
22
|
+
| "stripe-connect-issuing-card"
|
|
23
|
+
| "stripe-connect-issuing-cards-list";
|
|
13
24
|
|
|
14
25
|
export const componentNameMapping: Record<
|
|
15
26
|
ConnectElementTagName,
|
|
16
27
|
ConnectElementHTMLName
|
|
17
28
|
> = {
|
|
18
|
-
|
|
29
|
+
payments: "stripe-connect-payments",
|
|
30
|
+
payouts: "stripe-connect-payouts",
|
|
31
|
+
"payment-details": "stripe-connect-payment-details",
|
|
32
|
+
"account-onboarding": "stripe-connect-account-onboarding",
|
|
33
|
+
"payment-method-settings": "stripe-connect-payment-method-settings",
|
|
34
|
+
"account-management": "stripe-connect-account-management",
|
|
35
|
+
"notification-banner": "stripe-connect-notification-banner",
|
|
36
|
+
"instant-payouts": "stripe-connect-instant-payouts",
|
|
37
|
+
"issuing-card": "stripe-connect-issuing-card",
|
|
38
|
+
"issuing-cards-list": "stripe-connect-issuing-cards-list"
|
|
19
39
|
};
|
|
20
40
|
|
|
21
41
|
type StripeConnectInstanceExtended = StripeConnectInstance & {
|
|
@@ -28,7 +48,7 @@ interface StripeConnectWrapper {
|
|
|
28
48
|
|
|
29
49
|
const EXISTING_SCRIPT_MESSAGE =
|
|
30
50
|
"loadConnect was called but an existing Connect.js script already exists in the document; existing script parameters will be used";
|
|
31
|
-
const V0_URL = "https://connect-js.stripe.com/
|
|
51
|
+
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
32
52
|
|
|
33
53
|
export const findScript = (): HTMLScriptElement | null => {
|
|
34
54
|
return document.querySelectorAll<HTMLScriptElement>(
|
|
@@ -108,6 +128,12 @@ export const loadScript = (): Promise<StripeConnectWrapper> => {
|
|
|
108
128
|
return stripePromise;
|
|
109
129
|
};
|
|
110
130
|
|
|
131
|
+
const hasCustomMethod = (
|
|
132
|
+
tagName: ConnectElementTagName
|
|
133
|
+
): tagName is keyof typeof ConnectElementCustomMethodConfig => {
|
|
134
|
+
return tagName in ConnectElementCustomMethodConfig;
|
|
135
|
+
};
|
|
136
|
+
|
|
111
137
|
export const initStripeConnect = (
|
|
112
138
|
stripePromise: Promise<StripeConnectWrapper>,
|
|
113
139
|
initParams: IStripeConnectInitParams
|
|
@@ -123,6 +149,18 @@ export const initStripeConnect = (
|
|
|
123
149
|
htmlName = (tagName as unknown) as ConnectElementHTMLName;
|
|
124
150
|
}
|
|
125
151
|
const element = document.createElement(htmlName);
|
|
152
|
+
|
|
153
|
+
if (hasCustomMethod(tagName)) {
|
|
154
|
+
const methods = ConnectElementCustomMethodConfig[tagName];
|
|
155
|
+
for (const method in methods) {
|
|
156
|
+
(element as any)[method] = function(value: any) {
|
|
157
|
+
stripeConnectInstance.then(() => {
|
|
158
|
+
this[`${method}InternalOnly`](value);
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
126
164
|
stripeConnectInstance.then(instance => {
|
|
127
165
|
(element as any).setConnector((instance as any).connect);
|
|
128
166
|
});
|
package/types/config.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ConnectElementTagName } from "./shared.d";
|
|
2
|
+
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
5
|
+
|
|
6
|
+
export const ConnectElementCustomMethodConfig = {
|
|
7
|
+
"payment-details": {
|
|
8
|
+
setPayment: (payment: string | undefined): void => {},
|
|
9
|
+
setOnClose: (listener: (() => void) | undefined): void => {}
|
|
10
|
+
},
|
|
11
|
+
"account-onboarding": {
|
|
12
|
+
setFullTermsOfServiceUrl: (
|
|
13
|
+
termOfServiceUrl: string | undefined
|
|
14
|
+
): void => {},
|
|
15
|
+
setRecipientTermsOfServiceUrl: (
|
|
16
|
+
recipientTermsOfServiceUrl: string | undefined
|
|
17
|
+
): void => {},
|
|
18
|
+
setPrivacyPolicyUrl: (privacyPolicyUrl: string | undefined): void => {},
|
|
19
|
+
setSkipTermsOfServiceCollection: (
|
|
20
|
+
skipTermsOfServiceCollection: boolean | undefined
|
|
21
|
+
): void => {},
|
|
22
|
+
setOnExit: (listener: (() => void) | undefined): void => {}
|
|
23
|
+
},
|
|
24
|
+
"issuing-card": {
|
|
25
|
+
setDefaultCard: (defaultCard: string | undefined): void => {},
|
|
26
|
+
setCardArtFileLink: (cardArtFileLink: string | undefined): void => {},
|
|
27
|
+
setCardSwitching: (cardSwitching: boolean | undefined): void => {}
|
|
28
|
+
},
|
|
29
|
+
"issuing-cards-list": {
|
|
30
|
+
setCardArtFileLink: (cardArtFileLink: string | undefined): void => {}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// ensure that keys of ConnectElementCustomMethodConfig are from ConnectElementTagName
|
|
35
|
+
type HasType<T, Q extends T> = Q;
|
|
36
|
+
type CustomMethodConfigValidation = HasType<
|
|
37
|
+
ConnectElementTagName,
|
|
38
|
+
keyof typeof ConnectElementCustomMethodConfig
|
|
39
|
+
>;
|
package/types/shared.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ConnectElementCustomMethodConfig } from "./config";
|
|
2
|
+
|
|
1
3
|
export declare type LoadConnectAndInitialize = (
|
|
2
4
|
initParams: IStripeConnectInitParams
|
|
3
5
|
) => StripeConnectInstance;
|
|
@@ -209,6 +211,14 @@ export declare type AppearanceVariables = {
|
|
|
209
211
|
overlayZIndex?: number;
|
|
210
212
|
|
|
211
213
|
// Body Typography
|
|
214
|
+
/**
|
|
215
|
+
* The font size for the large body typography. Body typography variables accept a valid font size value.
|
|
216
|
+
*/
|
|
217
|
+
bodyLgFontSize?: string;
|
|
218
|
+
/**
|
|
219
|
+
* The font weight for the large body typography. Body typography variables accept a valid font weight value.
|
|
220
|
+
*/
|
|
221
|
+
bodyLgFontWeight?: string;
|
|
212
222
|
/**
|
|
213
223
|
* The font size for the medium body typography. Body typography variables accept a valid font size value.
|
|
214
224
|
*/
|
|
@@ -289,6 +299,18 @@ export declare type AppearanceVariables = {
|
|
|
289
299
|
headingXsTextTransform?: string;
|
|
290
300
|
|
|
291
301
|
// Label Typography
|
|
302
|
+
/**
|
|
303
|
+
* The font size for the large label typography. Label typography variables accept a valid font size value.
|
|
304
|
+
*/
|
|
305
|
+
labelLgFontSize?: string;
|
|
306
|
+
/**
|
|
307
|
+
* The font weight for the large label typography. Label typography variables accept a valid font weight value.
|
|
308
|
+
*/
|
|
309
|
+
labelLgFontWeight?: string;
|
|
310
|
+
/**
|
|
311
|
+
* The text transform for the large label typography. Label typography variables accept a valid text transform value.
|
|
312
|
+
*/
|
|
313
|
+
labelLgTextTransform?: string;
|
|
292
314
|
/**
|
|
293
315
|
* The font size for the medium label typography. Label typography variables accept a valid font size value.
|
|
294
316
|
*/
|
|
@@ -354,28 +376,14 @@ export interface IStripeConnectInitParams {
|
|
|
354
376
|
locale?: string;
|
|
355
377
|
}
|
|
356
378
|
|
|
357
|
-
type
|
|
358
|
-
[key in string]: HTMLElement | null;
|
|
359
|
-
};
|
|
360
|
-
type ConnectHTMLElementRecordBase = {
|
|
361
|
-
[tagName in ConnectElementTagName]: HTMLElement;
|
|
362
|
-
};
|
|
379
|
+
type ConnectElementCustomMethods = typeof ConnectElementCustomMethodConfig;
|
|
363
380
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
recipientTermsOfServiceUrl: string | undefined
|
|
371
|
-
) => void;
|
|
372
|
-
setPrivacyPolicyUrl: (privacyPolicyUrl: string | undefined) => void;
|
|
373
|
-
setSkipTermsOfServiceCollection: (
|
|
374
|
-
skipTermsOfServiceCollection: boolean | undefined
|
|
375
|
-
) => void;
|
|
376
|
-
setOnExit: (listener: () => void) => void;
|
|
377
|
-
};
|
|
378
|
-
}
|
|
381
|
+
type ConnectHTMLElementRecord = {
|
|
382
|
+
[K in keyof ConnectElementCustomMethods]: HTMLElement &
|
|
383
|
+
ConnectElementCustomMethods[K];
|
|
384
|
+
} & {
|
|
385
|
+
[key: string]: HTMLElement;
|
|
386
|
+
};
|
|
379
387
|
|
|
380
388
|
export interface StripeConnectInstance {
|
|
381
389
|
/**
|
|
@@ -403,4 +411,14 @@ export interface StripeConnectInstance {
|
|
|
403
411
|
/**
|
|
404
412
|
* Tagnames to be used with the `create` method of the Connect instance.
|
|
405
413
|
*/
|
|
406
|
-
export type ConnectElementTagName =
|
|
414
|
+
export type ConnectElementTagName =
|
|
415
|
+
| "payments"
|
|
416
|
+
| "payouts"
|
|
417
|
+
| "payment-details"
|
|
418
|
+
| "account-onboarding"
|
|
419
|
+
| "payment-method-settings"
|
|
420
|
+
| "account-management"
|
|
421
|
+
| "notification-banner"
|
|
422
|
+
| "instant-payouts"
|
|
423
|
+
| "issuing-card"
|
|
424
|
+
| "issuing-cards-list";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|