Design of a Mifos Core Connector for Mojaloop Payment Manager
chris-me-law opened this issue · 0 comments
Goal:
As an
FSP with Fineract\MIFOS Core Banking
I want to
be able to use the "PM4ML/SDK Core Connector"
so that
I can transact on Mojaloop effectively
Acceptance Criteria:
- Verify that an integration sequence diagram is finalised for the design
Complexity: <High|Medium|Low> > A short comment to remind the reason for the rating
Uncertainty: <High|Medium|Low> > A short comment to remind the reason for the rating
Tasks:
- Researching about Fineract api routes for performing the required functions.
- Reading through fineract api docs for this specific use case.
- Reviewing the routes being called in the existing mojaloop core connector for payment Hub
- Creating a sequence diagram to document the design of how the api should work
- Meet with Product Owner to validate design.
- Next steps implement validated design - See Implementation Issue
Done
- Acceptance Criteria pass
- Designs are up-to date
- Unit Tests pass
- Integration Tests pass
- Code Style & Coverage meets standards
- Changes made to config (default.json) are broadcast to team and follow-up tasks added to update helm charts and other deployment config.
- TBD
Pull Requests:
- TBD
Follow-up:
- N/A
Dependencies:
- N/A
Accountability:
- Owner: TBC
- QA/Review: TBC
Mifos Core Connector for Mojaloop Design Findings
The term fineract and Mifos are used interchangeably in this documentation to mean the same thing.
Overview
This documentation is an account of the experience I had while developing the mifos core connector. The idea is to make sure the steps of how I got everything working and testing is documented and can easily be referenced for someone else to use.
Deploying and setting up fineract for development
To setup fineract for development, you will need to do following.
Prerequisites
The following are required for you to successfully go through this documenation.
- Working knowledge of docker
- Docker installed on your machine
Deploy mariadb
Fineract uses mysql as it's default database management system. You will need to deploy an instance of mariadb on your localhost to be able to run fineract successfully.
Run this command to run a local instance of mariadb. Note the parameter -e MARIADB_ROOT_PASSWORD=mysql
which sets the password for the mariadb instance.
docker run --name mariadb-11.2 -p 3306:3306 -e MARIADB_ROOT_PASSWORD=mysql -d mariadb:11.2
After running this command, you will have a local running instance of mariadb.
Setup database
Fineact requires some database resources to be in place for it to start successfully.
Clone the fineract repository on your local machine and cd into the repo folder.
git clone https://github.com/apache/fineract.git; cd fineract
After cloning the repository, please execute the following commands at the root of fineract repo folder to create the database resources.
./gradlew createDB -PdbName=fineract_tenants
./gradlew createDB -PdbName=fineract_default
After running these commands, if they executed successfully, the database resources will be created and now we can proceed to run fineract.
Deploy fineract
After you have deployed an instance of mariadb and created the database resources, you can then deploy the latest stable release of Apache Fineract from Docker Hub.
Run this command to deploy fineract locally.
docker run --name fineract -p 8443:8443 -p 8080:8080 -e FINERACT_DEFAULT_TENANTDB_PWD=mysql -e FINERACT_DEFAULT_TENANTDB_HOSTNAME=localhost -e FINERACT_SERVER_SSL_ENABLED=false --network="host" apache/fineract
Existing public fineract instances
There are existing public instances of Apache fineract hosted and maintained by Mifos Initiative
Here is one I used for the development and validation of my api routes
You can make requests to this base url while referring to the api docs at Docs
Fineract Core Connector Sequence Diagram
Payee account in Fineract
Make sure to view this in github to see the rendered sequence diagram. Issue on Github
sequenceDiagram
SDK Scheme Adapter->>+Core Connector: GET /parties/IBAN/{ID}
Core Connector->>+Core Connector: Validate &Extract Account No from IBAN
Core Connector->>+Apache Fineract: GET /fineract-provider/api/v1/search?query={AccountNo}&resource=savingsaccount
Apache Fineract-->>+Core Connector: Response 200 OK [{}...]
Core Connector-->>+Core Connector: Extract Account Id
Core Connector->>+Apache Fineract: GET /fineract-provider/api/v1/savingsaccounts/{accountId}/
Apache Fineract-->>+Core Connector: Response 200 OK {...}
Core Connector->>+Core Connector: Verify Account is active and can receive deposits
Alt If Account Active
Core Connector-->>+Core Connector: Extract Client Id
Core Connector->>+Apache Fineract: GET /fineract-provider/api/v1/clients/{clientId}/
Apache Fineract-->>+Core Connector: Response 200 OK {...}
Core Connector-->>+SDK Scheme Adapter: Response 200 OK {...}
Else If Account Not Active
Core Connector-->>+SDK Scheme Adapter: Response 404 Not Found
End
SDK Scheme Adapter->>+Core Connector: POST /quoterequests
Core Connector-->>+Core Connector: No Fees for Deposits
Core Connector->>+Core Connector: Validate &Extract Account No from IBAN
Core Connector->>+Apache Fineract: GET /fineract-provider/api/v1/search?query={AccountNo}&resource=savingsaccount
Apache Fineract-->>+Core Connector: Response 200 OK [{}...]
Core Connector-->>+Core Connector: Extract Account Id
Core Connector->>+Apache Fineract: GET /fineract-provider/api/v1/savingsaccounts/{accountId}/
Apache Fineract-->>+Core Connector: Response 200 OK {...}
Core Connector->>+Core Connector: Verify Account is active and can receive deposits
Core Connector-->>+Core Connector: Extract Client Id
Core Connector->>+Apache Fineract: GET /fineract-provider/api/v1/clients/{clientId}/
Apache Fineract-->>+Core Connector: Response 200 OK {...}
Core Connector-->>+Core Connector: Tiered KYC Checks need to be performed here.
Core Connector-->>+SDK Scheme Adapter: Response 200 OK {...}
SDK Scheme Adapter->>+Core Connector: POST /transfers
Core Connector->>+Core Connector: Extract Account No from IBAN
Core Connector->>+Apache Fineract: GET /fineract-provider/api/v1/search?query={AccountNo}&resource=savingsaccount
Apache Fineract-->>+Core Connector: Response 200 OK [{}...]
Core Connector-->>+Core Connector: Extract Account Id
Core Connector->>+Apache Fineract: POST /fineract-provider/api/v1/savingsaccounts/{accountId}/transactions?command=deposit
Alt If No Error
Apache Fineract-->>+Core Connector: Response 200 OK {...}
Core Connector-->>+SDK Scheme Adapter: Response 200 OK {...}
Else If Error
Core Connector-->>+SDK Scheme Adapter: Response 500 Server Error
End