summaryrefslogtreecommitdiff
path: root/addons/payment_authorize/models/authorize_request.py
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/models/authorize_request.py
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/models/authorize_request.py')
-rw-r--r--addons/payment_authorize/models/authorize_request.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/addons/payment_authorize/models/authorize_request.py b/addons/payment_authorize/models/authorize_request.py
index 939abcaf049..5a5f30072f1 100644
--- a/addons/payment_authorize/models/authorize_request.py
+++ b/addons/payment_authorize/models/authorize_request.py
@@ -139,6 +139,11 @@ class AuthorizeAPI():
etree.SubElement(payment_profile, "customerType").text = 'business' if partner.is_company else 'individual'
billTo = etree.SubElement(payment_profile, "billTo")
etree.SubElement(billTo, "address").text = (partner.street or '' + (partner.street2 if partner.street2 else '')) or None
+
+ missing_fields = [partner._fields[field].string for field in ['city', 'country_id', 'zip'] if not partner[field]]
+ if missing_fields:
+ raise ValidationError({'missing_fields': missing_fields})
+
etree.SubElement(billTo, "city").text = partner.city
etree.SubElement(billTo, "state").text = partner.state_id.name or None
etree.SubElement(billTo, "zip").text = partner.zip