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.
-
Open the
exercises/distributor-kyc-update/client-extension.yaml
file within your course workspace. -
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
. -
Save the file.
-
Open the
exercises/distributor-kyc-update/src/main/java/com/clarityvisionsolutions/distributor/kyc/update/DistributorKYCUpdateController.java
file with a text editor or IDE. -
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.
-
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. -
Save the file.
-
Move the
distributor-kyc-update/
project folder into theclient-extensions/
folder of your course workspace. -
In a terminal, navigate to the
client-extensions/distributor-kyc-update/
folder -
Run this command:
blade gw deploy bootRun
-
Verify it deploys successfully.
INFO [fileinstall-directory-watcher][BundleStartStopLogger:68] STARTED distributorkycupdate_7.4.13 [1482]
-
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.
-
In your running Liferay instance, sign in as the Clarity Admin user.
- Username:
admin@clarityvisionsolutions.com
- Password:
learn
- Username:
-
Open the Global Menu (
), go to the Control Panel tab, and click Objects. -
Click on the Distributor Management folder and select Distributor Application.
-
Go to the Actions tab and click Add (
). -
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
-
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]
NOTE
If theclarity-distributor-kyc-update
function is unavailable, ensure the microservice client extension is deployed to Liferay and actively running. -
Click Save.
-
Open the Global Menu (
), go to the Applications tab, and click Distributor Applications. -
Click Add (
) to create a new entry. -
Fill out an entry including required fields and click Save.
-
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!
Capabilities
Product
Education
Contact Us