Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -36,7 +36,7 @@ class _gatewayPending extends \IPS\Task
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$transactions = \IPS\Db::i()->select( '*', 'nexus_transactions', array( 't_status=?', \IPS\nexus\Transaction::STATUS_GATEWAY_PENDING ), 't_id ASC', 20 ); // We deliberately don't run until exauhstion here because we want to wait and try again later if it fails
|
||||
$transactions = \IPS\Db::i()->select( '*', 'nexus_transactions', array( 't_status=?', \IPS\nexus\Transaction::STATUS_GATEWAY_PENDING ), 't_id ASC', 20 ); // We deliberately don't run until exhaustion here because we want to wait and try again later if it fails
|
||||
if ( !count( $transactions ) )
|
||||
{
|
||||
$this->enabled = FALSE;
|
||||
@@ -49,46 +49,50 @@ class _gatewayPending extends \IPS\Task
|
||||
/* Get it */
|
||||
$transaction = \IPS\nexus\Transaction::constructFromData( $transaction );
|
||||
|
||||
/* Try to capture it */
|
||||
try
|
||||
if ( $transaction->method instanceof \IPS\nexus\Gateway\Paypal )
|
||||
{
|
||||
$transaction->capture();
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
if ( $e->getMessage() === 'FAIL' or $e->getMessage() === 'RFND' or $transaction->date->getTimestamp() > ( time() - ( 86400 * 3 ) ) )
|
||||
/* Try to capture it */
|
||||
try
|
||||
{
|
||||
$status = $e->getMessage() === 'RFND' ? \IPS\nexus\Transaction::STATUS_REFUNDED : \IPS\nexus\Transaction::STATUS_REFUSED;
|
||||
|
||||
$transaction->status = $status;
|
||||
$transaction->save();
|
||||
$transaction->member->log( 'transaction', array(
|
||||
'type' => 'status',
|
||||
'status' => $status,
|
||||
'id' => $transaction->id
|
||||
), FALSE );
|
||||
|
||||
if ( $status === \IPS\nexus\Transaction::STATUS_REFUNDED )
|
||||
{
|
||||
$transaction->sendNotification();
|
||||
}
|
||||
$transaction->capture();
|
||||
}
|
||||
continue;
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
if ( $e->getMessage() === 'FAIL' or $e->getMessage() === 'RFND' or $transaction->date->getTimestamp() < ( time() - ( 86400 * 5 ) ) )
|
||||
{
|
||||
$status = $e->getMessage() === 'RFND' ? \IPS\nexus\Transaction::STATUS_REFUNDED : \IPS\nexus\Transaction::STATUS_REFUSED;
|
||||
|
||||
$transaction->status = $status;
|
||||
$transaction->save();
|
||||
$transaction->member->log( 'transaction', array(
|
||||
'type' => 'status',
|
||||
'status' => $status,
|
||||
'id' => $transaction->id
|
||||
), FALSE );
|
||||
|
||||
if ( $status === \IPS\nexus\Transaction::STATUS_REFUNDED )
|
||||
{
|
||||
$transaction->sendNotification();
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If it succeeded, take any fraud action */
|
||||
$fraudResult = $transaction->fraud_blocked ? $transaction->fraud_blocked->action : NULL;
|
||||
if ( $fraudResult )
|
||||
{
|
||||
$transaction->executeFraudAction( $fraudResult, TRUE );
|
||||
}
|
||||
if ( !$fraudResult or $fraudResult === \IPS\nexus\Transaction::STATUS_PAID )
|
||||
{
|
||||
$transaction->approve();
|
||||
}
|
||||
|
||||
/* Let the customer know */
|
||||
$transaction->sendNotification();
|
||||
|
||||
}
|
||||
|
||||
/* If it succeeded, take any fraud action */
|
||||
$fraudResult = $transaction->fraud_blocked ? $transaction->fraud_blocked->action : NULL;
|
||||
if ( $fraudResult )
|
||||
{
|
||||
$transaction->executeFraudAction( $fraudResult, TRUE );
|
||||
}
|
||||
if ( !$fraudResult or $fraudResult === \IPS\nexus\Transaction::STATUS_PAID )
|
||||
{
|
||||
$transaction->approve();
|
||||
}
|
||||
|
||||
/* Let the customer know */
|
||||
$transaction->sendNotification();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user