diff --git a/UI_V2/flask_server.py b/UI_V2/flask_server.py index c51604d..5bef28f 100644 --- a/UI_V2/flask_server.py +++ b/UI_V2/flask_server.py @@ -5,6 +5,7 @@ import logging from logging.handlers import RotatingFileHandler from flask import Flask, request, jsonify from flask_cors import CORS +from flask import Response try: from dotenv import load_dotenv @@ -31,16 +32,28 @@ app.logger.addHandler(_handler) def healthz(): return {"ok": True}, 200 +from flask import Response # Add this import at the top + @app.post("/api/payments/ipn") def ipn(): try: - # Pass the whole request object, not just request.data + # 1. Verify the request with the SDK data = verify_ipn(request) app.logger.info("IPN OK: %s", data) - return jsonify({"ok": True, "data": data}), 200 + + # 2. Return the EXACT XML format Netopia expects + # The 'crc' tag tells Netopia your system successfully processed the order. + xml_response = 'ok' + + return Response(xml_response, mimetype='application/xml'), 200 + except Exception as e: app.logger.exception("IPN verification failed: %s", e) - return jsonify({"ok": False, "error": str(e)}), 400 + + # If there's an error on your side, you can signal a temporary failure + # error_type="1" means "Temporary Error, please retry later" + error_xml = 'Internal Error' + return Response(error_xml, mimetype='application/xml'), 400 @app.get("/api/payments/status") diff --git a/UI_V2/requirements.txt b/UI_V2/requirements.txt index c32016c..77c48f0 100644 --- a/UI_V2/requirements.txt +++ b/UI_V2/requirements.txt @@ -2,4 +2,5 @@ flet==0.28.3 netopia-sdk==2.1.1 python-dotenv==1.2.0 Flask==3.1.2 -flask-cors==6.0.1 \ No newline at end of file +flask-cors==6.0.1 +flet-audio-0.1.0 \ No newline at end of file