INFOBefore you can integrate the widget, you must have worked with MX to enable your access to our PFM product.
Integrate on a Website (iframe)
Recommended This shows how to integrate the widget on a website using an iframe.Step 1
Create an iframe. If you’re integrating the Money Dashboard Widget, see IFrame Integration for a code example to help maintain proper display. Set the width and height to 100%, or use the widget’s supported dimensions.Example
Step 2
In the iframe’ssrc, you’ll need to request a widget URL by specifying the widget_type, using the Platform API or the SSO API.
For a list of acceptable values, see:
- Widget Types for Platform API
- Widget Types for SSO API
Example
Step 3
Optionally create listeners for the application events. See Postmessage UI Events for more info.Example
Step 4
Depending on the widget you’re integrating, you may have to create additional event listeners:- If integrating the Connections Widget, you must create listeners for all the Connections Widget events, which includes all the Connect Widget’s postMessage events.
- If integrating the Mini Finstrong Widget, you must create listeners for all the Mini Finstrong Widget’s events.
Example
Integrate on a Website (Widget Loader)
This shows how to integrate the widget on a website using the widget loader.Step 1
Request a widget URL by specifying thewidget_type, using the Platform API or the SSO API.
For a list of acceptable values, see:
- Widget Types for Platform API
- Widget Types for SSO API
Example
Step 2
Add the widget loader script to the page. Place this file before any other code related to the widgets. This custom script loads the widgets onto the page. You can load the widget loader from the MX production server or download and store it in your local environment. We update the widget loader when needed, so if you’re caching it on your server, refresh your cached version monthly.Example
Step 3
Add a widget placeholder element. Our widget loader will use this placeholder element to embed an iframe containing the widget. The element must have anid of md-widget.
Example
Step 4
Load the widget into the placeholder element. Create a new instance of theMoneyDesktopWidgetLoader class, which is defined in the widget loader script. When you instantiate MoneyDesktopWidgetLoader, you must pass in an object with at least the required URL parameter, and possibly one or more optional parameters.
The widget loader will wait until the page has been loaded, and then load the widget into the placeholder element.
Make sure the widget uses its supported dimensions.
Example
Integrate on a Mobile App
To integrate the widget on a mobile app:- Request a PFM widget URL by specifying the
widget_type, using the Platform API or SSO API. The URL you’ll receive is single-use and expires after 10 minutes. You must request a new URL every time the page is rendered. For a list of acceptable values, see:- Widget Types for Platform API
- Widget Types for SSO API
- Load the URL received from the previous request into a WebView.
- See Events in Mobile WebViews.
- Capture and parse URLs for application events.
- If you’re integrating the Connections Widget or Mini Finstrong Widget, you’ll need to capture and parse URLs for additional events. See PostMessage UI Events for more information.
Common Problems
This section covers some common problems with loading a widget URL into a WebView.Minimum Size
To embed our mobile widgets into a WebView, we require a device width of at least 320 pixels. Depending on the implementation of the WebView, smaller devices may not be provided the full width, leading to display issues.MONEY DASHBOARD INTEGRATIONIn order to have the benefit of the full responsive nature of our application, please don’t restrict the available browser width by adding margins or padding.
WKWebView vs. UIWebView (iOS)
In apps that run in iOS 8 and later, MX only supports WKWebView. If you previously implemented UIWebView, update your implementation to use WKWebView. Apple recommends this. For more information, see Apple’s developer documentation for UIWebView and WKWebView.Default Padding (iOS)
iOS adds additional padding to its WebViews by default, which sometimes causes problems. To fix this:- Select the WebView providing the widgets in your application and navigate to the size inspector.
- Change the layout margins from
"Default"to"Explicit". - Update the left and right margins to
"0". - Ensure the Width is at least 320 pixels.
Default Margin (iOS and Android)
Whether using WebViews on Android or iOS, most browsers will have a default margin (set in the user agent stylesheet) on the body element when rendering the HTML page responsible for loading a widget. This margin is deducted from the total available width of the containing element, which will cause a problem. To fix this:- Determine the computed width available on the body element.
- The width available to the iframe can be confirmed by inspecting the iframe injected by MX and typing window.innerWidth in the JavaScript console. The width available to the iframe must be at least 320 pixels.
- Confirm the body and HTML elements have their padding and margin set to “0.”
Viewport (iOS and Android)
For mobile widgets to render correctly, the viewport must be set in a meta tag on the HTML page used to load the widget URL. The viewport is the size of the window through which a page is seen. It can be smaller or larger than the actual size of a page or device screen. On most mobile devices, the virtual viewport is larger than the actual screen size; web pages are rendered according to the viewport size, then shrunk down to the actual screen size. This helps when viewing pages that aren’t optimized for mobile, but for pages that are optimized for mobile (like the mobile widgets), the viewport meta tag is used to guarantee that the page is rendered properly. Set a meta tag within the<head> element as follows.
Example
Widget Loader Configurations
This section is for integrating a widget on desktop using the Widget Loader. It shows the parameters you’ll use to set things like the widget’s height and width, additional configurations that let you set configurations for specific widgets, and also has the following sections to further help your integration:- Create a Loading Message
- Keeping a Session Alive and Logging Out
- Loading Multiple Widgets
- Loading Widgets at Different Times
- Master Widget Deep Linking
Widget Loader Parameters
When you instantiateMoneyDesktopWidgetLoader, you must pass in an object with at least the required URL parameter, and any of the following optional parameters.
| Parameter | Required? | Default Value | Description |
|---|---|---|---|
autoload | No | true | Determines if the widget loads automatically. See Loading Widgets at Different Times. |
config | No | This contains an object in which you can pass several configuration options specific to a given widget type. See Config Parameter for all options. | |
deepLink | No | accounts | Only use this for the Master Widget. This lets you set which widget loads in the Master Widget by default. See Master Widget Deep Linking for more information. |
height | No | 600 | The widget’s height, in pixels or a percentage. |
id | No | 'md-widget' | Tells the widget loader what element to place the widget in. See Loading Multiple Widgets. |
width | No | '100%' | The widget’s width, in pixels or a percentage. |
url | Yes | The widget’s URL, received through an SSO API or Platform API request. |
Config Parameter
Theconfig object, as shown in the following example, contains configurations options.
Example
accountsbudgetsconnectionsdebtsgoalshelpmastermini_budgetsmini_spendingmini_spending_plansettingsspendingspending_plantransactionstrends
| Configuration Option | Data Type | Widget | Description |
|---|---|---|---|
is_mobile_webview | Boolean | All | Renders the widget in a mobile WebView. Executes URL updates in place of the JavaScript event postMessages. |
language | String | All | Deprecated. See Supported Languages. Defaults to en-us. |
ui_message_version | Integer | All | Determines which version of postMessage events are triggered. All new implementations must include this option when getting any widget URL and must set it to version 4. Prior versions are deprecated and supported only for existing integrations. |
hide_mark_as_duplicate | Boolean | Connections | Hides the “mark as duplicate” feature option in the widget. |
hide_partner_managed_members | Boolean | Connections | Hides any “home” members that are managed by the partner. |
selected_institution_guid | String | Connections | Loads the widget to a specific selected institution. |
selected_member_guid | String | Connections | Loads the widget to a selected member. |
update_credentials | Boolean | Connections | Loads to the update credential feature for a current member. Optionally used with selected_member_guid. |
hide_account_filter | Boolean | Transactions | Hides the account filter feature within the widget. |
selected_account_guid | String | Transactions | Loads the widget to a selected account. |
Create a Loading Message
Any HTML placed inside of the widget placeholder element will be replaced once the widget iframe has loaded. This means you can use the placeholder element’s inner HTML to display a loading message. Because this is just HTML, it can be text, images, or anything you want. The following example adds some loading text that will appear until the widget has loaded.Example
Keeping a Session Alive and Logging Out
MX provides two important functions for the widget loader: ping and logout. The ping function resets the session timer, allowing you to keep the session open as long as needed. The default timeout period is 900 seconds, and ping can be used anywhere in that period to restart the timer. A custom timeout period can be set by contacting MX, but MX recommends using the ping method rather than setting a longer timeout.Loading Multiple Widgets
To load multiple widgets on a single page:- Define multiple placeholder elements, each with a unique CSS
id. - In your JavaScript, create an instance of
MoneyDesktopWidgetLoaderfor each widget. - Connect each loader instance to a placeholder element by setting the
idproperty value as the CSSid.
Example
Loading Widgets at Different Times
By default, widgets load automatically once the web page has loaded. If you’d like to load your widgets manually you can use the autoload option by setting autoload to false when instantiatingMoneyDesktopWidgetLoader.
When you’re ready to load a widget, call the load method on the instance of MoneyDesktopWidgetLoader with the URL.
Here’s an example of loading the Accounts Widget on page load, then loading the Transactions Widget when a button is selected.
Example
Master Widget Deep Linking
By default, the Master Widget displays the Accounts Widget on initial load. If you want to display a different widget on initial load, set thedeepLink attribute in MoneyDesktopWidgetLoader to one of the following values:
| Widget | deepLink Value |
|---|---|
| Accounts Widget | accounts |
| Budgets Widget | budgets |
| Debts Widget | debts |
| Goals Widget | goals |
| Investments Widget | investments |
| Net Worth Widget | net-worth |
| Spending Widget | spending |
| Spending Plan Widget | spending_plan |
| Transactions Widget | transactions |
| Trends Widget | trends |
deepLink to spending_plan as follows.
Example
<a href="http://yourinstitutiondomain.com/#spending">Click Here</a>. When a user clicks that link, they would be taken to the page that contains your implementation of the Master Widget. On that page you’d need logic that parses the URL to determine if a deepLink value should be set. This can be done with some simple JavaScript.
Your code might look like the following example.
Example
PostMessage UI Events
When certain events are triggered in our UI, we send you a postMessage UI event. These events have the information you need to take action in your codebase in response to the event. If integrating on mobile through a WebView, an alternative to standard postMessage UI events is required. See Events in Mobile WebViews for more information. PostMessage UI events from MX have the following properties:- The
mxfield that lets you filter out postMessage UI events coming from MX. - The
typefield that identifies what the event represents at a high level. - The
metadataobject field that has information related to thetype.
Example Integration
Events in Mobile WebViews
NOTEThis section only applies if you are embedding the widget in a WebView.
is_mobile_webview field with a value of true in your request to access WebView event messages.
In WebView integrations, you must capture the URLs delivered via window.location = "someurl" calls within the iframe and use the information provided in those calls to build the necessary logic for coordinating events.
All MX URL message events will have the mx:// prefix as well as the following format: mx://<entity|widget>/<event>?metadata=<metadata as an encodedURI JSON string>.
The following is an example URL message:
mx://account/created?metadata="{'guid':'ACT-1'}".
You must capture the URL, parse out the path and query string, then JSON-decode the metadata field.
Application Events
You must create listeners for our postMessage UI application events.Widget Load
This event is triggered when the widget is loaded.Widget Ping
This event is used to keep the widget session alive.Widget focusTrap
This event is triggered when popover content which traps the focus onto a particular element is opened or closed, but only in the case that no other popover content is already open. This event is triggered by some drawers, menu buttons, and modals.Connections Widget Event
You must create a listener for one event specific to the Connections Widget: the Member Deleted event. All postMessage UI events that apply to the Connect Widget also apply to the Connections Widget.Member Deleted
This event is triggered when a member has been deleted in the widget.Example
Mini Finstrong Widget Events
The following events are for the Finstrong Mini Widget.Sufficient Data, Primary Action Selected
This event is triggered when the user has enough data to generate a Finstrong health score and the primary action is selected.Example
Insufficient Data, Primary Action Selected
This event is triggered when the user doesn’t have enough data to generate a Finstrong health score and the primary action is selected.Example
Deprecated PostMessage Events
INFOThese events are deprecated and are only supported for existing integrations.
Maintaining Sessions
Because our widgets are embedded through iframes, the parent frame (usuallywindow) isn’t aware of any activity going on within the iframe. This can cause the online banking session to time out even though the user is actively using a widget. To prevent this, each of our widgets will periodically send a postMessage to the parent frame. The postMessage will contain a JSON-formatted string as follows.
The most common way to take advantage of these postMessages is to implement an event listener function that will capture any postMessages. When a postMessage is captured, you can then tell your application to maintain its session. An example also follows.
Widget Events
Sometimes, your application may want to know about specific events that have occurred within the widget iframe. To account for this, we send postMessages for specific widget events. All widget event postMessages will contain a JSON-formatted string with the structure shown to the right.INFOPostMessage events related to members — such as member updated — will contain the
connection_status field. This field indicates the current status of the member’s aggregation.- Account Created
- Account Updated
- Account Deleted
This event triggers when any account is created. The
is_manual field can be used to distinguish manual accounts from other accounts.- Member Created
- Member Updated
- Member Deleted
Triggered when a member is created. This event is triggered on the creation of the member before any aggregation is initiated. The aggregation-related fields, such as
most_recent_job_guid, may be null.- Transaction Created
- Transaction Updated
- Transaction Deleted
Triggered when a new transaction is created. This includes the creation of child transactions when the parent transaction is split.
- Focus Trap: trapped: true
- Focus Trap: trapped: false
This event is triggered when popover content is opened which traps the focus onto a particular element, but only in the case that no other popover content is already open. This event is triggered by drawers, menu buttons, and modals.
PostMessage UI Events in Mobile WebViews
Because of the technical limitations of WebView-based widget implementations, an alternative to standard postMessages is required. MX has developed a simple URL-based updating mechanism to replace event messages that are available to other implementations. Capture these URLs and use the information provided in them to build the necessary logic for coordinating application events. URL event messages are available for the widget events outlined in the following sections. When requesting widget URLs using the SSO API, you must include theis_mobile_webview field with a value of true in your request to access WebView event messages.
INFOPostMessage events related to members — such as member updated — will contain the
connection_status field. This field indicates the current status of the member’s aggregation.Sample Capture Scripts
The following are example capture scripts in the Java and Swift languages.Java
Swift
- Account Created URL
- Account Updated URL
- Account Deleted URL
This event message triggers when any account is created. The
is_manual field can be used to distinguish manual accounts from other accounts.- Base URL:
mx://accountCreated - Example payload:
mx://accountCreated?account_subtype=""?account_type="PROPERTY"?balance=25000?guid="ACT-12345"?id="A-12345"?is_closed="false"?is_hidden="false"?is_manual="true"?member_guid="MBR-12345"?name="Delorean"?property_type="VEHICLE"?type="account"
- Member Created URL
- Member Updated URL
- Member Deleted URL
- Base URL:
mx://memberCreated - Example payload:
mx://memberCreated?accounts_count=0?connection_status="CREATED"?guid="MBR-12345"?id=""?institution_guid?"INS-12345"?is_manual="false"?is_user_created="false"?most_recent_job_guid?""?name="Zen Bank"?type="member"
- Transaction Created URL
- Transaction Updated URL
- Transaction Deleted URL
- Base URL:
mx://transactionCreated - Example payload:
mx://transactionCreated?account_guid="ACT-12345"?amount=4.25?category_guid="CAT-12345"?date=1425384000?description="Transaction Description"?guid="TRN-12345"?has_been_split=false?memo="Transaction Memo"?parent_guid="TRN-45678"?transaction_type=2?type="transaction"

