admin管理员组

文章数量:1410689

I am trying to integrate Payfast on my flask application. The users are able to make payments but the ITN is not sent back. I always get the 307 Temporary Redirect response instead of 200 Ok. I am using flask so I have no idea why I always get this response.

In their documentation, they give a PHP example:

// Tell Payfast that this page is reachable by triggering a header 200
header('HTTP/1.0 200 OK');
flush();

I have tried everything like the following:

@orders.route('/status/notify', methods=['GET', 'POST'], strict_slashes=False)
def notify():
    return 'Ok', 200
@orders.route('/status/notify', methods=['GET', 'POST'])
@orders.route('/status/notify/', methods=['GET', 'POST'])
def notify():
    return 'Ok', 200
@orders.route('/status/notify', methods=['GET', 'POST'], strict_slashes=False)
def notify():
    current_app.logger.debug("Request received:")
    current_app.logger.debug(f"Method: {request.method}")
    current_app.logger.debug(f"Headers: {request.headers}")
    current_app.logger.debug(f"Data: {request.get_data()}")
    current_app.logger.debug(f"URL: {request.url}")

    pf_data = request.get_data()

    response = Response('OK', status=200)
    response.headers['Connection'] = 'close'
    return 'Ok'

And none of these work, I always get the same response.

How would I prevent the auto redirection for this route?

本文标签: pythonHow to immediately sent 200 Ok response in FlaskStack Overflow