Commit 6469e339 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_payzen: Process alarm more often for resently created Payments

If the payment is recently created (in the latest 30 min) process it every minute, if it is older them 30 min, process every 30 min.

We want to acknowledge the payment as fast as possible and usually when it occurs, it is processed on the first minutes.
parent 973cf9f0
......@@ -10,6 +10,10 @@
<key> <string>active_sense_method_id</string> </key>
<value> <string>Alarm_updatePayzenStartedPaymentTransaction</string> </value>
</item>
<item>
<key> <string>automatic_solve</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
......@@ -32,7 +36,9 @@
</item>
<item>
<key> <string>periodicity_hour_frequency</string> </key>
<value> <int>1</int> </value>
<value>
<none/>
</value>
</item>
<item>
<key> <string>periodicity_minute</string> </key>
......@@ -42,9 +48,7 @@
</item>
<item>
<key> <string>periodicity_minute_frequency</string> </key>
<value>
<none/>
</value>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>periodicity_month</string> </key>
......
kw = {}
if params is None:
params = {}
from DateTime import DateTime
now = DateTime()
last_active_process = context.getLastActiveProcess()
if not params.get('full', False) and last_active_process is not None:
last_active_process_start_date = last_active_process.getStartDate()
if (last_active_process_start_date + 0.02083) > now:
kw['creation_date'] = '>= %s' % last_active_process_start_date.ISO()
else:
context.newActiveProcess().getRelativeUrl()
else:
context.newActiveProcess().getRelativeUrl()
portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate(
portal_type="Payment Transaction",
......@@ -6,6 +25,7 @@ portal.portal_catalog.searchAndActivate(
payment_mode_uid=portal.portal_categories.payment_mode.payzen.getUid(),
method_id='PaymentTransaction_updateStatus',
packet_size=1, # just one to minimise errors
activate_kw={'tag': tag}
activate_kw={'tag': tag},
**kw
)
context.activate(after_tag=tag).getId()
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