Commit eff3f56d authored by Łukasz Nowak's avatar Łukasz Nowak

Simplify and split a bit.

Instead of doing analysis of passed dict, just accept payzen_dict, which will
be blindly applied.

Split to more methods, in order to have proper separation and being able to
test critical parts.
parent 1e275f82
...@@ -24,33 +24,39 @@ class PayzenService(XMLObject): ...@@ -24,33 +24,39 @@ class PayzenService(XMLObject):
"""See Payment Service Interface Documentation""" """See Payment Service Interface Documentation"""
pass pass
def navigate(self, page_template, REQUEST=None, **kw): def _getSignature(self, field_list):
"""Returns configured template used to do the payment""" field_list.sort()
self.Base_checkConsistency() signature = ''
temp_document = newTempDocument(self, 'id') for k, v in field_list:
signature += v + '+'
signature += self.getServicePassword()
return hashlib.sha1(signature).hexdigest()
def _getFieldList(self, payzen_dict):
field_list = [ field_list = [
('vads_action_mode', self.getPayzenVadsActionMode()), ('vads_action_mode', self.getPayzenVadsActionMode()),
('vads_ctx_mode', self.getPayzenVadsCtxMode()), ('vads_ctx_mode', self.getPayzenVadsCtxMode()),
('vads_contrib', 'ERP5'),
('vads_page_action', self.getPayzenVadsPageAction()), ('vads_page_action', self.getPayzenVadsPageAction()),
('vads_payment_config', 'SINGLE'), ('vads_payment_config', 'SINGLE'),
('vads_site_id', self.getServiceUsername()), ('vads_site_id', self.getServiceUsername()),
('vads_version', self.getPayzenVadsVersion()) ('vads_version', self.getPayzenVadsVersion())
] ]
# fetch all prepared vads_ values and remove them from dict # fetch all prepared vads_ values and remove them from dict
for k in kw.copy(): for k,v in payzen_dict.iteritems():
if k.startswith('vads_'): field_list.append((k, v))
field_list.append((k, kw.pop(k))) signature = self._getSignature(field_list)
field_list.sort()
signature = ''
for k, v in field_list:
signature += v + '+'
signature += self.getServicePassword()
signature = hashlib.sha1(signature).hexdigest()
field_list.append(('signature', signature)) field_list.append(('signature', signature))
return field_list
def navigate(self, page_template, payzen_dict, REQUEST=None, **kw):
"""Returns configured template used to do the payment"""
self.Base_checkConsistency()
temp_document = newTempDocument(self, 'id')
temp_document.edit( temp_document.edit(
link_url_string=self.getLinkUrlString(), link_url_string=self.getLinkUrlString(),
title='title', title='title',
field_list=field_list, field_list=self._getFieldList(payzen_dict),
# append the rest of transmitted parameters page template # append the rest of transmitted parameters page template
**kw **kw
) )
......
20 21
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment