Sha256: 992479ea55c966d87d4bd798cf1d3d14f0a0137b0d1241ca41d6853d46a8be6d
Contents?: true
Size: 2 KB
Versions: 1
Compression:
Stored size: 2 KB
Contents
function getPlaid(plaidData) { var url = null; var token = plaidData.data('token'); var env = plaidData.data('env'); if (typeof token === 'undefined') { url = '/plaid/authenticate'; token = null; } else { url = '/plaid/update'; } // set token for test environment if (env === 'tartan' && typeof plaidData.data('type') !== 'undefined') { token = 'test,' + plaidData.data('type') + ',connected' } var linkHandler = Plaid.create({ env: env, clientName: plaidData.data('client-name'), key: plaidData.data('key'), product: 'connect', webhook: plaidData.data('webhook'), onLoad: function () { // The Link module finished loading. }, onSuccess: function (public_token, metadata) { // Send the public_token to your app server here. // The metadata object contains info about the institution the // user selected and the account ID, if selectAccount is enabled. $.ajax({ type: 'POST', dataType: 'script', url: url, data: { public_token: public_token, name: metadata.institution.name, type: metadata.institution.type, owner_type: plaidData.data('owner-type'), owner_id: plaidData.data('owner-id'), number: plaidData.data('number') } }); }, onExit: function () { // The user exited the Link flow. } }); return linkHandler; } // Trigger the authentication view $(document).on("click", '#plaidLinkButton', function () { var plaidData = $(this); linkHandler = getPlaid(plaidData); var plaidType = plaidData.data('type') //open handler for the institution if (typeof plaidType === 'undefined') { linkHandler.open(); } else { linkHandler.open(plaidType); } });
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
plaid_rails-0.10.0 | app/assets/javascripts/plaid_rails/link.js |