Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

@@ -12,7 +12,7 @@
namespace IPS\nexus;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -58,7 +58,7 @@ class _Transaction extends \IPS\Patterns\ActiveRecord
public static function loadAndCheckPerms( $id )
{
$obj = static::load( $id );
if ( $obj->member->member_id !== \IPS\Member::loggedIn()->member_id )
{
throw new \OutOfRangeException;
@@ -75,7 +75,7 @@ class _Transaction extends \IPS\Patterns\ActiveRecord
public static function statuses()
{
$options = array();
$reflection = new \ReflectionClass( get_called_class() );
$reflection = new \ReflectionClass( \get_called_class() );
foreach ( $reflection->getConstants() as $k => $v )
{
if ( mb_substr( $k, 0, 7 ) === 'STATUS_' )
@@ -117,7 +117,7 @@ class _Transaction extends \IPS\Patterns\ActiveRecord
}
catch ( \OutOfRangeException $e )
{
return '';
return \IPS\Member::loggedIn()->language()->addToStack('gateway_deleted');
}
}
else
@@ -340,7 +340,7 @@ class _Transaction extends \IPS\Patterns\ActiveRecord
*/
public function get_fraud()
{
return $this->_data['fraud'] ? \IPS\nexus\Fraud\MaxMind\Response::buildFromJson( $this->_data['fraud'] ) : NULL;
return ( isset( $this->_data['fraud'] ) and $this->_data['fraud'] ) ? \IPS\nexus\Fraud\MaxMind\Response::buildFromJson( $this->_data['fraud'] ) : NULL;
}
/**
@@ -475,7 +475,7 @@ class _Transaction extends \IPS\Patterns\ActiveRecord
public function runFraudCheck( $maxMind=NULL )
{
/* Run MaxMind */
if ( \IPS\Settings::i()->maxmind_key and ( !\IPS\Settings::i()->maxmind_gateways or \IPS\Settings::i()->maxmind_gateways == '*' or in_array( $this->method->id, explode( ',', \IPS\Settings::i()->maxmind_gateways ) ) ) )
if ( \IPS\Settings::i()->maxmind_key and ( !\IPS\Settings::i()->maxmind_gateways or \IPS\Settings::i()->maxmind_gateways == '*' or \in_array( $this->method->id, explode( ',', \IPS\Settings::i()->maxmind_gateways ) ) ) )
{
if ( $maxMind === NULL )
{
@@ -580,6 +580,12 @@ class _Transaction extends \IPS\Patterns\ActiveRecord
'invoice_id' => $this->invoice->id,
'invoice_title' => $this->invoice->title,
) );
/* Notification */
if ( \in_array( $fraudResult, array( static::STATUS_HELD, static::STATUS_REVIEW, static::STATUS_DISPUTED ) ) )
{
\IPS\core\AdminNotification::send( 'nexus', 'Transaction', $fraudResult, TRUE, $this );
}
}
/* Save */
@@ -644,7 +650,10 @@ class _Transaction extends \IPS\Patterns\ActiveRecord
}
$this->extra = $extra;
$this->save();
/* Update member total spend */
$this->member->updateSpend( $this->amount->amount, $this->amount->currency );
/* Mark the invoice paid if necessary */
if ( !$amountToPayOnInvoice->amount->subtract( $this->amount->amount )->isGreaterThanZero() )
{
@@ -731,9 +740,12 @@ class _Transaction extends \IPS\Patterns\ActiveRecord
'refund' => $refundMethod
) );
}
/* Update member total spend */
$this->member->updateSpend( $this->amount->amount, $this->amount->currency, true );
}
else
{
{
$this->partial_refund = new \IPS\nexus\Money( $this->partial_refund->amount->add( $amount ), $this->currency );
if ( $amount >= $this->amount->amount )
@@ -757,8 +769,10 @@ class _Transaction extends \IPS\Patterns\ActiveRecord
'currency' => $this->currency
) );
}
/* Update member total spend accounting for partial refund */
$this->member->updateSpend( $amount, $this->amount->currency, true );
}
}
/* Credit */
elseif ( $refundMethod === 'credit' )
@@ -888,8 +902,8 @@ class _Transaction extends \IPS\Patterns\ActiveRecord
throw new \RuntimeException;
break;
}
\IPS\Email::buildFromTemplate( 'nexus', $key, array( $this, $this->invoice, $this->invoice->summary() ), \IPS\Email::TYPE_TRANSACTIONAL )
\IPS\Email::buildFromTemplate( 'nexus', $key, array( $this, $this->invoice, $this->invoice->summary( $this->invoice->member->language() ) ), \IPS\Email::TYPE_TRANSACTIONAL )
->send(
$this->invoice->member,
array_map(
@@ -899,7 +913,7 @@ class _Transaction extends \IPS\Patterns\ActiveRecord
},
iterator_to_array( $this->invoice->member->alternativeContacts( array( 'billing=1' ) ) )
),
( ( in_array( $emailKey, explode( ',', \IPS\Settings::i()->nexus_notify_copy_types ) ) AND \IPS\Settings::i()->nexus_notify_copy_email ) ? explode( ',', \IPS\Settings::i()->nexus_notify_copy_email ) : array() )
( ( \in_array( $emailKey, explode( ',', \IPS\Settings::i()->nexus_notify_copy_types ) ) AND \IPS\Settings::i()->nexus_notify_copy_email ) ? explode( ',', \IPS\Settings::i()->nexus_notify_copy_email ) : array() )
);
}
@@ -945,33 +959,33 @@ class _Transaction extends \IPS\Patterns\ActiveRecord
$return = array();
/* Approve button */
if ( in_array( $this->status, array( static::STATUS_WAITING, static::STATUS_HELD, static::STATUS_REVIEW ) ) and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_edit' ) )
if ( \in_array( $this->status, array( static::STATUS_WAITING, static::STATUS_HELD, static::STATUS_REVIEW ) ) and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_edit' ) )
{
$return['approve'] = array(
'title' => $this->auth ? 'transaction_capture' : 'transaction_approve',
'icon' => 'check',
'link' => $url->setQueryString( array( 'do' => 'approve' ) ),
'link' => $url->setQueryString( array( 'do' => 'approve' ) )->csrf(),
'data' => array( 'confirm' => '' )
);
}
/* Review button */
if ( in_array( $this->status, array( static::STATUS_WAITING, static::STATUS_HELD ) ) and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_edit' ) )
if ( \in_array( $this->status, array( static::STATUS_WAITING, static::STATUS_HELD ) ) and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_edit' ) )
{
$return['review'] = array(
'title' => 'transaction_flag_review',
'icon' => 'flag',
'link' => $url->setQueryString( array( 'do' => 'review' ) ),
'link' => $url->setQueryString( array( 'do' => 'review' ) )->csrf(),
);
}
/* Void button */
if ( $this->auth and in_array( $this->status, array( static::STATUS_HELD, static::STATUS_REVIEW ) ) and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_edit' ) )
if ( $this->auth and \in_array( $this->status, array( static::STATUS_HELD, static::STATUS_REVIEW ) ) and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_edit' ) )
{
$return['void'] = array(
'title' => 'transaction_void',
'icon' => 'times',
'link' => $url->setQueryString( array( 'do' => 'void' ) ),
'link' => $url->setQueryString( array( 'do' => 'void' ) )->csrf(),
'data' => array( 'confirm' => '' )
);
}
@@ -982,13 +996,13 @@ class _Transaction extends \IPS\Patterns\ActiveRecord
$return['void'] = array(
'title' => 'cancel',
'icon' => 'times',
'link' => $url->setQueryString( array( 'do' => 'void', 'override' => 1 ) ),
'link' => $url->setQueryString( array( 'do' => 'void', 'override' => 1 ) )->csrf(),
'data' => array( 'confirm' => '' )
);
}
/* Refund button */
elseif ( in_array( $this->status, array( static::STATUS_PAID, static::STATUS_HELD, static::STATUS_REVIEW, static::STATUS_PART_REFUNDED ) ) and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_refund' ) )
elseif ( \in_array( $this->status, array( static::STATUS_PAID, static::STATUS_HELD, static::STATUS_REVIEW, static::STATUS_PART_REFUNDED ) ) and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_refund' ) )
{
$return['refund'] = array(
'title' => 'transaction_refund_credit',
@@ -1004,7 +1018,7 @@ class _Transaction extends \IPS\Patterns\ActiveRecord
$return['delete'] = array(
'title' => 'delete',
'icon' => 'times-circle',
'link' => $url->setQueryString( 'do', 'delete' ),
'link' => $url->setQueryString( 'do', 'delete' )->csrf(),
'data' => array( 'confirm' => '', 'confirmSubMessage' => \IPS\Member::loggedIn()->language()->addToStack('trans_delete_warning') )
);
}
@@ -1028,7 +1042,7 @@ class _Transaction extends \IPS\Patterns\ActiveRecord
}
else
{
if ( !in_array( $this->status, array( static::STATUS_PENDING, static::STATUS_WAITING, static::STATUS_GATEWAY_PENDING ) ) )
if ( !\in_array( $this->status, array( static::STATUS_PENDING, static::STATUS_WAITING, static::STATUS_GATEWAY_PENDING ) ) )
{
$return[] = array(
's' => $this->status,