Fixes for handling payment drivers that do not exist in v5

This commit is contained in:
David Bomba 2021-12-31 09:23:54 +11:00
parent 16880ddc8b
commit 2e19d1e4a9
2 changed files with 12 additions and 1 deletions

View File

@ -14,6 +14,7 @@ namespace App\Models;
use App\Models\GatewayType; use App\Models\GatewayType;
use App\Utils\Number; use App\Utils\Number;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use PDO;
use stdClass; use stdClass;
class CompanyGateway extends BaseModel class CompanyGateway extends BaseModel
@ -125,7 +126,11 @@ class CompanyGateway extends BaseModel
{ {
$class = static::driver_class(); $class = static::driver_class();
if(!$class)
return false;
return new $class($this, $client); return new $class($this, $client);
} }
private function driver_class() private function driver_class()
@ -136,7 +141,9 @@ class CompanyGateway extends BaseModel
if (class_exists($class)) if (class_exists($class))
return $class; return $class;
throw new \Exception("Payment Driver does not exist"); return false;
// throw new \Exception("Payment Driver does not exist");
} }
/** /**

View File

@ -140,6 +140,10 @@ class PaymentMethod
foreach ($this->gateways as $gateway) { foreach ($this->gateways as $gateway) {
//if gateway doesn't exist or is not implemented - continue here //todo
if(!$gateway->driver($this->client))
continue;
foreach ($gateway->driver($this->client)->gatewayTypes() as $type) { foreach ($gateway->driver($this->client)->gatewayTypes() as $type) {
if (isset($gateway->fees_and_limits) && is_object($gateway->fees_and_limits) && property_exists($gateway->fees_and_limits, $type)) { if (isset($gateway->fees_and_limits) && is_object($gateway->fees_and_limits) && property_exists($gateway->fees_and_limits, $type)) {