-
Notifications
You must be signed in to change notification settings - Fork 0
/
Json.php
49 lines (34 loc) · 1.32 KB
/
Json.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php namespace components\payment; if(!defined('TX')) die('No direct access.');
class Json extends \dependencies\BaseComponent
{
public function get_status_updates($options, $sub_routes)
{
$updated = 0;
$errors = array();
$result = mk('Sql')->table('payment', 'Transactions')
->where('status', array("'OPEN'", "'UNCONFIRMED'"))
->execute()
->each(function($tx)use(&$updated, &$errors){
try{
//1,5 minute per item seems more than enough.
set_time_limit(90);
$handler = $tx->handler();
//Check with the handler if the status is updated.
if($handler && $handler->update_status($tx))
$updated++;
//Check if the transaction expired.
elseif($tx->status->get('string') === 'UNCONFIRMED' && $tx->is_expired->get('boolean') === true)
$updated++;
}
catch(\Exception $ex){
$errors[$tx->id->get('int')] = $ex->getMessage();
}
});
mk('Logging')->log('Payment', 'Manual status updates', $updated.'/'.$result->size().' updated with '.count($errors).' errors.');
return array(
'updated' => $updated,
'matched' => $result->size(),
'errors' => $errors
);
}
}