From cf57e400d51c2b32005adfa53956b2dcbc51ed29 Mon Sep 17 00:00:00 2001 From: "oluyemi.a.simbrellang.com" Date: Mon, 14 Apr 2025 18:02:30 +0100 Subject: [PATCH 1/2] done with kafka integration --- app/integrations/kafka.py | 2 +- app/integrations/simbrella.py | 42 +++++++++++++---------------------- 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/app/integrations/kafka.py b/app/integrations/kafka.py index 8a35a7c..a974343 100644 --- a/app/integrations/kafka.py +++ b/app/integrations/kafka.py @@ -51,7 +51,7 @@ class KafkaIntegration: :return: The message value (decoded) or None if no message is received """ consumer = KafkaIntegration._get_consumer() - # consumer.subscribe(["LOAN_REPAYMENT"]) + # consumer.subscribe(["PROCESS_PAYMENT"]) # consumer.subscribe([topic]) consumer.subscribe(['LOAN_REPAYMENT', 'PROCESS_PAYMENT']) diff --git a/app/integrations/simbrella.py b/app/integrations/simbrella.py index 073e7d2..f125d52 100644 --- a/app/integrations/simbrella.py +++ b/app/integrations/simbrella.py @@ -14,16 +14,6 @@ class SimbrellaClient: logger.info(f"BANK_CALL_BASE_URL = {SimbrellaClient.BANK_CALL_BASE_URL}") logger.info(f"Calling Disbursement endpoint with data: {data}") - data={ - "requestId": "RQID1743987402764", - "transactionId": "24", - "customerId": "CN437703", - "accountId": "ACN2167485", - "msisdn": "3451342", - "resultCode": "00", - "resultDescription": "Successful" - } - disbursement_data ={ "requestId": data['requestId'], "transactionId": data['transactionId'], @@ -61,10 +51,10 @@ class SimbrellaClient: collect_loan_data = { "transactionId": "T002", "fbnTransactionId": "FBN20231123", - "debtId": "273194670", - "customerId": "CN621868", + "debtId": data['debtId'], + "customerId": data['customerId'], "accountId": "2017821799", - "productId": "101", + "productId": data['productId'], "collectAmount": 80000, "penalCharge": 0, "collectionMethod": 1, @@ -86,16 +76,16 @@ class SimbrellaClient: @staticmethod def verify_transaction(data): - api_url = f"{SimbrellaClient.BANK_CALL_BASE_URL}/TransactionVerify" - logger.info(f"BANK_CALL_BASE_URL = {SimbrellaClient.BANK_CALL_BASE_URL}") - logger.info(f"Calling TransactionVerify endpoint with data: {data}") + # api_url = f"{SimbrellaClient.BANK_CALL_BASE_URL}/TransactionVerify" + # logger.info(f"BANK_CALL_BASE_URL = {SimbrellaClient.BANK_CALL_BASE_URL}") + # logger.info(f"Calling TransactionVerify endpoint with data: {data}") try: - logger.info(f"Here is your TransactionVerify Request data ***** : {data}") - response = requests.post(api_url, json=data, headers=get_headers()) - logger.info(f"TransactionVerify response: {response.json()}") + # logger.info(f"Here is your TransactionVerify Request data ***** : {data}") + # response = requests.post(api_url, json=data, headers=get_headers()) + # logger.info(f"TransactionVerify response: {response.json()}") - return response.json() + return data except Exception as e: logger.info(f"Failed to call TransactionVerify endpoint: {e}") @@ -103,9 +93,9 @@ class SimbrellaClient: @staticmethod def refresh_disbursement(data): - api_url = f"{SimbrellaClient.BANK_CALL_BASE_URL}/Disbursement" - logger.info(f"BANK_CALL_BASE_URL = {SimbrellaClient.BANK_CALL_BASE_URL}") - logger.info(f"Calling Disbursement endpoint with data: {data}") + # api_url = f"{SimbrellaClient.BANK_CALL_BASE_URL}/Disbursement" + # logger.info(f"BANK_CALL_BASE_URL = {SimbrellaClient.BANK_CALL_BASE_URL}") + # logger.info(f"Calling Disbursement endpoint with data: {data}") try: logger.info(f"Here is your Disbursement Request data ***** : {data}") @@ -122,9 +112,9 @@ class SimbrellaClient: @staticmethod def payment_callback(data): - api_url = f"{SimbrellaClient.BANK_CALL_BASE_URL}/Payment" - logger.info(f"BANK_CALL_BASE_URL = {SimbrellaClient.BANK_CALL_BASE_URL}") - logger.info(f"Calling Payment Callback endpoint with data: {data}") + # api_url = f"{SimbrellaClient.BANK_CALL_BASE_URL}/Payment" + # logger.info(f"BANK_CALL_BASE_URL = {SimbrellaClient.BANK_CALL_BASE_URL}") + # logger.info(f"Calling Payment Callback endpoint with data: {data}") try: logger.info(f"Here is your Payment Callback Request data ***** : {data}") From 62352ed740fb5d0cb31ce7138c6687f961e2f4da Mon Sep 17 00:00:00 2001 From: "oluyemi.a.simbrellang.com" Date: Mon, 14 Apr 2025 18:05:14 +0100 Subject: [PATCH 2/2] add dummy values for verify_transaction --- app/integrations/simbrella.py | 7 +++++-- app/routes/autocall.py | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/integrations/simbrella.py b/app/integrations/simbrella.py index f125d52..b279368 100644 --- a/app/integrations/simbrella.py +++ b/app/integrations/simbrella.py @@ -75,7 +75,7 @@ class SimbrellaClient: return 1 @staticmethod - def verify_transaction(data): + def verify_transaction(): # api_url = f"{SimbrellaClient.BANK_CALL_BASE_URL}/TransactionVerify" # logger.info(f"BANK_CALL_BASE_URL = {SimbrellaClient.BANK_CALL_BASE_URL}") # logger.info(f"Calling TransactionVerify endpoint with data: {data}") @@ -85,7 +85,10 @@ class SimbrellaClient: # response = requests.post(api_url, json=data, headers=get_headers()) # logger.info(f"TransactionVerify response: {response.json()}") - return data + return { + "status": "00", + "message": "Transaction verified" + } except Exception as e: logger.info(f"Failed to call TransactionVerify endpoint: {e}") diff --git a/app/routes/autocall.py b/app/routes/autocall.py index 75eddf3..cc3036e 100644 --- a/app/routes/autocall.py +++ b/app/routes/autocall.py @@ -9,19 +9,19 @@ autocall_bp = Blueprint("autocall", __name__) @autocall_bp.route("/refresh-verify-disbursement", methods=["GET"]) def verify_transaction(): - data = request.json() + # data = request.json() logger.info(f"Calling VerifyTransaction Components") - response = SimbrellaClient.verify_transaction(data) + response = SimbrellaClient.verify_transaction() return jsonify(response), 200 @autocall_bp.route("/refresh-disbursement", methods=["GET"]) def disbursement(): - data = request.json() + # data = request.json() logger.info(f"Calling Disbursement Components") - response = SimbrellaClient.verify_transaction(data) + response = SimbrellaClient.verify_transaction() return jsonify(response), 200