{"action":"closed","issue":{"url":"https://api.github.com/repos/odoo/odoo/issues/13834","repository_url":"https://api.github.com/repos/odoo/odoo","labels_url":"https://api.github.com/repos/odoo/odoo/issues/13834/labels{/name}","comments_url":"https://api.github.com/repos/odoo/odoo/issues/13834/comments","events_url":"https://api.github.com/repos/odoo/odoo/issues/13834/events","html_url":"https://github.com/odoo/odoo/issues/13834","id":183241839,"number":13834,"title":"[10.0] PayPal payment acquirer in eCommerce causes server error with live paypal, works in sandbox","user":{"login":"saulih","id":15038019,"avatar_url":"https://avatars.githubusercontent.com/u/15038019?v=3","gravatar_id":"","url":"https://api.github.com/users/saulih","html_url":"https://github.com/saulih","followers_url":"https://api.github.com/users/saulih/followers","following_url":"https://api.github.com/users/saulih/following{/other_user}","gists_url":"https://api.github.com/users/saulih/gists{/gist_id}","starred_url":"https://api.github.com/users/saulih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saulih/subscriptions","organizations_url":"https://api.github.com/users/saulih/orgs","repos_url":"https://api.github.com/users/saulih/repos","events_url":"https://api.github.com/users/saulih/events{/privacy}","received_events_url":"https://api.github.com/users/saulih/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-10-16T00:48:22Z","updated_at":"2016-12-09T09:48:31Z","closed_at":"2016-12-09T09:48:31Z","body":"**Impacted versions**: 10.0\n\n**Steps to reproduce**: \n- create a ecommerce web store with paypal payment acquirer enabled\n- paypal account settings: autoreturn on, payment data transfer off, encoding utf-8 (as instructed by documentation), autoreturn address www.mydomain.com/shop/confirmation\n- odoo paypal acquirer settings: IPN on, \"Authorize & capture the amount and confirm the SO on acquirer confirmation\"\n- complete checkout process and payment\n\n**Current behavior**: \n- upon returning from PayPal Odoo raises an exception and user gets server error 500\n\n```\nFile \"/usr/lib/python2.7/dist-packages/odoo/addons/payment_paypal/controllers/main.py\", line 70, in paypal_dpn\n    return werkzeug.utils.redirect(self._return_url)\nFile \"/usr/lib/python2.7/dist-packages/odoo/addons/payment_paypal/controllers/main.py\", line 44, in paypal_validate_data\n    paypal_urls = tx.acquirer_id._get_paypal_urls(tx.acquirer_id.environment or 'prod')\nAttributeError: 'NoneType' object has no attribute 'acquirer_id'\n```\n\n**Expected behavior**:\n- payment should be registered, sales order approved and user brought to order confirmation page\n\nWith a sandbox paypal account the process works, although it seems sandbox payments behave a little differently from live.\n\nI managed to get the payment process go thru with a live paypal account with following modifications to payment_paypal/controllers/main.py:\n\n**Original**:\n\n```\n    @http.route('/payment/paypal/dpn', type='http', auth=\"none\", methods=['POST', 'GET'], csrf=False)\n    def paypal_dpn(self, **post):\n        \"\"\" Paypal DPN \"\"\"\n        _logger.info('Beginning Paypal DPN form_feedback with post data %s', pprint.pformat(post))  # debug\n        return_url = self._get_return_url(**post)\n        self.paypal_validate_data(**post)\n        return werkzeug.utils.redirect(return_url)\n```\n\n**Modified**:\nwhen paypal payment is completed the user is returned to /payment/paypal/dpn rather than /shop/confirmation, and it's a GET request so the original code crashes when it can't validate nonexisting POST data.\n\n```\n    @http.route('/payment/paypal/dpn', type='http', auth=\"none\", methods=['POST', 'GET'], csrf=False)\n    def paypal_dpn(self, **post):\n        \"\"\" Paypal DPN \"\"\"\n        if post:\n            _logger.info('Beginning Paypal DPN form_feedback with post data %s', pprint.pformat(post))  # debug\n            return_url = self._get_return_url(**post)\n            self.paypal_validate_data(**post)\n        else:\n            _logger.info('No PayPal DPN data, redirecting to order confirmation')  # debug\n\n        return werkzeug.utils.redirect(\"/shop/confirmation\")\n```\n\nOnly issue remaining after this is that user's cart doesn't get emptied after returning to order confirmation page, related quotation gets confirmed into sales order but items remain in the cart.\n"}}
{"actor":{"display_login":"mart-e"}}