Version 4.3.6

This commit is contained in:
Neo committed 2025-12-19 05:49:12 -08:00
1 parent fe1acf984a
commit 1a0c7fd3c2
609 files changed
+14707 -5726

No files matched your search

+38 -18
View File
@@ -38,31 +38,51 @@ class _capture extends \IPS\Task
{
$taskFrequency = new \DateInterval( $this->frequency );
$time = \IPS\DateTime::create()->add( $taskFrequency )->add( $taskFrequency );
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_transactions', array( 't_auth<?', $time->getTimestamp() ) ), 'IPS\nexus\Transaction' ) as $transaction )
$this->runUntilTimeout( function() use ( $time )
{
if ( $transaction->method )
try
{
try
$transaction = \IPS\nexus\Transaction::constructFromData( \IPS\Db::i()->select( '*', 'nexus_transactions', array( 't_auth<?', $time->getTimestamp() ), 't_auth ASC', 1 )->first() );
if ( $transaction->method )
{
$transaction->capture();
try
{
$transaction->capture();
}
catch ( \Exception $e )
{
if ( in_array( $transaction->status, array( $transaction::STATUS_PENDING, $transaction::STATUS_WAITING, $transaction::STATUS_GATEWAY_PENDING ) ) )
{
$transaction->status = \IPS\nexus\Transaction::STATUS_REFUSED;
$extra = $transaction->extra;
$extra['history'][] = array( 's' => \IPS\nexus\Transaction::STATUS_REFUSED, 'noteRaw' => $e->getMessage() );
$transaction->extra = $extra;
}
$transaction->auth = NULL;
$transaction->save();
}
}
else
{
/* the gateway doesn't exist anymore, so reset the auth time */
$transaction->auth = NULL;
$extra = $transaction->extra;
$extra['history'][] = array( 's' => \IPS\nexus\Transaction::STATUS_REFUSED, 'on' => time(), 'noteRaw' => 'invalid_gateway' );
$transaction->extra = $extra;
$transaction->status = \IPS\nexus\Transaction::STATUS_REFUSED;
$transaction->save();
throw new \IPS\Task\Exception( $this, array( 'invalid_gateway', $transaction->id ) );
}
catch ( \Exception $e ) {}
}
else
catch ( \UnderflowException $e )
{
/* the gateway doesn't exist anymore, so reset the auth time */
$transaction->auth = NULL;
$extra = $transaction->extra;
$extra['history'][] = array( 's' => \IPS\nexus\Transaction::STATUS_REFUSED, 'on' => time(), 'noteRaw' => 'invalid_gateway' );
$transaction->extra = $extra;
$transaction->status = \IPS\nexus\Transaction::STATUS_REFUSED;
$transaction->save();
throw new \IPS\Task\Exception( $this, \IPS\Member::loggedIn()->language()->addToStack( 'invalid_gateway', FALSE, array( 'sprintf' => array( $transaction->id ) ) ) );
return FALSE;
}
}
});
}
/**