diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-01-25 15:41:45 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-01-25 15:41:45 +0100 |
| commit | cb50970f3f88c5e5e4f0608c6d07e66eb4698eb9 (patch) | |
| tree | fae668c499403db72b172b3c8802b869b1040ae7 /addons/payment_authorize/controllers/main.py | |
| parent | ffaca543c47adf5d0286ff8e9eeb99b193948679 (diff) | |
| parent | eefe879a37aba221bda84adfd880fb7876955920 (diff) | |
[MERGE] forward port branch 11.0 up to eefe879a37a
Diffstat (limited to 'addons/payment_authorize/controllers/main.py')
| -rw-r--r-- | addons/payment_authorize/controllers/main.py | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/addons/payment_authorize/controllers/main.py b/addons/payment_authorize/controllers/main.py index 6b0aae9bf6a..9614327401a 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__) @@ -35,11 +36,35 @@ class AuthorizeController(http.Controller): def authorize_s2s_create_json(self, **kwargs): acquirer_id = int(kwargs.get('acquirer_id')) acquirer = request.env['payment.acquirer'].browse(acquirer_id) + if not kwargs.get('partner_id'): + kwargs = dict(kwargs, partner_id=request.env.user.partner_id.id) return acquirer.s2s_process(kwargs).id @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: + if not kwargs.get('partner_id'): + kwargs = dict(kwargs, partner_id=request.env.user.partner_id.id) + 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 = { |
