Skip to content

Commit

Permalink
[BOT] Migrate hotfix 2.0.3 to GitHub.
Browse files Browse the repository at this point in the history
  • Loading branch information
nberhouche committed Jun 14, 2022
1 parent d9b83ee commit d35be2f
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 39 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion payment_lyra/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion payment_lyra/helpers/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
'LANGUAGE': 'en',

'GATEWAY_VERSION': 'V2',
'PLUGIN_VERSION': '2.0.2',
'PLUGIN_VERSION': '2.0.3',
'CMS_IDENTIFIER': 'Odoo_15',
}

Expand Down
18 changes: 7 additions & 11 deletions payment_lyra/models/payment_acquirer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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,
Expand All @@ -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 '',
Expand Down Expand Up @@ -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):
Expand Down
68 changes: 42 additions & 26 deletions payment_lyra/models/payment_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -59,40 +58,57 @@ 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()
return 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)
Expand Down Expand Up @@ -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':
Expand Down
1 change: 1 addition & 0 deletions payment_lyra/views/payment_lyra_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<input type="hidden" name="vads_version" t-att-value="vads_version" />
<input type="hidden" name="vads_return_mode" t-att-value="vads_return_mode" />
<input type="hidden" name="vads_order_id" t-att-value="vads_order_id" />
<input type="hidden" name="vads_ext_info_order_ref" t-att-value="vads_ext_info_order_ref" />
<input type="hidden" name="vads_contrib" t-att-value="vads_contrib" />
<input type="hidden" name="signature" t-att-value="lyra_signature" />

Expand Down

0 comments on commit d35be2f

Please sign in to comment.