Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

@@ -12,35 +12,52 @@
namespace IPS\nexus\modules\admin\payments;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use InvalidArgumentException;
use IPS\Dispatcher;
use IPS\Helpers\Form;
use IPS\Helpers\Form\Radio;
use IPS\Helpers\Wizard;
use IPS\Http\Url;
use IPS\Lang;
use IPS\nexus\Gateway;
use IPS\Node\Controller;
use IPS\Output;
use IPS\Request;
use IPS\Session;
use IPS\Task;
use OutOfRangeException;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Payment Gateways
*/
class _gateways extends \IPS\Node\Controller
class gateways extends Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
public static bool $csrfProtected = TRUE;
/**
* Node Class
*/
protected $nodeClass = 'IPS\nexus\Gateway';
protected string $nodeClass = 'IPS\nexus\Gateway';
/**
* Execute
*
* @return void
*/
public function execute()
public function execute() : void
{
\IPS\Dispatcher::i()->checkAcpPermission( 'gateways_manage' );
Dispatcher::i()->checkAcpPermission( 'gateways_manage' );
parent::execute();
}
@@ -49,7 +66,7 @@ class _gateways extends \IPS\Node\Controller
*
* @return array
*/
public function _getRootButtons()
public function _getRootButtons(): array
{
$buttons = parent::_getRootButtons();
@@ -66,39 +83,34 @@ class _gateways extends \IPS\Node\Controller
*
* @return void
*/
protected function form()
protected function form() : void
{
if ( \IPS\Request::i()->id )
if ( Request::i()->id )
{
return parent::form();
parent::form();
}
else
{
if ( \IPS\IN_DEV )
{
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'plupload/moxie.js', 'core', 'interface' ) );
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'plupload/plupload.dev.js', 'core', 'interface' ) );
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'plupload/moxie.js', 'core', 'interface' ) );
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'plupload/plupload.dev.js', 'core', 'interface' ) );
}
else
{
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'plupload/plupload.full.min.js', 'core', 'interface' ) );
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'plupload/plupload.full.min.js', 'core', 'interface' ) );
}
\IPS\Output::i()->output = (string) new \IPS\Helpers\Wizard( array(
Output::i()->output = (string) new Wizard( array(
'gateways_gateway' => function( $data )
{
$options = array();
foreach ( \IPS\nexus\Gateway::gateways() as $key => $class )
foreach ( Gateway::gateways() as $key => $class )
{
/* Deprecate Authorize.net, Braintree and 2Checkout don't allow them to be used for new gateways */
if( \in_array( $key, array( 'AuthorizeNet', 'TwoCheckout', 'Braintree' ) ) )
{
continue;
}
$options[ $key ] = 'gateway__' . $key;
}
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\Radio( 'gateways_gateway', TRUE, NULL, array( 'options' => $options ) ) );
$form = new Form;
$form->add( new Radio( 'gateways_gateway', TRUE, NULL, array( 'options' => $options ) ) );
if ( $values = $form->values() )
{
return array( 'gateway' => $values['gateways_gateway'] );
@@ -107,8 +119,8 @@ class _gateways extends \IPS\Node\Controller
},
'gateways_details' => function( $data )
{
$form = new \IPS\Helpers\Form('gw');
$class = \IPS\nexus\Gateway::gateways()[ $data['gateway'] ];
$form = new Form('gw');
$class = Gateway::gateways()[ $data['gateway'] ];
$obj = new $class;
$obj->gateway = $data['gateway'];
$obj->active = TRUE;
@@ -128,7 +140,7 @@ class _gateways extends \IPS\Node\Controller
{
$settings = $obj->testSettings( $settings );
}
catch ( \InvalidArgumentException $e )
catch ( InvalidArgumentException $e )
{
$form->error = $e->getMessage();
return $form;
@@ -144,14 +156,14 @@ class _gateways extends \IPS\Node\Controller
}
$obj->save();
\IPS\Lang::saveCustom( 'nexus', "nexus_paymethod_{$obj->id}", $name );
\IPS\Session::i()->log( 'acplogs__nexus_added_gateway', array( "nexus_paymethod_{$obj->id}" => TRUE ) );
Lang::saveCustom( 'nexus', "nexus_paymethod_{$obj->id}", $name );
Session::i()->log( 'acplogs__nexus_added_gateway', array( "nexus_paymethod_{$obj->id}" => TRUE ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=nexus&module=payments&controller=paymentsettings&tab=gateways') );
Output::i()->redirect( Url::internal('app=nexus&module=payments&controller=paymentsettings&tab=gateways') );
}
return $form;
}
), \IPS\Http\Url::internal('app=nexus&module=payments&controller=paymentsettings&tab=gateways&do=form') );
), Url::internal('app=nexus&module=payments&controller=paymentsettings&tab=gateways&do=form') );
}
}
@@ -160,42 +172,43 @@ class _gateways extends \IPS\Node\Controller
*
* @return void
*/
protected function delete()
protected function delete() : void
{
/* Get node */
/* @var Gateway $nodeClass */
$nodeClass = $this->nodeClass;
if ( \IPS\Request::i()->subnode )
if ( Request::i()->subnode )
{
$nodeClass = $nodeClass::$subnodeClass;
}
try
{
$node = $nodeClass::load( \IPS\Request::i()->id );
$node = $nodeClass::load( Request::i()->id );
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException )
{
\IPS\Output::i()->error( 'node_error', '2X411/1', 404, '' );
Output::i()->error( 'node_error', '2X411/1', 404, '' );
}
/* Permission check */
if( !$node->canDelete() )
{
\IPS\Output::i()->error( 'node_noperm_delete', '2X411/2', 403, '' );
Output::i()->error( 'node_noperm_delete', '2X411/2', 403, '' );
}
if( $node->hasActiveBillingAgreements() )
{
/* Make sure the user confirmed the deletion */
\IPS\Request::i()->confirmedDelete();
Request::i()->confirmedDelete();
\IPS\Task::queue( 'nexus', 'DeletePaymentMethod', array( 'id' => $node->id ), 3, array( 'id' ) );
\IPS\Session::i()->log( 'acplog__node_deleted_c', array( $this->title => TRUE, $node->titleForLog() => FALSE ) );
\IPS\Output::i()->redirect( $this->url->setQueryString( array( 'root' => ( $node->parent() ? $node->parent()->_id : '' ) ) ), 'deleted' );
Task::queue( 'nexus', 'DeletePaymentMethod', array( 'id' => $node->id ), 3, array( 'id' ) );
Session::i()->log( 'acplog__node_deleted_c', array( $node->_title => TRUE, $node->titleForLog() => FALSE ) );
Output::i()->redirect( $this->url->setQueryString( array( 'root' => ( $node->parent() ? $node->parent()->_id : '' ) ) ), 'deleted' );
}
else
{
return parent::delete();
parent::delete();
}
}
}