diff --git a/app/Models/SystemLog.php b/app/Models/SystemLog.php index ae05a07aec..7614c01ecc 100644 --- a/app/Models/SystemLog.php +++ b/app/Models/SystemLog.php @@ -67,6 +67,7 @@ class SystemLog extends Model const TYPE_CUSTOM = 306; const TYPE_BRAINTREE = 307; const TYPE_WEPAY = 309; + const TYPE_PAYFAST = 310; const TYPE_QUOTA_EXCEEDED = 400; diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php new file mode 100644 index 0000000000..991ac41d6d --- /dev/null +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -0,0 +1,52 @@ +payfast = $payfast; + } + + public function authorizeView($data) + { + // $data['gateway'] = $this->wepay_payment_driver; + + // return render('gateways.wepay.authorize.authorize', $data); + } + + public function authorizeResponse($request) + { + + + } + + + + +} + diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php new file mode 100644 index 0000000000..5a3536fc7a --- /dev/null +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -0,0 +1,93 @@ + CreditCard::class, + ]; + + const SYSTEM_LOG_TYPE = SystemLog::TYPE_PAYFAST; + + public function init() + { + + $this->payfast = new PayFastPayment( + [ + 'merchantId' => $this->company_gateway->getConfigField('merchantId'), + 'merchantKey' => $this->company_gateway->getConfigField('merchantKey'), + 'passPhrase' => $this->company_gateway->getConfigField('passPhrase'), + 'testMode' => $this->company_gateway->getConfigField('testMode') + ] + ); + + return $this; + } + + public function setPaymentMethod($payment_method_id) + { + $class = self::$methods[$payment_method_id]; + $this->payment_method = new $class($this); + return $this; + } + + public function authorizeView(array $data) + { + return $this->payment_method->authorizeView($data); //this is your custom implementation from here + } + + public function authorizeResponse($request) + { + return $this->payment_method->authorizeResponse($request); //this is your custom implementation from here + } + + public function processPaymentView(array $data) + { + return $this->payment_method->paymentView($data); //this is your custom implementation from here + } + + public function processPaymentResponse($request) + { + return $this->payment_method->paymentResponse($request); //this is your custom implementation from here + } + + public function refund(Payment $payment, $amount, $return_client_response = false) + { + return $this->payment_method->yourRefundImplementationHere(); //this is your custom implementation from here + } + + public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash) + { + return $this->payment_method->yourTokenBillingImplmentation(); //this is your custom implementation from here + } +} diff --git a/composer.json b/composer.json index aac5045c9a..e4323749a3 100644 --- a/composer.json +++ b/composer.json @@ -63,6 +63,7 @@ "maennchen/zipstream-php": "^1.2", "nwidart/laravel-modules": "^8.0", "omnipay/paypal": "^3.0", + "payfast/payfast-php-sdk": "^1.1", "pragmarx/google2fa": "^8.0", "predis/predis": "^1.1", "sentry/sentry-laravel": "^2", diff --git a/composer.lock b/composer.lock index 8f7e0b5d34..a5c64eb7a9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "013b0357f14c1782315168bc42234b34", + "content-hash": "cadeb954feac99fb76194b0ded979cab", "packages": [ { "name": "asm/php-ansible", @@ -5213,6 +5213,57 @@ }, "time": "2020-10-15T08:29:30+00:00" }, + { + "name": "payfast/payfast-php-sdk", + "version": "v1.1.2", + "source": { + "type": "git", + "url": "https://github.com/PayFast/payfast-php-sdk.git", + "reference": "1372980e38f381b84eed7eb46a40d5819a4fe58c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PayFast/payfast-php-sdk/zipball/1372980e38f381b84eed7eb46a40d5819a4fe58c", + "reference": "1372980e38f381b84eed7eb46a40d5819a4fe58c", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/guzzle": ">=6.0.0", + "php": ">=7.2.5" + }, + "require-dev": { + "phpunit/phpunit": "^9" + }, + "type": "library", + "autoload": { + "psr-4": { + "PayFast\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Claire Grant", + "email": "claire.grant@payfast.co.za" + } + ], + "description": "PayFast PHP Library", + "keywords": [ + "api", + "onsite", + "payfast", + "php" + ], + "support": { + "issues": "https://github.com/PayFast/payfast-php-sdk/issues", + "source": "https://github.com/PayFast/payfast-php-sdk/tree/v1.1.2" + }, + "time": "2021-03-15T19:58:26+00:00" + }, { "name": "php-http/client-common", "version": "2.3.0", diff --git a/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php b/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php new file mode 100644 index 0000000000..0ed71e8bf7 --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php @@ -0,0 +1,50 @@ +@extends('portal.ninja2020.layout.payments', ['gateway_title' => ctrans('texts.credit_card'), 'card_title' => ctrans('texts.credit_card')]) + +@section('gateway_head') + + + + + + + + + + + + + +@endsection + +@section('gateway_content') +
+ + @if(!Request::isSecure()) +{{ ctrans('texts.https_required') }}
+ @endif + + + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.method')]) + {{ ctrans('texts.credit_card') }} + @endcomponent + + @include('portal.ninja2020.gateways.wepay.includes.credit_card') + + @component('portal.ninja2020.gateways.includes.pay_now', ['id' => 'card_button']) + {{ ctrans('texts.add_payment_method') }} + @endcomponent +@endsection + +@section('gateway_footer') + +@endsection