Skip to content

Commit

Permalink
[FIX] fix model name in webhook payment providider
Browse files Browse the repository at this point in the history
[IMP] Add default values for MP item order description
[IMP] drop state_message argument in _set_done transaction

closes #57

Related: ingadhoc/multi-company#123
Signed-off-by: Nicolas Mac Rouillon <nmr@adhoc.com.ar>
  • Loading branch information
maq-adhoc committed May 11, 2023
1 parent 5f6c1c3 commit 8100e6a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion payment_mercadopago/__manifest__.py
Expand Up @@ -2,7 +2,7 @@
'name': 'Mercado Pago Payment Acquirer',
'category': 'Accounting/Payment Acquirers',
'summary': 'Payment Acquirer: MercadoPago',
'version': "16.0.1.0.0",
'version': "16.0.2.0.0",
'description': """
Mercado pago Payment
===================
Expand Down
2 changes: 1 addition & 1 deletion payment_mercadopago/controllers/main.py
Expand Up @@ -109,7 +109,7 @@ def mercadopago_notification(self, aquirer_id=False):
# For backward compatibility, add the aquirer_id separately.
if aquirer_id:
leaf += [('id', '=', int(aquirer_id))]
acquirer = request.env["payment.acquirer"].sudo().search(leaf, limit=1)
acquirer = request.env["payment.provider"].sudo().search(leaf, limit=1)

mercadopago_API = MercadoPagoAPI(acquirer)
payment_data = mercadopago_API.get_payment(payment_id)
Expand Down
7 changes: 4 additions & 3 deletions payment_mercadopago/models/payment_provider.py
Expand Up @@ -24,9 +24,9 @@ class PaymentProvider(models.Model):
is_validation = fields.Boolean()

# MercadoPago general item fields
mercadopago_item_id = fields.Char('Item ID')
mercadopago_item_title = fields.Char('Item Title')
mercadopago_item_description = fields.Char('Item Description')
mercadopago_item_id = fields.Char('Item ID', default='001')
mercadopago_item_title = fields.Char('Item Title', default='Website sale')
mercadopago_item_description = fields.Char('Item Description', default='Website sale item')
mercadopago_item_category = fields.Selection(
string='MercadoPago Category', help="The category",
selection=[
Expand Down Expand Up @@ -54,6 +54,7 @@ class PaymentProvider(models.Model):
('virtual_goods', "E-books, Music Files, Software, Digital Images, PDF Files and any item which can be electronically stored in a file, Mobile Recharge, DTH Recharge and any Online Recharge"),
('others', "Other categories"),
],
default='others'
)
mercadopago_capture_method = fields.Selection([
('deferred_capture', 'Deferred capture is posible'),
Expand Down
4 changes: 2 additions & 2 deletions payment_mercadopago/models/payment_transaction.py
Expand Up @@ -181,15 +181,15 @@ def _process_notification_data(self, notification_data):
message = self._get_mercadopago_response_msg(response_content)
if status in ['approved', 'processed']: # Approved
if self.state != 'done':
self._set_done(state_message=message)
self._set_done()
else:
_logger.info('The TX %s is already done. Cant set done twise' % self.reference)
if self.tokenize and not self.token_id:
self._mercadopago_tokenize_from_feedback_data(response_content)
elif status in ['authorized']: # Authorized: the card validation is ok
if self.operation == 'validation':
# TODO: revisar si tenemos que hacer algo más
self._set_done(state_message=message)
self._set_done()
if self.tokenize and not self.token_id:
self._mercadopago_tokenize_from_feedback_data(response_content)
elif status in ['cancelled', 'refunded', 'charged_back', 'rejected']: # Declined
Expand Down

0 comments on commit 8100e6a

Please sign in to comment.