fix netopia issue
This commit is contained in:
@@ -32,28 +32,16 @@ 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:
|
||||
# 1. Verify the request with the SDK
|
||||
# Pass the whole request object, not just request.data
|
||||
data = verify_ipn(request)
|
||||
app.logger.info("IPN OK: %s", data)
|
||||
|
||||
# 2. Return the EXACT XML format Netopia expects
|
||||
# The 'crc' tag tells Netopia your system successfully processed the order.
|
||||
xml_response = '<?xml version="1.0" encoding="utf-8" ?><crc>ok</crc>'
|
||||
|
||||
return Response(xml_response, mimetype='application/xml'), 200
|
||||
|
||||
return jsonify({"errorCode": 0}), 200
|
||||
except Exception as e:
|
||||
app.logger.exception("IPN verification failed: %s", e)
|
||||
|
||||
# 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 = '<?xml version="1.0" encoding="utf-8" ?><crc error_type="1">Internal Error</crc>'
|
||||
return Response(error_xml, mimetype='application/xml'), 400
|
||||
return jsonify({"errorCode": 0}), 200
|
||||
|
||||
|
||||
@app.get("/api/payments/status")
|
||||
|
||||
Reference in New Issue
Block a user