Learn how to build an onboarding flow to create Custom Connect Accounts. Also learn about new Connect account requirements, and see how to leverage Stripe hosted Connect Onboarding to simply enable onboarding globally.
Follow these instructions to spin-up a copy of this demo project up on your local machine for development and testing purposes. This is meant to be a guide to show you how to go about evolving a webhook handling system.
- Download and Install dependencies
git clone [email protected]:stripe-samples/developer-office-hours.git
cd developer-office-hours/2019-10-30-connect-onboarding/server/node
npm install
- Update API keys
Copy .env.example
and update the keys to your Stripe API Keys
- Start the server
node server.js
- Browse to
http://localhost:4242
Create the account and copy the account ID
- Browse to
http://localhost:4242/person.html?account={{account_id}}
Create the person
In the demo we ran out of time to demonstrate how to upload documents and attach them to person objects. The following is the client and server code to update the verification document:
// client.
function uploadDocument() {
var fd = new FormData();
fd.set('purpose', 'identity_document');
fd.set('file', document.getElementById('file').files[0]);
// NOTE: this is `files.stripe.com`
return fetch('https://files.stripe.com/v1/files', {
method: 'POST',
headers: {
'Authorization': `Bearer ${stripe._apiKey}`
},
body: fd
}).then(function(r) {
return r.json();
}).then(function(response) {
return response.id;
});
}
// server
app.post("/update-person-file", async (req, res) => {
const data = req.body;
try {
var person = await stripe.accounts.updatePerson(
data.account,
data.person, {
verification: {
document: {
front: data.file
}
}
}
)
} catch (err) {
console.log(err);
res.status(400)
res.send({ error: err })
return;
}
res.send(person);
});