Published on : June 11, 2020

Add a new content type under All Processes

ALL Processes URL : https://loantap.in/wp-admin/edit.php?post_type=all_process

Syntax to add content type

[content_types.add cprocess_ekyc/]

All the necessary configurations will be defined.

Example : process_type, api_endpoint, status

Example to set configuration :

[cprocess_ekyc.config.set_array]
  [init_url]https://prod.veri5digital.com/video-id-kyc/_init[/init_url]
  [download_aadhaar]https://prod.veri5digital.com/video-id-kyc/api/1.0/executeAadhaarXMLService[/download_aadhaar]
  [fetch_aadhaar]https://prod.veri5digital.com/video-id-kyc/_fetch[/fetch_aadhaar]
  [client_code]LOAN5475[/client_code]
  [api_key]457873112389875[/api_key]
  [salt]s2eHDgJ4gFr85[/salt]
  [otp_required]N[/otp_required]
  [status]
    [initiated label="Initiated" value="initiated" stage="open" stage_label='Open'/]
    [discarded label="Discarded" value="discarded" stage="closed" stage_label='Closed'/]
    [completed label="Completed" value="completed" stage="closed" stage_label='Closed'/]
  [/status]
[/cprocess_ekyc.config.set_array]

All the meta which needs to be mapped will be defined.

The important thing here is the ‘mapped_key’. This helps connect the data received from API to the keys that we want to store.

Example to map the keys :

[cprocess_ekyc.meta.set_array]
  [full_name mapped_key='name' data_type='printable' meta_type='khosla'/]
  [mobile mapped_key='mobile' data_type='printable' meta_type='khosla'/]
  [care_of mapped_key='co' data_type='printable' meta_type='khosla'/]
  [dob mapped_key='dob' data_type='printable' meta_type='khosla'/]
  [house mapped_key='house' data_type='printable' meta_type='khosla'/]
  [landmark mapped_key='landmark' data_type='printable' meta_type='khosla'/]
  [locality mapped_key='loc' data_type='printable' meta_type='khosla'/]
  [street mapped_key='street' data_type='printable' meta_type='khosla'/]
  [pin_code mapped_key='pc' data_type='printable' meta_type='khosla'/]
  [post_office mapped_key='po' data_type='printable' meta_type='khosla'/]
  [city mapped_key='vtc' data_type='printable' meta_type='khosla'/]
  [district mapped_key='dist' data_type='printable' meta_type='khosla'/]
  [state mapped_key='state' data_type='printable' meta_type='khosla'/]
  [gender mapped_key='gender' data_type="printable" meta_type="khosla" /]
  [aadhaar_masked mapped_key='document_id' data_type="printable" meta_type="khosla" /]
  [response_json label="Response Json" data_type="printable" meta_type="khosla" /]
[/cprocess_ekyc.meta.set_array]

Note: Every 3rd party Service will have its own config & meta.

A template to ‘initiate‘ the process will be defined.

This template is supposed to:

  1. Fetch all the current processes for ‘ekyc’ of the given lapp_id.
  2. Loop through the results and mark all of them as discarded (This is an optional process. So depending on the needs, you may or may not do this.)
  3. Create the process_id
  4. Add redundant data for the process
[cprocess_basic.redundant current_process='cprocess_ekyc' meta=<meta array> o.set=@template.meta_data /]

This service builds & returns back the meta array in the following format:

5[@template.set meta_data.main=<Meta data created from the meta config> /]
[@template.set meta_data.common=<Common meta for process_status, process_status_label, process_stage, process_stage_label> /]
[@template.set meta_data.status=<status> /]

5. Create the payload

[cprocess_basic.payload process_id=<process_id> current_process='cprocess_ekyc' process_type='ekyc' meta_data=<meta_data array> o.set=@template.payload/]

This service builds & returns back the ‘payload’ meta array in the following format:

[@template.set payload.process_id=<process_id>/]
[@template.set payload.process_type=<process_type> /]
[@template.set payload.status=<process status> /]
[@template.set payload.meta=<Meta data created from the meta config> /]
[@template.set payload.meta_common={@template.meta_data.common} /]

6. Return the payload

A template to ‘finish‘ the process will be defined

This template is supposed to:

  1. Check if all the required parameters are present in @process.data.body (In this case check for @process.data.lapp_id & @process.data.body.uuid)
  2. If either is not present, return with error
  3. Then fetch the process_id from process_meta for the given lapp_id where process status is ‘initiated’
  4. If no data is found, return with error
  5. Set the request header:
[@template.set_array req_header content-type="application/json"/]

6. Set the request array:

[@template.set_array req]
	    [client_code][@content_type.config.client_code][/client_code]
	    [uuid][env.@process.data.body.uuid/][/uuid]   
	    [api_key][@content_type.config.api_key][/api_key]
	  [/@template.set_array]

7. Create the string to hash

[@template.set hash_str="{@content_type.config.client_code}|{env.@process.data.body.uuid}|{@content_type.config.api_key}|{@content_type.config.salt}" /]

8. Create the hash code

[php.hash p1="sha256" p2="{@template.hash_str}" o.set=@template.req.hash/]

9. Create the request array

[@template.set_array request_arr body="{@template.req_json}" /]
[@template.set_array request_arr headers="{@template.req_header}" /]

10. Make a request to the vendor to get the result

[php.wp_remote_post p1="{@content_type.config.fetch_aadhaar}" p2="{@template.request_arr}" o.set=@template.result /]

11. The data that we need in result is base64 encoded in the ‘eKYC’ case. So we will decode that to get the array.

[php.base64_decode p1="{@template.response.response_data.kyc_info}" o.set=@template.document_data /]

Here we have to update the currently running process.

12. Add redundant data for the process

[cprocess_basic.redundant current_process='cprocess_ekyc' meta=<meta array> o.set=@template.meta_data /]

13. This service builds & returns back the meta array in the following format:

[@template.set meta_data.main=<Meta data created from the meta config> /]
[@template.set meta_data.common=<Common meta for process_status, process_status_label, process_stage, process_stage_label> /]
[@template.set meta_data.status=<status> /]

14. Create the payload

[cprocess_basic.payload process_id=<process_id> current_process='cprocess_ekyc' process_type='ekyc' meta_data=<meta_data array> o.set=@template.payload/]

15. This service builds & returns back the ‘payload’ meta array in the following format:

[@template.set payload.process_id=<process_id>/]
[@template.set payload.process_type=<process_type> /]
[@template.set payload.status=<process status> /]
[@template.set payload.meta=<Meta data created from the meta config> /] -> This will be added in the process_meta table
[@template.set payload.meta_common={@template.meta_data.common} /] -> This will be added in the process_meta table

16. Set the lapp_process_meta from response in payload

[@template.set payload.lapp_process_meta={@template.response.lapp_process_meta}/] -> This will be added in the lapp_processes table

17. Return the payload