Using Rewards with the Connect Widget
The MX Connect Widget is a ready-made user interface that allows developers to quickly add members to Platform and navigate the multi-factor authentication process. It can also be used to manage and resolve connection errors, and it even works with various premium features, such as rewards.
Connecting to an institution in rewards mode will gather rewards information for the member, as well as associated account and transaction data.
This guide assumes you are following MX's recommendation to use the Connect Widget. If your use case requires you to use API endpoints only, see our separate guide on this type of integration.
Prerequisites
Before you follow the steps in this guide make sure that you have:
- Signed up for the Platform API and received your development API Keys.
- Integrated the Connect Widget into your application or website. The best way to do this is to use one of the widget SDKs mentioned in Integration Guides that MX has created for this purpose.
- Ensure MX has enabled rewards.
Create a User
A user represents your end user in the MX Platform. Make a POST request to the /users endpoint, as shown below.
We recommend that you include a unique id of your choice with the request. You may also include metadata, such as the date the user was created or the end user's name. Don't include any sensitive information here, such as credentials.
None of these parameters are required, but the user object cannot be empty. We recommend that partners always set the id parameter when creating a user.
In the response, the API gives each new user an MX-defined guid (or user_guid when appearing outside the user object). Between your id and the guid, you can map between your system and ours. You'll need the user guid for nearly every request on the MX API, at least when using basic authorization.
Request a Connect Widget URL
There are many configuration options for the Connect Widget for performing various tasks. Use the following information to configure the Connect Widget for rewards.
Make a POST request to the /users/{user_guid}/widget_urls endpoint.
- In the path, set the
user_guidto the value for the user you created in step 1. - In the body:
- Set the
widget_typeparameter toconnect_widget - Set the
modetoreward
- Set the
The response will contain a URL to Connect Widget which you will load in the next step.
Load the URL and Let the End User Interact
Load the URL in your application or website. At this point the end user will interact with the Connect Widget. The widget handles the creation of a member as well as the process and any MFA that may be encountered. It automatically asks end users to search for an institution, give their credentials, or authenticate with OAuth. It also deals with any errors along the way.
You'll need to listen for a couple important event messages from the Connect Widget:
- member status updated which gives you the member GUID and the current
connection_status. - member connected tells you that the member has been successfully connected and you can move on to the next steps.
Alternatively, if the end user closes the Connect Widget early or some other problem occurs before you see a CONNECTED status, you can use the member_guid to immediately check the member's connection status with a dedicated API endpoint.
We suggest you add a Rewards Webhook. Please reachout to MX to have this enabled. We provide webhooks that send HTTPS POST callback requests to the URL of your choice. This webhook notifies you when any new data is available after a successful rewards fetch. For more information on webhooks, see our complete reference page.
List Rewards
Get a list of all rewards data associated with a member by making a GET request to the list rewards endpoint.
The response includes an array of rewards which include account numbers, balance, and type.
Make note of the guid as you can use this to read specific rewards using the read Rewards endpoint.
Read the Account
Using the account_guid, you can also fetch user account details by making a GET request to the read account.
This endpoint also exists outside of the Rewards product. To include rewards data in the response, you must use the beta accept header: `application/vnd.mx.api.v1beta+json'. If you do not use the correct Accept header, the response will be successful but will not include rewards data.
Notable rewards fields associated with a user's account include:
credit_card_product_guidenrolled_in_rewards_onprimary_reward_unitcurrent_reward_levelnext_reward_level
Read a Credit Card Product
If a rewards account is a credit card, the account details return a credit_card_product_guid. Use this guid to read more specific credit card details such as has_cashback_rewards or is_accepting_applications, to help drive next steps for your end users.