Updated

Build a Marketplace

Our Marketplace API allows you to power donations on your platform with managed accounts. A parent account can create donations and fetch analytics on behalf of its managed accounts. Managed accounts can directly connect their bank accounts to fund donations. From fundraising platforms to ridesharing apps, the Marketplace API makes it easy to manage donations across a network of users.

Create managed accounts

First, let’s learn how to create a managed account. Accounts are created with the Create a managed account endpoint. Specify an email for the account, and an optional name.

server.js
const headers = new Headers();
headers.set('Authorization', 'Basic ' + base64.encode('YOUR_PUBLIC_KEY' + ':' + 'YOUR_SECRET_KEY'));
headers.set('Content-Type', 'application/json');

const managed_account_id = fetch('https://api.getchange.io/api/v1/accounts', {
method: 'POST',
headers,
body: JSON.stringify({
email: '[email protected]',
name: 'My managed account'
})
}).then(response => response.json())
.then(account => account.id);

Attach bank accounts

Your managed accounts use their own bank accounts to fund donations. Change uses Plaid to let your customers add their bank accounts to their managed account.

Add an endpoint on your server that generates a link token.

server.js
const headers = new Headers();
headers.set('Authorization', 'Basic ' + base64.encode('YOUR_PUBLIC_KEY' + ':' + 'YOUR_SECRET_KEY'));

// Get this ID from the Account object returned in the previous step.
const managed_account_id = 'a_N4mD7soEB36dZMPPidR5WX3s';
const GENERATED_LINK_TOKEN = fetch(`https://api.getchange.io/api/v1/accounts/${managed_account_id}/link_bank_token`, {
method: 'POST',
headers
}).then(response => response.json());

We let you handle the Plaid integration on your client, so that you have full control over the in-app experience.

This guide is adapted from Plaid Link for Web. If you are intgrating for iOS, Android, or WebView, email us at [email protected] to request a guide.

Copy the following HTML into your client web page:

client.html
<button id="linkButton">Open Link - Institution Select</button>

<script src="https://cdn.plaid.com/link/v2/stable/link-initialize.js"></script>

<script>
function createLinkHandler() {
// The link token that you generated on the server.
const GENERATED_LINK_TOKEN = 'YOUR LINK TOKEN';
return Plaid.create({
token: GENERATED_LINK_TOKEN,
onLoad: function() {
// The Link module finished loading.
},
onSuccess: function(plaid_public_token, metadata) {
fetch('https://api.getchange.io/api/v1/accounts/attach_bank_account', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
link_token: GENERATED_LINK_TOKEN,
plaid_public_token: plaid_public_token,
bank_account_id: metadata.account_id
}),
});
},
onExit: function(err, metadata) {
// The user exited the Link flow.
if (err != null) {
// The user encountered a Plaid API error
// prior to exiting.
}
},
});
};

// Trigger the authentication view
document.getElementById('linkButton').onclick = function() {
createLinkHandler().open();
};
</script>

When a customer successfully completes the Plaid authentication flow, their bank will be attached to their managed account. You’re ready to make donations for the account!

Make donations

To make a donation for a managed account, use the Create a donation endpoint normally, but pass the Account ID via managed_account_id the param. The Account ID is returned when you Create a managed account.

server.js
const headers = new Headers();
headers.set('Authorization', 'Basic ' + base64.encode('YOUR_PUBLIC_KEY' + ':' + 'YOUR_SECRET_KEY'));
headers.set('Content-Type', 'application/json');

fetch('https://api.getchange.io/api/v1/donations', {
method: 'POST',
headers,
body: JSON.stringify({
// Get this ID from the Account object returned in the first step.
managed_account_id: 'a_N4mD7soEB36dZMPPidR5WX3s',
amount: 500,
nonprofit_id: 'n_IfEoPCaPqVsFAUI5xl0CBUOx',
funds_collected: true
})
});

Congrats, you’ve built the basics of a marketplace with the Change Marketplace API.

Made with ❤ in San Francisco