From f270fbe2d6ea10294ce58d87fec1273cb2d46d17 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 23 Oct 2021 11:45:22 +1100 Subject: [PATCH] Throw exception on paytrace failure --- app/Http/ValidationRules/ValidAmount.php | 2 +- app/PaymentDrivers/PaytracePaymentDriver.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Http/ValidationRules/ValidAmount.php b/app/Http/ValidationRules/ValidAmount.php index dc57b308eb42..4f5fe1700de3 100644 --- a/app/Http/ValidationRules/ValidAmount.php +++ b/app/Http/ValidationRules/ValidAmount.php @@ -26,7 +26,7 @@ class ValidAmount implements Rule */ public function passes($attribute, $value) { - return (bool) is_float($value) || is_int($value); + return (bool) is_float($value) || preg_match('#[^0-9]#',$value); } /** diff --git a/app/PaymentDrivers/PaytracePaymentDriver.php b/app/PaymentDrivers/PaytracePaymentDriver.php index 3b164f4a64b8..f834791c4311 100644 --- a/app/PaymentDrivers/PaytracePaymentDriver.php +++ b/app/PaymentDrivers/PaytracePaymentDriver.php @@ -11,6 +11,7 @@ namespace App\PaymentDrivers; +use App\Exceptions\SystemError; use App\Jobs\Util\SystemLogger; use App\Models\ClientGatewayToken; use App\Models\GatewayType; @@ -192,7 +193,7 @@ class PaytracePaymentDriver extends BaseDriver $auth_data = json_decode($response); if(!property_exists($auth_data, 'access_token')) - throw new \Exception('Error authenticating with PayTrace'); + throw new SystemError('Error authenticating with PayTrace'); $headers = []; $headers[] = 'Content-type: application/json';