merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit a489a58fc4dedad93c8eb9f6f6f6540e5d77981f
parent 0d201c9977c4c99781ec39237c1757d3950d5c38
Author: Marcello Stanisci <marcello.stanisci@inria.fr>
Date:   Thu, 27 Apr 2017 15:46:52 +0200

mitm proxies request using the same method used by
the client.

Diffstat:
Msrc/mitm/mitm.py | 13+++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/mitm/mitm.py b/src/mitm/mitm.py @@ -31,8 +31,8 @@ import json from random import randint from datetime import datetime -# FIXME make this as a standalone executable, and accept -# the exchange url as a cli option. +# FIXME make this as a standalone executable, like taler-merchant-mitm. +# accept the exchange url as a cli option. app = Flask(__name__) app.secret_key = base64.b64encode(os.urandom(64)).decode('utf-8') @@ -40,6 +40,9 @@ logger = logging.getLogger(__name__) exchange_url = os.environ.get("TALER_EXCHANGE_URL") assert(None != exchange_url) +# The functions taking 'resp' as parameter are responsible for +# modifying the data to return. + def track_transaction(resp): return resp @@ -55,8 +58,10 @@ def all(path): url[0] = xurl[0] url[1] = xurl[1] url = urlunparse(url) - print("Querying " + url) - r = requests.post(urljoin(url, path), json=body) + if "POST" == request.method: + r = requests.post(urljoin(url, path), json=body) + else: + r = requests.get(urljoin(url, path), json=body) resp = dict() if "application/json" == r.headers["Content-Type"]: resp = r.json()