Creating Clarity’s Bridging Microservice

Bridging APIs enable businesses to flexibly connect Liferay with external systems through microservices. Clarity’s workflows require third-party verification of new distributor applications to prevent fraud. By leveraging a microservice client extension, Clarity can integrate directly with their preferred KYC platform’s APIs. This microservice would submit application information for fraud processing, receive the verification outcome, and update the Distributor KYC Verification entry reflecting its status.

Through this exercise, you’ll learn how to leverage bridging APIs within a mock microservice to process and return third-party API responses.

Exercise: Implementing Clarity’s KYC Bridging APIs

Here, you'll build and deploy Clarity's microservice client extension implementing bridging APIs and handling third-party verifications.

  1. Open the exercises/distributor-kyc-update/client-extension.yaml file within your course workspace.

  2. Add the following code snippet in the blank space on line 3:

    clarity-distributor-kyc-update:
        name: Clarity Distributor KYC Update
        oAuth2ApplicationExternalReferenceCode: clarity-distributor-kyc-update-oauth-application-user-agent
        resourcePath: /distributor/kyc/update
        type: objectAction

    This definition block configures essential properties and sets the API endpoint path that Liferay will target when invoking its object action: /distributor/kyc/update.

  3. Save the file.

  4. Open the exercises/distributor-kyc-update/src/main/java/com/clarityvisionsolutions/distributor/kyc/update/DistributorKYCUpdateController.java file with a text editor or IDE.

  5. On line 47, replace the PLACEHOLDER text with /distributor/kyc/update.

    On line 47, replace the PLACEHOLDER text with /distributor/kyc/update.

    This maps incoming requests starting with /distributor/kyc/update to methods contained within this DistributorKYCUpdateController file.

  6. Replace the PLACEHOLDER text at line 51 with this code snippet:

    @PostMapping
    public ResponseEntity post(
    	@AuthenticationPrincipal Jwt jwt, @RequestBody String json) {
    
    	HttpStatus httpStatus = HttpStatus.OK;

    This defines the API endpoint that receives Liferay's KYC update requests as a JSON payload via an HTTP POST to /distributor/kyc/update, providing access to the requester's security details and preparing a successful HTTP response.

    Replace the PLACEHOLDER text at line 51 with this code snippet.

  7. Save the file.

  8. Move the distributor-kyc-update/ project folder into the client-extensions/ folder of your course workspace.

  9. In a terminal, navigate to the client-extensions/distributor-kyc-update/ folder

  10. Run this command:

    blade gw deploy bootRun
  11. Verify it deploys successfully.

    INFO [fileinstall-directory-watcher][BundleStartStopLogger:68] STARTED distributorkycupdate_7.4.13 [1482]
  12. When the application starts, go to http://localhost:58081/ready. If the application is ready for use, the page displays “READY.”

Your microservice is now ready to receive and process KYC verification requests.

Exercise: Invoking Clarity’s Bridging APIs

Here, you’ll add an object action to automatically invoke Clarity’s bridging APIs within the microservice.

  1. In your running Liferay instance, sign in as the Clarity Admin user.

    • Username: admin@clarityvisionsolutions.com
    • Password: learn
  2. Open the Global Menu (Global Menu), go to the Control Panel tab, and click Objects.

  3. Click on the Distributor Management folder and select Distributor Application.

  4. Go to the Actions tab and click Add (Add).

  5. Enter these values in the Basic Info tab:

    Field

    Value

    Action Label

    Add Distributor KYC Check

    Action Name

    addDistributorKYCCheck

    Description

    Submit third-party KYC verification checks for new distributor applications

    Active

    Yes

  6. Go to the Action Builder tab and set these values:

    Field

    Value

    Trigger

    On After Add

    Condition

    N/A

    Action

    object-action-executor[function#clarity-distributor-kyc-update]


    Go to the Action Builder tab and set these values.

    NOTE
    If the clarity-distributor-kyc-update function is unavailable, ensure the microservice client extension is deployed to Liferay and actively running.
  7. Click Save.

  8. Open the Global Menu (Global Menu), go to the Applications tab, and click Distributor Applications.

  9. Click Add (Add) to create a new entry.

  10. Fill out an entry including required fields and click Save.

    Fill out an entry including required fields and click Save.

  11. Click on the KYC Verifications tab to see the newly created verification.

    Click on the KYC Verifications tab to see the newly created verification.

    This verification was processed by the microservice, which generated a simulated Approved or Denied status.

    NOTE
    While this microservice returns a mock verification result for testing purposes, its logic can be extended to connect directly with third-party KYC platforms.

Conclusion

Great! You’ve learned how to implement bridging APIs using microservices to connect with third-party integrations. Next, you’ll conclude this Mastering Producing Liferay’s Headless APIs course before taking the badge exam!

Loading Knowledge

Capabilities

Product

Education

Contact Us

Connect

Powered by Liferay
© 2024 Liferay Inc. All Rights Reserved • Privacy Policy