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

+227 -162
View File
@@ -12,32 +12,63 @@
namespace IPS\nexus;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use Exception;
use InvalidArgumentException;
use IPS\Application;
use IPS\DateTime;
use IPS\Db;
use IPS\File;
use IPS\GeoLocation;
use IPS\Helpers\Form;
use IPS\Helpers\Form\Select;
use IPS\Helpers\Form\Translatable;
use IPS\Http\Url;
use IPS\Lang;
use IPS\Member;
use IPS\nexus\Customer\CreditCard;
use IPS\nexus\Fraud\MaxMind\Request;
use IPS\Node\Model;
use IPS\Settings;
use LogicException;
use OutOfRangeException;
use function count;
use function defined;
use function in_array;
use function is_array;
use function is_null;
use function strlen;
use function substr;
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;
}
/**
* Gateway Node
*/
class _Gateway extends \IPS\Node\Model
abstract class Gateway extends Model
{
/**
* Gateways
*
* @return array
*/
public static function gateways()
public static function gateways() : array
{
$return = array(
'Stripe' => 'IPS\nexus\Gateway\Stripe',
'Braintree' => 'IPS\nexus\Gateway\Braintree',
'PayPal' => 'IPS\nexus\Gateway\PayPal',
'AuthorizeNet' => 'IPS\nexus\Gateway\AuthorizeNet',
'TwoCheckout' => 'IPS\nexus\Gateway\TwoCheckout',
'Manual' => 'IPS\nexus\Gateway\Manual',
);
/* Extension Gateways */
foreach ( Application::allExtensions( 'nexus', 'Gateway', FALSE, 'core' ) as $key => $extension )
{
$return[$extension::$gatewayKey] = $extension::class;
}
if ( \IPS\NEXUS_TEST_GATEWAYS )
{
@@ -52,57 +83,71 @@ class _Gateway extends \IPS\Node\Model
*
* @return array
*/
public static function payoutGateways()
public static function payoutGateways() : array
{
return array(
$return = array(
'PayPal' => 'IPS\nexus\Gateway\PayPal\Payout',
'Manual' => 'IPS\nexus\Gateway\Manual\Payout',
);
/* Extension Gateways */
foreach ( Application::allExtensions( 'nexus', 'Payout', FALSE, 'core' ) as $key => $extension )
{
$return[ $extension::$gatewayKey ] = $extension::class;
}
return $return;
}
/**
* @brief [ActiveRecord] Multiton Store
*/
protected static $multitons;
protected static array $multitons;
/**
* @brief [ActiveRecord] Database Table
*/
public static $databaseTable = 'nexus_paymethods';
public static ?string $databaseTable = 'nexus_paymethods';
/**
* @brief [ActiveRecord] Database Prefix
*/
public static $databasePrefix = 'm_';
public static string $databasePrefix = 'm_';
/**
* @brief [Node] Order Database Column
*/
public static $databaseColumnOrder = 'position';
public static ?string $databaseColumnOrder = 'position';
/**
* @brief [Node] Node Title
*/
public static $nodeTitle = 'payment_methods';
public static string $nodeTitle = 'payment_methods';
/**
* @brief [Node] Title prefix. If specified, will look for a language key with "{$key}_title" as the key
*/
public static $titleLangPrefix = 'nexus_paymethod_';
public static ?string $titleLangPrefix = 'nexus_paymethod_';
/**
* Construct ActiveRecord from database row
*
* @param array $data Row from database table
* @param bool $updateMultitonStoreIfExists Replace current object in multiton store if it already exists there?
* @return static
* @param array $data Row from database table
* @param bool $updateMultitonStoreIfExists Replace current object in multiton store if it already exists there?
* @return static
*/
public static function constructFromData( $data, $updateMultitonStoreIfExists = TRUE )
public static function constructFromData( array $data, bool $updateMultitonStoreIfExists = TRUE ): Gateway
{
/* Might be a deleted/deprecated gateway */
if( !array_key_exists( $data['m_gateway'], static::gateways() ) )
{
throw new OutOfRangeException;
}
$classname = static::gateways()[ $data['m_gateway'] ];
if ( !class_exists( $classname ) )
{
throw new \OutOfRangeException;
throw new OutOfRangeException;
}
/* Initiate an object */
@@ -114,7 +159,7 @@ class _Gateway extends \IPS\Node\Model
{
if( static::$databasePrefix AND mb_strpos( $k, static::$databasePrefix ) === 0 )
{
$k = \substr( $k, \strlen( static::$databasePrefix ) );
$k = substr( $k, strlen( static::$databasePrefix ) );
}
$obj->_data[ $k ] = $v;
@@ -137,7 +182,7 @@ class _Gateway extends \IPS\Node\Model
* @note Return value NULL indicates the node cannot be enabled/disabled
* @return bool|null
*/
protected function get__enabled()
protected function get__enabled(): ?bool
{
return $this->enabled;
}
@@ -148,7 +193,7 @@ class _Gateway extends \IPS\Node\Model
* @param bool|int $enabled Whether to set it enabled or disabled
* @return void
*/
protected function set__enabled( $enabled )
protected function set__enabled( bool|int $enabled ) : void
{
$this->enabled = $enabled;
}
@@ -169,7 +214,7 @@ class _Gateway extends \IPS\Node\Model
'prefix' => 'foo_', // [Optional] Rather than specifying each key in the map, you can specify a prefix, and it will automatically look for restrictions with the key "[prefix]_add/edit/permissions/delete"
* @endcode
*/
protected static $restrictions = array(
protected static ?array $restrictions = array(
'app' => 'nexus',
'module' => 'payments',
'all' => 'gateways_manage',
@@ -178,17 +223,17 @@ class _Gateway extends \IPS\Node\Model
/**
* [Node] Add/Edit Form
*
* @param \IPS\Helpers\Form $form The form
* @param Form $form The form
* @return void
*/
public function form( &$form )
public function form( Form &$form ) : void
{
$form->add( new \IPS\Helpers\Form\Translatable( 'paymethod_name', NULL, TRUE, array( 'app' => 'nexus', 'key' => $this->id ? "nexus_paymethod_{$this->id}" : NULL ) ) );
$form->add( new Translatable( 'paymethod_name', NULL, TRUE, array( 'app' => 'nexus', 'key' => $this->id ? "nexus_paymethod_{$this->id}" : NULL ) ) );
$this->settings( $form );
$form->add( new \IPS\Helpers\Form\Select( 'paymethod_countries', ( $this->id and $this->countries !== '*' ) ? explode( ',', $this->countries ) : '*', FALSE, array( 'options' => array_map( function( $val )
$form->add( new Select( 'paymethod_countries', ( $this->id and $this->countries !== '*' ) ? explode( ',', $this->countries ) : '*', FALSE, array( 'options' => array_map( function( $val )
{
return "country-{$val}";
}, array_combine( \IPS\GeoLocation::$countries, \IPS\GeoLocation::$countries ) ), 'multiple' => TRUE, 'unlimited' => '*', 'unlimitedLang' => 'no_restriction' ) ) );
}, array_combine( GeoLocation::$countries, GeoLocation::$countries ) ), 'multiple' => TRUE, 'unlimited' => '*', 'unlimitedLang' => 'no_restriction' ) ) );
}
/**
@@ -197,17 +242,17 @@ class _Gateway extends \IPS\Node\Model
* @param array $values Values from the form
* @return array
*/
public function formatFormValues( $values )
public function formatFormValues( array $values ): array
{
if( isset( $values['paymethod_name'] ) )
{
\IPS\Lang::saveCustom( 'nexus', "nexus_paymethod_{$this->id}", $values['paymethod_name'] );
Lang::saveCustom( 'nexus', "nexus_paymethod_{$this->id}", $values['paymethod_name'] );
unset( $values['paymethod_name'] );
}
if( isset( $values['paymethod_countries'] ) )
{
$values['countries'] = \is_array( $values['paymethod_countries'] ) ? implode( ',', $values['paymethod_countries'] ) : $values['paymethod_countries'];
$values['countries'] = is_array( $values['paymethod_countries'] ) ? implode( ',', $values['paymethod_countries'] ) : $values['paymethod_countries'];
}
if( isset( $values['m_validationfile'] ) )
@@ -238,7 +283,7 @@ class _Gateway extends \IPS\Node\Model
* @param bool $adminCreatableOnly If TRUE, will only return gateways where the admin (opposed to the user) can create a new option
* @return array
*/
public static function cardStorageGateways( $adminCreatableOnly = FALSE )
public static function cardStorageGateways( bool $adminCreatableOnly = FALSE ) : array
{
$return = array();
foreach ( static::roots() as $gateway )
@@ -254,10 +299,10 @@ class _Gateway extends \IPS\Node\Model
/**
* Get gateways that support manual admin charges
*
* @param \IPS\nexus\Customer $customer The customer we're wanting to charge
* @param Customer $customer The customer we're wanting to charge
* @return array
*/
public static function manualChargeGateways( \IPS\nexus\Customer $customer )
public static function manualChargeGateways(Customer $customer ) : array
{
$return = array();
foreach ( static::roots() as $gateway )
@@ -275,7 +320,7 @@ class _Gateway extends \IPS\Node\Model
*
* @return array
*/
public static function billingAgreementGateways()
public static function billingAgreementGateways() : array
{
$return = array();
foreach ( static::roots() as $gateway )
@@ -291,9 +336,9 @@ class _Gateway extends \IPS\Node\Model
/**
* [ActiveRecord] Save Changed Columns
*
* @return void
* @return void
*/
public function save()
public function save(): void
{
parent::save();
static::recountCardStorageGateways();
@@ -304,28 +349,28 @@ class _Gateway extends \IPS\Node\Model
* Example code explains return value
*
* @code
array(
array(
'icon' => 'plus-circle', // Name of FontAwesome icon to use
'title' => 'foo', // Language key to use for button's title parameter
'link' => \IPS\Http\Url::internal( 'app=foo...' ) // URI to link to
'class' => 'modalLink' // CSS Class to use on link (Optional)
),
... // Additional buttons
);
* array(
* array(
* 'icon' => 'plus-circle', // Name of FontAwesome icon to use
* 'title' => 'foo', // Language key to use for button's title parameter
* 'link' => \IPS\Http\Url::internal( 'app=foo...' ) // URI to link to
* 'class' => 'modalLink' // CSS Class to use on link (Optional)
* ),
* ... // Additional buttons
* );
* @endcode
* @param string $url Base URL
* @param Url $url Base URL
* @param bool $subnode Is this a subnode?
* @return array
*/
public function getButtons( $url, $subnode=FALSE )
public function getButtons( Url $url, bool $subnode=FALSE ):array
{
$buttons = parent::getButtons( $url, $subnode );
/* If we have active billing agreements and the node isn't currently queued for deletion, add a special warning to the delete confirmation box */
if( $this->hasActiveBillingAgreements() AND isset( $buttons['delete'] ) )
{
$buttons['delete']['data']['delete-warning'] = \IPS\Member::loggedIn()->language()->addToStack('gateway_ba_delete_blurb');
$buttons['delete']['data']['delete-warning'] = Member::loggedIn()->language()->addToStack('gateway_ba_delete_blurb');
}
return $buttons;
@@ -336,16 +381,16 @@ class _Gateway extends \IPS\Node\Model
*
* @return bool
*/
public function deleteOrMoveQueued()
public function deleteOrMoveQueued(): bool
{
if( $this->hasActiveBillingAgreements() )
{
/* If we already know, don't bother */
if ( \is_null( $this->queued ) )
if ( is_null( $this->queued ) )
{
$this->queued = FALSE;
foreach( \IPS\Db::i()->select( 'data', 'core_queue', array( 'app=? AND `key`=?', 'nexus', 'DeletePaymentMethod' ) ) as $taskData )
foreach( Db::i()->select( 'data', 'core_queue', array( 'app=? AND `key`=?', 'nexus', 'DeletePaymentMethod' ) ) as $taskData )
{
$data = json_decode( $taskData, TRUE );
@@ -370,7 +415,7 @@ class _Gateway extends \IPS\Node\Model
*
* @return bool
*/
public function canCopy()
public function canCopy(): bool
{
if ( $this->deleteOrMoveQueued() === TRUE )
{
@@ -383,19 +428,19 @@ class _Gateway extends \IPS\Node\Model
/**
* [ActiveRecord] Delete
*
* @return void
* @return void
*/
public function delete()
public function delete(): void
{
/* Delete cards and billing agreements */
\IPS\Db::i()->delete( 'nexus_customer_cards', array( 'card_method=?', $this->id ) );
\IPS\Db::i()->delete( 'nexus_billing_agreements', array( 'ba_method=?', $this->id ) );
Db::i()->delete( 'nexus_customer_cards', array( 'card_method=?', $this->id ) );
Db::i()->delete( 'nexus_billing_agreements', array( 'ba_method=?', $this->id ) );
try
{
\IPS\File::get( 'nexus_Gateways', $this->validationfile )->delete();
File::get( 'nexus_Gateways', $this->validationfile )->delete();
}
catch( \Exception $ex ) { }
catch( Exception ) { }
/* Delete */
@@ -410,7 +455,7 @@ class _Gateway extends \IPS\Node\Model
*
* @return void
*/
protected static function recountCardStorageGateways()
protected static function recountCardStorageGateways() : void
{
$counts = array();
foreach ( static::roots() as $gateway )
@@ -423,30 +468,31 @@ class _Gateway extends \IPS\Node\Model
$counts[ $gateway->gateway ]++;
}
\IPS\Settings::i()->changeValues( array( 'card_storage_gateways' => \count( static::cardStorageGateways() ), 'billing_agreement_gateways' => \count( static::billingAgreementGateways() ), 'gateways_counts' => json_encode( $counts ) ) );
Settings::i()->changeValues( array( 'card_storage_gateways' => count( static::cardStorageGateways() ), 'billing_agreement_gateways' => count( static::billingAgreementGateways() ), 'gateways_counts' => json_encode( $counts ) ) );
}
/* !Features (Each gateway will override) */
const SUPPORTS_REFUNDS = FALSE;
const SUPPORTS_PARTIAL_REFUNDS = FALSE;
const SUPPORTS_AUTOPAY = FALSE;
/**
* Check the gateway can process this...
*
* @param $amount \IPS\nexus\Money The amount
* @param $billingAddress \IPS\GeoLocation|NULL The billing address, which may be NULL if one if not provided
* @param $customer \IPS\nexus\Customer The customer (Default NULL value is for backwards compatibility - it should always be provided.)
* @param $amount Money The amount
* @param $billingAddress GeoLocation|NULL The billing address, which may be NULL if one if not provided
* @param $customer Customer|null The customer (Default NULL value is for backwards compatibility - it should always be provided.)
* @param array $recurrings Details about recurring costs
* @return bool
*/
public function checkValidity( \IPS\nexus\Money $amount, \IPS\GeoLocation $billingAddress = NULL, \IPS\nexus\Customer $customer = NULL, $recurrings = array() )
public function checkValidity(Money $amount, ?GeoLocation $billingAddress = NULL, ?Customer $customer = NULL, array $recurrings = array() ) : bool
{
if ( $this->countries !== '*' )
{
if ( $billingAddress )
{
return \in_array( $billingAddress->country, explode( ',', $this->countries ) );
return in_array( $billingAddress->country, explode( ',', $this->countries ) );
}
else
{
@@ -460,10 +506,10 @@ class _Gateway extends \IPS\Node\Model
/**
* Can store cards?
*
* @param bool $adminCreatableOnly If TRUE, will only return gateways where the admin (opposed to the user) can create a new option
* @return bool
* @param bool $adminCreatableOnly If TRUE, will only return gateways where the admin (opposed to the user) can create a new option
* @return bool
*/
public function canStoreCards( $adminCreatableOnly = FALSE )
public function canStoreCards(bool $adminCreatableOnly = FALSE ): bool
{
return FALSE;
}
@@ -471,10 +517,10 @@ class _Gateway extends \IPS\Node\Model
/**
* Admin can manually charge using this gateway?
*
* @param \IPS\nexus\Customer $customer The customer we're wanting to charge
* @return bool
* @param Customer $customer The customer we're wanting to charge
* @return bool
*/
public function canAdminCharge( \IPS\nexus\Customer $customer )
public function canAdminCharge(Customer $customer ): bool
{
return FALSE;
}
@@ -482,9 +528,9 @@ class _Gateway extends \IPS\Node\Model
/**
* Supports billing agreements?
*
* @return bool
* @return bool
*/
public function billingAgreements()
public function billingAgreements(): bool
{
return FALSE;
}
@@ -492,11 +538,11 @@ class _Gateway extends \IPS\Node\Model
/**
* Has active billing agreements?
*
* @return bool
* @return bool
*/
public function hasActiveBillingAgreements()
public function hasActiveBillingAgreements(): bool
{
return (bool) \IPS\Db::i()->select( 'COUNT(*)', 'nexus_billing_agreements', array( 'ba_method=? AND ba_canceled=?', $this->id, 0 ) )->first();
return (bool) Db::i()->select( 'COUNT(*)', 'nexus_billing_agreements', array( 'ba_method=? AND ba_canceled=?', $this->id, 0 ) )->first();
}
/* !Payment Gateway */
@@ -504,9 +550,9 @@ class _Gateway extends \IPS\Node\Model
/**
* Should the submit button show when this payment method is shown?
*
* @return bool
* @return bool
*/
public function showSubmitButton()
public function showSubmitButton(): bool
{
return true;
}
@@ -514,26 +560,23 @@ class _Gateway extends \IPS\Node\Model
/**
* Payment Screen Fields
*
* @param \IPS\nexus\Invoice $invoice Invoice
* @param \IPS\nexus\Money $amount The amount to pay now
* @param \IPS\nexus\Customer $member The member the payment screen is for (if in the ACP charging to a member's card) or NULL for currently logged in member
* @param array $recurrings Details about recurring costs
* @param bool $type 'checkout' means the cusotmer is doing this on the normal checkout screen, 'admin' means the admin is doing this in the ACP, 'card' means the user is just adding a card
* @return array
* @param Invoice $invoice Invoice
* @param Money $amount The amount to pay now
* @param Customer|null $member The member the payment screen is for (if in the ACP charging to a member's card) or NULL for currently logged in member
* @param array $recurrings Details about recurring costs
* @param string $type 'checkout' means the cusotmer is doing this on the normal checkout screen, 'admin' means the admin is doing this in the ACP, 'card' means the user is just adding a card
* @return array
*/
public function paymentScreen( \IPS\nexus\Invoice $invoice, \IPS\nexus\Money $amount, \IPS\nexus\Customer $member = NULL, $recurrings = array(), $type = 'checkout' )
{
return array();
}
abstract public function paymentScreen(Invoice $invoice, Money $amount, ?Customer $member = NULL, array $recurrings = array(), string $type = 'checkout' ): array;
/**
* Manual Payment Instructions
*
* @param \IPS\nexus\Transaction $transaction Transaction
* @param string|NULL $email If this is for the email, will be 'html' or 'plaintext'. If for UI, will be NULL.
* @return array
* @param Transaction $transaction Transaction
* @param string|NULL $email If this is for the email, will be 'html' or 'plaintext'. If for UI, will be NULL.
* @return string
*/
public function manualPaymentInstructions( \IPS\nexus\Transaction $transaction, $email = NULL )
public function manualPaymentInstructions(Transaction $transaction, ?string $email = NULL ): string
{
return $transaction->member->language()->addToStack( "nexus_gateway_{$this->id}_ins" );
}
@@ -541,15 +584,15 @@ class _Gateway extends \IPS\Node\Model
/**
* Authorize
*
* @param \IPS\nexus\Transaction $transaction Transaction
* @param array|\IPS\nexus\Customer\CreditCard $values Values from form OR a stored card object if this gateway supports them
* @param \IPS\nexus\Fraud\MaxMind\Request|NULL $maxMind *If* MaxMind is enabled, the request object will be passed here so gateway can additional data before request is made
* @param Transaction $transaction Transaction
* @param array|CreditCard $values Values from form OR a stored card object if this gateway supports them
* @param Request|NULL $maxMind *If* MaxMind is enabled, the request object will be passed here so gateway can additional data before request is made
* @param array $recurrings Details about recurring costs
* @param string|NULL $source 'checkout' if the customer is doing this at a normal checkout, 'renewal' is an automatically generated renewal invoice, 'manual' is admin manually charging. NULL is unknown
* @return \IPS\DateTime|NULL Auth is valid until or NULL to indicate auth is good forever
* @throws \LogicException Message will be displayed to user
* @param string|NULL $source 'checkout' if the customer is doing this at a normal checkout, 'renewal' is an automatically generated renewal invoice, 'manual' is admin manually charging. NULL is unknown
* @return array|DateTime|NULL Auth is valid until or NULL to indicate auth is good forever
* @throws LogicException Message will be displayed to user
*/
public function auth( \IPS\nexus\Transaction $transaction, $values, \IPS\nexus\Fraud\MaxMind\Request $maxMind = NULL, $recurrings = array(), $source = NULL )
public function auth(Transaction $transaction, array|CreditCard $values, ?Request $maxMind = NULL, array $recurrings = array(), ?string $source = NULL ): DateTime|array|null
{
return NULL;
}
@@ -557,118 +600,142 @@ class _Gateway extends \IPS\Node\Model
/**
* Void
*
* @param \IPS\nexus\Transaction $transaction Transaction
* @return void
* @throws \Exception
* @param Transaction $transaction Transaction
* @return mixed
* @throws Exception
*/
public function void( \IPS\nexus\Transaction $transaction )
public function void(Transaction $transaction ): mixed
{
return $this->refund( $transaction );
return $this->refund($transaction );
}
/**
* Get output for API
*
* @param Member|NULL $authorizedMember The member making the API request or NULL for API Key / client_credentials
* @return array
* @apiresponse int id ID number
* @apiresponse string name Name
*/
public function apiOutput( Member $authorizedMember = NULL ): array
{
return array(
'id' => $this->id,
'name' => $this->_title
);
}
/**
* Capture
*
* @param \IPS\nexus\Transaction $transaction Transaction
* @return void
* @throws \LogicException
* @param Transaction $transaction Transaction
* @return void
* @throws LogicException
*/
public function capture( \IPS\nexus\Transaction $transaction )
{
}
abstract public function capture(Transaction $transaction ): void;
/**
* Refund
*
* @param \IPS\nexus\Transaction $transaction Transaction to be refunded
* @param float|NULL $amount Amount to refund (NULL for full amount - always in same currency as transaction)
* @return mixed Gateway reference ID for refund, if applicable
* @throws \Exception
* @param Transaction $transaction Transaction to be refunded
* @param mixed|NULL $amount Amount to refund (NULL for full amount - always in same currency as transaction)
* @param string|null $reason
* @return mixed Gateway reference ID for refund, if applicable
* @throws Exception
*/
public function refund( \IPS\nexus\Transaction $transaction, $amount = NULL )
{
throw new \Exception;
}
abstract public function refund(Transaction $transaction, mixed $amount = NULL, ?string $reason = NULL): mixed;
/**
* Refund Reasons that the gateway understands, if the gateway supports this
*
* @return array
* @return array
*/
public static function refundReasons()
public static function refundReasons(): array
{
return array();
return [];
}
/**
* Settings
*
* @param Form $form The form
* @return void
*/
abstract public function settings( Form $form ): void;
/**
* Test Settings
*
* @param array $settings Settings
* @return array
* @throws InvalidArgumentException
*/
abstract public function testSettings(array $settings=array() ): array;
/**
* Extra data to show on the ACP transaction page
*
* @param \IPS\nexus\Transaction $transaction Transaction
* @return string
*/
public function extraData( \IPS\nexus\Transaction $transaction )
* @param Transaction $transaction Transaction
* @return string
*/
public function extraData(Transaction $transaction ): string
{
return '';
}
/**
* Extra data to show on the ACP transaction page for a dispute
*
* @param \IPS\nexus\Transaction $transaction Transaction
* @param string $ref Dispute reference ID
* @return string
*/
public function disputeData( \IPS\nexus\Transaction $transaction, $ref )
* @param Transaction $transaction Transaction
* @param string|array $ref Dispute reference ID
* @return string
*/
public function disputeData(Transaction $transaction, string|array $ref ): string
{
return '';
}
/**
* Run any gateway-specific anti-fraud checks and return status for transaction
* This is only called if our local anti-fraud rules have not matched
*
* @param \IPS\nexus\Transaction $transaction Transaction
* @return string
* @param Transaction $transaction Transaction
* @return string
*/
public function fraudCheck( \IPS\nexus\Transaction $transaction )
public function fraudCheck(Transaction $transaction ): string
{
return $transaction::STATUS_PAID;
}
/**
* URL to view transaction in gateway
*
* @param \IPS\nexus\Transaction $transaction Transaction
* @return \IPS\Http\Url|NULL
*/
public function gatewayUrl( \IPS\nexus\Transaction $transaction )
* @param Transaction $transaction Transaction
* @return Url|NULL
*/
public function gatewayUrl(Transaction $transaction ): Url|null
{
return NULL;
}
/**
* Get output for API
* Automatically take payment
* Return an array of all transactions generated by this method
*
* @param \IPS\Member|NULL $authorizedMember The member making the API request or NULL for API Key / client_credentials
* @return array
* @apiresponse int id ID number
* @apiresponse string name Name
* @param Invoice $invoice
* @return Transaction[]
*/
public function apiOutput( \IPS\Member $authorizedMember = NULL )
public function autopay( Invoice $invoice ) : array
{
return array(
'id' => $this->id,
'name' => $this->_title
);
return [];
}
/**
* Returns the Apple Pay domain verification file if there's one.
*
* @return void|null
* @return File|null
*/
public static function getStripeAppleVerificationFile()
public static function getStripeAppleVerificationFile(): File|null
{
foreach ( static::roots() as $gateway )
{
@@ -676,13 +743,11 @@ class _Gateway extends \IPS\Node\Model
{
try
{
return \IPS\File::get( 'nexus_Gateways', $gateway->validationfile );
}
catch ( \Exception $e )
{
return NULL;
return File::get( 'nexus_Gateways', $gateway->validationfile );
}
catch ( Exception ){}
}
}
return null;
}
}