Skip to content
Snippets Groups Projects
Commit 48f02f32 authored by Juan Carlos Montoya's avatar Juan Carlos Montoya Committed by Victor Feyens
Browse files

[FIX] payment_paypal: no transaction found


The paypal payment flow was crashing because no transaction was found
when the client wasn't connected.

closes odoo/odoo#39408

Signed-off-by: default avatarDamien Bouvy (dbo) <dbo@odoo.com>
parent 5b53bad0
No related branches found
No related tags found
No related merge requests found
......@@ -59,7 +59,7 @@ class PaypalController(http.Controller):
reference = post.get('item_number')
tx = None
if reference:
tx = request.env['payment.transaction'].search([('reference', '=', reference)])
tx = request.env['payment.transaction'].sudo().search([('reference', '=', reference)])
paypal_url = tx.acquirer_id.paypal_get_form_action_url()
pdt_request = bool(post.get('amt')) # check for specific pdt param
if pdt_request:
......@@ -76,15 +76,15 @@ class PaypalController(http.Controller):
_logger.info('Paypal: validated data')
res = request.env['payment.transaction'].sudo().form_feedback(post, 'paypal')
if not res and tx:
tx.sudo()._set_transaction_error('Validation error occured. Please contact your administrator.')
tx._set_transaction_error('Validation error occured. Please contact your administrator.')
elif resp in ['INVALID', 'FAIL']:
_logger.warning('Paypal: answered INVALID/FAIL on data verification')
if tx:
tx.sudo()._set_transaction_error('Invalid response from Paypal. Please contact your administrator.')
tx._set_transaction_error('Invalid response from Paypal. Please contact your administrator.')
else:
_logger.warning('Paypal: unrecognized paypal answer, received %s instead of VERIFIED/SUCCESS or INVALID/FAIL (validation: %s)' % (resp, 'PDT' if pdt_request else 'IPN/DPN'))
if tx:
tx.sudo()._set_transaction_error('Unrecognized error from Paypal. Please contact your administrator.')
tx._set_transaction_error('Unrecognized error from Paypal. Please contact your administrator.')
return res
@http.route('/payment/paypal/ipn/', type='http', auth='public', methods=['POST'], csrf=False)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment