
Developed a USSD application with php and mysqli.
=================================================
Note :  if USSD times up when i dial the code again let me continue from the previous page.


1. Agents Assistance
   -----------------
   1. Onboarding 
   2. Pay premium
   3. Exit



 1. Onboarding :
     a, Enter agents id : call API : impact_tsp_app/api/agent_sync_api.php
request : {
    "agent_code": "R00013269"
}

results : {
    "ok": true,
    "message": "Agent validated and saved successfully",
    "data": {
        "agent_code": "R00013269",
        "agent_status": "Active",
        "agent_name": "Aaron Amihere",
        "sales_manager": "Seth Ofori Amankwah",
        "branch_name": "Head Office",
        "agency_index": 129,
        "branchindex": 135,
        "micro_hd_index": 125,
        "userindex": 244
    }
}

if "ok": true then move to the next page else let the agents keep on trying

   b, Enter Customer mobile number : call API :impact_tsp_app/api/get_name.php

Request :  {
  "mobile_no": "233244845114",
  "channel": "mtn-gh"
}

Results : {
    "ok": true,
    "mobile_no": "233244845114",
    "customer_name": "JENNIFER AKUA GIDI",
    "response": {
        "Message": "Success",
        "ResponseCode": "0000",
        "Data": {
            "IsRegistered": true,
            "Name": "JENNIFER AKUA GIDI",
            "Status": "active"
        }
    }
}

note :  if "customer_name": "" is empty capture it
    c, Enter Date Of Birth : 01-01-1980
    d, Select products call API : impact_tsp_app/api/products.php
results : {
    "success": true,
    "message": "Products retrieved successfully.",
    "data": {
        "count": 3,
        "products": [
            {
                "id": 1,
                "display_name": "Bronze",
                "life_benefit": 2000,
                "total_monthly_premium": 8
            },
            {
                "id": 2,
                "display_name": "Gold",
                "life_benefit": 5000,
                "total_monthly_premium": 13
            },
            {
                "id": 3,
                "display_name": "Platinum",
                "life_benefit": 7500,
                "total_monthly_premium": 17.5
            }
        ]
    }
}

note : call API to check date of birth : /impact_tsp_app/api/age.php?product_id=2&date_of_birth=1980-01-01

results : {
    "success": true,
    "message": "Customer is eligible for this product.",
    "data": {
        "product": {
            "id": 2,
            "display_name": "Gold",
            "minimum_age": 18,
            "maximum_age": 75
        },
        "customer": {
            "date_of_birth": "1985-05-20",
            "calculated_age": 41
        },
        "eligible": true
    }
}

e,Enter email address : eg martinboadudanso@gmail.com then call API's : /impact_tsp_app/api/validate_email.php
Request : 
{
    "email": "mdansokwaku@impactlife.com.gh"
}

Results : 
{
    "success": true,
    "valid": true,
    "message": "The email address has a valid format and domain.",
    "email": "mdansokwaku@impactlife.com.gh",
    "local_part": "mdansokwaku",
    "domain": "impactlife.com.gh",
    "valid_format": true,
    "dns_checked": true,
    "mx_found": false,
    "a_record_found": true
}

f,Enter occupation : eg Trader

g, Enter 
    - Next of Kin Name	: eg: Martin Danso
    - Next of Kin dateofbirth	: 1987-09-10 call API to validate :  /impact_tsp_app/api/age.php?product_id=2&date_of_birth=1987-09-10
Results : 
{
    "success": true,
    "message": "Customer is eligible for this product.",
    "data": {
        "product": {
            "id": 2,
            "display_name": "Gold",
            "minimum_age": 18,
            "maximum_age": 75
        },
        "customer": {
            "date_of_birth": "1987-09-10",
            "calculated_age": 38
        },
        "eligible": true
    }
}

    - Next of Kin Contact : eg:0244229547


f. Call Signup : /impact_tsp_app/api/signup.php

