From 8ecec2bfbb990e0d55f8e8d6dc958abea83aa9e0 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 6 Mar 2017 10:27:52 +0100 Subject: [PATCH] [FIX] payment_paypal: prevent the IPN feedback to return an HTTP error code When you enable the IPN notifications in your Paypal account configuration, the default IPN URL is mandatory. You are therefore obliged to put the IPN feedback URL of Odoo in this default URL, even if this is not used because each transaction done by Odoo specifies the URL to which the IPN notifications must be sent. Because of this, if you use your Paypal account for something else, e.g. Ebay, you receive notifications of payments for these other transactions, that have nothing to do with Odoo. In such a case, Odoo returned an HTTP error status code (e.g. 500), because Odoo couldn't find the given transactions, and then Paypal sent emails to the Paypal owner to tell the IPN feedback was failing. Eventually, after several fails, Paypal automatically disabled the IPN notifications of the given account. With this revision, we now avoid to raise the Validation errors in the case of the IPN feedback, and just logs it, to avoid Paypal to sent emails to the owner and to automatically disable the IPN notifications if it receives transactions from other services than Odoo. opw-702403 --- addons/payment_paypal/controllers/main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/payment_paypal/controllers/main.py b/addons/payment_paypal/controllers/main.py index 87b68e19510..798dfbcdcd8 100644 --- a/addons/payment_paypal/controllers/main.py +++ b/addons/payment_paypal/controllers/main.py @@ -8,6 +8,7 @@ import urllib2 import werkzeug from openerp import http, SUPERUSER_ID +from openerp.addons.payment.models.payment_acquirer import ValidationError from openerp.http import request _logger = logging.getLogger(__name__) @@ -89,7 +90,10 @@ class PaypalController(http.Controller): def paypal_ipn(self, **post): """ Paypal IPN. """ _logger.info('Beginning Paypal IPN form_feedback with post data %s', pprint.pformat(post)) # debug - self.paypal_validate_data(**post) + try: + self.paypal_validate_data(**post) + except ValidationError: + _logger.exception('Unable to validate the Paypal payment') return '' @http.route('/payment/paypal/dpn', type='http', auth="none", methods=['POST', 'GET'], csrf=False)