-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstripe-connect-module.html
More file actions
235 lines (231 loc) · 11.5 KB
/
stripe-connect-module.html
File metadata and controls
235 lines (231 loc) · 11.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<html data-navbar="navbar.html">
<head>
<title>Stripe Connect module documentation</title>
<link rel="stylesheet" href="/public/style.css" integrity="sha384-XmYAsTgQ0mGje5sxXJRryYc/mmaL3bnA+Hn9kHkpyRTgdpgM220bOzj5BgWZ41jo" crossorigin="anonymous" />
<script async="" src="/public/highlight.min.js" integrity="sha384-YicwDnP9OMQKl5DfX4/eDA3oUGqPTcuyq0+eFbwv595VqixFKEgoO/T8TxD0tjB8" crossorigin="anonymous"></script>
<script src="/public/browser.js" integrity="sha384-pNXFiUIAMNO/S1fGF4GF3fq8OV5x2fZdicewcpuMG/2EOOJ7+HH3no0GDKTePhCD" crossorigin="anonymous"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta charset="UTF-8" />
<body><a name="top" id="top"></a>
<div class="body-container">
<header>
<h1 id="dashboard">Stripe Connect module documentation</h1>
<section id="navigation" class="navigation">
<menu id="navbar-handle" class="super-navbar" style="display: none">
<li><a href="#" title="Show menu">Show navigation menu</a></li>
</menu>
<ul id="navbar-menu" style="display: block">
<li>
<h2>Dashboard</h2>
<ul>
<li><a href="/dashboard">Documentation</a></li>
<li><a href="/dashboard-configuration">Configuration variables</a></li>
<li><a href="/dashboard-sitemap">Visual sitemap</a></li>
<li><a href="/dashboard-ui">UI index</a></li>
<li><a href="/dashboard-api">API index</a></li>
</ul>
</li>
<li>
<h2>MaxMind GeoIP</h2>
<ul>
<li><a href="/maxmind-geoip-module">Documentation</a></li>
<li><a href="/maxmind-geoip-api">API index</a></li>
</ul>
</li>
<li>
<h2>Organizations</h2>
<ul>
<li><a href="/organizations-module">Documentation</a></li>
<li><a href="/organizations-configuration">Configuration variables</a></li>
<li><a href="/organizations-sitemap">Visual sitemap</a></li>
<li><a href="/organizations-ui">UI index</a></li>
<li><a href="/organizations-api">API index</a></li>
</ul>
</li>
<li>
<h2>Stripe Connect</h2>
<ul>
<li><a href="/stripe-connect-module">Documentation</a></li>
<li><a href="/stripe-connect-configuration">Configuration variables</a></li>
<li><a href="/stripe-connect-sitemap">Visual sitemap</a></li>
<li><a href="/stripe-connect-ui">UI index</a></li>
<li><a href="/stripe-connect-api">API index</a></li>
</ul>
</li>
<li>
<h2>Stripe Subscriptions</h2>
<ul>
<li><a href="/stripe-subscriptions-module">Documentation</a></li>
<li><a href="/stripe-subscriptions-configuration">Configuration variables</a></li>
<li><a href="/stripe-subscriptions-sitemap">Visual sitemap</a></li>
<li><a href="/stripe-subscriptions-ui">UI index</a></li>
<li><a href="/stripe-subscriptions-api">API index</a></li>
</ul>
</li>
<li>
<h2>Example app</h2>
<ul>
<li><a href="/example-web-app">Documentation</a></li>
<li><a href="/example-web-app-sitemap">Visual sitemap</a></li>
<li><a href="/example-web-app-ui">UI index</a></li>
</ul>
</li>
<li>
<h2>Example subscription app</h2>
<ul>
<li><a href="/example-subscription-web-app">Documentation</a></li>
<li><a href="/example-subscription-web-app-sitemap">Visual sitemap</a></li>
<li><a href="/example-subscription-web-app-ui">UI index</a></li>
</ul>
</li>
</ul>
<style>
.reveal,
.reveal ul {
display: block
}
</style>
<script>
var menu = document.getElementById("navbar-menu")
menu.style.display = "none"
var handle = document.getElementById("navbar-handle")
handle.style.display = "block"
handle.onclick = function(e) {
if (menu.style.display === "block") {
menu.style.display = "none"
menu.className = ""
handle.firstElementChild.firstElementChild.innerHTML = "Show navigation menu"
} else {
menu.style.display = "block"
menu.className = "reveal"
handle.firstElementChild.firstElementChild.innerHTML = "Hide navigation menu"
}
}
</script>
</section>
</header>
<div class="section-container">
<section class="full"><a name="content" id="content"></a>
<div class="content">
<h1 id="documentation-for-stripe-connect">Documentation for Stripe Connect</h1>
<h4>Index</h4>
<ul>
<li><a href="#introduction">Introduction</a></li>
<li><a href="#module-contents">Module contents</a></li>
<li><a href="#import-this-module">Import this module</a></li>
<li><a href="#setting-up-your-stripe-credentials">Setting up your Stripe credentials</a></li>
<li><a href="#storage-engine">Storage engine</a></li>
<li><a href="#access-the-api">Access the API</a></li>
<li><a href="https://github.com/userdashboard/stripe-connect">Github repository</a></li>
<li><a href="https://npmjs.org/userdashboard/stripe-connect">NPM package</a></li>
</ul>
<h1 id="introduction">Introduction</h1>
<p>Dashboard bundles everything a web app needs, all the "boilerplate" like signing in and changing passwords, into a parallel server so you can write a much smaller web app.</p>
<p>The Stripe Connect module adds a complete "custom" integration of Stripe's Connect API, allowing your users to provide personal or company information and receive payouts on your platform. A UI is provided for users to create and manage their registrations, and a basic administrator UI is provided for oversight. When a user has completed a Stripe account registration and it has been approved by Stripe their status will be changed to <code data-language="js">payouts_enabled</code> and your application can use this property to control access to your platform functionality.</p>
<p>Currently only automatic payouts are supported. Countries that are "in beta" support by Stripe are not supported and need to be added as they become generally available. The <a href="https://stripe.com/docs/api">Stripe API documentation</a> supplements this documentation.</p>
<h1 id="module-contents">Module contents</h1>
<p>Dashboard modules can add pages and API routes. For more details check the <code data-language="js">sitemap.txt</code> and <code data-language="js">api.txt</code> or <code data-language="js">env.txt</code> also contained in the online documentation.</p>
<table>
<thead>
<tr>
<th>Content type</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Proxy scripts</td>
<td></td>
</tr>
<tr>
<td>Server scripts</td>
<td>Yes</td>
</tr>
<tr>
<td>Content scripts</td>
<td></td>
</tr>
<tr>
<td>User pages</td>
<td>Yes</td>
</tr>
<tr>
<td>User API routes</td>
<td>Yes</td>
</tr>
<tr>
<td>Administrator pages</td>
<td>Yes</td>
</tr>
<tr>
<td>Administrator API routes</td>
<td>Yes</td>
</tr>
</tbody>
</table>
<h2 id="import-this-module">Import this module</h2>
<p>Install the module with NPM:</p>
<pre><code data-language="js">$ npm install @userdashboard/stripe-connect
</code></pre>
<p>Edit your <code data-language="js">package.json</code> to activate the module:</p>
<pre><code data-language="js">"dashboard": {
"modules": [
"@userdashboard/stripe-connect"
]
}
</code></pre>
<h2 id="setting-up-your-stripe-credentials">Setting up your Stripe credentials</h2>
<p>You will need to retrieve various keys from <a href="https://stripe.com">Stripe</a>. During development your webhook will be created automatically, but in production with multiple dashboard server instances they share a configured webhook:</p>
<ul>
<li>create your Stripe account and find your API keys</li>
<li>create a webhook for https://your_domain/webhooks/connect/index-connect-data</li>
<li>environment STRIPE_KEY=sk_test_xxxxxxx</li>
<li>environment STRIPE_PUBLISHABLE_KEY=pk_test_xxxxxxx</li>
<li>environment CONNECT_WEBHOOK_ENDPOINT_SECRET=whsec_xxxxxxxx</li>
</ul>
<h2 id="storage-engine">Storage engine</h2>
<p>By default this module will share whatever storage you use for Dashboard. You can specify an alternate storage module to use instead, or the same module with a separate database.</p>
<pre><code data-language="js">CONNECT_STORAGE=@userdashboard/storage-mongodb
CONNECT_MONGODB_URL=mongo://localhost:27017/connect
</code></pre>
<h3 id="access-the-api">Access the API</h3>
<p>Dashboard and official modules are completely API-driven and you can access the same APIs on behalf of the user making requests. You perform <code data-language="js">GET</code>, <code data-language="js">POST</code>, <code data-language="js">PATCH</code>, and <code data-language="js">DELETE</code> HTTP requests against the API endpoints to fetch or modify data. This example fetches the user's Connect accounts using NodeJS, you can do this with any language:</p>
<p>You can view API documentation within the NodeJS modules' <code data-language="js">api.txt</code> files, or on the <a href="https://userdashboard.github.io/stripe-connect-api">documentation site</a>.</p>
<pre><code data-language="js">const stripeAccounts = await proxy(`/api/user/connect/stripe-accounts?accountid=${accountid}&all=true`, accountid, sessionid)
const proxy = util.promisify((path, accountid, sessionid, callback) => {
const requestOptions = {
host: 'dashboard.example.com',
path: path,
port: '443',
method: 'GET',
headers: {
'x-application-server': 'application.example.com',
'x-application-server-token': process.env.APPLICATION_SERVER_TOKEN,
'x-accountid': accountid,
'x-sessionid': sessionid
}
}
const proxyRequest = require('https').request(requestOptions, (proxyResponse) => {
let body = ''
proxyResponse.on('data', (chunk) => {
body += chunk
})
return proxyResponse.on('end', () => {
return callback(null, JSON.parse(body))
})
})
proxyRequest.on('error', (error) => {
return callback(error)
})
return proxyRequest.end()
})
}
</code></pre>
</div>
<p><a href="#top">Top of page</a></p>
</section>
</div>
</div>
</body>
</head>
</html>