Request : 
{
    "mobile_no": "233556534409",
    "customer_name": "Martin Danso",
    "date_of_birth": "1980-01-01",
    "gender": "MALE",
    "product_id": 1,
    "momo_network": "MTN",
    "email": "araymong@impactlife.com.gh",
    "location": "Accra",
    "occupation": "Software Developer",
    "next_of_kin": {
        "mobile_no": "0244886993",
        "nextkin_name": "Jane Owusua",
        "date_of_birth": "1982-05-15",
        "gender": "FEMALE",
        "relationship": "MOTHER",
        "userindex": "193"
    }
}

Results : 
{
    "success": true,
    "message": "An existing pending registration was found for this mobile number. No duplicate record was created; the mandate request was submitted again.",
    "data": {
        "record_created": false,
        "main_life_id": 200,
        "policy_no": "TSP-260700000007",
        "mobile_no": "233556534409",
        "product": "Bronze",
        "premium": 8,
        "payment_status": "Pending",
        "momo_network": "MTN",
        "mandate": {
            "ok": true,
            "mandate_status": "PENDING",
            "is_pending": true,
            "http_code": 200,
            "api_num_used": 66,
            "api_num_next": 67,
            "startDate": "2026-07-23",
            "endDate": "2076-07-23",
            "referenceNo": "66-TSP-260700000007",
            "request": {
                "merchantId": "aede37cd-8527-4c81-91ec-99f5846ec5fd",
                "productId": "27aa4ce0-54ec-4a0c-97cb-4491b7fdd5fb",
                "debitAccount": "233556534409",
                "debitAmount": "8.00",
                "frequencyType": "MONTHLY",
                "startDate": "2026-07-23",
                "endDate": "2076-07-23",
                "debitDay": "1",
                "debitTime": "18:00",
                "referenceNo": "66-TSP-260700000007",
                "channel": "MTN",
                "currency": "GHS",
                "triggerDebitStatus": true,
                "notificationStatus": true,
                "configuration": [
                    {
                        "name": "retryAttempts",
                        "value": "3"
                    }
                ]
            },
            "response": {
                "responseCode": "03",
                "responseMessage": "your request is being processed"
            },
            "success_check": {
                "ok": true,
                "status": "PENDING",
                "is_pending": true,
                "reason": "ITC request is being processed or awaiting customer approval",
                "responseCode": "03",
                "responseMessage": "your request is being processed"
            },
            "url": "https://apis.itcsrvc.com/direct-debit/subscription/subscribe",
            "message": "Mandate request has been submitted and is being processed by ITC.",
            "itc_response_code": "03",
            "itc_response_message": "your request is being processed"
        }
    }
}


 2. Pay premium
























request
==================
1.after saving to table :  main_life & next_kin : call : mandate_create_api.php
2.if payment_status = "Pending" and mobile_no exist in the main_life dont save the record again just call : mandate_create_api.php




Request API
========================
1.create an API for products


table : product
==================
id	display_name	life_benefit	total_monthly_premium
1	Bronze	2000	8
2	Gold	5000	13
3	Platinum	7500	17.5

table : users_logs
==================
userindex_log	userindex	caption	logs_date	path	data_inf	attempted_username





2. create an API for age



table : product
==================
id	display_name	minimum_age	maximum_age
1	Bronze	18	75
2	Gold	18	75
3	Platinum	18	75

table : users_logs
==================
userindex_log	userindex	caption	logs_date	path	data_inf	attempted_username


3. create an API for signup
================================


table : main_life
=============================
main_life_id
mobile_no
customer_name
date_of_birth
gender
policy_no 
product
premium
payment_status ="Pending"
momo_network
onboarding_channel = "USSD"
input_date
email
location
date_of_enrolment
occupation



table : next_kin
==============================
next_kin_id
main_life_id
mobile_no
nextkin_name
date_of_birth
gender
relationship
userindex
input_date


table : users_logs
==================
userindex_log	userindex	caption	logs_date	path	data_inf	attempted_username







