Monetary values are represented as a combination of amount, decimals & currency. For example, {"amount": "40000000", "decimals": 3, "currency": "EUR"} means "40000.000 EUR"
Client-side user API
Via the client-side API, you can retrieve information on your own website about the user currently logged in.
Please note that in order to call the API from the client-side the originating domain needs to be whitelisted. Please reach out to your point of contact at Cashlink so that we can whitelist your domain.
Use this API to
Show the login status of your users when visiting your website
Display user specific information (email address & name)
Show or hide certain areas of your website based on the login status
If the user is logged in the user can be sent directly to the investor dashboard using this URL:
<server-url>/dashboard/investorOverview
The URL above will render a log in page if the user is not logged in, but if you want them to go directly to the login view you can use the following URL
<server-url>/login
User information can be retrieved client-side via postMessage:
<pre id="info">
<pre>
<iframe style="visibility: hidden; display: none" id=frame src="https://staging.cashlink-staging.de/external-info"></iframe>
<script>
let origin = 'https://staging.cashlink-staging.de';
let el = document.getElementById('frame');
function printInfo(user) {
let msg;
if (user) {
msg = `Name: ${user.name}\nE-Mail: ${user.email}`;
} else {
msg = "Not logged in";
}
document.getElementById('info').innerText = msg;
}
el.addEventListener('load', () => {
window.addEventListener('message', (evt) => {
if (evt.origin == origin) {
let res = evt.data;
console.log('response:', res);
if (res.success && res.result.user) {
printInfo(res.result.user);
} else {
printInfo(null);
}
}
});
el.contentWindow.postMessage({method: 'getExternalInfo'}, origin);
});
</script>
The response in the success case will be of the format
{
"success": true,
"result": {
"user": {"email": "foo@bar.baz", "name": "Maria Mustermann"},
"products": [/*... <same as for server-side API>*/]
}
}
In the failure case, the response format will be
{
"success": false,
"error": "could not fetch data"
}
This can only occur when Cashlink servers are not reachable. If the user is not logged in, the response will be