diff --git a/msystems/apps.py b/msystems/apps.py index 3bdc5db..4895bfe 100644 --- a/msystems/apps.py +++ b/msystems/apps.py @@ -55,6 +55,7 @@ "mpay_config": { "url": "", "payment_path": "service/pay", + "bill_path": "front/bills/bill", "service_id": "SERVICE1", # The same as mpass cert "service_certificate": "", diff --git a/msystems/views/mpay.py b/msystems/views/mpay.py index 34c6d24..c42dc58 100644 --- a/msystems/views/mpay.py +++ b/msystems/views/mpay.py @@ -1,5 +1,6 @@ import decimal import logging +from functools import reduce from lxml import etree from django.db import transaction @@ -217,6 +218,9 @@ def mpay_bill_payment_redirect(request): if not bill: return HttpResponseNotFound() + host = f"{request.scheme}://{request.get_host()}/" + bill_path = f"{MsystemsConfig.mpay_config['bill_path']}/{bill_id}/" + redirect_back_url = urljoin(host, bill_path) redirect_url = urljoin(MsystemsConfig.mpay_config['url'], MsystemsConfig.mpay_config['payment_path']) - query = f"OrderKey={bill.code}&ServiceID={MsystemsConfig.mpay_config['service_id']}" + query = f"OrderKey={bill.code}&ServiceID={MsystemsConfig.mpay_config['service_id']}&ReturnUrl={redirect_back_url}" return redirect(f"{redirect_url}?{query}")