From ebc58a18bb7f585d8a31c7f2971dcd62edbf2876 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 24 Oct 2021 15:14:36 +1100 Subject: [PATCH] Minor fixes --- app/Http/ValidationRules/ValidAmount.php | 5 ++++- app/PaymentDrivers/BaseDriver.php | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/Http/ValidationRules/ValidAmount.php b/app/Http/ValidationRules/ValidAmount.php index d2832e83a046..e87cd4239977 100644 --- a/app/Http/ValidationRules/ValidAmount.php +++ b/app/Http/ValidationRules/ValidAmount.php @@ -26,7 +26,10 @@ class ValidAmount implements Rule */ public function passes($attribute, $value) { - return trim($value, '-1234567890.,') === ''; + return is_numeric((string)$value); + //return filter_var((string)$value, FILTER_VALIDATE_FLOAT); +// return preg_match('^(?=.)([+-]?([0-9]*)(\.([0-9]+))?)$^', (string)$value); + // return trim($value, '-1234567890.,') === ''; } diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index e1b0e65fee77..397583bd6e43 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -221,6 +221,19 @@ class BaseDriver extends AbstractPaymentDriver { $this->confirmGatewayFee(); + /*Never create a payment with a duplicate transaction reference*/ + if(array_key_exists('transaction_reference', $data)){ + + $_payment = Payment::where('transaction_reference', $data['transaction_reference']) + ->where('client_id', $this->client->id) + ->first(); + + if($_payment) + return $_payment; + + } + + $payment = PaymentFactory::create($this->client->company->id, $this->client->user->id); $payment->client_id = $this->client->id; $payment->company_gateway_id = $this->company_gateway->id;