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

Improve PayZen logic. (WIP, compatibility break)

As stopped and delivered states are used in accounting reports, reuse started
state on Payment Transaction as confirmation, that PayZen was able to register
it.

Confirmed state means that user went to PayZen website, but it is not known if
anything happened.

Planned state means that transaction was not even tried to be registered in payzen.

Stopped means, that PayZen confirmed payment.
parent 8ff22d0f
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<key> <string>active_sense_method_id</string> </key>
<value> <string>Alarm_updatePayzenConfirmedPaymentTransaction</string> </value>
<value> <string>Alarm_updatePayzenConfirmedStartedPaymentTransaction</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -22,7 +22,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>payzen_update_confirmed_payment_transaction</string> </value>
<value> <string>payzen_update_confirmed_started_payment_transaction</string> </value>
</item>
<item>
<key> <string>periodicity_hour</string> </key>
......@@ -89,7 +89,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Update status of confirmed Payment Transaction related with PayZen</string> </value>
<value> <string>Update status of confirmed/started Payment Transaction related with PayZen</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -53,7 +53,7 @@
<value> <string>portal = context.getPortalObject()\n
portal.portal_catalog.searchAndActivate(\n
portal_type="Payment Transaction", \n
simulation_state="confirmed",\n
simulation_state=["confirmed", "started"],\n
method_id=\'PaymentTransaction_updateStatus\',\n
packet_size=1, # just one to minimise errors\n
activate_kw={\'tag\': tag}\n
......@@ -67,7 +67,7 @@ context.activate(after_tag=tag).getId()\n
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_updatePayzenConfirmedPaymentTransaction</string> </value>
<value> <string>Alarm_updatePayzenConfirmedStartedPaymentTransaction</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>context.getPortalObject().portal_workflow.doActionFor(context, \'confirm_action\', comment=\'Transaction being registered in Payzen\')\n
<value> <string>context.getPortalObject().portal_workflow.doActionFor(context, \'confirm_action\', comment=\'Transaction waiting for update from PayZen\')\n
</string> </value>
</item>
<item>
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>context.getPortalObject().portal_workflow.doActionFor(context, \'start_action\', comment=\'Started automatically on Payzen Update\')\n
<value> <string>context.getPortalObject().portal_workflow.doActionFor(context, \'start_action\', comment=\'Transaction confirmed to exists on PayZen side\')\n
</string> </value>
</item>
<item>
......
<?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, \'start_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>
......@@ -51,7 +51,7 @@
<item>
<key> <string>_body</string> </key>
<value> <string>portal = context.getPortalObject()\n
if context.getSimulationState() != \'confirmed\':\n
if context.getSimulationState() not in [\'confirmed\', \'started\']:\n
return\n
service = portal.portal_secure_payments.find()\n
portal.system_event_module.newContent(title=\'Transaction %s Payzen status update\' % context.getTitle(), portal_type=\'Payzen Event\', source_value=service, destination_value=context).updateStatus()\n
......
......@@ -97,7 +97,9 @@ if transaction_status in mark_transaction_id_list:\n
payzen_event.confirm()\n
payzen_event.acknowledge(comment=\'Automatic acknowledge as result of correct communication\')\n
if transaction.getSimulationState() == \'planned\':\n
transaction.PaymentTransaction_confirm()\n
transaction.confirm()\n
if transaction.getSimulationState() == \'confirmed\':\n
transaction.PaymentTransaction_start()\n
\n
elif transaction_status in continue_transaction_id_list:\n
# Check authAmount and authDevise and if match, start transaction\n
......@@ -111,7 +113,9 @@ elif transaction_status in continue_transaction_id_list:\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
return\n
transaction.PaymentTransaction_start()\n
if transaction.getSimulationState() == \'planned\':\n
transaction.confirm()\n
transaction.PaymentTransaction_stop()\n
payzen_event.confirm()\n
payzen_event.acknowledge(comment=\'Automatic acknowledge as result of correct communication\')\n
else:\n
......
58
\ No newline at end of file
59
\ No newline at end of file
portal_alarms/payzen_update_confirmed_payment_transaction
portal_alarms/payzen_update_confirmed_started_payment_transaction
portal_alarms/register_planned_payment_transaction_payzen
\ 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