diff --git a/addons/payment_ogone/controllers/main.py b/addons/payment_ogone/controllers/main.py index c24e52d220d..c74039c1e68 100644 --- a/addons/payment_ogone/controllers/main.py +++ b/addons/payment_ogone/controllers/main.py @@ -1,25 +1,20 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -import base64 import logging import pprint import re -import markupsafe import werkzeug from odoo import _, http from odoo.exceptions import ValidationError from odoo.http import request -from odoo.tools import ustr _logger = logging.getLogger(__name__) class OgoneController(http.Controller): - _hosted_payment_page_return_url = '/payment/ogone/hostedpaymentpage' - _flexcheckout_return_url = '/payment/ogone/flexcheckout' - _directlink_return_url = '/payment/ogone/directlink' + _return_url = '/payment/ogone/return' _backward_compatibility_urls = [ '/payment/ogone/accept', '/payment/ogone/test/accept', '/payment/ogone/decline', '/payment/ogone/test/decline', @@ -31,84 +26,11 @@ class OgoneController(http.Controller): ] # Facilitates the migration of users who registered the URLs in Ogone's backend prior to 14.3 @http.route( - _hosted_payment_page_return_url, type='http', auth='public', methods=['GET', 'POST'], - csrf=False - ) # 'GET' or 'POST' depending on the configuration in Ogone backend - def ogone_return_from_hosted_payment_page(self, **feedback_data): - """ Process the data returned by Ogone after redirection to the Hosted Payment Page. - - :param dict feedback_data: The feedback data - """ - # Check the source and integrity of the data - data = self._homogenize_data(feedback_data) - self._verify_signature(feedback_data, data) - - # Handle the feedback data - data['FEEDBACK_TYPE'] = 'hosted_payment_page' - _logger.info("entering _handle_feedback_data with data:\n%s", pprint.pformat(data)) - request.env['payment.transaction'].sudo()._handle_feedback_data('ogone', data) - return werkzeug.utils.redirect('/payment/status') - - @http.route( - _flexcheckout_return_url, type='http', auth='public', methods=['GET', 'POST'], csrf=False - ) # 'GET' or 'POST' depending on the configuration in Ogone backend - def ogone_return_from_flexcheckout(self, **feedback_data): - """ Process the data returned by Ogone after redirection to Flexcheckout. - - :param dict feedback_data: The feedback data - """ - # Check the source and integrity of the data - data = self._homogenize_data(feedback_data) - self._verify_signature(feedback_data, data) - - # Create a token from the feedback data - data['FEEDBACK_TYPE'] = 'flexcheckout' - _logger.info("entering _handle_feedback_data with data:\n%s", pprint.pformat(data)) - tx_sudo = request.env['payment.transaction'].sudo()._handle_feedback_data('ogone', data) - - # Process the payment through the token - tree = tx_sudo._ogone_send_order_request(request_3ds_authentication=True) - feedback_data = { - 'FEEDBACK_TYPE': 'directlink', - 'ORDERID': tree.get('orderID'), - 'tree': tree, - } - _logger.info( - "entering _handle_feedback_data with data:\n%s", pprint.pformat(feedback_data) - ) - request.env['payment.transaction'].sudo()._handle_feedback_data('ogone', feedback_data) - - # Handle the response - redirect_html_element = tree.find('HTML_ANSWER') - if redirect_html_element: - # Ogone has inserted an HTML_ANSWER element in its response XML tree. This means that a - # redirection to DirectLink's authentication page is required, as FlexCheckout is not - # capable of handling authentications... - # As per the documentation, the HTML must be inserted as-is into the current page, and - # consists of a