mosparo-api-client
Service icon

mosparo API Client

Stable version 1.0.0 (Compatible with OutSystems 11)
Uploaded
 on 2 Nov (4 weeks ago)
 by 
mosparo
0.0
 (0 ratings)
mosparo-api-client

mosparo API Client

Documentation
1.0.0

1. Setup mosparo

To use the mosparo API client or the mosparo Integration assets, you need your own mosparo installation. You can read more about installing mosparo in our documentation: https://documentation.mosparo.io/docs/category/installation

2. Create project

In your mosparo installation, create a project. To do this, click the "Create project" button on the dashboard and follow the wizard.

3. Add module

To protect your form in OutSystems, add the module and include both server actions, as well as all necessary structures, within your module.

4. Add frontend code

Now, you need to add the frontend part of mosparo to your form. For this, please review the demo of this asset. It's essential to adjust the JavaScript code to suit your specific form. It's also important to send the submit and validation tokens back to the server action. In our demo, we use two hidden fields and one of mosparo's callbacks to send the data in the form request. You can use other methods, but in the end, it's essential to have the submit and validation tokens in the server action.

In general, the primary goal of the API client module is to provide the necessary functionality for verifying submissions, rather than offering frontend functionality. We strongly recommend using the Reactive mosparo Integration module.

5. Build request

Before you can send the data to mosparo for verification, you need to build the request. Create a variable of the record type "MosparoRequest". Fill in all the values: submit and validation tokens are the two tokens from the frontend. The form data are your form fields, provided as a "MosparoFormFieldData" object.

6. Verify request

After you build the request, you can use the server actions to verify the data. Place the server action "VerifySubmission" in your "Save" server action. Set the host, public, and private key as well as the form data request as the parameters of the action.

7. Process verification result

Add an If-Block to abort the process if the verification failed. If "Submittable" of the response of the server action is false, please abort the process and show a message to the user (for example).

For the "True" path, add the second server action "ConfirmFieldValidation". 

8. Confirm verified fields

To prevent a user from bypassing the mosparo protection, we have to ensure that all relevant fields are verified. For this, we have a second server action "ConfirmFieldValidation". Place this server action after the If block we added in step 7. Set the verification result as a parameter and define a comma-separated string with the names of the fields that should be verified.

9. Process result

After the field validation, we should again display an error message if the process fails. If the result of the action is "True", we can then process the data (for example, by sending it by email or storing it in a database).

10. Test your form

Please test your form now. mosparo should verify the submission and display the verified submission in your project in mosparo.