# © 2024 - 2025 criptomart.net
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import logging
import pprint

from odoo import http
from odoo.http import request
from odoo.addons.payment_redsys.controllers.main import RedsysController

_logger = logging.getLogger(__name__)



class RedsysController(RedsysController):
    _return_url = '/payment/redsys/return'
    _cancel_url = '/payment/redsys/cancel'
    _exception_url = '/payment/redsys/error'
    _reject_url = '/payment/redsys/reject'


    @http.route(['/payment/redsys/result/<page>'], type='http', auth='public',methods=['GET'], website=True)
    def redsys_result(self, page, **post):
        _logger.info('________ Redsys return sync: %s -- %s',
            pprint.pformat(post), page)
        # double check
        if post:
            request.env['payment.transaction'].sudo()._handle_notification_data('redsys', post)
        return request.redirect('/payment/status')
