From 3751379f1e9a4c215fb6eb898b4ccc67659b9ace Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 21:51:50 +0700 Subject: initial commit 2 --- addons/payment_payumoney/controllers/__init__.py | 4 ++++ addons/payment_payumoney/controllers/main.py | 28 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 addons/payment_payumoney/controllers/__init__.py create mode 100644 addons/payment_payumoney/controllers/main.py (limited to 'addons/payment_payumoney/controllers') diff --git a/addons/payment_payumoney/controllers/__init__.py b/addons/payment_payumoney/controllers/__init__.py new file mode 100644 index 00000000..5d4b25db --- /dev/null +++ b/addons/payment_payumoney/controllers/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import main diff --git a/addons/payment_payumoney/controllers/main.py b/addons/payment_payumoney/controllers/main.py new file mode 100644 index 00000000..a4715e17 --- /dev/null +++ b/addons/payment_payumoney/controllers/main.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +import logging +import pprint +import werkzeug + +from odoo import http +from odoo.http import request + +_logger = logging.getLogger(__name__) + + +class PayuMoneyController(http.Controller): + @http.route(['/payment/payumoney/return', '/payment/payumoney/cancel', '/payment/payumoney/error'], type='http', auth='public', csrf=False, save_session=False) + def payu_return(self, **post): + """ PayUmoney. + The session cookie created by Odoo has not the attribute SameSite. Most of browsers will force this attribute + with the value 'Lax'. After the payment, PayUMoney will perform a POST request on this route. For all these reasons, + the cookie won't be added to the request. As a result, if we want to save the session, the server will create + a new session cookie. Therefore, the previous session and all related information will be lost, so it will lead + to undesirable behaviors. This is the reason why `save_session=False` is needed. + """ + _logger.info( + 'PayUmoney: entering form_feedback with post data %s', pprint.pformat(post)) + if post: + request.env['payment.transaction'].sudo().form_feedback(post, 'payumoney') + return werkzeug.utils.redirect('/payment/process') -- cgit v1.2.3