From fdd71166df3665dcbcc5ff74e702826460d7e441 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 10 Jul 2021 16:26:06 +1000 Subject: [PATCH] Minor fixes for Payfast --- app/PaymentDrivers/PayFastPaymentDriver.php | 32 +++++++++------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 32cd2643edc4..2ed0a070f0b0 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -21,7 +21,6 @@ use App\PaymentDrivers\PayFast\Token; use App\Utils\Traits\MakesHash; use Illuminate\Http\Request; use Illuminate\Support\Facades\Cache; -use PayFastPayment; class PayFastPaymentDriver extends BaseDriver { @@ -38,19 +37,16 @@ class PayFastPaymentDriver extends BaseDriver public $payment_method; //initialized payment method public static $methods = [ - GatewayType::CREDIT_CARD => CreditCard::class, + GatewayType::CREDIT_CARD => CreditCard::class, ]; - const SYSTEM_LOG_TYPE = SystemLog::TYPE_PAYFAST; - + const SYSTEM_LOG_TYPE = SystemLog::TYPE_PAYFAST; //developer resources //https://sandbox.payfast.co.za/ - - public function gatewayTypes(): array { $types = []; @@ -59,7 +55,7 @@ class PayFastPaymentDriver extends BaseDriver return $types; } - + public function endpointUrl() { if($this->company_gateway->getConfigField('testMode')) @@ -73,7 +69,7 @@ class PayFastPaymentDriver extends BaseDriver try{ - $this->payfast = new PayFastPayment( + $this->payfast = new \PayFast\PayFastPayment( [ 'merchantId' => $this->company_gateway->getConfigField('merchantId'), 'merchantKey' => $this->company_gateway->getConfigField('merchantKey'), @@ -100,12 +96,12 @@ class PayFastPaymentDriver extends BaseDriver public function authorizeView(array $data) { - return $this->payment_method->authorizeView($data); + return $this->payment_method->authorizeView($data); } public function authorizeResponse($request) { - return $this->payment_method->authorizeResponse($request); + return $this->payment_method->authorizeResponse($request); } public function processPaymentView(array $data) @@ -130,7 +126,7 @@ class PayFastPaymentDriver extends BaseDriver return (new Token($this))->tokenBilling($cgt, $payment_hash); } - // public function generateSignature($data, $passPhrase = null) + // public function generateSignature($data, $passPhrase = null) // { // // Create parameter string // $pfOutput = ''; @@ -202,20 +198,20 @@ class PayFastPaymentDriver extends BaseDriver $hash = Cache::get($data['m_payment_id']); - switch ($hash) + switch ($hash) { case 'cc_auth': return $this->setPaymentMethod(GatewayType::CREDIT_CARD) - ->authorizeResponse($request); + ->authorizeResponse($request); break; - + default: - + $payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$data['m_payment_id']])->first(); return $this->setPaymentMethod(GatewayType::CREDIT_CARD) ->setPaymentHash($payment_hash) - ->processPaymentResponse($request); + ->processPaymentResponse($request); break; } @@ -223,6 +219,6 @@ class PayFastPaymentDriver extends BaseDriver } return response()->json([], 200); - - } + + } }