Commit a6425473 authored by Łukasz Nowak's avatar Łukasz Nowak

Support planned transactions for user which paid something.

parent 57028e7f
<?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
transaction = context\n
portal = transaction.getPortalObject()\n
integration_site = portal.restrictedTraverse(portal.portal_preferences.getPreferredPayzenIntegrationSite())\n
state_list = portal.getPortalCurrentInventoryStateList() + portal.getPortalTransitInventoryStateList()\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
if previous_transaction is None:\n
return None\n
\n
previous_id = None\n
possible_previous_id = integration_site.getMappingFromCategory(\'causality/%s\' % previous_transaction.getRelativeUrl())\n
if possible_previous_id != \'Causality/%s\' % transaction.getRelativeUrl():\n
previous_id = possible_previous_id.split(\'/\')[1]\n
\n
return previous_id\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PaymentTransaction_getPreviousPayzenId</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -60,26 +60,11 @@ payzen_event = state_change[\'object\']\n
transaction = payzen_event.getDestinationValue()\n
portal = transaction.getPortalObject()\n
integration_site = portal.restrictedTraverse(portal.portal_preferences.getPreferredPayzenIntegrationSite())\n
state_list = portal.getPortalCurrentInventoryStateList() + portal.getPortalTransitInventoryStateList()\n
service = portal.portal_secure_payments.find()\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
if previous_transaction is None:\n
raise ValueError(\'It was not possible to find any previous transaction\')\n
\n
previous_id = None\n
possible_previous_id = integration_site.getMappingFromCategory(\'causality/%s\' % previous_transaction.getRelativeUrl())\n
if possible_previous_id != \'Causality/%s\' % transaction.getRelativeUrl():\n
previous_id = possible_previous_id.split(\'/\')[1]\n
\n
previous_id = transaction.PaymentTransaction_getPreviousPayzenId()\n
if previous_id is None:\n
raise ValueError(\'Transaction %s had not defined payzen integration\' % previous_transaction.getRelativeUrl())\n
raise ValueError(\'No previous id found\')\n
\n
previous_date, previous_id = previous_id.split(\'_\')\n
today = DateTime().toZone(\'UTC\').asdatetime().strftime(\'%Y%m%d\')\n
......
60
\ No newline at end of file
61
\ No newline at end of file
......@@ -53,6 +53,16 @@
<value> <string># TODO: Return configured web page in case of system issues.\n
from DateTime import DateTime\n
portal = context.getPortalObject()\n
\n
previous_id = context.PaymentTransaction_getPreviousPayzenId()\n
if context.getSimulationState() == \'planned\' and previous_id is not None:\n
# och, it was possible to register this transaction\n
context.PaymentTransaction_registerPayzen()\n
message = context.Base_translateString("Payment was automatically registered to PayZen system.")\n
return context.getWebSiteValue().Base_redirect(keep_items={\'portal_status_message\': message})\n
\n
# XXX: Support confirmed state similary\n
\n
service = portal.portal_secure_payments.find()\n
integration_site = portal.restrictedTraverse(portal.portal_preferences.getPreferredPayzenIntegrationSite())\n
system_event_kw = {\n
......
363
\ No newline at end of file
364
\ 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