summaryrefslogtreecommitdiff
path: root/addons/payment_ogone/controllers/main.py
diff options
context:
space:
mode:
authorToufik Benjaa <tbe@odoo.com>2018-07-11 17:47:29 +0200
committerToufik Benjaa <tbe@odoo.com>2018-09-19 18:25:32 +0200
commit6ed44181d081b3cfd8875dc82e4e155970cc07f5 (patch)
tree5449ac99ea4191b9b747918d0d1d8702ebad3cc5 /addons/payment_ogone/controllers/main.py
parent46dc8ceef90ec5472b1aa4b45509f23d6c3e2624 (diff)
[IMP] payment_*: payment acquirers error handling
This commit aims to improve the user experience when using payment acquirers. There currently are no error feedback with some acquirers, which leaves the user wondering what is going on and what is the real status of its payment. In some cases, the user is currently being redirected to the home page even though the payment has failed. We want to make it more obvious to the user that something unexpected has happened by redirecting to an intermediate page that will provide good feedback on payments status. Another goal of this commit is to order acquirers by sequence instead of by flow and to select the first acquirer by default. This feature was already implmented in commit fe294fd43e521bd2d339e962f43acf46c3d4cb97, some UI adaptations were needed though. Related to task #36680 Closes #26958
Diffstat (limited to 'addons/payment_ogone/controllers/main.py')
-rw-r--r--addons/payment_ogone/controllers/main.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/addons/payment_ogone/controllers/main.py b/addons/payment_ogone/controllers/main.py
index 409e09b8a9e..6bebff17f34 100644
--- a/addons/payment_ogone/controllers/main.py
+++ b/addons/payment_ogone/controllers/main.py
@@ -7,6 +7,7 @@ from werkzeug.urls import url_unquote_plus
from odoo import http
from odoo.http import request
from odoo.addons.payment.models.payment_acquirer import ValidationError
+from odoo.addons.payment.controllers.portal import PaymentProcessing
_logger = logging.getLogger(__name__)
@@ -27,7 +28,7 @@ class OgoneController(http.Controller):
""" Ogone contacts using GET, at least for accept """
_logger.info('Ogone: entering form_feedback with post data %s', pprint.pformat(post)) # debug
request.env['payment.transaction'].sudo().form_feedback(post, 'ogone')
- return werkzeug.utils.redirect(url_unquote_plus(post.pop('return_url', '/')))
+ return werkzeug.utils.redirect("/payment/process")
@http.route(['/payment/ogone/s2s/create_json'], type='json', auth='public', csrf=False)
def ogone_s2s_create_json(self, **kwargs):
@@ -40,11 +41,18 @@ class OgoneController(http.Controller):
def ogone_s2s_create_json_3ds(self, verify_validity=False, **kwargs):
if not kwargs.get('partner_id'):
kwargs = dict(kwargs, partner_id=request.env.user.partner_id.id)
- token = request.env['payment.acquirer'].browse(int(kwargs.get('acquirer_id'))).s2s_process(kwargs)
+ token = False
+ error = None
+
+ try:
+ token = request.env['payment.acquirer'].browse(int(kwargs.get('acquirer_id'))).s2s_process(kwargs)
+ except Exception as e:
+ error = str(e)
if not token:
res = {
'result': False,
+ 'error': error,
}
return res
@@ -94,7 +102,9 @@ class OgoneController(http.Controller):
tx = token.validate(**params)
if tx and tx.html_3ds:
return tx.html_3ds
- return werkzeug.utils.redirect(post.get('return_url', '/') + (error and '#error=%s' % werkzeug.url_quote(error) or ''))
+ # add the payment transaction into the session to let the page /payment/process to handle it
+ PaymentProcessing.add_payment_transaction(tx)
+ return werkzeug.utils.redirect("/payment/process")
@http.route([
'/payment/ogone/validate/accept',
@@ -104,7 +114,7 @@ class OgoneController(http.Controller):
def ogone_validation_form_feedback(self, **post):
""" Feedback from 3d secure for a bank card validation """
request.env['payment.transaction'].sudo().form_feedback(post, 'ogone')
- return werkzeug.utils.redirect(werkzeug.url_unquote(post.pop('return_url', '/')))
+ return werkzeug.utils.redirect("/payment/process")
@http.route(['/payment/ogone/s2s/feedback'], auth='none', csrf=False)
def feedback(self, **kwargs):