From d75339f1d38041a0dc40deb95bfe7233c93397d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernanda=20Hern=C3=A1ndez?= Date: Thu, 9 Feb 2023 18:22:51 +0000 Subject: [PATCH] [FIX] payment_authorize: use name to send values when partner is a company Currently, the name's fields to send to Authorize when the partner is a company are: * firstName * lastName if we consider following name `Company Duck Inc`: the code is sending: * firstName: '' * lastName: 'Duck' Only it sends the `lastName` with the second word found in the name, due to the new validations in Authorize.Net, this kind of transactions are marked as suspicious and it's not confirming the transactions, leave them as pending, this commit is sending the full name in `lastName` instead of only second word to meet with the validation in Authorize.Net Also, we are sending the fields `firstName` and `lastName`, with the maximum length allowed by Authorize. closes odoo/odoo#112977 X-original-commit: 77d83b327fd99ed090194ec0d3a771c9afc47115 Signed-off-by: Morgane Demesmaeker --- addons/payment_authorize/models/authorize_request.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/payment_authorize/models/authorize_request.py b/addons/payment_authorize/models/authorize_request.py index 72351add28d..3c8c202e7a0 100644 --- a/addons/payment_authorize/models/authorize_request.py +++ b/addons/payment_authorize/models/authorize_request.py @@ -161,11 +161,14 @@ class AuthorizeAPI: # but is not allowed for transactions with a payment.token. bill_to = {} if 'profile' not in tx_data: - split_name = payment_utils.split_partner_name(tx.partner_name) + if tx.partner_id.is_company: + split_name = '', tx.partner_name + else: + split_name = payment_utils.split_partner_name(tx.partner_name) # max lengths are defined by the Authorize API bill_to = { 'billTo': { - 'firstName': '' if tx.partner_id.is_company else split_name[0][:50], + 'firstName': split_name[0][:50], 'lastName': split_name[1][:50], # lastName is always required 'company': tx.partner_name[:50] if tx.partner_id.is_company else '', 'address': tx.partner_address,