From ec2a3d63bf5c1e345e0334d64e22a64b2bd93828 Mon Sep 17 00:00:00 2001 From: Kamil Malinowski Date: Mon, 8 Apr 2024 17:42:16 +0200 Subject: [PATCH] OM-150 Added return url for mpay payment --- msystems/apps.py | 1 + msystems/views/mpay.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) 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}")