Commit 4bcc3c50 authored by Łukasz Nowak's avatar Łukasz Nowak

Implement navigate.

Allow to pass page_template which will be run in context of temporary object
with all required parameters.

Delegate responsiblity of dynamic data preparation to caller, check only service
consistency.
parent 00c2198e
...@@ -2,6 +2,8 @@ import zope ...@@ -2,6 +2,8 @@ import zope
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, interfaces from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5Type.Document import newTempDocument
import hashlib
class PayzenService(XMLObject): class PayzenService(XMLObject):
meta_type = 'Payzen Service' meta_type = 'Payzen Service'
...@@ -22,13 +24,37 @@ class PayzenService(XMLObject): ...@@ -22,13 +24,37 @@ class PayzenService(XMLObject):
"""See Payment Service Interface Documentation""" """See Payment Service Interface Documentation"""
pass pass
def navigate(self, REQUEST=None, **kw): def navigate(self, page_template, REQUEST=None, **kw):
"""Navigation not implemented """Returns configured template used to do the payment"""
self.Base_checkConsistency()
Payzen.eu assumes that POST is done directly to the website thus there is temp_document = newTempDocument(self, 'id')
no need to provide "proxy" method. field_list = [
""" ('vads_action_mode', self.getPayzenVadsActionMode()),
raise NotImplementedError('Method will not be implemented') ('vads_ctx_mode', self.getPayzenVadsCtxMode()),
('vads_page_action', self.getPayzenVadsPageAction()),
('vads_payment_config', 'SINGLE'),
('vads_site_id', self.getServiceUsername()),
('vads_version', self.getPayzenVadsVersion())
]
# fetch all prepared vads_ values and remove them from dict
for k in kw.copy():
if k.startswith('vads_'):
field_list.append((k, kw.pop(k)))
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))
temp_document.edit(
link_url_string=self.getLinkUrlString(),
title='title',
field_list=field_list,
# append the rest of transmitted parameters page template
**kw
)
return getattr(temp_document, page_template)()
def notifySuccess(self, REQUEST=None, **kw): def notifySuccess(self, REQUEST=None, **kw):
"""See Payment Service Interface Documentation""" """See Payment Service Interface Documentation"""
......
18 19
\ 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