add more logs

This commit is contained in:
2025-12-19 15:00:21 +02:00
parent de2cf6988d
commit bcca5ed270

View File

@@ -40,15 +40,32 @@ def healthz():
@app.post("/api/payments/ipn") @app.post("/api/payments/ipn")
def ipn(): def ipn():
try: try:
app.logger.info("--- RAW REQUEST INSPECTION ---")
app.logger.info(f"Headers: {dict(request.headers)}")
app.logger.info(f"Form Data: {dict(request.form)}")
app.logger.info(f"JSON Data: {request.get_json(silent=True)}")
# Check common Netopia signature locations
sig = (request.headers.get('X-Netopia-Signature') or
request.form.get('data') or
(request.get_json(silent=True) or {}).get('data'))
if sig:
app.logger.info(f"FOUND SIGNATURE: {sig[:50]}...")
try:
import jwt
decoded = jwt.decode(sig, options={"verify_signature": False})
app.logger.info(f"DECODED POS FROM NETOPIA: {decoded.get('posSignature')}")
except Exception as e:
app.logger.error(f"Could not decode found signature: {e}")
else:
app.logger.error("NO SIGNATURE FOUND IN HEADERS, FORM, OR JSON")
# Pass the whole request object, not just request.data # Pass the whole request object, not just request.data
data = verify_ipn(request) data = verify_ipn(request)
sig_header = request.headers.get('X-Netopia-Signature')
if sig_header:
# This doesn't verify, it just PEERS inside the message to see the POS Signature
unverified_payload = jwt.decode(sig_header, options={"verify_signature": False})
app.logger.info(f"JWT PAYLOAD POS: {unverified_payload.get('posSignature')}")
app.logger.info("IPN OK: %s", data) app.logger.info("IPN OK: %s", data)
return jsonify({"errorCode": 0}), 200 return jsonify({"errorCode": 0}), 200
except Exception as e: except Exception as e: