verify loan
This commit is contained in:
+80
@@ -229,6 +229,77 @@ def salary_loanoffers():
|
||||
"product_data": offers_data,
|
||||
}, 200
|
||||
|
||||
@app.route('/salary/loanselect', methods=["POST"])
|
||||
def salary_loanselect():
|
||||
try:
|
||||
data = request.json
|
||||
if not data:
|
||||
return {
|
||||
"message": "Please provide bvn and loan",
|
||||
"data": None,
|
||||
"error": "Bad request"
|
||||
}, 400
|
||||
# validate input
|
||||
loan = data["loan"]
|
||||
bvn = data["bvn"]
|
||||
if username == 'loan' and password == 'loan' :
|
||||
loan = load_offer(loan,bvn)
|
||||
return {
|
||||
"message": "REQUEST_PIN",
|
||||
"loan": loan,
|
||||
"active_loan_count": 0,
|
||||
"active_loan": []
|
||||
}, 201
|
||||
else:
|
||||
return {
|
||||
"message": "Error fetching loan!, invalid bvn or loan",
|
||||
"data": None,
|
||||
"error": "Unauthorized"
|
||||
}, 404
|
||||
|
||||
except Exception as e:
|
||||
return {
|
||||
"message": "Something went wrong!",
|
||||
"error": str(e),
|
||||
"data": None
|
||||
}, 500
|
||||
|
||||
|
||||
@app.route('/salary/verifloan', methods=["POST"])
|
||||
def salary_verifloan():
|
||||
try:
|
||||
data = request.json
|
||||
if not data:
|
||||
return {
|
||||
"message": "Please provide pin",
|
||||
"data": None,
|
||||
"error": "Bad request"
|
||||
}, 400
|
||||
# validate input
|
||||
bvn = data["bvn"]
|
||||
pin = data["pin"]
|
||||
loan = data["loan"]
|
||||
SELECT_ACC = "SELECT id, uid,pin,bvn FROM demo_bank_accounts WHERE bvn='" + bvn + "' AND pin = '" + pin + "' "
|
||||
with connection:
|
||||
with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor:
|
||||
cursor.execute(SELECT_ACC)
|
||||
account = cursor.fetchall()
|
||||
|
||||
account_found = count = len( account )
|
||||
|
||||
if account_found == 1 :
|
||||
return {
|
||||
"status": "1",
|
||||
"data": account
|
||||
}, 201
|
||||
else:
|
||||
return {
|
||||
"status": "-1",
|
||||
"data": None,
|
||||
"message" : "Invalid Pin",
|
||||
"error": "1"
|
||||
}, 404
|
||||
|
||||
def products():
|
||||
product_data = [
|
||||
{"cid": "1", "description": "Product Loan 01" , "active" : 0 },
|
||||
@@ -237,6 +308,15 @@ def products():
|
||||
]
|
||||
return product_data
|
||||
|
||||
def load_offer(loan,bvn):
|
||||
OFFER_QUERY = "SELECT uid AS cid,loan,amount,description,days_duration,active FROM loan_offers WHERE loan='" + loan +"'"
|
||||
with connection:
|
||||
with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor:
|
||||
cursor.execute(OFFER_QUERY)
|
||||
select_demoS = cursor.fetchall()
|
||||
|
||||
loan_data = json.dumps( [dict(ix) for ix in select_demoS] )
|
||||
return json.loads( loan_data )
|
||||
|
||||
def offers():
|
||||
OFFER_QUERY = "SELECT uid AS cid,loan,amount,description,days_duration,active FROM loan_offers ORDER BY amount ASC"
|
||||
|
||||
Reference in New Issue
Block a user