<commit_before># Copyright 2018-2019 <NAME>
# License AGPL-3 or later (https://www.gnu.org/licenses/agpl).

import logging

from odoo import _, api, fields, models
from odoo.addons.payment.models.payment_acquirer import ValidationError

from .. import paysera, utils

_LOG = logging.getLogger(__name__)


class PaymentTransaction(models.Model):
    _inherit = 'payment.transaction'

    @api.model
    def _paysera_form_get_tx_from_data(self, data):
        '''Extracts the order ID from received data.

        Returns the corresponding transaction.'''
        # Decode the encoded parameters and write them into `data` dict.
        data['params'] = utils.decode_form_data(data.get('data', ''))

        reference = data['params'].get('orderid')
        if not reference:
            msg = 'Paysera: missing order ID in received data'
            _LOG.error(msg)
            raise ValidationError(msg)

        txs = self.env['payment.transaction'].search([
            ('reference', '=', reference),
        ])
        if not txs or len(txs) > 1:
            msg = 'Paysera: received data for reference ID: %s' % reference
            if not txs:
                msg += '; no order found'<commit_msg>remove unused import<commit_after># Copyright 2018-2019 <NAME>
# License AGPL-3 or later (https://www.gnu.org/licenses/agpl).

import logging

from odoo import _, api, models
from odoo.addons.payment.models.payment_acquirer import ValidationError

from .. import paysera, utils

_LOG = logging.getLogger(__name__)


class PaymentTransaction(models.Model):
    _inherit = 'payment.transaction'

    @api.model
    def _paysera_form_get_tx_from_data(self, data):
        '''Extracts the order ID from received data.

        Returns the corresponding transaction.'''
        # Decode the encoded parameters and write them into `data` dict.
        data['params'] = utils.decode_form_data(data.get('data', ''))

        reference = data['params'].get('orderid')
        if not reference:
            msg = 'Paysera: missing order ID in received data'
            _LOG.error(msg)
            raise ValidationError(msg)

        txs = self.env['payment.transaction'].search([
            ('reference', '=', reference),
        ])
        if not txs or len(txs) > 1:
            msg = 'Paysera: received data for reference ID: %s' % reference
            if not txs:
                msg += '; no order found'
{'fraction_non_alphanumeric': 0.11101871101871102, 'fraction_numerical': 0.008316008316008316, 'mean_word_length': 2.6565349544072947, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3128959', 'n_tokens_mistral': 711, 'n_tokens_neox': 682, 'n_words': 200}