# Part of Odoo. See LICENSE file for full copyright and licensing details. import base64 import logging import pprint import re 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): _flexcheckout_return_url = '/payment/ogone/flexcheckout' _directlink_return_url = '/payment/ogone/directlink' @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) # 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