Commit 3717426e authored by Gabriel Monnerat's avatar Gabriel Monnerat

remove paramater that is not supported on IPaymentService and refactor code to...

remove paramater that is not supported on IPaymentService and refactor code to be possible pass a list of parameters to page template. With this will be possible create one form more ergonomic to post to paypal
parent c4102d17
...@@ -57,13 +57,22 @@ class PaypalService(XMLObject): ...@@ -57,13 +57,22 @@ class PaypalService(XMLObject):
def initialize(self, REQUEST=None, **kw): def initialize(self, REQUEST=None, **kw):
"""See Payment Service Interface Documentation""" """See Payment Service Interface Documentation"""
def navigate(self, page_template, REQUEST=None, **kw): def _getFieldList(self, paypal_dict):
field_list = []
for k,v in paypal_dict.iteritems():
field_list.append((k, v))
return field_list
def navigate(self, REQUEST=None, **kw):
"""See Payment Service Interface Documentation""" """See Payment Service Interface Documentation"""
self.Base_checkConsistency() self.Base_checkConsistency()
page_template = kw.pop("page_template")
paypal_dict = kw.get("paypal_dict", {})
temp_document = newTempDocument(self, 'id') temp_document = newTempDocument(self, 'id')
temp_document.edit( temp_document.edit(
link_url_string=self.getLinkUrlString(), link_url_string=self.getLinkUrlString(),
title='title', title=self.getTitle(),
field_list=self._getFieldList(paypal_dict),
# append the rest of transmitted parameters page template # append the rest of transmitted parameters page template
**kw **kw
) )
......
...@@ -79,17 +79,21 @@ class TestERP5PaypalSecurePayment(TestERP5PaypalSecurePaymentMixin): ...@@ -79,17 +79,21 @@ class TestERP5PaypalSecurePayment(TestERP5PaypalSecurePaymentMixin):
service_username="business@sample.com" service_username="business@sample.com"
) )
pt_id = str(random.random()) pt_id = str(random.random())
page_template_text = """ page_template_text = """<tal:block tal:repeat="value here/field_list">key=<tal:block tal:replace="python: value[0]"/> value=<tal:block tal:replace="python: value[1]"/>
link=<tal:block tal:replace='here/link_url_string'/> </tal:block>link=<tal:block tal:replace='here/link_url_string'/>
business=<tal:block tal:replace='here/service_username'/> business=<tal:block tal:replace='here/service_username'/>
""" """
self.portal.portal_skins.custom.manage_addProduct['PageTemplates']\ self.portal.portal_skins.custom.manage_addProduct['PageTemplates']\
.manage_addPageTemplate(id=pt_id, text=page_template_text) .manage_addPageTemplate(id=pt_id, text=page_template_text)
# flush skin cache # flush skin cache
self.portal.changeSkin(None) self.portal.changeSkin(None)
paypal_dict = {
"return" : "http://ipn/"
}
try: try:
result = self.service.navigate(pt_id) result = self.service.navigate(page_template=pt_id, paypal_dict=paypal_dict)
self.assertEquals(result, """link=http://paypal/ self.assertEquals(result, """key=return value=http://ipn/
link=http://paypal/
business=business@sample.com""") business=business@sample.com""")
finally: finally:
self.portal.portal_skins.custom.manage_delObjects([pt_id]) self.portal.portal_skins.custom.manage_delObjects([pt_id])
......
1 2
\ 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