---
# System prepended metadata

title: E-wallet

---

# E-wallet

## Steps to setup project
1. Create database (manually or sqlalchemy models)
2. Ensure that your flask is connected with db successfully
3. Ensure that your flask accepts request (e.g. create "/" endpoint and send request to it)
4. Project Structure (e.g. separate part that receives request and part that writes/reads data from db, view/model)
5. Setup CAS Auth and ensure that your request goes through with CAS

## Learning
- Flask
- Pipenv?
- SQLAlchemy?
- Zappa?
- Cryptography library (fernet?)


## Database
- Customer table
- Balance/Ewallet table?
- Transaction table
- Topup history table? or use one table for spend/topup


## Flask (Code)
- Models
- CAS Authentication
- Creating customers (at what point customer is created, probably after CAS auth)
-- CAS will provide TP, email, name (probably there is some validate token func that returns those)
-- Missing pin, phone_no
-- The pin should be encrypted (can use fernet library, dont forget to save fernet key when run first time and store as env variable)
- Transaction
-- View transactions - should be CAS protected backend, I think frontend might be pin protected
- Topup
-- Transaction go through APay
-- Create a payment intent using APay endpoint and pass metadata(should probably be unique) and amount associated with receipt/topup transaction
-- Store transaction details
-- Redirect customer to APay
-- Create endpoint that accepts callback from APay
-- APay will return back the payment transaction status and metadata
-- Update customer balance based on payment transaction status and metadata
- Payment
-- Research
