[FIX] payment_adyen: ignore missing street numbers
Commit ceb8b78 introduced a mechanism to throw an error if some address fields were empty. The mechanism was introduced to prevent us from sending False as an address detail to Adyen when it was not set since it might negatively affect the fraud check score. It however caused some payments not to go through because it relied on Odoo's utils to extract the house number from the address, which would fail in some circumstances (e.g., when the number is placed before the street name). In some other cases, empty address details that were previously accepted by Adyen caused the error to be thrown. With this commit, we now pass Unknown instead of False or empty string for the address details that are not set and that are not required by Adyen in practice, unlike what is stated in AVS documentation. This delegates the responsibility to block the payment to Adyen as the address check and the related error are removed from Odoo. closes odoo/odoo#149365 X-original-commit: 771b7ebd55646d8c96938e562802b47cb92d18fb Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com> Signed-off-by: anko-odoo <anko@odoo.com>
This commit is contained in:
@@ -139,13 +139,6 @@ msgstr ""
|
||||
msgid "Payment processing failed"
|
||||
msgstr ""
|
||||
|
||||
#. module: payment_adyen
|
||||
#. odoo-python
|
||||
#: code:addons/payment_adyen/utils.py:0
|
||||
#, python-format
|
||||
msgid "Please complete your address details."
|
||||
msgstr ""
|
||||
|
||||
#. module: payment_adyen
|
||||
#. odoo-python
|
||||
#: code:addons/payment_adyen/models/payment_transaction.py:0
|
||||
|
||||
@@ -10,6 +10,7 @@ from odoo.tools import mute_logger
|
||||
|
||||
from odoo.addons.payment import utils as payment_utils
|
||||
from odoo.addons.payment.tests.http_common import PaymentHttpCommon
|
||||
from odoo.addons.payment_adyen import utils as adyen_utils
|
||||
from odoo.addons.payment_adyen.controllers.main import AdyenController
|
||||
from odoo.addons.payment_adyen.tests.common import AdyenCommon
|
||||
|
||||
@@ -511,3 +512,14 @@ class AdyenTest(AdyenCommon, PaymentHttpCommon):
|
||||
payload = dict(self.webhook_notification_payload, additionalData={'hmacSignature': 'dummy'})
|
||||
tx = self._create_transaction('direct')
|
||||
self.assertRaises(Forbidden, AdyenController._verify_notification_signature, payload, tx)
|
||||
|
||||
@mute_logger('odoo.addons.payment_adyen.models.payment_transaction')
|
||||
def test_no_information_missing_from_partner_address(self):
|
||||
test_partner = self.env['res.partner'].create({
|
||||
'name': 'Dummy Partner',
|
||||
'email': 'norbert.buyer@example.com',
|
||||
'phone': '0032 12 34 56 78',
|
||||
})
|
||||
test_address = adyen_utils.format_partner_address(test_partner)
|
||||
for key in ('city', 'country', 'stateOrProvince', 'street',):
|
||||
self.assertTrue(test_address.get(key))
|
||||
|
||||
@@ -50,17 +50,16 @@ def format_partner_address(partner):
|
||||
:rtype: dict
|
||||
"""
|
||||
street_data = partner._get_street_split()
|
||||
address = {
|
||||
'city': partner.city,
|
||||
# Unlike what is stated in https://docs.adyen.com/risk-management/avs-checks/, not all fields
|
||||
# are required at all time. Thus, we fall back to 'Unknown' when a field is not set to avoid
|
||||
# blocking the payment (empty string are not accepted) or passing `False` (which may not pass
|
||||
# the fraud check).
|
||||
return {
|
||||
'city': partner.city or 'Unknown',
|
||||
'country': partner.country_id.code or 'ZZ', # 'ZZ' if the country is not known.
|
||||
'stateOrProvince': partner.state_id.code or '', # The state is not always required.
|
||||
'postalCode': partner.zip,
|
||||
'stateOrProvince': partner.state_id.code or 'Unknown', # The state is not always required.
|
||||
'postalCode': partner.zip or '',
|
||||
# Fill in the address fields if the format is supported, or fallback to the raw address.
|
||||
'street': street_data.get('street_name', partner.street),
|
||||
'houseNumberOrName': street_data.get('street_number'),
|
||||
'street': street_data.get('street_name', partner.street) or 'Unknown',
|
||||
'houseNumberOrName': street_data.get('street_number') or '',
|
||||
}
|
||||
for key, value in address.items():
|
||||
if key == 'stateOrProvince' and partner.country_id.code not in ['CA', 'US', 'GB']:
|
||||
continue
|
||||
if not value:
|
||||
raise ValidationError(_("Please complete your address details."))
|
||||
|
||||
Reference in New Issue
Block a user