summaryrefslogtreecommitdiff
path: root/addons/payment_authorize/controllers
diff options
context:
space:
mode:
authorfda-odoo <fda@odoo.com>2017-12-13 16:07:59 +0100
committerfda-odoo <fda@odoo.com>2018-01-24 15:28:53 +0100
commitdaf6ab1c872ed9a04517dccd2b32db8dd4855163 (patch)
treea511831833b0fc273afb71f542188e4da418b0ff /addons/payment_authorize/controllers
parent50beec7fa0029f6ece11df02a26e333a8430ee95 (diff)
[FIX] Payment, payment_authorize: show an error if customer doesn't have a complete profil on authorize.net payment.
If the user has no Zip code, country or city, authorize refuse the payment, but Odoo doens't show any error. The commit invite the user to log in in this case or to fill his missing information
Diffstat (limited to 'addons/payment_authorize/controllers')
-rw-r--r--addons/payment_authorize/controllers/main.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/addons/payment_authorize/controllers/main.py b/addons/payment_authorize/controllers/main.py
index 6b0aae9bf6a..451a5875b6d 100644
--- a/addons/payment_authorize/controllers/main.py
+++ b/addons/payment_authorize/controllers/main.py
@@ -3,8 +3,9 @@ import pprint
import logging
from werkzeug import urls, utils
-from odoo import http
+from odoo import http, _
from odoo.http import request
+from odoo.exceptions import ValidationError
_logger = logging.getLogger(__name__)
@@ -39,7 +40,27 @@ class AuthorizeController(http.Controller):
@http.route(['/payment/authorize/s2s/create_json_3ds'], type='json', auth='public', csrf=False)
def authorize_s2s_create_json_3ds(self, verify_validity=False, **kwargs):
- token = request.env['payment.acquirer'].browse(int(kwargs.get('acquirer_id'))).s2s_process(kwargs)
+ token = False
+ acquirer = request.env['payment.acquirer'].browse(int(kwargs.get('acquirer_id')))
+
+ try:
+ token = acquirer.s2s_process(kwargs)
+ except ValidationError as e:
+ message = e.args[0]
+ if isinstance(message, dict) and 'missing_fields' in message:
+ msg = _("The transaction cannot be processed because some contact details are missing or invalid: ")
+ message = msg + ', '.join(message['missing_fields']) + '. '
+ if request.env.user._is_public():
+ message += _("Please sign in to complete your profile.")
+ # update message if portal mode = b2b
+ if request.env['ir.config_parameter'].sudo().get_param('auth_signup.allow_uninvited', 'False').lower() == 'false':
+ message += _("If you don't have any account, please ask your salesperson to update your profile. ")
+ else:
+ message += _("Please complete your profile. ")
+
+ return {
+ 'error': message
+ }
if not token:
res = {