diff --git a/CHANGELOG.md b/CHANGELOG.md
index f9ee06b..de9695a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+2.0.3, 2022-06-14
+=============
+- Fix invoice payment with payment links.
+
2.0.2, 2022-06-07
=============
- Update list of supported payment means.
diff --git a/payment_lyra/__manifest__.py b/payment_lyra/__manifest__.py
index f24a029..3893fc8 100644
--- a/payment_lyra/__manifest__.py
+++ b/payment_lyra/__manifest__.py
@@ -9,7 +9,7 @@
{
'name': 'Lyra Collect Payment Acquirer',
- 'version': '2.0.2',
+ 'version': '2.0.3',
'summary': 'Accept payments with Lyra Collect secure payment gateway.',
'category': 'Accounting/Payment Acquirers',
'author': 'Lyra Network',
diff --git a/payment_lyra/helpers/constants.py b/payment_lyra/helpers/constants.py
index d64d6ed..04a51a6 100644
--- a/payment_lyra/helpers/constants.py
+++ b/payment_lyra/helpers/constants.py
@@ -31,7 +31,7 @@
'LANGUAGE': 'en',
'GATEWAY_VERSION': 'V2',
- 'PLUGIN_VERSION': '2.0.2',
+ 'PLUGIN_VERSION': '2.0.3',
'CMS_IDENTIFIER': 'Odoo_15',
}
diff --git a/payment_lyra/models/payment_acquirer.py b/payment_lyra/models/payment_acquirer.py
index 1853c3d..c81118f 100644
--- a/payment_lyra/models/payment_acquirer.py
+++ b/payment_lyra/models/payment_acquirer.py
@@ -27,16 +27,10 @@
from ..helpers import constants, tools
from .card import LyraCard
from .language import LyraLanguage
+from odoo.addons.payment import utils as payment_utils
-try:
- import urlparse
-except ImportError:
- import urllib.parse as urlparse
-
-try:
- from odoo.addons.payment import utils as payment_utils
-except ImportError:
- pass
+import urllib.parse as urlparse
+import re
_logger = logging.getLogger(__name__)
@@ -200,6 +194,8 @@ def lyra_form_generate_values(self, values):
# Enable redirection?
AcquirerLyra.lyra_redirect = True if str(self.lyra_redirect_enabled) == '1' else False
+ order_id = re.sub("[^0-9a-zA-Z_-]+", "", values.get('reference'))
+
tx_values = dict() # Values to sign in unicode.
tx_values.update({
'vads_site_id': self.lyra_site_id,
@@ -213,7 +209,8 @@ def lyra_form_generate_values(self, values):
'vads_payment_config': self._get_payment_config(amount),
'vads_version': constants.LYRA_PARAMS.get('GATEWAY_VERSION'),
'vads_url_return': urlparse.urljoin(base_url, LyraController._return_url),
- 'vads_order_id': str(values.get('reference')),
+ 'vads_order_id': str(order_id),
+ 'vads_ext_info_order_ref': str(values.get('reference')),
'vads_contrib': constants.LYRA_PARAMS.get('CMS_IDENTIFIER') + u'_' + constants.LYRA_PARAMS.get('PLUGIN_VERSION') + u'/' + release.version,
'vads_language': self.lyra_language or '',
@@ -241,7 +238,6 @@ def lyra_form_generate_values(self, values):
lyra_tx_values[key] = tx_values[key].encode('utf-8')
- lyra_tx_values['lyra_signature'] = self._lyra_generate_sign(self, tx_values)
return lyra_tx_values
def lyra_get_form_action_url(self):
diff --git a/payment_lyra/models/payment_transaction.py b/payment_lyra/models/payment_transaction.py
index fc3ed02..476975c 100644
--- a/payment_lyra/models/payment_transaction.py
+++ b/payment_lyra/models/payment_transaction.py
@@ -42,7 +42,6 @@ class TransactionLyra(models.Model):
# FORM RELATED METHODS
# --------------------------------------------------
- # Odoo 15.
def _get_specific_rendering_values(self, processing_values):
""" Override of payment to return Lyra specific rendering values. """
res = super()._get_specific_rendering_values(processing_values)
@@ -59,32 +58,49 @@ def _get_specific_rendering_values(self, processing_values):
values.update({
'vads_cust_id': str(self.partner_id.id) or '',
- 'vads_cust_first_name': partner_first_name or '',
- 'vads_cust_last_name': partner_last_name or '',
- 'vads_cust_address': self.partner_address or '',
- 'vads_cust_zip': self.partner_zip or '',
- 'vads_cust_city': self.partner_city or '',
- 'vads_cust_state': self.partner_state_id.code or '',
- 'vads_cust_country': self.partner_country_id.code or '',
- 'vads_cust_email': self.partner_email or '',
- 'vads_cust_phone': self.partner_phone or '',
+ 'vads_cust_first_name': partner_first_name and partner_first_name[0:62] or '',
+ 'vads_cust_last_name': partner_last_name and partner_last_name[0:62] or '',
+ 'vads_cust_address': self.partner_address and self.partner_address[0:254] or '',
+ 'vads_cust_zip': self.partner_zip and self.partner_zip[0:62] or '',
+ 'vads_cust_city': self.partner_city and self.partner_city[0:62] or '',
+ 'vads_cust_state': self.partner_state_id.code and self.partner_state_id.code[0:62] or '',
+ 'vads_cust_country': self.partner_country_id.code and self.partner_country_id.code.upper() or '',
+ 'vads_cust_email': self.partner_email and self.partner_email[0:126] or '',
+ 'vads_cust_phone': self.partner_phone and self.partner_phone[0:31] or '',
})
- partner_shipping_id = self.sale_order_ids[0].partner_shipping_id
- if partner_shipping_id:
- # Set shipping info.
- partner_shipping_first_name, partner_shipping_last_name = payment_utils.split_partner_name(partner_shipping_id.name) or ('', '')
+ # Set shipping info.
+ try:
+ shipping_address = self.sale_order_ids[0].partner_shipping_id
+
+ partner_shipping_first_name, partner_shipping_last_name = payment_utils.split_partner_name(shipping_address.name) or ('', '')
+ partner_ship_to_street = shipping_address.street and shipping_address.street[0:62] or ''
+ partner_ship_to_zip = shipping_address.zip and shipping_address.zip[0:62] or ''
+ partner_ship_to_city = shipping_address.city and shipping_address.city[0:62] or ''
+ partner_ship_to_state = shipping_address.state_id.name and shipping_address.state_id.name[0:62] or ''
+ partner_ship_to_country = shipping_address.country_id.code and shipping_address.country_id.code.upper() or ''
+ partner_ship_to_phone_num = shipping_address.phone and shipping_address.phone[0:31] or ''
+
+ except Exception:
+ partner_shipping_first_name = values['vads_cust_first_name']
+ partner_shipping_last_name = values['vads_cust_last_name']
+ partner_ship_to_street = values['vads_cust_address'] and values['vads_cust_address'][0:62] or ''
+ partner_ship_to_zip = values['vads_cust_zip']
+ partner_ship_to_city = values['vads_cust_city']
+ partner_ship_to_state = values['vads_cust_state']
+ partner_ship_to_country = values['vads_cust_country']
+ partner_ship_to_phone_num = values['vads_cust_phone']
- values.update({
- 'vads_ship_to_first_name': partner_shipping_first_name or '',
- 'vads_ship_to_last_name': partner_shipping_last_name or '',
- 'vads_ship_to_street': partner_shipping_id.street or '',
- 'vads_ship_to_zip': partner_shipping_id.zip or '',
- 'vads_ship_to_city': partner_shipping_id.city or '',
- 'vads_ship_to_state': partner_shipping_id.state_id.code or '',
- 'vads_ship_to_country': partner_shipping_id.country_id.code or '',
- 'vads_ship_to_phone_num': partner_shipping_id.phone or ''
- })
+ values.update({
+ 'vads_ship_to_first_name': partner_shipping_first_name and partner_shipping_first_name[0:62] or '',
+ 'vads_ship_to_last_name': partner_shipping_last_name and partner_shipping_last_name[0:62] or '',
+ 'vads_ship_to_street': partner_ship_to_street,
+ 'vads_ship_to_zip': partner_ship_to_zip,
+ 'vads_ship_to_city': partner_ship_to_city,
+ 'vads_ship_to_state': partner_ship_to_state,
+ 'vads_ship_to_country': partner_ship_to_country,
+ 'vads_ship_to_phone_num': partner_ship_to_phone_num
+ })
values['lyra_signature'] = self.acquirer_id._lyra_generate_sign(self, values)
values['api_url'] = self.acquirer_id.lyra_get_form_action_url()
@@ -92,7 +108,7 @@ def _get_specific_rendering_values(self, processing_values):
@api.model
def _lyra_form_get_tx_from_data(self, data):
- shasign, status, reference = data.get('signature'), data.get('vads_trans_status'), data.get('vads_order_id')
+ shasign, status, reference = data.get('signature'), data.get('vads_trans_status'), data.get('vads_ext_info_order_ref') or data.get('vads_order_id')
if not reference or not shasign or not status:
error_msg = 'Lyra Collect : received bad data {}'.format(data)
@@ -132,7 +148,7 @@ def _process_feedback_data(self, data):
if self.provider != 'lyra' and self.provider != 'lyramulti':
return
- self.acquirer_reference = data.get('vads_order_id')
+ self.acquirer_reference = data.get('vads_ext_info_order_ref') or data.get('vads_order_id')
html_3ds = _('3DS authentication: ')
if data.get('vads_threeds_status') == 'Y':
diff --git a/payment_lyra/views/payment_lyra_templates.xml b/payment_lyra/views/payment_lyra_templates.xml
index 0ed3a05..aaa9c8c 100644
--- a/payment_lyra/views/payment_lyra_templates.xml
+++ b/payment_lyra/views/payment_lyra_templates.xml
@@ -24,6 +24,7 @@
+