@stripe/connect-js 2.0.4 → 3.0.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 +45 -20
- package/dist/connect.js +45 -20
- package/dist/index.d.ts +2 -0
- package/dist/pure.d.ts +2 -2
- package/dist/pure.esm.js +46 -20
- package/dist/pure.js +46 -20
- package/dist/shared.d.ts +13 -4
- package/package.json +1 -1
- package/pure.d.ts +2 -2
- package/src/index.ts +10 -6
- package/src/pure.test.ts +11 -4
- package/src/pure.ts +11 -3
- package/src/shared.ts +76 -29
- package/types/index.d.ts +4 -2
- package/types/shared.d.ts +313 -65
- package/dist/src/index.d.ts +0 -3
package/dist/connect.esm.js
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
const componentNameMapping = {
|
|
2
|
-
|
|
2
|
+
payments: "stripe-connect-payments",
|
|
3
|
+
payouts: "stripe-connect-payouts",
|
|
4
|
+
"payment-details": "stripe-connect-payment-details",
|
|
5
|
+
"account-onboarding": "stripe-connect-account-onboarding",
|
|
6
|
+
"payment-method-settings": "stripe-connect-payment-method-settings",
|
|
7
|
+
"account-management": "stripe-connect-account-management",
|
|
8
|
+
"notification-banner": "stripe-connect-notification-banner",
|
|
9
|
+
"instant-payouts": "stripe-connect-instant-payouts",
|
|
10
|
+
"issuing-card": "stripe-connect-issuing-card",
|
|
11
|
+
"issuing-cards-list": "stripe-connect-issuing-cards-list"
|
|
3
12
|
};
|
|
4
13
|
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/
|
|
14
|
+
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
6
15
|
const findScript = () => {
|
|
7
16
|
return document.querySelectorAll(`script[src="${V0_URL}"]`)[0];
|
|
8
17
|
};
|
|
@@ -59,13 +68,38 @@ const loadScript = () => {
|
|
|
59
68
|
});
|
|
60
69
|
return stripePromise;
|
|
61
70
|
};
|
|
62
|
-
const initStripeConnect =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
71
|
+
const initStripeConnect = (stripePromise, initParams) => {
|
|
72
|
+
const stripeConnectInstance = stripePromise.then(wrapper => wrapper.initialize(initParams));
|
|
73
|
+
return {
|
|
74
|
+
create: tagName => {
|
|
75
|
+
let htmlName = componentNameMapping[tagName];
|
|
76
|
+
if (!htmlName) {
|
|
77
|
+
htmlName = tagName;
|
|
78
|
+
}
|
|
79
|
+
const element = document.createElement(htmlName);
|
|
80
|
+
stripeConnectInstance.then(instance => {
|
|
81
|
+
element.setConnector(instance.connect);
|
|
82
|
+
});
|
|
83
|
+
return element;
|
|
84
|
+
},
|
|
85
|
+
update: updateOptions => {
|
|
86
|
+
stripeConnectInstance.then(instance => {
|
|
87
|
+
instance.update(updateOptions);
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
debugInstance: () => {
|
|
91
|
+
return stripeConnectInstance;
|
|
92
|
+
},
|
|
93
|
+
logout: () => {
|
|
94
|
+
return stripeConnectInstance.then(instance => {
|
|
95
|
+
instance.logout();
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
67
99
|
};
|
|
68
100
|
const createWrapper = stripeConnect => {
|
|
101
|
+
window.StripeConnect = window.StripeConnect || {};
|
|
102
|
+
window.StripeConnect.optimizedLoading = true;
|
|
69
103
|
const wrapper = {
|
|
70
104
|
initialize: params => {
|
|
71
105
|
var _a;
|
|
@@ -75,19 +109,10 @@ const createWrapper = stripeConnect => {
|
|
|
75
109
|
sdk: true,
|
|
76
110
|
sdkOptions: {
|
|
77
111
|
// This will be replaced by the npm package version when bundling
|
|
78
|
-
sdkVersion: "
|
|
112
|
+
sdkVersion: "3.0.0-beta.1"
|
|
79
113
|
}
|
|
80
114
|
})
|
|
81
115
|
}));
|
|
82
|
-
// We wrap create so we can map its different strings to supported components
|
|
83
|
-
const oldCreate = stripeConnectInstance.create.bind(stripeConnectInstance);
|
|
84
|
-
stripeConnectInstance.create = tagName => {
|
|
85
|
-
let htmlName = componentNameMapping[tagName];
|
|
86
|
-
if (!htmlName) {
|
|
87
|
-
htmlName = tagName;
|
|
88
|
-
}
|
|
89
|
-
return oldCreate(htmlName);
|
|
90
|
-
};
|
|
91
116
|
return stripeConnectInstance;
|
|
92
117
|
}
|
|
93
118
|
};
|
|
@@ -103,9 +128,9 @@ stripePromise$1.catch(err => {
|
|
|
103
128
|
console.warn(err);
|
|
104
129
|
}
|
|
105
130
|
});
|
|
106
|
-
const
|
|
131
|
+
const loadConnectAndInitialize = initParams => {
|
|
107
132
|
loadCalled = true;
|
|
108
|
-
return stripePromise$1
|
|
133
|
+
return initStripeConnect(stripePromise$1, initParams);
|
|
109
134
|
};
|
|
110
135
|
|
|
111
|
-
export {
|
|
136
|
+
export { loadConnectAndInitialize };
|
package/dist/connect.js
CHANGED
|
@@ -3,10 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const componentNameMapping = {
|
|
6
|
-
|
|
6
|
+
payments: "stripe-connect-payments",
|
|
7
|
+
payouts: "stripe-connect-payouts",
|
|
8
|
+
"payment-details": "stripe-connect-payment-details",
|
|
9
|
+
"account-onboarding": "stripe-connect-account-onboarding",
|
|
10
|
+
"payment-method-settings": "stripe-connect-payment-method-settings",
|
|
11
|
+
"account-management": "stripe-connect-account-management",
|
|
12
|
+
"notification-banner": "stripe-connect-notification-banner",
|
|
13
|
+
"instant-payouts": "stripe-connect-instant-payouts",
|
|
14
|
+
"issuing-card": "stripe-connect-issuing-card",
|
|
15
|
+
"issuing-cards-list": "stripe-connect-issuing-cards-list"
|
|
7
16
|
};
|
|
8
17
|
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/
|
|
18
|
+
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
10
19
|
const findScript = () => {
|
|
11
20
|
return document.querySelectorAll(`script[src="${V0_URL}"]`)[0];
|
|
12
21
|
};
|
|
@@ -63,13 +72,38 @@ const loadScript = () => {
|
|
|
63
72
|
});
|
|
64
73
|
return stripePromise;
|
|
65
74
|
};
|
|
66
|
-
const initStripeConnect =
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
75
|
+
const initStripeConnect = (stripePromise, initParams) => {
|
|
76
|
+
const stripeConnectInstance = stripePromise.then(wrapper => wrapper.initialize(initParams));
|
|
77
|
+
return {
|
|
78
|
+
create: tagName => {
|
|
79
|
+
let htmlName = componentNameMapping[tagName];
|
|
80
|
+
if (!htmlName) {
|
|
81
|
+
htmlName = tagName;
|
|
82
|
+
}
|
|
83
|
+
const element = document.createElement(htmlName);
|
|
84
|
+
stripeConnectInstance.then(instance => {
|
|
85
|
+
element.setConnector(instance.connect);
|
|
86
|
+
});
|
|
87
|
+
return element;
|
|
88
|
+
},
|
|
89
|
+
update: updateOptions => {
|
|
90
|
+
stripeConnectInstance.then(instance => {
|
|
91
|
+
instance.update(updateOptions);
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
debugInstance: () => {
|
|
95
|
+
return stripeConnectInstance;
|
|
96
|
+
},
|
|
97
|
+
logout: () => {
|
|
98
|
+
return stripeConnectInstance.then(instance => {
|
|
99
|
+
instance.logout();
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
};
|
|
71
103
|
};
|
|
72
104
|
const createWrapper = stripeConnect => {
|
|
105
|
+
window.StripeConnect = window.StripeConnect || {};
|
|
106
|
+
window.StripeConnect.optimizedLoading = true;
|
|
73
107
|
const wrapper = {
|
|
74
108
|
initialize: params => {
|
|
75
109
|
var _a;
|
|
@@ -79,19 +113,10 @@ const createWrapper = stripeConnect => {
|
|
|
79
113
|
sdk: true,
|
|
80
114
|
sdkOptions: {
|
|
81
115
|
// This will be replaced by the npm package version when bundling
|
|
82
|
-
sdkVersion: "
|
|
116
|
+
sdkVersion: "3.0.0-beta.1"
|
|
83
117
|
}
|
|
84
118
|
})
|
|
85
119
|
}));
|
|
86
|
-
// We wrap create so we can map its different strings to supported components
|
|
87
|
-
const oldCreate = stripeConnectInstance.create.bind(stripeConnectInstance);
|
|
88
|
-
stripeConnectInstance.create = tagName => {
|
|
89
|
-
let htmlName = componentNameMapping[tagName];
|
|
90
|
-
if (!htmlName) {
|
|
91
|
-
htmlName = tagName;
|
|
92
|
-
}
|
|
93
|
-
return oldCreate(htmlName);
|
|
94
|
-
};
|
|
95
120
|
return stripeConnectInstance;
|
|
96
121
|
}
|
|
97
122
|
};
|
|
@@ -107,9 +132,9 @@ stripePromise$1.catch(err => {
|
|
|
107
132
|
console.warn(err);
|
|
108
133
|
}
|
|
109
134
|
});
|
|
110
|
-
const
|
|
135
|
+
const loadConnectAndInitialize = initParams => {
|
|
111
136
|
loadCalled = true;
|
|
112
|
-
return stripePromise$1
|
|
137
|
+
return initStripeConnect(stripePromise$1, initParams);
|
|
113
138
|
};
|
|
114
139
|
|
|
115
|
-
exports.
|
|
140
|
+
exports.loadConnectAndInitialize = loadConnectAndInitialize;
|
package/dist/index.d.ts
ADDED
package/dist/pure.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const
|
|
1
|
+
import { LoadConnectAndInitialize } from "./shared";
|
|
2
|
+
export declare const loadConnectAndInitialize: LoadConnectAndInitialize;
|
package/dist/pure.esm.js
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
const componentNameMapping = {
|
|
2
|
-
|
|
2
|
+
payments: "stripe-connect-payments",
|
|
3
|
+
payouts: "stripe-connect-payouts",
|
|
4
|
+
"payment-details": "stripe-connect-payment-details",
|
|
5
|
+
"account-onboarding": "stripe-connect-account-onboarding",
|
|
6
|
+
"payment-method-settings": "stripe-connect-payment-method-settings",
|
|
7
|
+
"account-management": "stripe-connect-account-management",
|
|
8
|
+
"notification-banner": "stripe-connect-notification-banner",
|
|
9
|
+
"instant-payouts": "stripe-connect-instant-payouts",
|
|
10
|
+
"issuing-card": "stripe-connect-issuing-card",
|
|
11
|
+
"issuing-cards-list": "stripe-connect-issuing-cards-list"
|
|
3
12
|
};
|
|
4
13
|
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/
|
|
14
|
+
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
6
15
|
const findScript = () => {
|
|
7
16
|
return document.querySelectorAll(`script[src="${V0_URL}"]`)[0];
|
|
8
17
|
};
|
|
@@ -59,13 +68,38 @@ const loadScript = () => {
|
|
|
59
68
|
});
|
|
60
69
|
return stripePromise;
|
|
61
70
|
};
|
|
62
|
-
const initStripeConnect =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
71
|
+
const initStripeConnect = (stripePromise, initParams) => {
|
|
72
|
+
const stripeConnectInstance = stripePromise.then(wrapper => wrapper.initialize(initParams));
|
|
73
|
+
return {
|
|
74
|
+
create: tagName => {
|
|
75
|
+
let htmlName = componentNameMapping[tagName];
|
|
76
|
+
if (!htmlName) {
|
|
77
|
+
htmlName = tagName;
|
|
78
|
+
}
|
|
79
|
+
const element = document.createElement(htmlName);
|
|
80
|
+
stripeConnectInstance.then(instance => {
|
|
81
|
+
element.setConnector(instance.connect);
|
|
82
|
+
});
|
|
83
|
+
return element;
|
|
84
|
+
},
|
|
85
|
+
update: updateOptions => {
|
|
86
|
+
stripeConnectInstance.then(instance => {
|
|
87
|
+
instance.update(updateOptions);
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
debugInstance: () => {
|
|
91
|
+
return stripeConnectInstance;
|
|
92
|
+
},
|
|
93
|
+
logout: () => {
|
|
94
|
+
return stripeConnectInstance.then(instance => {
|
|
95
|
+
instance.logout();
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
67
99
|
};
|
|
68
100
|
const createWrapper = stripeConnect => {
|
|
101
|
+
window.StripeConnect = window.StripeConnect || {};
|
|
102
|
+
window.StripeConnect.optimizedLoading = true;
|
|
69
103
|
const wrapper = {
|
|
70
104
|
initialize: params => {
|
|
71
105
|
var _a;
|
|
@@ -75,27 +109,19 @@ const createWrapper = stripeConnect => {
|
|
|
75
109
|
sdk: true,
|
|
76
110
|
sdkOptions: {
|
|
77
111
|
// This will be replaced by the npm package version when bundling
|
|
78
|
-
sdkVersion: "
|
|
112
|
+
sdkVersion: "3.0.0-beta.1"
|
|
79
113
|
}
|
|
80
114
|
})
|
|
81
115
|
}));
|
|
82
|
-
// We wrap create so we can map its different strings to supported components
|
|
83
|
-
const oldCreate = stripeConnectInstance.create.bind(stripeConnectInstance);
|
|
84
|
-
stripeConnectInstance.create = tagName => {
|
|
85
|
-
let htmlName = componentNameMapping[tagName];
|
|
86
|
-
if (!htmlName) {
|
|
87
|
-
htmlName = tagName;
|
|
88
|
-
}
|
|
89
|
-
return oldCreate(htmlName);
|
|
90
|
-
};
|
|
91
116
|
return stripeConnectInstance;
|
|
92
117
|
}
|
|
93
118
|
};
|
|
94
119
|
return wrapper;
|
|
95
120
|
};
|
|
96
121
|
|
|
97
|
-
const
|
|
98
|
-
|
|
122
|
+
const loadConnectAndInitialize = initParams => {
|
|
123
|
+
const maybeConnect = loadScript();
|
|
124
|
+
return initStripeConnect(maybeConnect, initParams);
|
|
99
125
|
};
|
|
100
126
|
|
|
101
|
-
export {
|
|
127
|
+
export { loadConnectAndInitialize };
|
package/dist/pure.js
CHANGED
|
@@ -3,10 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const componentNameMapping = {
|
|
6
|
-
|
|
6
|
+
payments: "stripe-connect-payments",
|
|
7
|
+
payouts: "stripe-connect-payouts",
|
|
8
|
+
"payment-details": "stripe-connect-payment-details",
|
|
9
|
+
"account-onboarding": "stripe-connect-account-onboarding",
|
|
10
|
+
"payment-method-settings": "stripe-connect-payment-method-settings",
|
|
11
|
+
"account-management": "stripe-connect-account-management",
|
|
12
|
+
"notification-banner": "stripe-connect-notification-banner",
|
|
13
|
+
"instant-payouts": "stripe-connect-instant-payouts",
|
|
14
|
+
"issuing-card": "stripe-connect-issuing-card",
|
|
15
|
+
"issuing-cards-list": "stripe-connect-issuing-cards-list"
|
|
7
16
|
};
|
|
8
17
|
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/
|
|
18
|
+
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
10
19
|
const findScript = () => {
|
|
11
20
|
return document.querySelectorAll(`script[src="${V0_URL}"]`)[0];
|
|
12
21
|
};
|
|
@@ -63,13 +72,38 @@ const loadScript = () => {
|
|
|
63
72
|
});
|
|
64
73
|
return stripePromise;
|
|
65
74
|
};
|
|
66
|
-
const initStripeConnect =
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
75
|
+
const initStripeConnect = (stripePromise, initParams) => {
|
|
76
|
+
const stripeConnectInstance = stripePromise.then(wrapper => wrapper.initialize(initParams));
|
|
77
|
+
return {
|
|
78
|
+
create: tagName => {
|
|
79
|
+
let htmlName = componentNameMapping[tagName];
|
|
80
|
+
if (!htmlName) {
|
|
81
|
+
htmlName = tagName;
|
|
82
|
+
}
|
|
83
|
+
const element = document.createElement(htmlName);
|
|
84
|
+
stripeConnectInstance.then(instance => {
|
|
85
|
+
element.setConnector(instance.connect);
|
|
86
|
+
});
|
|
87
|
+
return element;
|
|
88
|
+
},
|
|
89
|
+
update: updateOptions => {
|
|
90
|
+
stripeConnectInstance.then(instance => {
|
|
91
|
+
instance.update(updateOptions);
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
debugInstance: () => {
|
|
95
|
+
return stripeConnectInstance;
|
|
96
|
+
},
|
|
97
|
+
logout: () => {
|
|
98
|
+
return stripeConnectInstance.then(instance => {
|
|
99
|
+
instance.logout();
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
};
|
|
71
103
|
};
|
|
72
104
|
const createWrapper = stripeConnect => {
|
|
105
|
+
window.StripeConnect = window.StripeConnect || {};
|
|
106
|
+
window.StripeConnect.optimizedLoading = true;
|
|
73
107
|
const wrapper = {
|
|
74
108
|
initialize: params => {
|
|
75
109
|
var _a;
|
|
@@ -79,27 +113,19 @@ const createWrapper = stripeConnect => {
|
|
|
79
113
|
sdk: true,
|
|
80
114
|
sdkOptions: {
|
|
81
115
|
// This will be replaced by the npm package version when bundling
|
|
82
|
-
sdkVersion: "
|
|
116
|
+
sdkVersion: "3.0.0-beta.1"
|
|
83
117
|
}
|
|
84
118
|
})
|
|
85
119
|
}));
|
|
86
|
-
// We wrap create so we can map its different strings to supported components
|
|
87
|
-
const oldCreate = stripeConnectInstance.create.bind(stripeConnectInstance);
|
|
88
|
-
stripeConnectInstance.create = tagName => {
|
|
89
|
-
let htmlName = componentNameMapping[tagName];
|
|
90
|
-
if (!htmlName) {
|
|
91
|
-
htmlName = tagName;
|
|
92
|
-
}
|
|
93
|
-
return oldCreate(htmlName);
|
|
94
|
-
};
|
|
95
120
|
return stripeConnectInstance;
|
|
96
121
|
}
|
|
97
122
|
};
|
|
98
123
|
return wrapper;
|
|
99
124
|
};
|
|
100
125
|
|
|
101
|
-
const
|
|
102
|
-
|
|
126
|
+
const loadConnectAndInitialize = initParams => {
|
|
127
|
+
const maybeConnect = loadScript();
|
|
128
|
+
return initStripeConnect(maybeConnect, initParams);
|
|
103
129
|
};
|
|
104
130
|
|
|
105
|
-
exports.
|
|
131
|
+
exports.loadConnectAndInitialize = loadConnectAndInitialize;
|
package/dist/shared.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type
|
|
1
|
+
import { IStripeConnectInitParams, StripeConnectInstance, ConnectElementTagName } from "../types";
|
|
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";
|
|
4
|
+
export declare const componentNameMapping: Record<ConnectElementTagName, ConnectElementHTMLName>;
|
|
5
|
+
type StripeConnectInstanceExtended = StripeConnectInstance & {
|
|
6
|
+
debugInstance: () => Promise<StripeConnectInstance>;
|
|
7
|
+
};
|
|
8
|
+
interface StripeConnectWrapper {
|
|
9
|
+
initialize: (params: IStripeConnectInitParams) => StripeConnectInstance;
|
|
10
|
+
}
|
|
3
11
|
export declare const findScript: () => HTMLScriptElement | null;
|
|
4
|
-
export declare const loadScript: () => Promise<StripeConnectWrapper
|
|
5
|
-
export declare const initStripeConnect: (
|
|
12
|
+
export declare const loadScript: () => Promise<StripeConnectWrapper>;
|
|
13
|
+
export declare const initStripeConnect: (stripePromise: Promise<StripeConnectWrapper>, initParams: IStripeConnectInitParams) => StripeConnectInstanceExtended;
|
|
14
|
+
export {};
|
package/package.json
CHANGED
package/pure.d.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IStripeConnectInitParams, StripeConnectInstance } from "../types";
|
|
2
|
+
import {
|
|
3
|
+
loadScript,
|
|
4
|
+
initStripeConnect,
|
|
5
|
+
LoadConnectAndInitialize
|
|
6
|
+
} from "./shared";
|
|
2
7
|
|
|
3
8
|
// Execute our own script injection after a tick to give users time to do their
|
|
4
9
|
// own script injection.
|
|
@@ -12,10 +17,9 @@ stripePromise.catch((err: Error) => {
|
|
|
12
17
|
}
|
|
13
18
|
});
|
|
14
19
|
|
|
15
|
-
export const
|
|
20
|
+
export const loadConnectAndInitialize: LoadConnectAndInitialize = (
|
|
21
|
+
initParams: IStripeConnectInitParams
|
|
22
|
+
): StripeConnectInstance => {
|
|
16
23
|
loadCalled = true;
|
|
17
|
-
|
|
18
|
-
return stripePromise.then(maybeConnect => initStripeConnect(maybeConnect));
|
|
24
|
+
return initStripeConnect(stripePromise, initParams);
|
|
19
25
|
};
|
|
20
|
-
|
|
21
|
-
export {};
|
package/src/pure.test.ts
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
2
|
|
|
3
|
+
import { IStripeConnectInitParams } from "../types";
|
|
3
4
|
import { SCRIPT_SELECTOR } from "./utils/jestHelpers";
|
|
4
5
|
|
|
5
6
|
describe("pure module", () => {
|
|
6
|
-
test("does not inject the script if
|
|
7
|
+
test("does not inject the script if loadConnectAndInitialize is not called", async () => {
|
|
7
8
|
require("./pure");
|
|
8
9
|
|
|
9
10
|
expect(document.querySelector(SCRIPT_SELECTOR)).toBe(null);
|
|
10
11
|
});
|
|
11
12
|
|
|
12
|
-
test("it injects the script if
|
|
13
|
-
const {
|
|
14
|
-
|
|
13
|
+
test("it injects the script if loadConnectAndInitialize is called", async () => {
|
|
14
|
+
const { loadConnectAndInitialize } = require("./pure");
|
|
15
|
+
const mockInitParams: IStripeConnectInitParams = {
|
|
16
|
+
publishableKey: "pk_123",
|
|
17
|
+
fetchClientSecret: async () => {
|
|
18
|
+
return "secret_123";
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
loadConnectAndInitialize(mockInitParams);
|
|
15
22
|
|
|
16
23
|
expect(document.querySelector(SCRIPT_SELECTOR)).not.toBe(null);
|
|
17
24
|
});
|
package/src/pure.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IStripeConnectInitParams, StripeConnectInstance } from "../types";
|
|
2
|
+
import {
|
|
3
|
+
loadScript,
|
|
4
|
+
initStripeConnect,
|
|
5
|
+
LoadConnectAndInitialize
|
|
6
|
+
} from "./shared";
|
|
2
7
|
|
|
3
|
-
export const
|
|
4
|
-
|
|
8
|
+
export const loadConnectAndInitialize: LoadConnectAndInitialize = (
|
|
9
|
+
initParams: IStripeConnectInitParams
|
|
10
|
+
): StripeConnectInstance => {
|
|
11
|
+
const maybeConnect = loadScript();
|
|
12
|
+
return initStripeConnect(maybeConnect, initParams);
|
|
5
13
|
};
|
package/src/shared.ts
CHANGED
|
@@ -1,23 +1,53 @@
|
|
|
1
1
|
import {
|
|
2
|
-
StripeConnectWrapper,
|
|
3
2
|
IStripeConnectInitParams,
|
|
4
|
-
|
|
3
|
+
StripeConnectInstance,
|
|
4
|
+
ConnectElementTagName,
|
|
5
|
+
ConnectHTMLElementRecord
|
|
5
6
|
} from "../types";
|
|
6
7
|
|
|
7
|
-
export type
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
export type LoadConnectAndInitialize = (
|
|
9
|
+
initParams: IStripeConnectInitParams
|
|
10
|
+
) => StripeConnectInstance;
|
|
11
|
+
|
|
12
|
+
export type ConnectElementHTMLName =
|
|
13
|
+
| "stripe-connect-payments"
|
|
14
|
+
| "stripe-connect-payouts"
|
|
15
|
+
| "stripe-connect-payment-details"
|
|
16
|
+
| "stripe-connect-account-onboarding"
|
|
17
|
+
| "stripe-connect-payment-method-settings"
|
|
18
|
+
| "stripe-connect-account-management"
|
|
19
|
+
| "stripe-connect-notification-banner"
|
|
20
|
+
| "stripe-connect-instant-payouts"
|
|
21
|
+
| "stripe-connect-issuing-card"
|
|
22
|
+
| "stripe-connect-issuing-cards-list";
|
|
23
|
+
|
|
24
|
+
export const componentNameMapping: Record<
|
|
12
25
|
ConnectElementTagName,
|
|
13
26
|
ConnectElementHTMLName
|
|
14
27
|
> = {
|
|
15
|
-
|
|
28
|
+
payments: "stripe-connect-payments",
|
|
29
|
+
payouts: "stripe-connect-payouts",
|
|
30
|
+
"payment-details": "stripe-connect-payment-details",
|
|
31
|
+
"account-onboarding": "stripe-connect-account-onboarding",
|
|
32
|
+
"payment-method-settings": "stripe-connect-payment-method-settings",
|
|
33
|
+
"account-management": "stripe-connect-account-management",
|
|
34
|
+
"notification-banner": "stripe-connect-notification-banner",
|
|
35
|
+
"instant-payouts": "stripe-connect-instant-payouts",
|
|
36
|
+
"issuing-card": "stripe-connect-issuing-card",
|
|
37
|
+
"issuing-cards-list": "stripe-connect-issuing-cards-list"
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type StripeConnectInstanceExtended = StripeConnectInstance & {
|
|
41
|
+
debugInstance: () => Promise<StripeConnectInstance>;
|
|
16
42
|
};
|
|
17
43
|
|
|
44
|
+
interface StripeConnectWrapper {
|
|
45
|
+
initialize: (params: IStripeConnectInitParams) => StripeConnectInstance;
|
|
46
|
+
}
|
|
47
|
+
|
|
18
48
|
const EXISTING_SCRIPT_MESSAGE =
|
|
19
49
|
"loadConnect was called but an existing Connect.js script already exists in the document; existing script parameters will be used";
|
|
20
|
-
const V0_URL = "https://connect-js.stripe.com/
|
|
50
|
+
const V0_URL = "https://connect-js.stripe.com/v0.1/connect.js";
|
|
21
51
|
|
|
22
52
|
export const findScript = (): HTMLScriptElement | null => {
|
|
23
53
|
return document.querySelectorAll<HTMLScriptElement>(
|
|
@@ -44,13 +74,13 @@ const injectScript = (): HTMLScriptElement => {
|
|
|
44
74
|
|
|
45
75
|
let stripePromise: Promise<StripeConnectWrapper> | null = null;
|
|
46
76
|
|
|
47
|
-
export const loadScript = (): Promise<StripeConnectWrapper
|
|
77
|
+
export const loadScript = (): Promise<StripeConnectWrapper> => {
|
|
48
78
|
// Ensure that we only attempt to load Connect.js at most once
|
|
49
79
|
if (stripePromise !== null) {
|
|
50
80
|
return stripePromise;
|
|
51
81
|
}
|
|
52
82
|
|
|
53
|
-
stripePromise = new Promise((resolve, reject) => {
|
|
83
|
+
stripePromise = new Promise<StripeConnectWrapper>((resolve, reject) => {
|
|
54
84
|
if (typeof window === "undefined") {
|
|
55
85
|
reject(
|
|
56
86
|
"ConnectJS won't load when rendering code in the server - it can only be loaded on a browser. This error is expected when loading ConnectJS in SSR environments, like NextJS. It will have no impact in the UI, however if you wish to avoid it, you can switch to the `pure` version of the connect.js loader: https://github.com/stripe/connect-js#importing-loadconnect-without-side-effects."
|
|
@@ -98,16 +128,45 @@ export const loadScript = (): Promise<StripeConnectWrapper | null> => {
|
|
|
98
128
|
};
|
|
99
129
|
|
|
100
130
|
export const initStripeConnect = (
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
131
|
+
stripePromise: Promise<StripeConnectWrapper>,
|
|
132
|
+
initParams: IStripeConnectInitParams
|
|
133
|
+
): StripeConnectInstanceExtended => {
|
|
134
|
+
const stripeConnectInstance = stripePromise.then(wrapper =>
|
|
135
|
+
wrapper.initialize(initParams)
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
return {
|
|
139
|
+
create: tagName => {
|
|
140
|
+
let htmlName = componentNameMapping[tagName];
|
|
141
|
+
if (!htmlName) {
|
|
142
|
+
htmlName = tagName as ConnectElementHTMLName;
|
|
143
|
+
}
|
|
144
|
+
const element = document.createElement(htmlName);
|
|
145
|
+
stripeConnectInstance.then(instance => {
|
|
146
|
+
(element as any).setConnector((instance as any).connect);
|
|
147
|
+
});
|
|
106
148
|
|
|
107
|
-
|
|
149
|
+
return element as ConnectHTMLElementRecord[typeof tagName];
|
|
150
|
+
},
|
|
151
|
+
update: updateOptions => {
|
|
152
|
+
stripeConnectInstance.then(instance => {
|
|
153
|
+
instance.update(updateOptions);
|
|
154
|
+
});
|
|
155
|
+
},
|
|
156
|
+
debugInstance: () => {
|
|
157
|
+
return stripeConnectInstance;
|
|
158
|
+
},
|
|
159
|
+
logout: () => {
|
|
160
|
+
return stripeConnectInstance.then(instance => {
|
|
161
|
+
instance.logout();
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
};
|
|
108
165
|
};
|
|
109
166
|
|
|
110
167
|
const createWrapper = (stripeConnect: any) => {
|
|
168
|
+
(window as any).StripeConnect = (window as any).StripeConnect || {};
|
|
169
|
+
(window as any).StripeConnect.optimizedLoading = true;
|
|
111
170
|
const wrapper: StripeConnectWrapper = {
|
|
112
171
|
initialize: (params: IStripeConnectInitParams) => {
|
|
113
172
|
const metaOptions = (params as any).metaOptions ?? {};
|
|
@@ -122,18 +181,6 @@ const createWrapper = (stripeConnect: any) => {
|
|
|
122
181
|
}
|
|
123
182
|
}
|
|
124
183
|
});
|
|
125
|
-
|
|
126
|
-
// We wrap create so we can map its different strings to supported components
|
|
127
|
-
const oldCreate = stripeConnectInstance.create.bind(
|
|
128
|
-
stripeConnectInstance
|
|
129
|
-
);
|
|
130
|
-
stripeConnectInstance.create = (tagName: ConnectElementTagName) => {
|
|
131
|
-
let htmlName = componentNameMapping[tagName];
|
|
132
|
-
if (!htmlName) {
|
|
133
|
-
htmlName = tagName as ConnectElementHTMLName;
|
|
134
|
-
}
|
|
135
|
-
return oldCreate(htmlName);
|
|
136
|
-
};
|
|
137
184
|
return stripeConnectInstance;
|
|
138
185
|
}
|
|
139
186
|
};
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IStripeConnectInitParams, StripeConnectInstance } from "../types";
|
|
2
2
|
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const loadConnectAndInitialize: (
|
|
4
|
+
initParams: IStripeConnectInitParams
|
|
5
|
+
) => StripeConnectInstance;
|
|
4
6
|
export * from "./shared";
|
package/types/shared.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export declare type
|
|
1
|
+
export declare type LoadConnectAndInitialize = (
|
|
2
|
+
initParams: IStripeConnectInitParams
|
|
3
|
+
) => StripeConnectInstance;
|
|
2
4
|
|
|
3
5
|
export declare type OverlayOption = "dialog" | "drawer";
|
|
4
6
|
|
|
@@ -6,114 +8,342 @@ export declare type OverlayOption = "dialog" | "drawer";
|
|
|
6
8
|
* Appearance options for the Connect instance.
|
|
7
9
|
*/
|
|
8
10
|
export declare type AppearanceOptions = {
|
|
11
|
+
/**
|
|
12
|
+
* The type of overlay used throughout the Connect.js design system. Set this to be either a Dialog or Drawer.
|
|
13
|
+
*/
|
|
9
14
|
overlays?: OverlayOption;
|
|
10
15
|
variables?: AppearanceVariables;
|
|
11
16
|
};
|
|
12
17
|
|
|
13
18
|
export declare type AppearanceVariables = {
|
|
19
|
+
// Commonly used
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The font family value used throughout embedded components. If an embedded component inherits a font-family value from an element on your site in which it’s placed, this setting overrides that inheritance.
|
|
23
|
+
*/
|
|
24
|
+
fontFamily?: string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The baseline font size set on the embedded component root. This scales the value of other font size variables. This supports pixel values only.
|
|
28
|
+
*/
|
|
29
|
+
fontSizeBase?: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The base spacing unit that derives all spacing values. Increase or decrease this value to make your layout more or less spacious. This supports pixel values only.
|
|
33
|
+
*/
|
|
34
|
+
spacingUnit?: string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The general border radius used in embedded components. This sets the default border radius for all components. This supports pixel values only.
|
|
38
|
+
*/
|
|
39
|
+
borderRadius?: string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The primary color used throughout embedded components. Set this to your primary brand color. This accepts hex values or RGB/HSL strings.
|
|
43
|
+
*/
|
|
14
44
|
colorPrimary?: string;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The background color for embedded components, including overlays, tooltips, and popovers. This accepts hex values or RGB/HSL strings.
|
|
48
|
+
*/
|
|
49
|
+
colorBackground?: string;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The color used for regular text. This accepts hex values or RGB/HSL strings.
|
|
53
|
+
*/
|
|
54
|
+
colorText?: string;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The color used to indicate errors or destructive actions. This accepts hex values or RGB/HSL strings.
|
|
58
|
+
*/
|
|
59
|
+
colorDanger?: string;
|
|
60
|
+
|
|
61
|
+
// Less commonly used
|
|
62
|
+
|
|
15
63
|
// Primary Button
|
|
16
|
-
|
|
64
|
+
/**
|
|
65
|
+
* The color used as a background for primary buttons. This accepts hex values or RGB/HSL strings.
|
|
66
|
+
*/
|
|
17
67
|
buttonPrimaryColorBackground?: string;
|
|
68
|
+
/**
|
|
69
|
+
* The border color used for primary buttons. This accepts hex values or RGB/HSL strings.
|
|
70
|
+
*/
|
|
71
|
+
buttonPrimaryColorBorder?: string;
|
|
72
|
+
/**
|
|
73
|
+
* The text color used for primary buttons. This accepts hex values or RGB/HSL strings.
|
|
74
|
+
*/
|
|
18
75
|
buttonPrimaryColorText?: string;
|
|
76
|
+
|
|
19
77
|
// Secondary Button
|
|
20
|
-
|
|
78
|
+
/**
|
|
79
|
+
* The color used as a background for secondary buttons. This accepts hex values or RGB/HSL strings.
|
|
80
|
+
*/
|
|
21
81
|
buttonSecondaryColorBackground?: string;
|
|
82
|
+
/**
|
|
83
|
+
* The color used as a border for secondary buttons. This accepts hex values or RGB/HSL strings.
|
|
84
|
+
*/
|
|
85
|
+
buttonSecondaryColorBorder?: string;
|
|
86
|
+
/**
|
|
87
|
+
* The text color used for secondary buttons. This accepts hex values or RGB/HSL strings.
|
|
88
|
+
*/
|
|
22
89
|
buttonSecondaryColorText?: string;
|
|
23
|
-
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The color used for secondary text. This accepts hex values or RGB/RGBA/HSL strings.
|
|
93
|
+
*/
|
|
94
|
+
colorSecondaryText?: string;
|
|
95
|
+
/**
|
|
96
|
+
* The color used for primary actions and links. This accepts hex values or RGB/HSL strings.
|
|
97
|
+
*/
|
|
24
98
|
actionPrimaryColorText?: string;
|
|
99
|
+
/**
|
|
100
|
+
* The color used for secondary actions and links. This accepts hex values or RGB/HSL strings.
|
|
101
|
+
*/
|
|
25
102
|
actionSecondaryColorText?: string;
|
|
26
|
-
// Border
|
|
27
|
-
colorBorder?: string;
|
|
28
|
-
// Form
|
|
29
|
-
formHighlightColorBorder?: string;
|
|
30
|
-
formAccentColor?: string;
|
|
31
|
-
// Text
|
|
32
|
-
colorText?: string;
|
|
33
|
-
colorSecondaryText?: string;
|
|
34
|
-
// Background
|
|
35
|
-
colorBackground?: string;
|
|
36
|
-
offsetBackgroundColor?: string;
|
|
37
|
-
formBackgroundColor?: string;
|
|
38
|
-
|
|
39
|
-
// Feedback Colors
|
|
40
|
-
colorDanger?: string;
|
|
41
103
|
|
|
42
104
|
// Neutral Badge Colors
|
|
43
|
-
|
|
105
|
+
/**
|
|
106
|
+
* The background color used to represent neutral state or lack of state in status badges. This accepts hex values or RGB/HSL strings.
|
|
107
|
+
*/
|
|
44
108
|
badgeNeutralColorBackground?: string;
|
|
109
|
+
/**
|
|
110
|
+
* The text color used to represent neutral state or lack of state in status badges. This accepts hex values or RGB/HSL strings.
|
|
111
|
+
*/
|
|
45
112
|
badgeNeutralColorText?: string;
|
|
113
|
+
/**
|
|
114
|
+
* The border color used to represent neutral state or lack of state in status badges. This accepts hex values or RGB/RGBA/HSL strings.
|
|
115
|
+
*/
|
|
116
|
+
badgeNeutralColorBorder?: string;
|
|
46
117
|
|
|
47
118
|
// Success Badge Colors
|
|
48
|
-
|
|
119
|
+
/**
|
|
120
|
+
* The background color used to reinforce a successful outcome in status badges. This accepts hex values or RGB/HSL strings.
|
|
121
|
+
*/
|
|
49
122
|
badgeSuccessColorBackground?: string;
|
|
123
|
+
/**
|
|
124
|
+
* The text color used to reinforce a successful outcome in status badges. This accepts hex values or RGB/HSL strings.
|
|
125
|
+
*/
|
|
50
126
|
badgeSuccessColorText?: string;
|
|
127
|
+
/**
|
|
128
|
+
* The border color used to reinforce a successful outcome in status badges. This accepts hex values or RGB/RGBA/HSL strings.
|
|
129
|
+
*/
|
|
130
|
+
badgeSuccessColorBorder?: string;
|
|
51
131
|
|
|
52
132
|
// Warning Badge Colors
|
|
53
|
-
|
|
133
|
+
/**
|
|
134
|
+
* The background color used in status badges to highlight things that might require action, but are optional to resolve. This accepts hex values or RGB/HSL strings.
|
|
135
|
+
*/
|
|
54
136
|
badgeWarningColorBackground?: string;
|
|
137
|
+
/**
|
|
138
|
+
* The text color used in status badges to highlight things that might require action, but are optional to resolve. This accepts hex values or RGB/HSL strings.
|
|
139
|
+
*/
|
|
55
140
|
badgeWarningColorText?: string;
|
|
141
|
+
/**
|
|
142
|
+
* The border color used in status badges to highlight things that might require action, but are optional to resolve. This accepts hex values or RGB/RGBA/HSL strings.
|
|
143
|
+
*/
|
|
144
|
+
badgeWarningColorBorder?: string;
|
|
56
145
|
|
|
57
146
|
// Danger Badge Colors
|
|
58
|
-
|
|
147
|
+
/**
|
|
148
|
+
* The background color used in status badges for high-priority, critical situations that the user must address immediately, and to indicate failed or unsuccessful outcomes. This accepts hex values or RGB/HSL strings.
|
|
149
|
+
*/
|
|
59
150
|
badgeDangerColorBackground?: string;
|
|
151
|
+
/**
|
|
152
|
+
* The text color used in status badges for high-priority, critical situations that the user must address immediately, and to indicate failed or unsuccessful outcomes. This accepts hex values or RGB/HSL strings.
|
|
153
|
+
*/
|
|
60
154
|
badgeDangerColorText?: string;
|
|
155
|
+
/**
|
|
156
|
+
* The border color used in status badges for high-priority, critical situations that the user must address immediately, and to indicate failed or unsuccessful outcomes. This accepts hex values or RGB/RGBA/HSL strings.
|
|
157
|
+
*/
|
|
158
|
+
badgeDangerColorBorder?: string;
|
|
159
|
+
|
|
160
|
+
// Background
|
|
161
|
+
/**
|
|
162
|
+
* The background color used when highlighting information, like the selected row on a table or particular piece of UI. This accepts hex values or RGB/HSL strings.
|
|
163
|
+
*/
|
|
164
|
+
offsetBackgroundColor?: string;
|
|
165
|
+
/**
|
|
166
|
+
* The background color used for form items. This accepts hex values or RGB/HSL strings.
|
|
167
|
+
*/
|
|
168
|
+
formBackgroundColor?: string;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* The color used for borders throughout the component. This accepts hex values or RGB/RGBA/HSL strings.
|
|
172
|
+
*/
|
|
173
|
+
colorBorder?: string;
|
|
174
|
+
|
|
175
|
+
// Form
|
|
176
|
+
/**
|
|
177
|
+
* The color used to highlight form items when focused. This accepts hex values or RGB/RGBA/HSL strings.
|
|
178
|
+
*/
|
|
179
|
+
formHighlightColorBorder?: string;
|
|
180
|
+
/**
|
|
181
|
+
* The color used for to fill in form items like checkboxes, radio buttons and switches. This accepts hex values or RGB/HSL strings.
|
|
182
|
+
*/
|
|
183
|
+
formAccentColor?: string;
|
|
61
184
|
|
|
62
185
|
// Border Sizing
|
|
63
|
-
|
|
186
|
+
/**
|
|
187
|
+
* The border radius used for buttons. This supports pixel values only.
|
|
188
|
+
*/
|
|
64
189
|
buttonBorderRadius?: string;
|
|
190
|
+
/**
|
|
191
|
+
* The border radius used for form elements. This supports pixel values only.
|
|
192
|
+
*/
|
|
65
193
|
formBorderRadius?: string;
|
|
194
|
+
/**
|
|
195
|
+
* The border radius used for badges. This supports pixel values only.
|
|
196
|
+
*/
|
|
66
197
|
badgeBorderRadius?: string;
|
|
198
|
+
/**
|
|
199
|
+
* The border radius used for overlays. This supports pixel values only.
|
|
200
|
+
*/
|
|
67
201
|
overlayBorderRadius?: string;
|
|
68
202
|
|
|
69
|
-
// Overlay
|
|
70
|
-
overlayZIndex?: number;
|
|
71
|
-
|
|
72
203
|
// Font Sizing
|
|
73
|
-
fontSizeBase?: string;
|
|
74
204
|
|
|
75
|
-
//
|
|
76
|
-
|
|
205
|
+
// Overlay
|
|
206
|
+
/**
|
|
207
|
+
* A z-index to use for the overlay throughout embedded components. Set this number to control the z-order of the overlay.
|
|
208
|
+
*/
|
|
209
|
+
overlayZIndex?: number;
|
|
77
210
|
|
|
78
211
|
// Body Typography
|
|
212
|
+
/**
|
|
213
|
+
* The font size for the large body typography. Body typography variables accept a valid font size value.
|
|
214
|
+
*/
|
|
79
215
|
bodyLgFontSize?: string;
|
|
216
|
+
/**
|
|
217
|
+
* The font weight for the large body typography. Body typography variables accept a valid font weight value.
|
|
218
|
+
*/
|
|
80
219
|
bodyLgFontWeight?: string;
|
|
220
|
+
/**
|
|
221
|
+
* The font size for the medium body typography. Body typography variables accept a valid font size value.
|
|
222
|
+
*/
|
|
81
223
|
bodyMdFontSize?: string;
|
|
224
|
+
/**
|
|
225
|
+
* The font weight for the medium body typography. Body typography variables accept a valid font weight value.
|
|
226
|
+
*/
|
|
82
227
|
bodyMdFontWeight?: string;
|
|
228
|
+
/**
|
|
229
|
+
* The font size for the small body typography. Body typography variables accept a valid font size value.
|
|
230
|
+
*/
|
|
83
231
|
bodySmFontSize?: string;
|
|
232
|
+
/**
|
|
233
|
+
* The font weight for the small body typography. Body typography variables accept a valid font weight value.
|
|
234
|
+
*/
|
|
84
235
|
bodySmFontWeight?: string;
|
|
85
236
|
|
|
86
|
-
// Label Typography
|
|
87
|
-
labelLgFontSize?: string;
|
|
88
|
-
labelLgFontWeight?: string;
|
|
89
|
-
labelLgTextTransform?: string;
|
|
90
|
-
labelMdFontSize?: string;
|
|
91
|
-
labelMdFontWeight?: string;
|
|
92
|
-
labelMdTextTransform?: string;
|
|
93
|
-
labelSmFontSize?: string;
|
|
94
|
-
labelSmFontWeight?: string;
|
|
95
|
-
labelSmTextTransform?: string;
|
|
96
|
-
|
|
97
237
|
// Heading Typography
|
|
238
|
+
/**
|
|
239
|
+
* The font size for the extra large heading typography. Heading typography variables accept a valid font size value.
|
|
240
|
+
*/
|
|
98
241
|
headingXlFontSize?: string;
|
|
242
|
+
/**
|
|
243
|
+
* The font weight for the extra large heading typography. Heading typography variables accept a valid font weight value.
|
|
244
|
+
*/
|
|
99
245
|
headingXlFontWeight?: string;
|
|
246
|
+
/**
|
|
247
|
+
* The text transform for the extra large heading typography. Heading typography variables accept a valid text transform value.
|
|
248
|
+
*/
|
|
100
249
|
headingXlTextTransform?: string;
|
|
250
|
+
/**
|
|
251
|
+
* The font size for the large heading typography. Heading typography variables accept a valid font size value.
|
|
252
|
+
*/
|
|
101
253
|
headingLgFontSize?: string;
|
|
254
|
+
/**
|
|
255
|
+
* The font weight for the large heading typography. Heading typography variables accept a valid font weight value.
|
|
256
|
+
*/
|
|
102
257
|
headingLgFontWeight?: string;
|
|
258
|
+
/**
|
|
259
|
+
* The text transform for the large heading typography. Heading typography variables accept a valid text transform value.
|
|
260
|
+
*/
|
|
103
261
|
headingLgTextTransform?: string;
|
|
262
|
+
/**
|
|
263
|
+
* The font size for the medium heading typography. Heading typography variables accept a valid font size value.
|
|
264
|
+
*/
|
|
104
265
|
headingMdFontSize?: string;
|
|
266
|
+
/**
|
|
267
|
+
* The font weight for the medium heading typography. Heading typography variables accept a valid font weight value.
|
|
268
|
+
*/
|
|
105
269
|
headingMdFontWeight?: string;
|
|
270
|
+
/**
|
|
271
|
+
* The text transform for the medium heading typography. Heading typography variables accept a valid text transform value.
|
|
272
|
+
*/
|
|
106
273
|
headingMdTextTransform?: string;
|
|
274
|
+
/**
|
|
275
|
+
* The font size for the small heading typography. Heading typography variables accept a valid font size value.
|
|
276
|
+
*/
|
|
107
277
|
headingSmFontSize?: string;
|
|
278
|
+
/**
|
|
279
|
+
* The font weight for the small heading typography. Heading typography variables accept a valid font weight value.
|
|
280
|
+
*/
|
|
108
281
|
headingSmFontWeight?: string;
|
|
282
|
+
/**
|
|
283
|
+
* The text transform for the small heading typography. Heading typography variables accept a valid text transform value.
|
|
284
|
+
*/
|
|
109
285
|
headingSmTextTransform?: string;
|
|
286
|
+
/**
|
|
287
|
+
* The font size for the extra small heading typography. Heading typography variables accept a valid font size value.
|
|
288
|
+
*/
|
|
110
289
|
headingXsFontSize?: string;
|
|
290
|
+
/**
|
|
291
|
+
* The font weight for the extra small heading typography. Heading typography variables accept a valid font weight value.
|
|
292
|
+
*/
|
|
111
293
|
headingXsFontWeight?: string;
|
|
294
|
+
/**
|
|
295
|
+
* The text transform for the extra small heading typography. Heading typography variables accept a valid text transform value.
|
|
296
|
+
*/
|
|
112
297
|
headingXsTextTransform?: string;
|
|
298
|
+
|
|
299
|
+
// Label Typography
|
|
300
|
+
/**
|
|
301
|
+
* The font size for the large label typography. Label typography variables accept a valid font size value.
|
|
302
|
+
*/
|
|
303
|
+
labelLgFontSize?: string;
|
|
304
|
+
/**
|
|
305
|
+
* The font weight for the large label typography. Label typography variables accept a valid font weight value.
|
|
306
|
+
*/
|
|
307
|
+
labelLgFontWeight?: string;
|
|
308
|
+
/**
|
|
309
|
+
* The text transform for the large label typography. Label typography variables accept a valid text transform value.
|
|
310
|
+
*/
|
|
311
|
+
labelLgTextTransform?: string;
|
|
312
|
+
/**
|
|
313
|
+
* The font size for the medium label typography. Label typography variables accept a valid font size value.
|
|
314
|
+
*/
|
|
315
|
+
labelMdFontSize?: string;
|
|
316
|
+
/**
|
|
317
|
+
* The font weight for the medium label typography. Label typography variables accept a valid font weight value.
|
|
318
|
+
*/
|
|
319
|
+
labelMdFontWeight?: string;
|
|
320
|
+
/**
|
|
321
|
+
* The text transform for the medium label typography. Label typography variables accept a valid text transform value.
|
|
322
|
+
*/
|
|
323
|
+
labelMdTextTransform?: string;
|
|
324
|
+
/**
|
|
325
|
+
* The font size for the small label typography. Label typography variables accept a valid font size value.
|
|
326
|
+
*/
|
|
327
|
+
labelSmFontSize?: string;
|
|
328
|
+
/**
|
|
329
|
+
* The font weight for the small label typography. Label typography variables accept a valid font weight value.
|
|
330
|
+
*/
|
|
331
|
+
labelSmFontWeight?: string;
|
|
332
|
+
/**
|
|
333
|
+
* The text transform for the small label typography. Label typography variables accept a valid text transform value.
|
|
334
|
+
*/
|
|
335
|
+
labelSmTextTransform?: string;
|
|
113
336
|
};
|
|
114
337
|
|
|
115
338
|
export type IStripeConnectUpdateParams = {
|
|
339
|
+
/**
|
|
340
|
+
* Appearance options for the Connect instance.
|
|
341
|
+
*/
|
|
116
342
|
appearance?: AppearanceOptions;
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* The locale to use for the Connect instance.
|
|
346
|
+
*/
|
|
117
347
|
locale?: string;
|
|
118
348
|
};
|
|
119
349
|
|
|
@@ -127,9 +357,10 @@ export interface IStripeConnectInitParams {
|
|
|
127
357
|
publishableKey: string;
|
|
128
358
|
|
|
129
359
|
/**
|
|
130
|
-
*
|
|
360
|
+
* Function that fetches client secret
|
|
361
|
+
* @returns A promise that resolves with a new client secret.
|
|
131
362
|
*/
|
|
132
|
-
|
|
363
|
+
fetchClientSecret: () => Promise<string>;
|
|
133
364
|
|
|
134
365
|
/**
|
|
135
366
|
* Appearance options for the Connect instance.
|
|
@@ -137,24 +368,37 @@ export interface IStripeConnectInitParams {
|
|
|
137
368
|
*/
|
|
138
369
|
appearance?: AppearanceOptions;
|
|
139
370
|
|
|
140
|
-
/**
|
|
141
|
-
* Callback function that returns a new client secret. Used to support long running sessions and called on account session expiry.
|
|
142
|
-
*/
|
|
143
|
-
refreshClientSecret?: () => Promise<string>;
|
|
144
|
-
|
|
145
371
|
/**
|
|
146
372
|
* The locale to use for the Connect instance.
|
|
147
373
|
*/
|
|
148
374
|
locale?: string;
|
|
149
375
|
}
|
|
150
376
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
377
|
+
type ConnectHTMLElementRecordFallback = {
|
|
378
|
+
[key in string]: HTMLElement | null;
|
|
379
|
+
};
|
|
380
|
+
type ConnectHTMLElementRecordBase = {
|
|
381
|
+
[tagName in ConnectElementTagName]: HTMLElement;
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
interface ConnectHTMLElementRecord
|
|
385
|
+
extends ConnectHTMLElementRecordBase,
|
|
386
|
+
ConnectHTMLElementRecordFallback {
|
|
387
|
+
"payment-details": HTMLElement & {
|
|
388
|
+
setPayment: (payment: string | undefined) => void;
|
|
389
|
+
setOnClose: (listener: (() => void) | undefined) => void;
|
|
390
|
+
};
|
|
391
|
+
"account-onboarding": HTMLElement & {
|
|
392
|
+
setFullTermsOfServiceUrl: (termOfServiceUrl: string | undefined) => void;
|
|
393
|
+
setRecipientTermsOfServiceUrl: (
|
|
394
|
+
recipientTermsOfServiceUrl: string | undefined
|
|
395
|
+
) => void;
|
|
396
|
+
setPrivacyPolicyUrl: (privacyPolicyUrl: string | undefined) => void;
|
|
397
|
+
setSkipTermsOfServiceCollection: (
|
|
398
|
+
skipTermsOfServiceCollection: boolean | undefined
|
|
399
|
+
) => void;
|
|
400
|
+
setOnExit: (listener: (() => void) | undefined) => void;
|
|
401
|
+
};
|
|
158
402
|
}
|
|
159
403
|
|
|
160
404
|
export interface StripeConnectInstance {
|
|
@@ -163,7 +407,9 @@ export interface StripeConnectInstance {
|
|
|
163
407
|
* @tagName Name of the Connect component to create.
|
|
164
408
|
* @returns An HTML component corresponding to that connect component
|
|
165
409
|
*/
|
|
166
|
-
create:
|
|
410
|
+
create: <T extends ConnectElementTagName>(
|
|
411
|
+
tagName: T
|
|
412
|
+
) => ConnectHTMLElementRecord[T];
|
|
167
413
|
|
|
168
414
|
/**
|
|
169
415
|
* Updates the Connect instance with new parameters.
|
|
@@ -181,12 +427,14 @@ export interface StripeConnectInstance {
|
|
|
181
427
|
/**
|
|
182
428
|
* Tagnames to be used with the `create` method of the Connect instance.
|
|
183
429
|
*/
|
|
184
|
-
export type ConnectElementTagName =
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
430
|
+
export type ConnectElementTagName =
|
|
431
|
+
| "payments"
|
|
432
|
+
| "payouts"
|
|
433
|
+
| "payment-details"
|
|
434
|
+
| "account-onboarding"
|
|
435
|
+
| "payment-method-settings"
|
|
436
|
+
| "account-management"
|
|
437
|
+
| "notification-banner"
|
|
438
|
+
| "instant-payouts"
|
|
439
|
+
| "issuing-card"
|
|
440
|
+
| "issuing-cards-list";
|
package/dist/src/index.d.ts
DELETED