Commit 0bc9bafa authored by Łukasz Nowak's avatar Łukasz Nowak

Simplify status synchronisation.

Do all transitions, keep comments and inform in event in case when expected
state is not reached.
parent 37ba2f58
<?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>context.getPortalObject().portal_workflow.doActionFor(context, \'confirm_action\', comment=\'Transaction synchronised with PayZen\')\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PaymentTransaction_confirm</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>portal_workflow = context.getPortalObject().portal_workflow\n
if portal_workflow.isTransitionPossible(context, \'stopAction\'):\n
portal_workflow.doActionFor(context, \'stop_action\', comment=\'Transaction considered as paid by PayZen\')\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PaymentTransaction_stop</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -91,13 +91,16 @@ integration_tool = portal.restrictedTraverse(portal.portal_preferences.getPrefer ...@@ -91,13 +91,16 @@ integration_tool = portal.restrictedTraverse(portal.portal_preferences.getPrefer
mark_transaction_id_list = [\'0\', \'1\', \'3\', \'4\', \'5\', \'10\', \'11\', \'12\']\n mark_transaction_id_list = [\'0\', \'1\', \'3\', \'4\', \'5\', \'10\', \'11\', \'12\']\n
continue_transaction_id_list = [\'6\']\n continue_transaction_id_list = [\'6\']\n
\n \n
isTransitionPossible = context.getPortalObject().portal_workflow.isTransitionPossible\n
doActionFor = context.getPortalObject().portal_workflow.doActionFor\n
\n
if transaction_status in mark_transaction_id_list:\n if transaction_status in mark_transaction_id_list:\n
# Mark on payment transaction history log that transaction was not processed yet\n # Mark on payment transaction history log that transaction was not processed yet\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 transaction.getSimulationState() == \'planned\':\n if isTransitionPossible(transaction, \'confirm_action\'):\n
transaction.confirm()\n doActionFor(transaction, \'confirm_action\', 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
...@@ -111,11 +114,15 @@ elif transaction_status in continue_transaction_id_list:\n ...@@ -111,11 +114,15 @@ elif transaction_status in continue_transaction_id_list:\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
if transaction.getSimulationState() == \'planned\':\n comment = \'PayZen considered as paid.\'\n
transaction.confirm()\n for action in (\'confirm_action\', \'start_action\', \'stop_action\'):\n
transaction.PaymentTransaction_stop()\n if isTransitionPossible(transaction, action):\n
payzen_event.confirm()\n doActionFor(transaction, action, comment=comment)\n
payzen_event.acknowledge(comment=\'Automatic acknowledge as result of correct communication\')\n if transaction.getSimulationState() == \'stopped\':\n
payzen_event.confirm()\n
payzen_event.acknowledge(comment=\'Automatic acknowledge as result of correct communication\')\n
else:\n
payzen_event.confirm(comment=\'Expected to put transaction in stopped state, but achieved only %s state\' % transaction.getSimulationState())\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\' % (transaction_status, transaction_status_description))\n
return\n return\n
......
66 67
\ 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