Skip to content

Commit

Permalink
style: Added DocBlocks for BaseGateway
Browse files Browse the repository at this point in the history
  • Loading branch information
seebeen committed Sep 24, 2023
1 parent 9804401 commit 5067f10
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions src/Module/BaseGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
use WHMCS\Database\Capsule;
use WHMCS\Invoice;

/**
* Base Third Party Gateway Module
*/
abstract class BaseGateway extends BaseModule
{
/**
Expand All @@ -21,7 +24,6 @@ abstract class BaseGateway extends BaseModule
*/
protected readonly array $meta;


/**
* {@inheritDoc}
*/
Expand All @@ -32,13 +34,18 @@ protected function __construct()
parent::__construct();
}

/**
* Gateways load the settings via WHMCS native function
*
* @return array
*/
protected function loadSettings(): array
{
return getGatewayVariables($this->moduleName);
}

/**
* Get the Gateway module Meta Data
* Get the Gateway module MetaData
*
* @return array
*/
Expand All @@ -59,6 +66,11 @@ public function getTransactions(int $invoiceId): ?array
}
}

/**
* Get the gateway logs for this gateway
*
* @return array
*/
public function getGatewayLogs(): array
{
$logs = [];
Expand All @@ -79,6 +91,12 @@ public function getGatewayLogs(): array
return $logs;
}

/**
* Get a gateway log for a specific transaction
*
* @param string $transactionId The transaction ID
* @return array|null Gateway log
*/
public function getGatewayLog(string $transactionId): ?array
{
$logs = array_filter(
Expand All @@ -92,10 +110,16 @@ public function getGatewayLog(string $transactionId): ?array
/**
* Returns a transaction ID for the transaction log
*
* @param $log
* @param array $log The transaction log
* @return string The transaction ID
*/
abstract protected function getTransactionId(array $log): string;

/**
* Main third party gateway callback function
*
* This function is called by WHMCS when the gateway sends a callback to WHMCS
*/
public function checkResponse(): void
{
if (empty($_POST)) {
Expand All @@ -120,6 +144,12 @@ public function checkResponse(): void
$this->gatewayCallback($data, $invoiceId);
}

/**
* Gateway callback function to be implemented by the gateway
*
* @param array $data Gateway callback data
* @param int $invoiceId Invoice ID
*/
abstract protected function gatewayCallback(array $data, int $invoiceId): void;

/**
Expand Down

0 comments on commit 5067f10

Please sign in to comment.