Commit 32e1051b authored by Romain Courteaud's avatar Romain Courteaud

Test payzen manual payment creation.

parent 09651ea3
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Integration Base Category Mapping" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_destination_reference</string> </key>
<value> <string>source_project</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>SourceProject</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SourceProject</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Integration Base Category Mapping</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>mode</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Payment Service to use with PayZen.</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>preferred_payzen_payment_service_reference_property</string> </value>
</item>
<item>
<key> <string>mode</string> </key>
<value> <string>w</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>preference</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>property_default</string> </key>
<value> <string>python: \'\'</string> </value>
</item>
<item>
<key> <string>write_permission</string> </key>
<value> <string>Manage properties</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -51,11 +51,13 @@ ...@@ -51,11 +51,13 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n <value> <string>portal = context.getPortalObject()\n
\n
portal.portal_catalog.searchAndActivate(\n portal.portal_catalog.searchAndActivate(\n
portal_type="Payment Transaction", \n portal_type="Payment Transaction", \n
simulation_state=["confirmed"],\n simulation_state=["confirmed"],\n
causality_state=["solved"],\n causality_state=["solved"],\n
method_id=\'PaymentTransaction_startExternalPayment\',\n payment_mode_uid=portal.portal_categories.payment_mode.payzen.getUid(),\n
method_id=\'PaymentTransaction_startPayzenPayment\',\n
packet_size=1, # just one to minimise errors\n packet_size=1, # just one to minimise errors\n
activate_kw={\'tag\': tag}\n activate_kw={\'tag\': tag}\n
)\n )\n
......
...@@ -50,22 +50,15 @@ ...@@ -50,22 +50,15 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>from DateTime import DateTime\n <value> <string>portal = context.getPortalObject()\n
from Products.ZSQLCatalog.SQLCatalog import Query\n
from Products.ERP5Type.DateUtils import addToDate\n
\n
portal = context.getPortalObject()\n
portal.portal_catalog.searchAndActivate(\n portal.portal_catalog.searchAndActivate(\n
portal_type="Payment Transaction", \n portal_type="Payment Transaction", \n
simulation_state=["started"],\n simulation_state=["started"],\n
causality_state=["solved"],\n causality_state=["solved"],\n
payment_mode_uid=portal.portal_categories.payment_mode.payzen.getUid(),\n
method_id=\'PaymentTransaction_updateStatus\',\n method_id=\'PaymentTransaction_updateStatus\',\n
packet_size=1, # just one to minimise errors\n packet_size=1, # just one to minimise errors\n
activate_kw={\'tag\': tag},\n activate_kw={\'tag\': tag}\n
**{\'delivery.start_date\': Query(range="max",\n
**{\'delivery.start_date\': addToDate(\n
DateTime().latestTime(),\n
to_add={\'day\': -1})} )}\n
)\n )\n
context.activate(after_tag=tag).getId()\n context.activate(after_tag=tag).getId()\n
</string> </value> </string> </value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
if (context.getPaymentMode() != \'payzen\'):\n
return\n
\n
portal = context.getPortalObject()\n
integration_site = portal.restrictedTraverse(portal.portal_preferences.getPreferredPayzenIntegrationSite())\n
\n
ticket_relative_url = integration_site.getCategoryFromMapping(\'SourceProject/%s\' % context.getId().replace(\'-\', \'_\'))\n
if ticket_relative_url != \'source_project/%s\' % context.getId().replace(\'-\', \'_\'):\n
ticket = portal.restrictedTraverse(ticket_relative_url)\n
else:\n
ticket = portal.support_request_module.newContent(\n
portal_type=\'Support Request\',\n
source_project_value=context,\n
title=\'Payzen Transaction to check\',\n
)\n
ticket.validate(comment=\'New automatic ticket for %s\' % context.getTitle())\n
\n
try:\n
mapping = integration_site.getCategoryFromMapping(\n
\'SourceProject/%s\' % context.getId().replace(\'-\', \'_\'),\n
create_mapping_line=True,\n
create_mapping=True)\n
except ValueError:\n
pass\n
integration_site.SourceProject[context.getId().replace(\'-\', \'_\')].setDestinationReference(ticket.getRelativeUrl())\n
\n
return ticket\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PaymentTransaction_addPayzenTicket</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
portal = context.getPortalObject()\n
payment_service = portal.portal_secure_payments.find(\n
service_reference=portal.portal_preferences.getPreferredPayzenPaymentServiceReference())\n
\n
kw.update({\n
\'portal_type\': \'Payzen Event\',\n
\'source_value\': payment_service,\n
\'destination_value\': context,\n
})\n
\n
return portal.system_event_module.newContent(**kw)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PaymentTransaction_createPayzenEvent</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
portal = context.getPortalObject()\n
integration_site = portal.restrictedTraverse(portal.portal_preferences.getPreferredPayzenIntegrationSite())\n
\n
transaction_date, transaction_id = context.PaymentTransaction_getPayzenId()\n
if transaction_id is not None:\n
# XXX raise?\n
return None, None\n
\n
now = DateTime().toZone(\'UTC\')\n
today = now.asdatetime().strftime(\'%Y%m%d\')\n
\n
transaction_id = str(portal.portal_ids.generateNewId(\n
id_group=\'%s_%s\' % (integration_site.getRelativeUrl(), today),\n
id_generator=\'uid\')).zfill(6)\n
\n
mapping_id = \'%s_%s\' % (today, transaction_id)\n
# integration_site.Causality[mapping_id].setDestinationReference(context.getRelativeUrl())\n
# try:\n
# integration_site.getCategoryFromMapping(\'Causality/%s\' % mapping_id, create_mapping_line=True, create_mapping=True)\n
# except ValueError:\n
# mapping = integration_site.Causality[mapping_id]\n
# mapping.setDestinationReference(\'%s\' % context.getRelativeUrl())\n
# else:\n
# raise ValueError, "Payzen transaction_id already exists"\n
\n
try:\n
mapping = integration_site.getCategoryFromMapping(\n
\'Causality/%s\' % context.getId().replace(\'-\', \'_\'),\n
create_mapping_line=True,\n
create_mapping=True)\n
except ValueError:\n
pass\n
integration_site.Causality[context.getId().replace(\'-\', \'_\')].setDestinationReference(mapping_id)\n
\n
return context.PaymentTransaction_getPayzenId()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PaymentTransaction_generatePayzenId</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -50,39 +50,28 @@ ...@@ -50,39 +50,28 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>from DateTime import DateTime\n <value> <string>from zExceptions import Unauthorized\n
transaction = context\n if REQUEST is not None:\n
return None\n raise Unauthorized\n
\n \n
portal = transaction.getPortalObject()\n portal = context.getPortalObject()\n
integration_site = portal.restrictedTraverse(portal.portal_preferences.getPreferredPayzenIntegrationSite())\n integration_site = portal.restrictedTraverse(portal.portal_preferences.getPreferredPayzenIntegrationSite())\n
state_list = portal.getPortalCurrentInventoryStateList()\n
previous_transaction = portal.portal_catalog.getResultValue(\n
destination_section_uid = transaction.getDestinationSectionUid(),\n
portal_type=transaction.getPortalType(),\n
simulation_state=state_list,\n
sort_on=((\'delivery.start_date\', \'DESC\'),),\n
limit=1,\n
)\n
\n \n
if previous_transaction is None:\n payzen_id = integration_site.getCategoryFromMapping(\'Causality/%s\' % context.getId().replace(\'-\', \'_\'))\n
return None\n if payzen_id != \'causality/%s\' % context.getId().replace(\'-\', \'_\'):\n
\n date, payzen_id = payzen_id.split(\'_\', 1)\n
previous_id = None\n return DateTime(date).toZone(\'UTC\'), payzen_id\n
possible_previous_id = integration_site.getMappingFromCategory(\'causality/%s\' % previous_transaction.getRelativeUrl())\n else:\n
if possible_previous_id != \'Causality/%s\' % previous_transaction.getRelativeUrl():\n return None, None\n
previous_id = possible_previous_id.split(\'/\')[1]\n
\n
return previous_id\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string>REQUEST=None</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>PaymentTransaction_getPreviousPayzenId</string> </value> <value> <string>PaymentTransaction_getPayzenId</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
if (context.getPaymentMode() != \'payzen\'):\n
return\n
\n
portal = context.getPortalObject()\n
ticket = context.PaymentTransaction_addPayzenTicket()\n
\n
site_message = portal.event_module.newContent(\n
portal_type=\'Site Message\',\n
start_date=DateTime(),\n
destination_value=context.getDestinationSectionValue(),\n
follow_up=ticket.getRelativeUrl(),\n
source_value=context.getSourceSectionValue(),\n
# XXX Hardcoded script provided by another bt5\n
text_content=\'Please pay your payment by clicking <a \'\\\n
\'href="%s/PaymentTransaction_redirectToManualPayzenPayment">here</a>.\' % \\\n
context.getRelativeUrl(),\n
)\n
site_message.start(comment=\'Requested manual payment.\')\n
return site_message\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PaymentTransaction_sendManualPayzenPaymentUrl</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from DateTime import DateTime\n
portal = context.getPortalObject()\n
\n
state = context.getSimulationState()\n
if (state != \'confirmed\') or (context.getPaymentMode() != \'payzen\'):\n
return\n
else:\n
# Request manual payment\n
context.PaymentTransaction_sendManualPayzenPaymentUrl()\n
context.start(comment=\'Requested manual payment\')\n
\n
# raise NotImplementedError\n
# if context.PaymentTransaction_getPreviousPayzenId() is not None:\n
# # there is previous payment\n
# context.setStartDate(DateTime())\n
# context.updateCausalityState()\n
# portal.system_event_module.newContent(\n
# title=\'Transaction %s Payzen registration\' % context.getTitle(),\n
# portal_type=\'Payzen Event\',\n
# source_value=service,\n
# destination_value=context).registerPayzen()\n
# comment=\'Automatically duplicated in payzen.\'\n
# else:\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PaymentTransaction_startPayzenPayment</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -50,108 +50,25 @@ ...@@ -50,108 +50,25 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string>from DateTime import DateTime\n
from DateTime import DateTime\n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
service = None\n
\n
def addTicket(transaction):\n
portal = transaction.getPortalObject()\n
ticket = portal.portal_catalog.getResultValue(portal_type=\'Support Request\',\n
default_source_project_uid=transaction.getUid(),\n
validation_state=\'validated\')\n
tag = \'ticket_creation_%s\' % transaction.getUid()\n
activate_kw={\'tag\': tag}\n
if ticket is None and \\\n
portal.portal_activities.countMessageWithTag(tag) == 0:\n
ticket = portal.support_request_module.newContent(\n
portal_type=\'Support Request\',\n
source_project_uid=transaction.getUid(),\n
activate_kw=activate_kw)\n
ticket.validate(comment=\'New automatic ticket for %s\' % \\\n
transaction.getTitle())\n
return ticket\n
return None\n
\n
try:\n
service = portal.portal_secure_payments.find()\n
except ValueError, e:\n
portal.system_event_module.newContent(\n
title=\'Transaction %s cannot be updated, because of service error: %s\' % \\\n
(context.getTitle(), e), portal_type=\'Payzen Event\',\n
source_value=service, destination_value=context)\\\n
.confirm()\n
return\n
\n
def createRequestManualPaymentTicket(transaction):\n
# no previous payment\n
# shall create ticket + web message for user\n
portal = transaction.getPortalObject()\n
ticket = addTicket(context)\n
if ticket is not None:\n
tag = \'site_message_creation_%s\' % transaction.getUid()\n
activate_kw={\'tag\': tag}\n
site_message = portal.portal_catalog.getResultValue(\n
portal_type=\'Site Message\', default_follow_up_uid=ticket.getUid())\n
if site_message is None and \\\n
portal.portal_activities.countMessageWithTag(tag) == 0:\n
site_message = portal.event_module.newContent(\n
portal_type=\'Site Message\',\n
start_date=DateTime(),\n
destination_uid=transaction.getDestinationSectionUid(),\n
follow_up=ticket.getRelativeUrl(),\n
source_uid=transaction.getSourceSectionUid(),\n
text_content=\'Please pay your payment by clicking <a \'\\\n
\'href="%s/AccountingTransaction_startPayment">here</a>.\' % \\\n
transaction.getRelativeUrl(),\n
activate_kw=activate_kw)\n
site_message.start(comment=\'Requested manual payment.\')\n
\n \n
state = context.getSimulationState()\n state = context.getSimulationState()\n
if state == \'confirmed\':\n if (state != \'started\') or (context.getPaymentMode() != \'payzen\'):\n
if context.PaymentTransaction_getPreviousPayzenId() is not None:\n return\n
# there is previous payment\n else:\n
context.setStartDate(DateTime())\n transaction_date, transaction_id = context.PaymentTransaction_getPayzenId()\n
context.updateCausalityState()\n
portal.system_event_module.newContent(\n
title=\'Transaction %s Payzen registration\' % context.getTitle(),\n
portal_type=\'Payzen Event\',\n
source_value=service,\n
destination_value=context).registerPayzen()\n
comment=\'Automatically duplicated in payzen.\'\n
else:\n
createRequestManualPaymentTicket(context)\n
comment=\'Requested manual payment\'\n
context.start(comment=comment)\n
\n
elif state == \'started\':\n
transaction_id = portal.restrictedTraverse(\n
portal.portal_preferences.getPreferredPayzenIntegrationSite()\n
).getMappingFromCategory(\'causality/%s\' % context.getRelativeUrl())\n
if transaction_id != \'Causality/%s\' % context.getRelativeUrl():\n
transaction_id = transaction_id.split(\'/\')[1]\n
else:\n
transaction_id = None\n
\n \n
if transaction_id is None:\n if transaction_id is None:\n
# inform administrators\n # inform administrators\n
addTicket(context)\n context.PaymentTransaction_addPayzenTicket()\n
else:\n else:\n
# so the payment is registered in payzen\n # so the payment is registered in payzen\n
portal.system_event_module.newContent(\n context.PaymentTransaction_createPayzenEvent().updateStatus()\n
title=\'Transaction %s Payzen status update\' % context.getTitle(),\n
portal_type=\'Payzen Event\',\n
source_value=service,\n
destination_value=context).updateStatus()\n
if context.getSimulationState() != \'stopped\':\n if context.getSimulationState() != \'stopped\':\n
# not paid yet and shall be, lets open ticket\n # not paid yet and shall be, lets open ticket\n
addTicket(context)\n context.PaymentTransaction_addPayzenTicket()\n
else:\n </string> </value>
raise NotImplementedError(\'State %s is not supported\' % state)\n
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
......
...@@ -50,46 +50,50 @@ ...@@ -50,46 +50,50 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>def storeWorkflowComment(ctx, comment):\n <value> <string>from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
def storeWorkflowComment(ctx, comment):\n
portal = ctx.getPortalObject()\n portal = ctx.getPortalObject()\n
workflow_tool = portal.portal_workflow\n workflow_tool = portal.portal_workflow\n
workflow_tool.doActionFor(ctx, \'edit_action\', comment=comment)\n workflow_tool.doActionFor(ctx, \'edit_action\', comment=comment)\n
\n \n
payzen_event = state_change[\'object\']\n payzen_event = context\n
transaction = payzen_event.getDestinationValue()\n transaction = payzen_event.getDestinationValue()\n
portal = transaction.getPortalObject()\n portal = transaction.getPortalObject()\n
\n \n
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n assert signature in (True, False)\n
if signature is not True:\n if signature is False:\n
# signature is wrong, bye bye\n # signature is wrong, bye bye\n
payzen_event.confirm(comment=\'Signature does not match\')\n payzen_event.confirm(comment=\'Signature does not match\')\n
return\n return\n
\n \n
transaction_code_mapping = {\n transaction_code_mapping = {\n
\'0\' : \'Initial (being treated)\',\n \'0\': \'Initial (being treated)\',\n
\'1\' : \'To be validated \',\n \'1\': \'To be validated \',\n
\'2\' : \'To be forced - Contact issuer\',\n \'2\': \'To be forced - Contact issuer\',\n
\'3\' : \'To be validated and authorized\',\n \'3\': \'To be validated and authorized\',\n
\'4\' : \'Waiting for submission\',\n \'4\': \'Waiting for submission\',\n
\'5\' : \'Waiting for authorization\',\n \'5\': \'Waiting for authorization\',\n
\'6\' : \'Submitted\',\n \'6\': \'Submitted\',\n
\'7\' : \'Expired\',\n \'7\': \'Expired\',\n
\'8\' : \'Refused\',\n \'8\': \'Refused\',\n
\'9\' : \'Cancelled\',\n \'9\': \'Cancelled\',\n
\'10\': \'Waiting\',\n \'10\': \'Waiting\',\n
\'11\': \'Being submitted\',\n \'11\': \'Being submitted\',\n
\'12\': \'Being authorized\',\n \'12\': \'Being authorized\',\n
\'13\': \'Failed\',\n \'13\': \'Failed\',\n
}\n }\n
mark_transaction_id_list = [\'0\', \'1\', \'3\', \'4\', \'5\', \'10\', \'11\', \'12\']\n
continue_transaction_id_list = [\'6\']\n
\n \n
transaction_status = data_kw[\'transactionStatus\']\n transaction_status = data_kw[\'transactionStatus\']\n
\n
transaction_status_description = transaction_code_mapping.get(transaction_status, None)\n transaction_status_description = transaction_code_mapping.get(transaction_status, None)\n
if transaction_status_description is None:\n if transaction_status_description is None:\n
payzen_event.confirm(comment=\'Unknown transactionStatus %r\' % transaction_status)\n payzen_event.confirm(comment=\'Unknown transactionStatus %r\' % transaction_status)\n
return\n return\n
integration_tool = portal.restrictedTraverse(portal.portal_preferences.getPreferredPayzenIntegrationSite())\n
mark_transaction_id_list = [\'0\', \'1\', \'3\', \'4\', \'5\', \'10\', \'11\', \'12\']\n
continue_transaction_id_list = [\'6\']\n
\n \n
isTransitionPossible = context.getPortalObject().portal_workflow.isTransitionPossible\n isTransitionPossible = context.getPortalObject().portal_workflow.isTransitionPossible\n
doActionFor = context.getPortalObject().portal_workflow.doActionFor\n doActionFor = context.getPortalObject().portal_workflow.doActionFor\n
...@@ -99,38 +103,47 @@ if transaction_status in mark_transaction_id_list:\n ...@@ -99,38 +103,47 @@ if transaction_status in mark_transaction_id_list:\n
storeWorkflowComment(transaction, \'Transaction status %s (%s) did not changed the document state\' % (transaction_status, transaction_status_description))\n storeWorkflowComment(transaction, \'Transaction status %s (%s) did not changed the document state\' % (transaction_status, transaction_status_description))\n
payzen_event.confirm()\n payzen_event.confirm()\n
payzen_event.acknowledge(comment=\'Automatic acknowledge as result of correct communication\')\n payzen_event.acknowledge(comment=\'Automatic acknowledge as result of correct communication\')\n
if isTransitionPossible(transaction, \'confirm_action\'):\n if isTransitionPossible(transaction, \'confirm\'):\n
doActionFor(transaction, \'confirm_action\', comment=\'Confirmed as really saw in PayZen.\')\n transaction.confirm(comment=\'Confirmed as really saw in PayZen.\')\n
\n \n
elif transaction_status in continue_transaction_id_list:\n elif transaction_status in continue_transaction_id_list:\n
# Check authAmount and authDevise and if match, stop transaction\n # Check authAmount and authDevise and if match, stop transaction\n
auth_amount = int(data_kw[\'authAmount\'])\n auth_amount = int(data_kw[\'authAmount\'])\n
auth_devise = data_kw[\'authDevise\']\n auth_devise = data_kw[\'authDevise\']\n
transaction_amount = int(round((transaction.PaymentTransaction_getTotalPayablePrice() * -100), 2))\n transaction_amount = int(round((transaction.PaymentTransaction_getTotalPayablePrice() * -100), 2))\n
\n
if transaction_amount != auth_amount:\n if transaction_amount != auth_amount:\n
payzen_event.confirm(comment=\'Received amount (%r) does not match stored on transaction (%r)\'% (auth_amount, transaction_amount))\n payzen_event.confirm(comment=\'Received amount (%r) does not match stored on transaction (%r)\'% (auth_amount, transaction_amount))\n
return\n return\n
\n
transaction_devise = transaction.getResourceValue().Currency_getIntegrationMapping()\n transaction_devise = transaction.getResourceValue().Currency_getIntegrationMapping()\n
if transaction_devise != auth_devise:\n if transaction_devise != auth_devise:\n
payzen_event.confirm(comment=\'Received devise (%r) does not match stored on transaction (%r)\'% (auth_devise, transaction_devise))\n payzen_event.confirm(comment=\'Received devise (%r) does not match stored on transaction (%r)\'% (auth_devise, transaction_devise))\n
return\n return\n
\n
comment = \'PayZen considered as paid.\'\n comment = \'PayZen considered as paid.\'\n
for action in (\'confirm_action\', \'start_action\', \'stop_action\'):\n if isTransitionPossible(transaction, \'confirm\'):\n
if isTransitionPossible(transaction, action):\n transaction.confirm(comment=comment)\n
doActionFor(transaction, action, comment=comment)\n if isTransitionPossible(transaction, \'start\'):\n
transaction.start(comment=comment)\n
if isTransitionPossible(transaction, \'stop\'):\n
transaction.stop(comment=comment)\n
\n
if transaction.getSimulationState() == \'stopped\':\n if transaction.getSimulationState() == \'stopped\':\n
payzen_event.confirm()\n payzen_event.confirm()\n
payzen_event.acknowledge(comment=\'Automatic acknowledge as result of correct communication\')\n payzen_event.acknowledge(comment=\'Automatic acknowledge as result of correct communication\')\n
else:\n else:\n
payzen_event.confirm(comment=\'Expected to put transaction in stopped state, but achieved only %s state\' % transaction.getSimulationState())\n payzen_event.confirm(comment=\'Expected to put transaction in stopped state, but achieved only %s state\' % transaction.getSimulationState())\n
\n
else:\n else:\n
payzen_event.confirm(comment=\'Transaction status %r (%r) is not supported\' % (transaction_status, transaction_status_description))\n payzen_event.confirm(comment=\'Transaction status %r (%r) is not supported\' \\\n
% (transaction_status, transaction_status_description))\n
return\n return\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>state_change, data_kw, signature</string> </value> <value> <string>data_kw, signature, REQUEST=None</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -94,6 +94,7 @@ ...@@ -94,6 +94,7 @@
<value> <value>
<list> <list>
<string>my_preferred_payzen_integration_site</string> <string>my_preferred_payzen_integration_site</string>
<string>my_preferred_payzen_payment_service_reference</string>
</list> </list>
</value> </value>
</item> </item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>items</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_preferred_payzen_payment_service_reference</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_category</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Preferred PayZen Payment Service</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: [(\'\', \'\')] + [(x.getTitle(), x.getReference()) for x in here.portal_catalog(portal_type=\'Payzen Service\', sort_on=((\'title\', \'ASC\'),),checked_permission=\'View\')]</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from DateTime import DateTime\n
payzen_event = state_change[\'object\']\n
\n
# Get required arguments\n
kwargs = state_change.kwargs\n
\n
# Required args\n
# Raise TypeError if all parameters are not provided\n
try:\n
vads_url_cancel = kwargs[\'vads_url_cancel\']\n
vads_url_error = kwargs[\'vads_url_error\']\n
vads_url_referral = kwargs[\'vads_url_referral\']\n
vads_url_refused = kwargs[\'vads_url_refused\']\n
vads_url_success = kwargs[\'vads_url_success\']\n
vads_url_return = kwargs[\'vads_url_return\']\n
except KeyError:\n
raise TypeError, "PayzenEvent_generateNavigationPage takes exactly 6 arguments"\n
\n
payment_transaction = payzen_event.getDestinationValue(portal_type="Payment Transaction")\n
now = DateTime()\n
payment_transaction.AccountingTransaction_updateStartDate(now)\n
\n
transaction_date, transaction_id = payment_transaction.PaymentTransaction_generatePayzenId()\n
if transaction_id is None:\n
raise ValueError, "Transaction already registered"\n
\n
payzen_event.confirm()\n
payzen_event.acknowledge(comment=\'Automatic acknowledge as result of correct communication\')\n
\n
today = now.toZone(\'UTC\').asdatetime().strftime(\'%Y%m%d\')\n
payzen_dict = {\n
\'vads_currency\': payment_transaction.getResourceValue().Currency_getIntegrationMapping(),\n
\'vads_amount\': str(int(round((payment_transaction.PaymentTransaction_getTotalPayablePrice() * -100), 0))),\n
\'vads_trans_date\': now.toZone(\'UTC\').asdatetime().strftime(\'%Y%m%d%H%M%S\'),\n
\'vads_trans_id\': transaction_id,\n
\'vads_language\': \'en\',\n
\'vads_url_cancel\': vads_url_cancel,\n
\'vads_url_error\': vads_url_error,\n
\'vads_url_referral\': vads_url_referral,\n
\'vads_url_refused\': vads_url_refused,\n
\'vads_url_success\': vads_url_success,\n
\'vads_url_return\': vads_url_return,\n
}\n
\n
payment_service = payzen_event.getSourceValue(portal_type="Payzen Service")\n
html_document = payment_service.navigate(\n
page_template=\'payzen_payment\',\n
pay=\'Click to pay\',\n
payzen_dict=payzen_dict,\n
)\n
payzen_event.newContent(\n
title=\'Shown Page\',\n
portal_type=\'Payzen Event Message\',\n
text_content=html_document,\n
)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PayzenEvent_generateNavigationPage</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -55,13 +55,10 @@ ...@@ -55,13 +55,10 @@
In order to not transmit sensitive information the registration is done by looking the newest\n In order to not transmit sensitive information the registration is done by looking the newest\n
payzen related transaction for destination_section and doing its duplicate"""\n payzen related transaction for destination_section and doing its duplicate"""\n
\n \n
raise NotImplementedError\n
\n
from DateTime import DateTime\n from DateTime import DateTime\n
payzen_event = state_change[\'object\']\n payzen_event = state_change[\'object\']\n
transaction = payzen_event.getDestinationValue()\n transaction = payzen_event.getDestinationValue()\n
portal = transaction.getPortalObject()\n portal = transaction.getPortalObject()\n
integration_site = portal.restrictedTraverse(portal.portal_preferences.getPreferredPayzenIntegrationSite())\n
service = portal.portal_secure_payments.find()\n service = portal.portal_secure_payments.find()\n
\n \n
previous_id = transaction.PaymentTransaction_getPreviousPayzenId()\n previous_id = transaction.PaymentTransaction_getPreviousPayzenId()\n
...@@ -69,25 +66,10 @@ if previous_id is None:\n ...@@ -69,25 +66,10 @@ if previous_id is None:\n
payzen_event.confirm(comment=\'No previous id found\')\n payzen_event.confirm(comment=\'No previous id found\')\n
return\n return\n
\n \n
previous_date, previous_id = previous_id.split(\'_\')\n transaction_date, transaction_id = transaction.PaymentTransaction_generatePayzenId()\n
today = DateTime().toZone(\'UTC\').asdatetime().strftime(\'%Y%m%d\')\n if transaction_id is None:\n
transaction_id = str(portal.portal_ids.generateNewId(\n
id_group=\'%s_%s\' % (service.getRelativeUrl(), today),\n
id_generator=\'uid\')).zfill(6)\n
\n
mapping_id = \'%s_%s\' % (today, transaction_id)\n
\n
if not integration_site.getMappingFromCategory(\'causality/%s\' % transaction.getRelativeUrl()) == \'Causality/%s\' % transaction.getRelativeUrl():\n
raise ValueError(\'Transaction already mapped in integration tool.\')\n raise ValueError(\'Transaction already mapped in integration tool.\')\n
\n \n
try:\n
integration_site.getCategoryFromMapping(\'Causality/%s\' % mapping_id, create_mapping_line=True, create_mapping=True)\n
except ValueError:\n
mapping = integration_site.Causality[mapping_id]\n
mapping.setDestinationReference(\'causality/%s\' % transaction.getRelativeUrl())\n
else:\n
raise ValueError(\'Key %s already found.\' % mapping_id)\n
\n
# do causality mapping in integration_site between transaction.getRelativeUrl and today + transaction_id\n # do causality mapping in integration_site between transaction.getRelativeUrl and today + transaction_id\n
payzen_dict = {}\n payzen_dict = {}\n
payzen_dict.update(\n payzen_dict.update(\n
...@@ -95,7 +77,7 @@ payzen_dict.update(\n ...@@ -95,7 +77,7 @@ payzen_dict.update(\n
amount=str(int(round((transaction.PaymentTransaction_getTotalPayablePrice() * -100), 0))),\n amount=str(int(round((transaction.PaymentTransaction_getTotalPayablePrice() * -100), 0))),\n
presentationDate=transaction.getStartDate().toZone(\'UTC\').asdatetime(),\n presentationDate=transaction.getStartDate().toZone(\'UTC\').asdatetime(),\n
newTransactionId=transaction_id,\n newTransactionId=transaction_id,\n
transmissionDate=DateTime(previous_date).toZone(\'UTC\').asdatetime(),\n transmissionDate=transaction_date.asdatetime(),\n
transactionId=previous_id\n transactionId=previous_id\n
)\n )\n
\n \n
......
...@@ -50,24 +50,29 @@ ...@@ -50,24 +50,29 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>raise NotImplementedError\n <value> <string>payzen_event = state_change[\'object\']\n
\n payment_transaction = payzen_event.getDestinationValue(portal_type="Payment Transaction")\n
payzen_event = state_change[\'object\']\n
payment_transaction = payzen_event.getDestinationValue()\n
portal = payment_transaction.getPortalObject()\n portal = payment_transaction.getPortalObject()\n
service = portal.portal_secure_payments.find()\n
integration_tool = portal.restrictedTraverse(portal.portal_preferences.getPreferredPayzenIntegrationSite())\n
\n \n
transaction_id = integration_tool.getMappingFromCategory(\'causality/%s\' % payment_transaction.getRelativeUrl())\n transaction_date, transaction_id = payment_transaction.PaymentTransaction_getPayzenId()\n
if transaction_id == \'Causality/%s\' % payment_transaction.getRelativeUrl():\n if transaction_id is None:\n
raise ValueError(\'Transaction not registered in payzen integration tool\')\n raise ValueError(\'Transaction not registered in payzen integration tool\')\n
transaction_id = transaction_id.split(\'/\')[1]\n
transmissionDate, transactionId = transaction_id.split(\'_\')\n
\n \n
data_kw, signature, sent_text, received_text = service.soap_getInfo(DateTime(transmissionDate).toZone(\'UTC\').asdatetime(), transactionId)\n payment_service = payzen_event.getSourceValue(portal_type="Payzen Service")\n
sent = payzen_event.newContent(title=\'Sent SOAP\', portal_type=\'Payzen Event Message\', text_content=sent_text)\n data_kw, signature, sent_text, received_text = payment_service.soap_getInfo(\n
received = payzen_event.newContent(title=\'Received SOAP\', portal_type=\'Payzen Event Message\', text_content=received_text, predecessor_value=sent)\n transaction_date.toZone(\'UTC\').asdatetime(),\n
context.PayzenEvent_processUpdate(state_change, data_kw, signature)\n transaction_id)\n
\n
sent = payzen_event.newContent(\n
title=\'Sent SOAP\', \n
portal_type=\'Payzen Event Message\', \n
text_content=sent_text)\n
received = payzen_event.newContent(\n
title=\'Received SOAP\', \n
portal_type=\'Payzen Event Message\', \n
text_content=received_text, \n
predecessor_value=sent)\n
payzen_event.PayzenEvent_processUpdate(data_kw, signature)\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
...@@ -22,10 +22,7 @@ ...@@ -22,10 +22,7 @@
<key> <string>transitions</string> </key> <key> <string>transitions</string> </key>
<value> <value>
<tuple> <tuple>
<string>register_payzen</string> <string>generate_manual_payment_page</string>
<string>report_error</string>
<string>report_success</string>
<string>start_payment</string>
<string>update_status</string> <string>update_status</string>
</tuple> </tuple>
</value> </value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="TransitionDefinition" module="Products.DCWorkflow.Transitions"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string>PayzenEvent_generateNavigationPage</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>generate_manual_payment_page</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -2,3 +2,4 @@ slapos_accounting ...@@ -2,3 +2,4 @@ slapos_accounting
erp5_tiosafe_core erp5_tiosafe_core
erp5_system_event erp5_system_event
erp5_payzen_secure_payment erp5_payzen_secure_payment
erp5_crm
\ No newline at end of file
87 88
\ No newline at end of file \ No newline at end of file
...@@ -4,6 +4,7 @@ portal_integrations/slapos_payzen_test_integration ...@@ -4,6 +4,7 @@ portal_integrations/slapos_payzen_test_integration
portal_integrations/slapos_payzen_test_integration/Causality portal_integrations/slapos_payzen_test_integration/Causality
portal_integrations/slapos_payzen_test_integration/Resource portal_integrations/slapos_payzen_test_integration/Resource
portal_integrations/slapos_payzen_test_integration/Resource/** portal_integrations/slapos_payzen_test_integration/Resource/**
portal_integrations/slapos_payzen_test_integration/SourceProject
portal_secure_payments/slapos_payzen_test portal_secure_payments/slapos_payzen_test
portal_secure_payments/slapos_payzen_test/** portal_secure_payments/slapos_payzen_test/**
sale_trade_condition_module/payzen_sale_trade_condition sale_trade_condition_module/payzen_sale_trade_condition
\ No newline at end of file
testSlapOSPayzenSkins testSlapOSPayzenSkins
testSlapOSPayzenAlarm
testSlapOSPayzenWorkflow
\ No newline at end of file
...@@ -52,72 +52,30 @@ ...@@ -52,72 +52,30 @@
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string># TODO: Return configured web page in case of system issues.\n <value> <string># TODO: Return configured web page in case of system issues.\n
from ZTUtils import make_query\n from ZTUtils import make_query\n
from DateTime import DateTime\n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
service = portal.portal_secure_payments.find()\n
integration_site = portal.restrictedTraverse(portal.portal_preferences.getPreferredPayzenIntegrationSite())\n
\n \n
now = DateTime()\n transaction_date, transaction_id = payment.PaymentTransaction_getPayzenId()\n
today = now.toZone(\'UTC\').asdatetime().strftime(\'%Y%m%d\')\n if transaction_id is not None:\n
current_today = today\n
transaction_id = None\n
current_id = None\n
if integration_site.getMappingFromCategory(\'causality/%s\' % context.getRelativeUrl()) != \'Causality/%s\' % context.getRelativeUrl():\n
current_id = integration_site.getMappingFromCategory(\'causality/%s\' % context.getRelativeUrl())\n
current_today, transaction_id = current_id.split(\'_\')\n
\n
if current_id is not None:\n
message = context.Base_translateString("Payment already registered.")\n message = context.Base_translateString("Payment already registered.")\n
return context.getWebSiteValue().Base_redirect(keep_items={\'portal_status_message\': message})\n return context.getWebSiteValue().Base_redirect(keep_items={\'portal_status_message\': message})\n
\n \n
system_event_kw = {\n callback_websection = context.getWebSiteValue().payzen_callback\n
\'portal_type\': \'Payzen Event\',\n
\'source_value\': service,\n
\'destination_value\': context,\n
}\n
system_event = portal.system_event_module.newContent(title=\'User navigation script for %s\' % context.getTitle(), **system_event_kw)\n
\n
transaction_id = str(portal.portal_ids.generateNewId(\n
id_group=\'%s_%s\' % (service.getRelativeUrl(), today),\n
id_generator=\'uid\')).zfill(6)\n
\n
mapping_id = \'%s_%s\' % (today, transaction_id)\n
try:\n
integration_site.getCategoryFromMapping(\'Causality/%s\' % mapping_id, create_mapping_line=True, create_mapping=True)\n
except ValueError:\n
mapping = integration_site.Causality[mapping_id]\n
mapping.setDestinationReference(\'causality/%s\' % context.getRelativeUrl())\n
if current_today != today:\n
# Cleanup as integration site does not support multiple mappings to with external site\n
integration_site.Causality.deleteContent(current_id.split(\'/\')[1])\n
else:\n
system_event.confirm(comment=\'Key %s already found!\' % mapping_id)\n
return \'There was system issue\'\n
\n
\n
context.AccountingTransaction_updateStartDate(now)\n
context.updateCausalityState()\n
callback = context.getWebSiteValue().payzen_callback\n
query = make_query(dict(transaction=context.getRelativeUrl()))\n query = make_query(dict(transaction=context.getRelativeUrl()))\n
payzen_dict = {}\n \n
payzen_dict.update(\n system_event = context.PaymentTransaction_createPayzenEvent(\n
vads_currency=integration_site.getMappingFromCategory(\'resource/currency_module/%s\' % context.getResourceReference()).split(\'/\')[-1],\n title=\'User navigation script for %s\' % context.getTitle()\n
vads_amount=str(int(round((context.PaymentTransaction_getTotalPayablePrice() * -100), 0))),\n
vads_trans_date=now.toZone(\'UTC\').asdatetime().strftime(\'%Y%m%d%H%M%S\'),\n
vads_trans_id=transaction_id,\n
vads_language=\'en\',\n
vads_url_cancel=callback.cancel.absolute_url() + \'?\' + query,\n
vads_url_error=callback.error.absolute_url() + \'?\' + query,\n
vads_url_referral=callback.referral.absolute_url() + \'?\' + query,\n
vads_url_refused=callback.refused.absolute_url() + \'?\' + query,\n
vads_url_success=callback.success.absolute_url() + \'?\' + query,\n
vads_url_return=getattr(callback, \'return\').absolute_url() + \'?\' + query\n
)\n )\n
system_event.confirm()\n system_event.generateManualPaymentPage(\n
result = service.navigate(page_template=\'payzen_payment\', pay=\'Click to pay\', payzen_dict=payzen_dict)\n vads_url_cancel=\'%s?%s\' % (callback_websection.cancel.absolute_url(), query),\n
system_event.newContent(title=\'Shown Page\', portal_type=\'Payzen Event Message\', text_content=result)\n vads_url_error=\'%s?%s\' % (callback_websection.error.absolute_url(), query),\n
system_event.acknowledge(comment=\'Automatic acknowledge as result of correct communication\')\n vads_url_referral=\'%s?%s\' % (callback_websection.referral.absolute_url(), query),\n
return result\n vads_url_refused=\'%s?%s\' % (callback_websection.refused.absolute_url(), query),\n
vads_url_success=\'%s?%s\' % (callback_websection.success.absolute_url(), query),\n
vads_url_return=\'%s?%s\' % (getattr(callback_websection, \'return\').absolute_url(), query),\n
)\n
\n
return system_event.contentValues(\n
portal_type="Payzen Event Message")[0].getTextContent()\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -126,7 +84,7 @@ return result\n ...@@ -126,7 +84,7 @@ return result\n
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>AccountingTransaction_startPayment</string> </value> <value> <string>PaymentTransaction_redirectToManualPayzenPayment</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
8 9
\ 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