I'm trying to create an integration with Plaid and they have the following script that runs to get variables from their service. I need to be able to capture these outputs and pass to my controller to continue the flow but am not very experience with Javascript Remoting or Javascript for that matter.
Here's the code I have, I need to get the public_token and metadata.account_id to my controller. I've tried filling fields on my VF page with those values but have had no luck getting that to work.
I don't have my controller set up in the example as I tried to take another approach.
Any help is appreciated!
<apex:page standardController="Account">
<button id='linkButton'>Open Plaid Link</button>
<script src="https://cdn.plaid.com/link/stable/link-initialize.js"></script>
<script type="text/javascript">
var linkHandler = Plaid.create({
env: 'tartan',
clientName: 'Plaid Test',
key: 'xxxxxKeyxxxxx',
product: 'auth',
selectAccount: true,
onSuccess: function(public_token, metadata) {
// Send the public_token and account ID to your app server.
console.log('public_token: ' + public_token);
console.log('account ID: ' + metadata.account_id);
var ptoken = public_token;
var acctId = metadata.account_id;
document.getElementbyId('{!$Component.theForm.thepageblock.publicToken}').value = ptoken;
return false;
},
});
// Trigger the Link UI
document.getElementById('linkButton').onclick = function() {
linkHandler.open();
};
</script>
<apex:form id="theForm">
<apex:pageblock id="thepageblock">
<apex:inputText id="publicToken"/>
<br />
<apex:inputText id="accountId"/>
</apex:pageblock>
</apex:form>
</apex:page>
apex:inputText id="publicToken"
value in controller? and<apex:inputText id="accountId"/>