[FIX] payment_acquirer_paypal: fixed return url management in DPN controller

bzr revid: tde@openerp.com-20131127160218-v4qkzcike1rm8g6b
This commit is contained in:
Thibault Delavallée 2013-11-27 17:02:18 +01:00
parent c8142a4e8f
commit abb4fdc647
2 changed files with 9 additions and 2 deletions

View File

@ -4,6 +4,10 @@ from openerp.addons.web import http
from openerp.addons.web.http import request
from openerp.addons.website.models import website
try:
import simplejson as json
except ImportError:
import json
import logging
import pprint
import requests
@ -56,8 +60,11 @@ class PaypalController(http.Controller):
def paypal_dpn(self, **post):
""" Paypal DPN """
_logger.info('Beginning Paypal DPN form_feedback with post data %s', pprint.pformat(post)) # debug
return_url = post.pop('return_url', '')
if not return_url:
custom = json.loads(post.pop('custom', '{}'))
return_url = custom.pop('return_url', '/')
self.paypal_validate_data(**post)
return_url = post.pop('return_url', '/')
return request.redirect(return_url)
@website.route([

View File

@ -67,7 +67,7 @@ class AcquirerPaypal(osv.Model):
'cancel_return': '%s' % urlparse.urljoin(base_url, PaypalController._cancel_url),
}
if tx_custom_values and tx_custom_values.get('return_url'):
tx_values['custom'] = 'return_url=%s' % tx_custom_values.pop('return_url')
tx_values['custom'] = json.dumps({'return_url': '%s' % tx_custom_values.pop('return_url')})
if tx_custom_values:
tx_values.update(tx_custom_values)
return tx_values