SDK Functions | Parallel Developer Documentation

Version: Current – v2.x

The Parallel JavaScript SDK includes the following functions on the Parallel object if you're including our JavaScript directly or via the NPM Module.

  • React Module
  • ES Module
  • Manual Loading
import { useParallel } from '@parallelmarkets/react'

const ButtonBox = () => {
const { parallel } = useParallel()

// library may still be loading
if (!parallel) return null

// you can now call any of the functions below on the `parallel` variable
return <button onClick={() => parallel.login()}>Custom Parallel Button</button>
}
FunctionDescription
getProfile(callback, errback)Get the profile details (including unique id) for the individual or business that completed a Parallel flow. This can only be called if the user has authorized sharing information and completed a flow.
getLoginStatus(callback)Get the login status of a user. It takes a single argument that is a callback function, which will be called once the user's login status can be determined. The callback function will be called with one argument described here.
hideButton()Hide the Parallel Login button that was rendered inside any elements on the page with the class parallel-login-button.
init(config)Initialize the Parallel JavaScript SDK. Takes a single argument that is an object containing a client_id and any other desired configuration options.
login(opts)Initiate a Parallel Markets user login flow explicitly. This is useful if you want to start a flow based on some user action (apart from clicking a Parallel Passport button). Takes a single optional argument that is an object. The following optional keys are supported:
  • email: A user's email, used to pre-fill the signup page form.
  • first_name: A user's first name, used to pre-fill the signup page form.
  • last_name: A user's last name, used to pre-fill the signup page form.
  • external_id: An external identifier associated with the subject that will be completing the Parallel flow. See Using an External Identifier for more information.
  • expected_entity_type: Either self or a business_type. Providing self will initiate desired flows for the user as an individual (skipping the option to select a business). A business_type can be used to send a user directly to the creation page for a new Business after authenticating, with the expected_entity_type pre-filled in the form.
  • expected_business_name: The legal name of a Business. Used with the name of an existing Business to send a user directly into the desired flow(s) for the Business after authentication, skipping the entity selection step. Otherwise, used to send a user directly to the creation page for a new Business, with the expected_business_name prefilled in the form.
  • partner_supporting: If data will be shared with any downstream organizations (e.g. Investment management platforms with many issuers), your client's name can be set here. This will update the messaging on the consent screen to indicate that the user is sharing data with your organization for the purposes of onboarding with your client.
  • ref_code: A custom tracking string that can be used to record the source of the initial handoff (for instance, a marketing campaign or other tracking parameter like fund-launch-email). The ref_code will be available in the dashboard as well as in the API response when retrieving a record.
  • redirect_uri_signature: The signature generated when signing a Dynamic Redirect URI.
  • required_entity_id: The ID associated with a record, used to force the user to complete the flow for a particular record. See Starting a Flow For a Specific Record for more information.
logout()End the user's session on your site. Note that this will only invalidate the authentication tokens from the context of your site and will not affect the user's session (if any) on parallelmarkets.com.
showButton()Show the Parallel Login button inside any elements on the page with the class parallel-login-button.
subscribe(event, callback)Subscribe to a range of events by passing a string value which is the name of the event and defining a callback function for when the event fires. The callback will take in a response object containing any relevant status values, errors, authentication responses, etc.
subscribeWithButton(callback, errback)Show the Login button if user is not authenticated, and if/when user is authenticated callback will be called with one argument. On authentication issue or user cancelation, errback will be called.
unsubscribe(event, callback)Un-subscribe a callback from any events previously subscribed to using subscribe().

Optimizing the User Experience

In production1, users will be asked to provide their first name, last name and email address before beginning a flow. If you have already know those details for your user, you can supply values for first_name, last_name and email in the call to Parallel.login(). When all 3 values are present, the user will forward automatically to the email confirmation screen in the Parallel flow.

This makes the process faster, more consistently accurate and creates a seamless bridge between your site and the Parallel experience.

Sample

Parallel.login({
first_name: 'Richard',
last_name: 'Branson',
email: 'rb@virgin.com',
})
  1. In the sandbox environment, users will be asked to set a password in order to initiate a flow. As such, prefilling will work, but the "auto-advance" feature will not. For more information on what to expect in the sandbox environment, please refer to the Sandbox End-User Experience.