From 50749cd2bbe41ff82a2b45d503ca3cf751439d17 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 24 Jun 2021 14:43:14 +1000 Subject: [PATCH 01/61] Payfast --- app/Models/SystemLog.php | 1 + app/PaymentDrivers/PayFast/CreditCard.php | 52 +++++++++++ app/PaymentDrivers/PayFastPaymentDriver.php | 93 +++++++++++++++++++ composer.json | 1 + composer.lock | 53 ++++++++++- .../gateways/payfast/authorize.blade.php | 50 ++++++++++ 6 files changed, 249 insertions(+), 1 deletion(-) create mode 100644 app/PaymentDrivers/PayFast/CreditCard.php create mode 100644 app/PaymentDrivers/PayFastPaymentDriver.php create mode 100644 resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php diff --git a/app/Models/SystemLog.php b/app/Models/SystemLog.php index ae05a07aec22..7614c01ecccc 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 000000000000..991ac41d6da4 --- /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 000000000000..5a3536fc7ace --- /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 aac5045c9a80..e4323749a332 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 8f7e0b5d340e..a5c64eb7a99c 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 000000000000..0ed71e8bf772 --- /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') +
+ @csrf + + + + + + +
+ + @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 From 15bdb3ff3c4b3ed7a4c19e6d094c0fd72f8ef65b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 24 Jun 2021 15:46:10 +1000 Subject: [PATCH 02/61] Payfast --- app/Models/CompanyGateway.php | 7 ++ app/PaymentDrivers/PayFast/CreditCard.php | 66 ++++++++++++++++++- app/PaymentDrivers/PayFastPaymentDriver.php | 50 +++++++++++--- .../gateways/payfast/authorize.blade.php | 35 ++++------ 4 files changed, 125 insertions(+), 33 deletions(-) diff --git a/app/Models/CompanyGateway.php b/app/Models/CompanyGateway.php index 35565ca410d3..a7860e982446 100644 --- a/app/Models/CompanyGateway.php +++ b/app/Models/CompanyGateway.php @@ -358,6 +358,11 @@ class CompanyGateway extends BaseModel return $fee; } + public function webhookUrl() + { + return route('payment_webhook', ['company_key' => $this->company->company_key, 'company_gateway_id' => $this->hashed_id]); + } + /** * we need to average out the gateway fees across all the invoices * so lets iterate. @@ -399,4 +404,6 @@ class CompanyGateway extends BaseModel return $this ->where('id', $this->decodePrimaryKey($value))->firstOrFail(); } + + } diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index 991ac41d6da4..85fef271eac9 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -32,11 +32,71 @@ class CreditCard $this->payfast = $payfast; } +/* + $data = array(); + $data['merchant_id'] = $this->getMerchantId(); + $data['merchant_key'] = $this->getMerchantKey(); + $data['return_url'] = $this->getReturnUrl(); + $data['cancel_url'] = $this->getCancelUrl(); + $data['notify_url'] = $this->getNotifyUrl(); + + if ($this->getCard()) { + $data['name_first'] = $this->getCard()->getFirstName(); + $data['name_last'] = $this->getCard()->getLastName(); + $data['email_address'] = $this->getCard()->getEmail(); + } + + $data['m_payment_id'] = $this->getTransactionId(); + $data['amount'] = $this->getAmount(); + $data['item_name'] = $this->getDescription(); + $data['custom_int1'] = $this->getCustomInt1(); + $data['custom_int2'] = $this->getCustomInt2(); + $data['custom_int3'] = $this->getCustomInt3(); + $data['custom_int4'] = $this->getCustomInt4(); + $data['custom_int5'] = $this->getCustomInt5(); + $data['custom_str1'] = $this->getCustomStr1(); + $data['custom_str2'] = $this->getCustomStr2(); + $data['custom_str3'] = $this->getCustomStr3(); + $data['custom_str4'] = $this->getCustomStr4(); + $data['custom_str5'] = $this->getCustomStr5(); + + if ($this->getPaymentMethod()) { + $data['payment_method'] = $this->getPaymentMethod(); + } + + if (1 == $this->getSubscriptionType()) { + $data['subscription_type'] = $this->getSubscriptionType(); + $data['billing_date'] = $this->getBillingDate(); + $data['recurring_amount'] = $this->getRecurringAmount(); + $data['frequency'] = $this->getFrequency(); + $data['cycles'] = $this->getCycles(); + } + if (2 == $this->getSubscriptionType()) { + $data['subscription_type'] = $this->getSubscriptionType(); + } + + $data['passphrase'] = $this->getParameter('passphrase'); 123456789012aV + $data['signature'] = $this->generateSignature($data); + */ + public function authorizeView($data) { - // $data['gateway'] = $this->wepay_payment_driver; - - // return render('gateways.wepay.authorize.authorize', $data); + $data = [ + 'merchant_id' => $this->payfast->company_gateway->getConfigField('merchantId'), + 'merchant_key' => $this->payfast->company_gateway->getConfigField('merchantKey'), + 'return_url' => route('client.payment_methods.index'), + 'cancel_url' => route('client.payment_methods.index'), + 'notify_url' => $this->company_gateway->webhookUrl(), + 'amount' => 0, + 'item_name' => 'pre-auth', + 'subscription_type' => 2, + 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), + ]; + + $data['signature'] = $this->payfast->generateSignature($data); + $data['gateway'] = $this->payfast; + + return render('gateways.payfast.authorize', $data); } public function authorizeResponse($request) diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 5a3536fc7ace..3948b8cbbf44 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -18,6 +18,7 @@ use App\Models\PaymentHash; use App\Models\SystemLog; use App\PaymentDrivers\PayFast\CreditCard; use App\Utils\Traits\MakesHash; +use \PayFastPayment; class PayFastPaymentDriver extends BaseDriver { @@ -39,17 +40,33 @@ class PayFastPaymentDriver extends BaseDriver const SYSTEM_LOG_TYPE = SystemLog::TYPE_PAYFAST; + //Live: https://www.payfast.co.za/eng/process + //Sandbox: https://sandbox.payfast.co.za/eng/process + + public function gatewayTypes(): array + { + $types = []; + + $types[] = GatewayType::CREDIT_CARD; + + return $types; + } + 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') - ] - ); + try{ + $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') + ] + ); + } catch(Exception $e) { + echo 'There was an exception: '.$e->getMessage(); + } return $this; } @@ -90,4 +107,21 @@ class PayFastPaymentDriver extends BaseDriver { return $this->payment_method->yourTokenBillingImplmentation(); //this is your custom implementation from here } + + public function generateSignature($data, $passPhrase = null) + { + // Create parameter string + $pfOutput = ''; + foreach( $data as $key => $val ) { + if($val !== '') { + $pfOutput .= $key .'='. urlencode( trim( $val ) ) .'&'; + } + } + // Remove last ampersand + $getString = substr( $pfOutput, 0, -1 ); + if( $passPhrase !== null ) { + $getString .= '&passphrase='. urlencode( trim( $passPhrase ) ); + } + return md5( $getString ); + } } diff --git a/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php b/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php index 0ed71e8bf772..41a54580f5e4 100644 --- a/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php +++ b/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php @@ -1,32 +1,25 @@ @extends('portal.ninja2020.layout.payments', ['gateway_title' => ctrans('texts.credit_card'), 'card_title' => ctrans('texts.credit_card')]) @section('gateway_head') - - - - - - - - - - - @endsection @section('gateway_content') -
- @csrf + + + + + + + + + + + - - - - - -
+ + @if(!Request::isSecure())

{{ ctrans('texts.https_required') }}

@@ -38,8 +31,6 @@ {{ 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 From 6f1593a35e084ee47261aca1f471d147ccf1c1f4 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 24 Jun 2021 15:51:30 +1000 Subject: [PATCH 03/61] Padding our DriverTemplate --- app/PaymentDrivers/DriverTemplate.php | 16 ++++++++++++++++ app/PaymentDrivers/PayFast/CreditCard.php | 1 + app/PaymentDrivers/PayFastPaymentDriver.php | 11 ++++++++--- .../gateways/payfast/authorize.blade.php | 2 +- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/app/PaymentDrivers/DriverTemplate.php b/app/PaymentDrivers/DriverTemplate.php index 083db80e8d68..c38f126d8e33 100644 --- a/app/PaymentDrivers/DriverTemplate.php +++ b/app/PaymentDrivers/DriverTemplate.php @@ -39,6 +39,22 @@ class DriverTemplate extends BaseDriver const SYSTEM_LOG_TYPE = SystemLog::TYPE_STRIPE; //define a constant for your gateway ie TYPE_YOUR_CUSTOM_GATEWAY - set the const in the SystemLog model + public function init() + { + return $this; /* This is where you boot the gateway with your auth credentials*/ + } + + /* Returns an array of gateway types for the payment gateway */ + public function gatewayTypes(): array + { + $types = []; + + $types[] = GatewayType::CREDIT_CARD; + + return $types; + } + + /* Sets the payment method initialized */ public function setPaymentMethod($payment_method_id) { $class = self::$methods[$payment_method_id]; diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index 85fef271eac9..a95815507161 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -95,6 +95,7 @@ class CreditCard $data['signature'] = $this->payfast->generateSignature($data); $data['gateway'] = $this->payfast; + $data['payment_endpoint_url'] = $this->payfast->endpointUrl(); return render('gateways.payfast.authorize', $data); } diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 3948b8cbbf44..c759a2ee561a 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -40,9 +40,6 @@ class PayFastPaymentDriver extends BaseDriver const SYSTEM_LOG_TYPE = SystemLog::TYPE_PAYFAST; - //Live: https://www.payfast.co.za/eng/process - //Sandbox: https://sandbox.payfast.co.za/eng/process - public function gatewayTypes(): array { $types = []; @@ -52,6 +49,14 @@ class PayFastPaymentDriver extends BaseDriver return $types; } + public function endpointUrl() + { + if($this->company_gateway->getConfigField('testMode')) + return 'https://sandbox.payfast.co.za/eng/process'; + + return 'https://www.payfast.co.za/eng/process'; + } + public function init() { diff --git a/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php b/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php index 41a54580f5e4..f7eb6cabc7f9 100644 --- a/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php +++ b/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php @@ -6,7 +6,7 @@ @endsection @section('gateway_content') -
+ From a01df6742723ea8b1550db758609df2a6e8c471a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 24 Jun 2021 18:43:51 +1000 Subject: [PATCH 04/61] Fixes for payfast driver --- app/PaymentDrivers/PayFast/CreditCard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index a95815507161..045a964211d4 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -86,7 +86,7 @@ class CreditCard 'merchant_key' => $this->payfast->company_gateway->getConfigField('merchantKey'), 'return_url' => route('client.payment_methods.index'), 'cancel_url' => route('client.payment_methods.index'), - 'notify_url' => $this->company_gateway->webhookUrl(), + 'notify_url' => $this->payfast->company_gateway->webhookUrl(), 'amount' => 0, 'item_name' => 'pre-auth', 'subscription_type' => 2, From f04291826c746f800cc1857cab9376eccdb502e8 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 24 Jun 2021 18:45:44 +1000 Subject: [PATCH 05/61] Fixes for payfast driver --- .../portal/ninja2020/gateways/payfast/authorize.blade.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php b/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php index f7eb6cabc7f9..f12491735b35 100644 --- a/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php +++ b/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php @@ -16,10 +16,7 @@ - - - - + @if(!Request::isSecure())

{{ ctrans('texts.https_required') }}

@@ -34,6 +31,7 @@ @component('portal.ninja2020.gateways.includes.pay_now', ['id' => 'card_button']) {{ ctrans('texts.add_payment_method') }} @endcomponent + @endsection @section('gateway_footer') From 94c424a15b44a2bdf8177af4c6dbd18726412dab Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 24 Jun 2021 18:49:53 +1000 Subject: [PATCH 06/61] Fixes for payfast driver --- .../portal/ninja2020/gateways/payfast/authorize.blade.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php b/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php index f12491735b35..b1db2d411bc0 100644 --- a/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php +++ b/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php @@ -6,7 +6,7 @@ @endsection @section('gateway_content') -
+ @@ -17,7 +17,7 @@ - + @if(!Request::isSecure())

{{ ctrans('texts.https_required') }}

@endif @@ -28,10 +28,10 @@ {{ ctrans('texts.credit_card') }} @endcomponent - @component('portal.ninja2020.gateways.includes.pay_now', ['id' => 'card_button']) + @component('portal.ninja2020.gateways.includes.pay_now', ['id' => 'server_response']) {{ ctrans('texts.add_payment_method') }} @endcomponent -
+ @endsection @section('gateway_footer') From 3baa0e3d9a4f1ace4f502a82efc3864fb2a733c4 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 24 Jun 2021 19:45:45 +1000 Subject: [PATCH 07/61] PayFast Webhook URL listener --- app/PaymentDrivers/DriverTemplate.php | 5 +++++ app/PaymentDrivers/PayFastPaymentDriver.php | 7 +++++++ .../ninja2020/gateways/payfast/authorize.blade.php | 13 ++++++++++--- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/app/PaymentDrivers/DriverTemplate.php b/app/PaymentDrivers/DriverTemplate.php index c38f126d8e33..36c0f9bf5b72 100644 --- a/app/PaymentDrivers/DriverTemplate.php +++ b/app/PaymentDrivers/DriverTemplate.php @@ -11,6 +11,7 @@ namespace App\PaymentDrivers; +use App\Http\Requests\Payments\PaymentWebhookRequest; use App\Models\ClientGatewayToken; use App\Models\GatewayType; use App\Models\Payment; @@ -91,4 +92,8 @@ class DriverTemplate extends BaseDriver { return $this->payment_method->yourTokenBillingImplmentation(); //this is your custom implementation from here } + + public function processWebhookRequest(PaymentWebhookRequest $request, Payment $payment = null) + { + } } diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index c759a2ee561a..87005a7960b9 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -128,5 +128,12 @@ class PayFastPaymentDriver extends BaseDriver $getString .= '&passphrase='. urlencode( trim( $passPhrase ) ); } return md5( $getString ); + } + + public function processWebhookRequest(PaymentWebhookRequest $request, Payment $payment = null) + { + + nlog($request->all()); + return response()->json([], 200); } } diff --git a/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php b/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php index b1db2d411bc0..06cdd2dc56ba 100644 --- a/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php +++ b/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php @@ -17,6 +17,7 @@ + @if(!Request::isSecure())

{{ ctrans('texts.https_required') }}

@@ -28,9 +29,15 @@ {{ ctrans('texts.credit_card') }} @endcomponent - @component('portal.ninja2020.gateways.includes.pay_now', ['id' => 'server_response']) - {{ ctrans('texts.add_payment_method') }} - @endcomponent +
+ +
+ @endsection From c961d32c81e7465891f864b308348848b393c2a8 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 24 Jun 2021 19:59:14 +1000 Subject: [PATCH 08/61] Minor fixes --- app/Http/Controllers/PaymentWebhookController.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/Http/Controllers/PaymentWebhookController.php b/app/Http/Controllers/PaymentWebhookController.php index 2c83d1a5eb63..39598ea51e5a 100644 --- a/app/Http/Controllers/PaymentWebhookController.php +++ b/app/Http/Controllers/PaymentWebhookController.php @@ -21,8 +21,6 @@ class PaymentWebhookController extends Controller public function __invoke(PaymentWebhookRequest $request, string $company_key, string $company_gateway_id) { - // MultiDB::findAndSetDbByCompanyKey($company_key); - $payment = $request->getPayment(); if(!$payment) From 95bbc4108c6d882bd5b210a7ad1a5513263cdb3b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 08:59:52 +1000 Subject: [PATCH 09/61] Payfast custom notify URL --- .../PaymentNotificationWebhookController.php | 33 +++++++++++++++ .../PaymentNotificationWebhookRequest.php | 42 +++++++++++++++++++ app/PaymentDrivers/BaseDriver.php | 9 ++++ app/PaymentDrivers/PayFast/CreditCard.php | 4 +- app/PaymentDrivers/PayFastPaymentDriver.php | 11 ++++- routes/api.php | 4 ++ 6 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 app/Http/Controllers/PaymentNotificationWebhookController.php create mode 100644 app/Http/Requests/Payments/PaymentNotificationWebhookRequest.php diff --git a/app/Http/Controllers/PaymentNotificationWebhookController.php b/app/Http/Controllers/PaymentNotificationWebhookController.php new file mode 100644 index 000000000000..d310899593cc --- /dev/null +++ b/app/Http/Controllers/PaymentNotificationWebhookController.php @@ -0,0 +1,33 @@ +decodePrimaryKey($company_gateway_id)); + $client = Client::find($this->decodePrimaryKey($client_hash)); + + return $company_gateway + ->driver($client) + ->processWebhookRequest($request); + } +} diff --git a/app/Http/Requests/Payments/PaymentNotificationWebhookRequest.php b/app/Http/Requests/Payments/PaymentNotificationWebhookRequest.php new file mode 100644 index 000000000000..54119add0454 --- /dev/null +++ b/app/Http/Requests/Payments/PaymentNotificationWebhookRequest.php @@ -0,0 +1,42 @@ +company_key); + + return true; + } + + public function rules() + { + return [ + // + ]; + } + +} diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index a95c4e26ce23..b2747d741853 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -546,4 +546,13 @@ class BaseDriver extends AbstractPaymentDriver $this->client->company, ); } + + public function genericWebhookUrl() + { + return route('payment_notification_webhook', [ + 'company_key' => $this->client->company->company_key, + 'company_gateway_id' => $this->company_gateway->id, + 'client' => $this->client->id, + ]); + } } diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index 045a964211d4..6167d9ff794b 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -86,8 +86,8 @@ class CreditCard 'merchant_key' => $this->payfast->company_gateway->getConfigField('merchantKey'), 'return_url' => route('client.payment_methods.index'), 'cancel_url' => route('client.payment_methods.index'), - 'notify_url' => $this->payfast->company_gateway->webhookUrl(), - 'amount' => 0, + 'notify_url' => $this->payfast->genericWebhookUrl(), + 'amount' => 1, 'item_name' => 'pre-auth', 'subscription_type' => 2, 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 87005a7960b9..8c7b80ce4e7b 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -40,6 +40,14 @@ class PayFastPaymentDriver extends BaseDriver const SYSTEM_LOG_TYPE = SystemLog::TYPE_PAYFAST; + + + //developer resources + //https://sandbox.payfast.co.za/ + + + + public function gatewayTypes(): array { $types = []; @@ -70,7 +78,7 @@ class PayFastPaymentDriver extends BaseDriver ] ); } catch(Exception $e) { - echo 'There was an exception: '.$e->getMessage(); + echo '##PAYFAST## There was an exception: '.$e->getMessage(); } return $this; @@ -135,5 +143,6 @@ class PayFastPaymentDriver extends BaseDriver nlog($request->all()); return response()->json([], 200); + } } diff --git a/routes/api.php b/routes/api.php index 58aa8e1e798c..18e97cf40517 100644 --- a/routes/api.php +++ b/routes/api.php @@ -198,6 +198,10 @@ Route::match(['get', 'post'], 'payment_webhook/{company_key}/{company_gateway_id ->middleware(['guest']) ->name('payment_webhook'); +Route::match(['get', 'post'], 'payment_notification_webhook/{company_key}/{company_gateway_id}/{client}', 'PaymentNotificationWebhookController') + ->middleware(['guest']) + ->name('payment_notification_webhook'); + Route::post('api/v1/postmark_webhook', 'PostMarkController@webhook'); Route::get('token_hash_router', 'OneTimeTokenController@router'); Route::get('webcron', 'WebCronController@index'); From f4ce2320f0ce2c181900ad8869ce99da0e78c765 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 10:14:31 +1000 Subject: [PATCH 10/61] Gelf logging --- composer.lock | 556 +++++++++++++++++++++++++------------------------- 1 file changed, 281 insertions(+), 275 deletions(-) diff --git a/composer.lock b/composer.lock index 62f78144b1bc..2faaa2858fc4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,11 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], -<<<<<<< HEAD - "content-hash": "cadeb954feac99fb76194b0ded979cab", -======= - "content-hash": "cc2b7b338c5d0b4ee700f965bf294772", ->>>>>>> v5-develop + "content-hash": "26f6cde504d8ed4276289151e695250e", "packages": [ { "name": "asm/php-ansible", @@ -16,12 +12,12 @@ "source": { "type": "git", "url": "https://github.com/maschmann/php-ansible.git", - "reference": "82d567334aced59b6aa0fa872cdc7ddc561ad7e0" + "reference": "26809472cab66fb0175ae53f7281afd6b31d1296" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/maschmann/php-ansible/zipball/82d567334aced59b6aa0fa872cdc7ddc561ad7e0", - "reference": "82d567334aced59b6aa0fa872cdc7ddc561ad7e0", + "url": "https://api.github.com/repos/maschmann/php-ansible/zipball/26809472cab66fb0175ae53f7281afd6b31d1296", + "reference": "26809472cab66fb0175ae53f7281afd6b31d1296", "shasum": "" }, "require": { @@ -58,9 +54,9 @@ ], "support": { "issues": "https://github.com/maschmann/php-ansible/issues", - "source": "https://github.com/maschmann/php-ansible/tree/v3.0" + "source": "https://github.com/maschmann/php-ansible/tree/v3.0.1" }, - "time": "2021-05-09T14:58:03+00:00" + "time": "2021-06-25T20:09:17+00:00" }, { "name": "asm89/stack-cors", @@ -163,16 +159,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.184.2", + "version": "3.185.6", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "78fe691ab466fecf195209672f6c00c5d4ed219a" + "reference": "35310302912fdc3b4a0e829b84424c41e3fd9727" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/78fe691ab466fecf195209672f6c00c5d4ed219a", - "reference": "78fe691ab466fecf195209672f6c00c5d4ed219a", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/35310302912fdc3b4a0e829b84424c41e3fd9727", + "reference": "35310302912fdc3b4a0e829b84424c41e3fd9727", "shasum": "" }, "require": { @@ -247,22 +243,22 @@ "support": { "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.184.2" + "source": "https://github.com/aws/aws-sdk-php/tree/3.185.6" }, - "time": "2021-06-11T18:20:15+00:00" + "time": "2021-07-02T18:13:18+00:00" }, { "name": "bacon/bacon-qr-code", - "version": "2.0.3", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/Bacon/BaconQrCode.git", - "reference": "3e9d791b67d0a2912922b7b7c7312f4b37af41e4" + "reference": "f73543ac4e1def05f1a70bcd1525c8a157a1ad09" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Bacon/BaconQrCode/zipball/3e9d791b67d0a2912922b7b7c7312f4b37af41e4", - "reference": "3e9d791b67d0a2912922b7b7c7312f4b37af41e4", + "url": "https://api.github.com/repos/Bacon/BaconQrCode/zipball/f73543ac4e1def05f1a70bcd1525c8a157a1ad09", + "reference": "f73543ac4e1def05f1a70bcd1525c8a157a1ad09", "shasum": "" }, "require": { @@ -300,22 +296,22 @@ "homepage": "https://github.com/Bacon/BaconQrCode", "support": { "issues": "https://github.com/Bacon/BaconQrCode/issues", - "source": "https://github.com/Bacon/BaconQrCode/tree/2.0.3" + "source": "https://github.com/Bacon/BaconQrCode/tree/2.0.4" }, - "time": "2020-10-30T02:02:47+00:00" + "time": "2021-06-18T13:26:35+00:00" }, { "name": "beganovich/snappdf", - "version": "v1.6.0", + "version": "v1.7.0", "source": { "type": "git", "url": "https://github.com/beganovich/snappdf.git", - "reference": "5c0a7e2e2c33441c0dd9d1fcbfc8de71c3cc920c" + "reference": "4ae1315e793385b385699bdd0328106c39644a91" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/beganovich/snappdf/zipball/5c0a7e2e2c33441c0dd9d1fcbfc8de71c3cc920c", - "reference": "5c0a7e2e2c33441c0dd9d1fcbfc8de71c3cc920c", + "url": "https://api.github.com/repos/beganovich/snappdf/zipball/4ae1315e793385b385699bdd0328106c39644a91", + "reference": "4ae1315e793385b385699bdd0328106c39644a91", "shasum": "" }, "require": { @@ -353,22 +349,22 @@ "description": "Convert webpages or HTML into the PDF file using Chromium or Google Chrome.", "support": { "issues": "https://github.com/beganovich/snappdf/issues", - "source": "https://github.com/beganovich/snappdf/tree/v1.6.0" + "source": "https://github.com/beganovich/snappdf/tree/v1.7.0" }, - "time": "2021-03-19T21:20:07+00:00" + "time": "2021-06-26T23:28:52+00:00" }, { "name": "braintree/braintree_php", - "version": "6.2.0", + "version": "6.3.0", "source": { "type": "git", "url": "https://github.com/braintree/braintree_php.git", - "reference": "5c9f7a5008ac4589b0a332b17473d4be9f4845bc" + "reference": "69e4fab9896ae084ffed1b6bcd2ed186954d14f9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/braintree/braintree_php/zipball/5c9f7a5008ac4589b0a332b17473d4be9f4845bc", - "reference": "5c9f7a5008ac4589b0a332b17473d4be9f4845bc", + "url": "https://api.github.com/repos/braintree/braintree_php/zipball/69e4fab9896ae084ffed1b6bcd2ed186954d14f9", + "reference": "69e4fab9896ae084ffed1b6bcd2ed186954d14f9", "shasum": "" }, "require": { @@ -402,9 +398,9 @@ "description": "Braintree PHP Client Library", "support": { "issues": "https://github.com/braintree/braintree_php/issues", - "source": "https://github.com/braintree/braintree_php/tree/6.2.0" + "source": "https://github.com/braintree/braintree_php/tree/6.3.0" }, - "time": "2021-05-17T16:35:57+00:00" + "time": "2021-06-21T21:36:45+00:00" }, { "name": "brick/math", @@ -1322,16 +1318,16 @@ }, { "name": "doctrine/cache", - "version": "1.11.3", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/doctrine/cache.git", - "reference": "3bb5588cec00a0268829cc4a518490df6741af9d" + "reference": "c9622c6820d3ede1e2315a6a377ea1076e421d88" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/cache/zipball/3bb5588cec00a0268829cc4a518490df6741af9d", - "reference": "3bb5588cec00a0268829cc4a518490df6741af9d", + "url": "https://api.github.com/repos/doctrine/cache/zipball/c9622c6820d3ede1e2315a6a377ea1076e421d88", + "reference": "c9622c6820d3ede1e2315a6a377ea1076e421d88", "shasum": "" }, "require": { @@ -1401,7 +1397,7 @@ ], "support": { "issues": "https://github.com/doctrine/cache/issues", - "source": "https://github.com/doctrine/cache/tree/1.11.3" + "source": "https://github.com/doctrine/cache/tree/2.0.3" }, "funding": [ { @@ -1417,35 +1413,36 @@ "type": "tidelift" } ], - "time": "2021-05-25T09:01:55+00:00" + "time": "2021-05-25T09:43:04+00:00" }, { "name": "doctrine/dbal", - "version": "2.13.1", + "version": "2.13.2", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "c800380457948e65bbd30ba92cc17cda108bf8c9" + "reference": "8dd39d2ead4409ce652fd4f02621060f009ea5e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/c800380457948e65bbd30ba92cc17cda108bf8c9", - "reference": "c800380457948e65bbd30ba92cc17cda108bf8c9", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/8dd39d2ead4409ce652fd4f02621060f009ea5e4", + "reference": "8dd39d2ead4409ce652fd4f02621060f009ea5e4", "shasum": "" }, "require": { - "doctrine/cache": "^1.0", + "doctrine/cache": "^1.0|^2.0", "doctrine/deprecations": "^0.5.3", "doctrine/event-manager": "^1.0", "ext-pdo": "*", "php": "^7.1 || ^8" }, "require-dev": { - "doctrine/coding-standard": "8.2.0", + "doctrine/coding-standard": "9.0.0", "jetbrains/phpstorm-stubs": "2020.2", "phpstan/phpstan": "0.12.81", - "phpunit/phpunit": "^7.5.20|^8.5|9.5.0", + "phpunit/phpunit": "^7.5.20|^8.5|9.5.5", "squizlabs/php_codesniffer": "3.6.0", + "symfony/cache": "^4.4", "symfony/console": "^2.0.5|^3.0|^4.0|^5.0", "vimeo/psalm": "4.6.4" }, @@ -1508,7 +1505,7 @@ ], "support": { "issues": "https://github.com/doctrine/dbal/issues", - "source": "https://github.com/doctrine/dbal/tree/2.13.1" + "source": "https://github.com/doctrine/dbal/tree/2.13.2" }, "funding": [ { @@ -1524,7 +1521,7 @@ "type": "tidelift" } ], - "time": "2021-04-17T17:30:19+00:00" + "time": "2021-06-18T21:48:39+00:00" }, { "name": "doctrine/deprecations", @@ -2092,16 +2089,16 @@ }, { "name": "firebase/php-jwt", - "version": "v5.3.0", + "version": "v5.4.0", "source": { "type": "git", "url": "https://github.com/firebase/php-jwt.git", - "reference": "3c2d70f2e64e2922345e89f2ceae47d2463faae1" + "reference": "d2113d9b2e0e349796e72d2a63cf9319100382d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/firebase/php-jwt/zipball/3c2d70f2e64e2922345e89f2ceae47d2463faae1", - "reference": "3c2d70f2e64e2922345e89f2ceae47d2463faae1", + "url": "https://api.github.com/repos/firebase/php-jwt/zipball/d2113d9b2e0e349796e72d2a63cf9319100382d2", + "reference": "d2113d9b2e0e349796e72d2a63cf9319100382d2", "shasum": "" }, "require": { @@ -2110,6 +2107,9 @@ "require-dev": { "phpunit/phpunit": ">=4.8 <=9" }, + "suggest": { + "paragonie/sodium_compat": "Support EdDSA (Ed25519) signatures when libsodium is not present" + }, "type": "library", "autoload": { "psr-4": { @@ -2140,9 +2140,9 @@ ], "support": { "issues": "https://github.com/firebase/php-jwt/issues", - "source": "https://github.com/firebase/php-jwt/tree/v5.3.0" + "source": "https://github.com/firebase/php-jwt/tree/v5.4.0" }, - "time": "2021-05-20T17:37:02+00:00" + "time": "2021-06-23T19:00:23+00:00" }, { "name": "fruitcake/laravel-cors", @@ -2223,21 +2223,21 @@ }, { "name": "google/apiclient", - "version": "v2.9.2", + "version": "v2.10.1", "source": { "type": "git", "url": "https://github.com/googleapis/google-api-php-client.git", - "reference": "e9ef4c26a044b8d39a46bcf296be795fe24a1849" + "reference": "11871e94006ce7a419bb6124d51b6f9ace3f679b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-api-php-client/zipball/e9ef4c26a044b8d39a46bcf296be795fe24a1849", - "reference": "e9ef4c26a044b8d39a46bcf296be795fe24a1849", + "url": "https://api.github.com/repos/googleapis/google-api-php-client/zipball/11871e94006ce7a419bb6124d51b6f9ace3f679b", + "reference": "11871e94006ce7a419bb6124d51b6f9ace3f679b", "shasum": "" }, "require": { "firebase/php-jwt": "~2.0||~3.0||~4.0||~5.0", - "google/apiclient-services": "~0.13", + "google/apiclient-services": "~0.200", "google/auth": "^1.10", "guzzlehttp/guzzle": "~5.3.3||~6.0||~7.0", "guzzlehttp/psr7": "^1.2", @@ -2286,22 +2286,22 @@ ], "support": { "issues": "https://github.com/googleapis/google-api-php-client/issues", - "source": "https://github.com/googleapis/google-api-php-client/tree/v2.9.2" + "source": "https://github.com/googleapis/google-api-php-client/tree/v2.10.1" }, - "time": "2021-06-09T22:15:08+00:00" + "time": "2021-06-25T14:25:44+00:00" }, { "name": "google/apiclient-services", - "version": "v0.181.0", + "version": "v0.201.1", "source": { "type": "git", "url": "https://github.com/googleapis/google-api-php-client-services.git", - "reference": "a4ea5fd96887d654d10d446b239e1ff60240e2c1" + "reference": "ee1072221acf7c32e3de9b18e11fec3ab23ec38f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/a4ea5fd96887d654d10d446b239e1ff60240e2c1", - "reference": "a4ea5fd96887d654d10d446b239e1ff60240e2c1", + "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/ee1072221acf7c32e3de9b18e11fec3ab23ec38f", + "reference": "ee1072221acf7c32e3de9b18e11fec3ab23ec38f", "shasum": "" }, "require": { @@ -2312,9 +2312,12 @@ }, "type": "library", "autoload": { - "psr-0": { - "Google_Service_": "src" - } + "psr-4": { + "Google\\Service\\": "src" + }, + "files": [ + "autoload.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -2327,22 +2330,22 @@ ], "support": { "issues": "https://github.com/googleapis/google-api-php-client-services/issues", - "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.181.0" + "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.201.1" }, - "time": "2021-06-13T11:20:02+00:00" + "time": "2021-06-27T11:20:22+00:00" }, { "name": "google/auth", - "version": "v1.15.1", + "version": "v1.16.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-auth-library-php.git", - "reference": "4e0c9367719df9703e96f5ad613041b87742471c" + "reference": "c747738d2dd450f541f09f26510198fbedd1c8a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-auth-library-php/zipball/4e0c9367719df9703e96f5ad613041b87742471c", - "reference": "4e0c9367719df9703e96f5ad613041b87742471c", + "url": "https://api.github.com/repos/googleapis/google-auth-library-php/zipball/c747738d2dd450f541f09f26510198fbedd1c8a0", + "reference": "c747738d2dd450f541f09f26510198fbedd1c8a0", "shasum": "" }, "require": { @@ -2350,7 +2353,7 @@ "guzzlehttp/guzzle": "^5.3.1|^6.2.1|^7.0", "guzzlehttp/psr7": "^1.2", "php": ">=5.4", - "psr/cache": "^1.0", + "psr/cache": "^1.0|^2.0", "psr/http-message": "^1.0" }, "require-dev": { @@ -2384,9 +2387,9 @@ "support": { "docs": "https://googleapis.github.io/google-auth-library-php/master/", "issues": "https://github.com/googleapis/google-auth-library-php/issues", - "source": "https://github.com/googleapis/google-auth-library-php/tree/v1.15.1" + "source": "https://github.com/googleapis/google-auth-library-php/tree/v1.16.0" }, - "time": "2021-04-21T17:42:05+00:00" + "time": "2021-06-22T18:06:03+00:00" }, { "name": "graham-campbell/result-type", @@ -3181,16 +3184,16 @@ }, { "name": "laravel/framework", - "version": "v8.46.0", + "version": "v8.49.1", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "a18266c612e0e6aba5e0174b3c873d2d217dccfb" + "reference": "62aee1bfeefd82f160c7aa3b4c63cb2f053215c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/a18266c612e0e6aba5e0174b3c873d2d217dccfb", - "reference": "a18266c612e0e6aba5e0174b3c873d2d217dccfb", + "url": "https://api.github.com/repos/laravel/framework/zipball/62aee1bfeefd82f160c7aa3b4c63cb2f053215c0", + "reference": "62aee1bfeefd82f160c7aa3b4c63cb2f053215c0", "shasum": "" }, "require": { @@ -3269,7 +3272,7 @@ "guzzlehttp/guzzle": "^6.5.5|^7.0.1", "league/flysystem-cached-adapter": "^1.0", "mockery/mockery": "^1.4.2", - "orchestra/testbench-core": "^6.8", + "orchestra/testbench-core": "^6.23", "pda/pheanstalk": "^4.0", "phpunit/phpunit": "^8.5.8|^9.3.3", "predis/predis": "^1.1.2", @@ -3345,7 +3348,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2021-06-08T13:36:46+00:00" + "time": "2021-07-02T16:50:12+00:00" }, { "name": "laravel/slack-notification-channel", @@ -3605,16 +3608,16 @@ }, { "name": "league/commonmark", - "version": "1.6.2", + "version": "1.6.5", "source": { "type": "git", "url": "https://github.com/thephpleague/commonmark.git", - "reference": "7d70d2f19c84bcc16275ea47edabee24747352eb" + "reference": "44ffd8d3c4a9133e4bd0548622b09c55af39db5f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/7d70d2f19c84bcc16275ea47edabee24747352eb", - "reference": "7d70d2f19c84bcc16275ea47edabee24747352eb", + "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/44ffd8d3c4a9133e4bd0548622b09c55af39db5f", + "reference": "44ffd8d3c4a9133e4bd0548622b09c55af39db5f", "shasum": "" }, "require": { @@ -3632,7 +3635,7 @@ "github/gfm": "0.29.0", "michelf/php-markdown": "~1.4", "mikehaertl/php-shellcommand": "^1.4", - "phpstan/phpstan": "^0.12", + "phpstan/phpstan": "^0.12.90", "phpunit/phpunit": "^7.5 || ^8.5 || ^9.2", "scrutinizer/ocular": "^1.5", "symfony/finder": "^4.2" @@ -3702,7 +3705,7 @@ "type": "tidelift" } ], - "time": "2021-05-12T11:39:41+00:00" + "time": "2021-06-26T11:57:13+00:00" }, { "name": "league/csv", @@ -3790,16 +3793,16 @@ }, { "name": "league/flysystem", - "version": "1.1.3", + "version": "1.1.4", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "9be3b16c877d477357c015cec057548cf9b2a14a" + "reference": "f3ad69181b8afed2c9edf7be5a2918144ff4ea32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/9be3b16c877d477357c015cec057548cf9b2a14a", - "reference": "9be3b16c877d477357c015cec057548cf9b2a14a", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/f3ad69181b8afed2c9edf7be5a2918144ff4ea32", + "reference": "f3ad69181b8afed2c9edf7be5a2918144ff4ea32", "shasum": "" }, "require": { @@ -3815,7 +3818,6 @@ "phpunit/phpunit": "^8.5.8" }, "suggest": { - "ext-fileinfo": "Required for MimeType", "ext-ftp": "Allows you to use FTP server storage", "ext-openssl": "Allows you to use FTPS server storage", "league/flysystem-aws-s3-v2": "Allows you to use S3 storage with AWS SDK v2", @@ -3873,7 +3875,7 @@ ], "support": { "issues": "https://github.com/thephpleague/flysystem/issues", - "source": "https://github.com/thephpleague/flysystem/tree/1.x" + "source": "https://github.com/thephpleague/flysystem/tree/1.1.4" }, "funding": [ { @@ -3881,7 +3883,7 @@ "type": "other" } ], - "time": "2020-08-23T07:39:11+00:00" + "time": "2021-06-23T21:56:05+00:00" }, { "name": "league/flysystem-aws-s3-v3", @@ -4249,16 +4251,16 @@ }, { "name": "livewire/livewire", - "version": "v2.4.4", + "version": "v2.5.1", "source": { "type": "git", "url": "https://github.com/livewire/livewire.git", - "reference": "33101c83b75728651b9e668a4559f97def7c9138" + "reference": "a4ffb135693e7982e5b982ca203f5dc7a7ae1126" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/livewire/livewire/zipball/33101c83b75728651b9e668a4559f97def7c9138", - "reference": "33101c83b75728651b9e668a4559f97def7c9138", + "url": "https://api.github.com/repos/livewire/livewire/zipball/a4ffb135693e7982e5b982ca203f5dc7a7ae1126", + "reference": "a4ffb135693e7982e5b982ca203f5dc7a7ae1126", "shasum": "" }, "require": { @@ -4309,7 +4311,7 @@ "description": "A front-end framework for Laravel.", "support": { "issues": "https://github.com/livewire/livewire/issues", - "source": "https://github.com/livewire/livewire/tree/v2.4.4" + "source": "https://github.com/livewire/livewire/tree/v2.5.1" }, "funding": [ { @@ -4317,7 +4319,7 @@ "type": "github" } ], - "time": "2021-04-28T15:31:15+00:00" + "time": "2021-06-15T13:24:48+00:00" }, { "name": "maennchen/zipstream-php", @@ -4568,16 +4570,16 @@ }, { "name": "mtdowling/jmespath.php", - "version": "2.6.0", + "version": "2.6.1", "source": { "type": "git", "url": "https://github.com/jmespath/jmespath.php.git", - "reference": "42dae2cbd13154083ca6d70099692fef8ca84bfb" + "reference": "9b87907a81b87bc76d19a7fb2d61e61486ee9edb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/jmespath/jmespath.php/zipball/42dae2cbd13154083ca6d70099692fef8ca84bfb", - "reference": "42dae2cbd13154083ca6d70099692fef8ca84bfb", + "url": "https://api.github.com/repos/jmespath/jmespath.php/zipball/9b87907a81b87bc76d19a7fb2d61e61486ee9edb", + "reference": "9b87907a81b87bc76d19a7fb2d61e61486ee9edb", "shasum": "" }, "require": { @@ -4585,7 +4587,7 @@ "symfony/polyfill-mbstring": "^1.17" }, "require-dev": { - "composer/xdebug-handler": "^1.4", + "composer/xdebug-handler": "^1.4 || ^2.0", "phpunit/phpunit": "^4.8.36 || ^7.5.15" }, "bin": [ @@ -4623,22 +4625,22 @@ ], "support": { "issues": "https://github.com/jmespath/jmespath.php/issues", - "source": "https://github.com/jmespath/jmespath.php/tree/2.6.0" + "source": "https://github.com/jmespath/jmespath.php/tree/2.6.1" }, - "time": "2020-07-31T21:01:56+00:00" + "time": "2021-06-14T00:11:39+00:00" }, { "name": "myclabs/php-enum", - "version": "1.8.0", + "version": "1.8.2", "source": { "type": "git", "url": "https://github.com/myclabs/php-enum.git", - "reference": "46cf3d8498b095bd33727b13fd5707263af99421" + "reference": "8bef486e885cae67ced6e43257300e8acc3f06ad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/php-enum/zipball/46cf3d8498b095bd33727b13fd5707263af99421", - "reference": "46cf3d8498b095bd33727b13fd5707263af99421", + "url": "https://api.github.com/repos/myclabs/php-enum/zipball/8bef486e885cae67ced6e43257300e8acc3f06ad", + "reference": "8bef486e885cae67ced6e43257300e8acc3f06ad", "shasum": "" }, "require": { @@ -4648,7 +4650,7 @@ "require-dev": { "phpunit/phpunit": "^9.5", "squizlabs/php_codesniffer": "1.*", - "vimeo/psalm": "^4.5.1" + "vimeo/psalm": "^4.6.2" }, "type": "library", "autoload": { @@ -4673,7 +4675,7 @@ ], "support": { "issues": "https://github.com/myclabs/php-enum/issues", - "source": "https://github.com/myclabs/php-enum/tree/1.8.0" + "source": "https://github.com/myclabs/php-enum/tree/1.8.2" }, "funding": [ { @@ -4685,20 +4687,20 @@ "type": "tidelift" } ], - "time": "2021-02-15T16:11:48+00:00" + "time": "2021-07-04T17:44:39+00:00" }, { "name": "nesbot/carbon", - "version": "2.49.0", + "version": "2.50.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "93d9db91c0235c486875d22f1e08b50bdf3e6eee" + "reference": "f47f17d17602b2243414a44ad53d9f8b9ada5fdb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/93d9db91c0235c486875d22f1e08b50bdf3e6eee", - "reference": "93d9db91c0235c486875d22f1e08b50bdf3e6eee", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/f47f17d17602b2243414a44ad53d9f8b9ada5fdb", + "reference": "f47f17d17602b2243414a44ad53d9f8b9ada5fdb", "shasum": "" }, "require": { @@ -4750,15 +4752,15 @@ { "name": "Brian Nesbitt", "email": "brian@nesbot.com", - "homepage": "http://nesbot.com" + "homepage": "https://markido.com" }, { "name": "kylekatarnls", - "homepage": "http://github.com/kylekatarnls" + "homepage": "https://github.com/kylekatarnls" } ], "description": "An API extension for DateTime that supports 281 different languages.", - "homepage": "http://carbon.nesbot.com", + "homepage": "https://carbon.nesbot.com", "keywords": [ "date", "datetime", @@ -4778,20 +4780,20 @@ "type": "tidelift" } ], - "time": "2021-06-02T07:31:40+00:00" + "time": "2021-06-28T22:38:45+00:00" }, { "name": "nikic/php-parser", - "version": "v4.10.5", + "version": "v4.11.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "4432ba399e47c66624bc73c8c0f811e5c109576f" + "reference": "fe14cf3672a149364fb66dfe11bf6549af899f94" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4432ba399e47c66624bc73c8c0f811e5c109576f", - "reference": "4432ba399e47c66624bc73c8c0f811e5c109576f", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/fe14cf3672a149364fb66dfe11bf6549af899f94", + "reference": "fe14cf3672a149364fb66dfe11bf6549af899f94", "shasum": "" }, "require": { @@ -4832,9 +4834,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.10.5" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.11.0" }, - "time": "2021-05-03T19:11:20+00:00" + "time": "2021-07-03T13:36:55+00:00" }, { "name": "nwidart/laravel-modules", @@ -4919,16 +4921,16 @@ }, { "name": "nyholm/psr7", - "version": "1.4.0", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/Nyholm/psr7.git", - "reference": "23ae1f00fbc6a886cbe3062ca682391b9cc7c37b" + "reference": "2212385b47153ea71b1c1b1374f8cb5e4f7892ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Nyholm/psr7/zipball/23ae1f00fbc6a886cbe3062ca682391b9cc7c37b", - "reference": "23ae1f00fbc6a886cbe3062ca682391b9cc7c37b", + "url": "https://api.github.com/repos/Nyholm/psr7/zipball/2212385b47153ea71b1c1b1374f8cb5e4f7892ec", + "reference": "2212385b47153ea71b1c1b1374f8cb5e4f7892ec", "shasum": "" }, "require": { @@ -4942,7 +4944,7 @@ "psr/http-message-implementation": "1.0" }, "require-dev": { - "http-interop/http-factory-tests": "^0.8", + "http-interop/http-factory-tests": "^0.9", "php-http/psr7-integration-tests": "^1.0", "phpunit/phpunit": "^7.5 || 8.5 || 9.4", "symfony/error-handler": "^4.4" @@ -4980,7 +4982,7 @@ ], "support": { "issues": "https://github.com/Nyholm/psr7/issues", - "source": "https://github.com/Nyholm/psr7/tree/1.4.0" + "source": "https://github.com/Nyholm/psr7/tree/1.4.1" }, "funding": [ { @@ -4992,7 +4994,7 @@ "type": "github" } ], - "time": "2021-02-18T15:41:32+00:00" + "time": "2021-07-02T08:32:20+00:00" }, { "name": "omnipay/common", @@ -7173,16 +7175,16 @@ }, { "name": "sentry/sentry", - "version": "3.2.2", + "version": "3.3.1", "source": { "type": "git", "url": "https://github.com/getsentry/sentry-php.git", - "reference": "02237728bdc5b82b0a14c37417644e3f3606db9b" + "reference": "fafef24c1bc242e614a1afd9533d5dcb7e9c42fe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/getsentry/sentry-php/zipball/02237728bdc5b82b0a14c37417644e3f3606db9b", - "reference": "02237728bdc5b82b0a14c37417644e3f3606db9b", + "url": "https://api.github.com/repos/getsentry/sentry-php/zipball/fafef24c1bc242e614a1afd9533d5dcb7e9c42fe", + "reference": "fafef24c1bc242e614a1afd9533d5dcb7e9c42fe", "shasum": "" }, "require": { @@ -7227,7 +7229,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2.x-dev" + "dev-master": "3.3.x-dev" } }, "autoload": { @@ -7261,7 +7263,7 @@ ], "support": { "issues": "https://github.com/getsentry/sentry-php/issues", - "source": "https://github.com/getsentry/sentry-php/tree/3.2.2" + "source": "https://github.com/getsentry/sentry-php/tree/3.3.1" }, "funding": [ { @@ -7273,20 +7275,20 @@ "type": "custom" } ], - "time": "2021-05-06T10:15:01+00:00" + "time": "2021-06-19T11:37:25+00:00" }, { "name": "sentry/sentry-laravel", - "version": "2.6.0", + "version": "2.7.0", "source": { "type": "git", "url": "https://github.com/getsentry/sentry-laravel.git", - "reference": "1a4db2b49b8c6b464785ce984227afec2c3ebaa3" + "reference": "91d6644fee3ba447769dc73eda2487a93218c04e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/getsentry/sentry-laravel/zipball/1a4db2b49b8c6b464785ce984227afec2c3ebaa3", - "reference": "1a4db2b49b8c6b464785ce984227afec2c3ebaa3", + "url": "https://api.github.com/repos/getsentry/sentry-laravel/zipball/91d6644fee3ba447769dc73eda2487a93218c04e", + "reference": "91d6644fee3ba447769dc73eda2487a93218c04e", "shasum": "" }, "require": { @@ -7294,7 +7296,7 @@ "nyholm/psr7": "^1.0", "php": "^7.2 | ^8.0", "sentry/sdk": "^3.1", - "sentry/sentry": "3.2.*", + "sentry/sentry": "^3.3", "symfony/psr-http-message-bridge": "^1.0 | ^2.0" }, "require-dev": { @@ -7352,7 +7354,7 @@ ], "support": { "issues": "https://github.com/getsentry/sentry-laravel/issues", - "source": "https://github.com/getsentry/sentry-laravel/tree/2.6.0" + "source": "https://github.com/getsentry/sentry-laravel/tree/2.7.0" }, "funding": [ { @@ -7364,20 +7366,20 @@ "type": "custom" } ], - "time": "2021-05-25T12:59:50+00:00" + "time": "2021-06-16T09:26:40+00:00" }, { "name": "stripe/stripe-php", - "version": "v7.83.0", + "version": "v7.87.0", "source": { "type": "git", "url": "https://github.com/stripe/stripe-php.git", - "reference": "bb7244c7334ad8bf30d31bb4972d5aff57df1563" + "reference": "9392f03cb8d8803bf8273378ce42d5cbbf1e24fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/stripe/stripe-php/zipball/bb7244c7334ad8bf30d31bb4972d5aff57df1563", - "reference": "bb7244c7334ad8bf30d31bb4972d5aff57df1563", + "url": "https://api.github.com/repos/stripe/stripe-php/zipball/9392f03cb8d8803bf8273378ce42d5cbbf1e24fc", + "reference": "9392f03cb8d8803bf8273378ce42d5cbbf1e24fc", "shasum": "" }, "require": { @@ -7423,9 +7425,9 @@ ], "support": { "issues": "https://github.com/stripe/stripe-php/issues", - "source": "https://github.com/stripe/stripe-php/tree/v7.83.0" + "source": "https://github.com/stripe/stripe-php/tree/v7.87.0" }, - "time": "2021-06-07T23:15:45+00:00" + "time": "2021-06-30T18:22:47+00:00" }, { "name": "swiftmailer/swiftmailer", @@ -7504,16 +7506,16 @@ }, { "name": "symfony/console", - "version": "v5.3.0", + "version": "v5.3.2", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "058553870f7809087fa80fa734704a21b9bcaeb2" + "reference": "649730483885ff2ca99ca0560ef0e5f6b03f2ac1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/058553870f7809087fa80fa734704a21b9bcaeb2", - "reference": "058553870f7809087fa80fa734704a21b9bcaeb2", + "url": "https://api.github.com/repos/symfony/console/zipball/649730483885ff2ca99ca0560ef0e5f6b03f2ac1", + "reference": "649730483885ff2ca99ca0560ef0e5f6b03f2ac1", "shasum": "" }, "require": { @@ -7582,7 +7584,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.3.0" + "source": "https://github.com/symfony/console/tree/v5.3.2" }, "funding": [ { @@ -7598,7 +7600,7 @@ "type": "tidelift" } ], - "time": "2021-05-26T17:43:10+00:00" + "time": "2021-06-12T09:42:48+00:00" }, { "name": "symfony/css-selector", @@ -7734,16 +7736,16 @@ }, { "name": "symfony/error-handler", - "version": "v5.3.0", + "version": "v5.3.3", "source": { "type": "git", "url": "https://github.com/symfony/error-handler.git", - "reference": "0e6768b8c0dcef26df087df2bbbaa143867a59b2" + "reference": "43323e79c80719e8a4674e33484bca98270d223f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/error-handler/zipball/0e6768b8c0dcef26df087df2bbbaa143867a59b2", - "reference": "0e6768b8c0dcef26df087df2bbbaa143867a59b2", + "url": "https://api.github.com/repos/symfony/error-handler/zipball/43323e79c80719e8a4674e33484bca98270d223f", + "reference": "43323e79c80719e8a4674e33484bca98270d223f", "shasum": "" }, "require": { @@ -7783,7 +7785,7 @@ "description": "Provides tools to manage errors and ease debugging PHP code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/error-handler/tree/v5.3.0" + "source": "https://github.com/symfony/error-handler/tree/v5.3.3" }, "funding": [ { @@ -7799,7 +7801,7 @@ "type": "tidelift" } ], - "time": "2021-05-26T17:43:10+00:00" + "time": "2021-06-24T08:13:00+00:00" }, { "name": "symfony/event-dispatcher", @@ -7967,16 +7969,16 @@ }, { "name": "symfony/filesystem", - "version": "v5.3.0", + "version": "v5.3.3", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "348116319d7fb7d1faa781d26a48922428013eb2" + "reference": "19b71c8f313b411172dd5f470fd61f24466d79a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/348116319d7fb7d1faa781d26a48922428013eb2", - "reference": "348116319d7fb7d1faa781d26a48922428013eb2", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/19b71c8f313b411172dd5f470fd61f24466d79a9", + "reference": "19b71c8f313b411172dd5f470fd61f24466d79a9", "shasum": "" }, "require": { @@ -8009,7 +8011,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v5.3.0" + "source": "https://github.com/symfony/filesystem/tree/v5.3.3" }, "funding": [ { @@ -8025,7 +8027,7 @@ "type": "tidelift" } ], - "time": "2021-05-26T17:43:10+00:00" + "time": "2021-06-30T07:27:52+00:00" }, { "name": "symfony/finder", @@ -8090,16 +8092,16 @@ }, { "name": "symfony/http-client", - "version": "v5.3.0", + "version": "v5.3.3", "source": { "type": "git", "url": "https://github.com/symfony/http-client.git", - "reference": "ef85ca5fa7a4f9c57592fab49faeccdf22b13136" + "reference": "fde4bdb10bf197f932ebccfcb9982881d296fc4c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client/zipball/ef85ca5fa7a4f9c57592fab49faeccdf22b13136", - "reference": "ef85ca5fa7a4f9c57592fab49faeccdf22b13136", + "url": "https://api.github.com/repos/symfony/http-client/zipball/fde4bdb10bf197f932ebccfcb9982881d296fc4c", + "reference": "fde4bdb10bf197f932ebccfcb9982881d296fc4c", "shasum": "" }, "require": { @@ -8157,7 +8159,7 @@ "description": "Provides powerful methods to fetch HTTP resources synchronously or asynchronously", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-client/tree/v5.3.0" + "source": "https://github.com/symfony/http-client/tree/v5.3.3" }, "funding": [ { @@ -8173,7 +8175,7 @@ "type": "tidelift" } ], - "time": "2021-05-26T17:43:10+00:00" + "time": "2021-06-24T08:13:00+00:00" }, { "name": "symfony/http-client-contracts", @@ -8255,16 +8257,16 @@ }, { "name": "symfony/http-foundation", - "version": "v5.3.1", + "version": "v5.3.3", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "8827b90cf8806e467124ad476acd15216c2fceb6" + "reference": "0e45ab1574caa0460d9190871a8ce47539e40ccf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/8827b90cf8806e467124ad476acd15216c2fceb6", - "reference": "8827b90cf8806e467124ad476acd15216c2fceb6", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/0e45ab1574caa0460d9190871a8ce47539e40ccf", + "reference": "0e45ab1574caa0460d9190871a8ce47539e40ccf", "shasum": "" }, "require": { @@ -8308,7 +8310,7 @@ "description": "Defines an object-oriented layer for the HTTP specification", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v5.3.1" + "source": "https://github.com/symfony/http-foundation/tree/v5.3.3" }, "funding": [ { @@ -8324,20 +8326,20 @@ "type": "tidelift" } ], - "time": "2021-06-02T09:32:00+00:00" + "time": "2021-06-27T09:19:40+00:00" }, { "name": "symfony/http-kernel", - "version": "v5.3.1", + "version": "v5.3.3", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "74eb022e3bac36b3d3a897951a98759f2b32b864" + "reference": "90ad9f4b21ddcb8ebe9faadfcca54929ad23f9f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/74eb022e3bac36b3d3a897951a98759f2b32b864", - "reference": "74eb022e3bac36b3d3a897951a98759f2b32b864", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/90ad9f4b21ddcb8ebe9faadfcca54929ad23f9f8", + "reference": "90ad9f4b21ddcb8ebe9faadfcca54929ad23f9f8", "shasum": "" }, "require": { @@ -8420,7 +8422,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v5.3.1" + "source": "https://github.com/symfony/http-kernel/tree/v5.3.3" }, "funding": [ { @@ -8436,20 +8438,20 @@ "type": "tidelift" } ], - "time": "2021-06-02T10:07:12+00:00" + "time": "2021-06-30T08:27:49+00:00" }, { "name": "symfony/mime", - "version": "v5.3.0", + "version": "v5.3.2", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "ed710d297b181f6a7194d8172c9c2423d58e4852" + "reference": "47dd7912152b82d0d4c8d9040dbc93d6232d472a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/ed710d297b181f6a7194d8172c9c2423d58e4852", - "reference": "ed710d297b181f6a7194d8172c9c2423d58e4852", + "url": "https://api.github.com/repos/symfony/mime/zipball/47dd7912152b82d0d4c8d9040dbc93d6232d472a", + "reference": "47dd7912152b82d0d4c8d9040dbc93d6232d472a", "shasum": "" }, "require": { @@ -8503,7 +8505,7 @@ "mime-type" ], "support": { - "source": "https://github.com/symfony/mime/tree/v5.3.0" + "source": "https://github.com/symfony/mime/tree/v5.3.2" }, "funding": [ { @@ -8519,7 +8521,7 @@ "type": "tidelift" } ], - "time": "2021-05-26T17:43:10+00:00" + "time": "2021-06-09T10:58:01+00:00" }, { "name": "symfony/options-resolver", @@ -9400,16 +9402,16 @@ }, { "name": "symfony/process", - "version": "v5.3.0", + "version": "v5.3.2", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "53e36cb1c160505cdaf1ef201501669c4c317191" + "reference": "714b47f9196de61a196d86c4bad5f09201b307df" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/53e36cb1c160505cdaf1ef201501669c4c317191", - "reference": "53e36cb1c160505cdaf1ef201501669c4c317191", + "url": "https://api.github.com/repos/symfony/process/zipball/714b47f9196de61a196d86c4bad5f09201b307df", + "reference": "714b47f9196de61a196d86c4bad5f09201b307df", "shasum": "" }, "require": { @@ -9442,7 +9444,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v5.3.0" + "source": "https://github.com/symfony/process/tree/v5.3.2" }, "funding": [ { @@ -9458,7 +9460,7 @@ "type": "tidelift" } ], - "time": "2021-05-26T12:52:38+00:00" + "time": "2021-06-12T10:15:01+00:00" }, { "name": "symfony/psr-http-message-bridge", @@ -9719,16 +9721,16 @@ }, { "name": "symfony/string", - "version": "v5.3.0", + "version": "v5.3.3", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "a9a0f8b6aafc5d2d1c116dcccd1573a95153515b" + "reference": "bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/a9a0f8b6aafc5d2d1c116dcccd1573a95153515b", - "reference": "a9a0f8b6aafc5d2d1c116dcccd1573a95153515b", + "url": "https://api.github.com/repos/symfony/string/zipball/bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1", + "reference": "bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1", "shasum": "" }, "require": { @@ -9782,7 +9784,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.3.0" + "source": "https://github.com/symfony/string/tree/v5.3.3" }, "funding": [ { @@ -9798,20 +9800,20 @@ "type": "tidelift" } ], - "time": "2021-05-26T17:43:10+00:00" + "time": "2021-06-27T11:44:38+00:00" }, { "name": "symfony/translation", - "version": "v5.3.0", + "version": "v5.3.3", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "251de0d921c42ef0a81494d8f37405421deefdf6" + "reference": "380b8c9e944d0e364b25f28e8e555241eb49c01c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/251de0d921c42ef0a81494d8f37405421deefdf6", - "reference": "251de0d921c42ef0a81494d8f37405421deefdf6", + "url": "https://api.github.com/repos/symfony/translation/zipball/380b8c9e944d0e364b25f28e8e555241eb49c01c", + "reference": "380b8c9e944d0e364b25f28e8e555241eb49c01c", "shasum": "" }, "require": { @@ -9877,7 +9879,7 @@ "description": "Provides tools to internationalize your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/translation/tree/v5.3.0" + "source": "https://github.com/symfony/translation/tree/v5.3.3" }, "funding": [ { @@ -9893,7 +9895,7 @@ "type": "tidelift" } ], - "time": "2021-05-29T22:28:28+00:00" + "time": "2021-06-27T12:22:47+00:00" }, { "name": "symfony/translation-contracts", @@ -9975,16 +9977,16 @@ }, { "name": "symfony/var-dumper", - "version": "v5.3.0", + "version": "v5.3.3", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "1d3953e627fe4b5f6df503f356b6545ada6351f3" + "reference": "46aa709affb9ad3355bd7a810f9662d71025c384" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/1d3953e627fe4b5f6df503f356b6545ada6351f3", - "reference": "1d3953e627fe4b5f6df503f356b6545ada6351f3", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/46aa709affb9ad3355bd7a810f9662d71025c384", + "reference": "46aa709affb9ad3355bd7a810f9662d71025c384", "shasum": "" }, "require": { @@ -10043,7 +10045,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v5.3.0" + "source": "https://github.com/symfony/var-dumper/tree/v5.3.3" }, "funding": [ { @@ -10059,7 +10061,7 @@ "type": "tidelift" } ], - "time": "2021-05-27T12:28:50+00:00" + "time": "2021-06-24T08:13:00+00:00" }, { "name": "tijsverkoyen/css-to-inline-styles", @@ -10914,16 +10916,16 @@ }, { "name": "barryvdh/laravel-debugbar", - "version": "v3.6.1", + "version": "v3.6.2", "source": { "type": "git", "url": "https://github.com/barryvdh/laravel-debugbar.git", - "reference": "f6f0f895a33cac801286a74355d146bb5384a5da" + "reference": "70b89754913fd89fef16d0170a91dbc2a5cd633a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/f6f0f895a33cac801286a74355d146bb5384a5da", - "reference": "f6f0f895a33cac801286a74355d146bb5384a5da", + "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/70b89754913fd89fef16d0170a91dbc2a5cd633a", + "reference": "70b89754913fd89fef16d0170a91dbc2a5cd633a", "shasum": "" }, "require": { @@ -10983,15 +10985,19 @@ ], "support": { "issues": "https://github.com/barryvdh/laravel-debugbar/issues", - "source": "https://github.com/barryvdh/laravel-debugbar/tree/v3.6.1" + "source": "https://github.com/barryvdh/laravel-debugbar/tree/v3.6.2" }, "funding": [ + { + "url": "https://fruitcake.nl", + "type": "custom" + }, { "url": "https://github.com/barryvdh", "type": "github" } ], - "time": "2021-06-02T06:42:22+00:00" + "time": "2021-06-14T14:29:26+00:00" }, { "name": "brianium/paratest", @@ -12192,16 +12198,16 @@ }, { "name": "nunomaduro/collision", - "version": "v5.4.0", + "version": "v5.5.0", "source": { "type": "git", "url": "https://github.com/nunomaduro/collision.git", - "reference": "41b7e9999133d5082700d31a1d0977161df8322a" + "reference": "b5cb36122f1c142c3c3ee20a0ae778439ef0244b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/collision/zipball/41b7e9999133d5082700d31a1d0977161df8322a", - "reference": "41b7e9999133d5082700d31a1d0977161df8322a", + "url": "https://api.github.com/repos/nunomaduro/collision/zipball/b5cb36122f1c142c3c3ee20a0ae778439ef0244b", + "reference": "b5cb36122f1c142c3c3ee20a0ae778439ef0244b", "shasum": "" }, "require": { @@ -12276,7 +12282,7 @@ "type": "patreon" } ], - "time": "2021-04-09T13:38:32+00:00" + "time": "2021-06-22T20:47:22+00:00" }, { "name": "openlss/lib-array2xml", @@ -13042,16 +13048,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.5", + "version": "9.5.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "89ff45ea9d70e35522fb6654a2ebc221158de276" + "reference": "fb9b8333f14e3dce976a60ef6a7e05c7c7ed8bfb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/89ff45ea9d70e35522fb6654a2ebc221158de276", - "reference": "89ff45ea9d70e35522fb6654a2ebc221158de276", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/fb9b8333f14e3dce976a60ef6a7e05c7c7ed8bfb", + "reference": "fb9b8333f14e3dce976a60ef6a7e05c7c7ed8bfb", "shasum": "" }, "require": { @@ -13081,7 +13087,7 @@ "sebastian/global-state": "^5.0.1", "sebastian/object-enumerator": "^4.0.3", "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^2.3.2", + "sebastian/type": "^2.3.4", "sebastian/version": "^3.0.2" }, "require-dev": { @@ -13129,7 +13135,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.5" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.6" }, "funding": [ { @@ -13141,7 +13147,7 @@ "type": "github" } ], - "time": "2021-06-05T04:49:07+00:00" + "time": "2021-06-23T05:14:38+00:00" }, { "name": "sebastian/cli-parser", @@ -14000,16 +14006,16 @@ }, { "name": "sebastian/type", - "version": "2.3.2", + "version": "2.3.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "0d1c587401514d17e8f9258a27e23527cb1b06c1" + "reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/0d1c587401514d17e8f9258a27e23527cb1b06c1", - "reference": "0d1c587401514d17e8f9258a27e23527cb1b06c1", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b8cd8a1c753c90bc1a0f5372170e3e489136f914", + "reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914", "shasum": "" }, "require": { @@ -14044,7 +14050,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/2.3.2" + "source": "https://github.com/sebastianbergmann/type/tree/2.3.4" }, "funding": [ { @@ -14052,7 +14058,7 @@ "type": "github" } ], - "time": "2021-06-04T13:02:07+00:00" + "time": "2021-06-15T12:49:02+00:00" }, { "name": "sebastian/version", @@ -14109,16 +14115,16 @@ }, { "name": "swagger-api/swagger-ui", - "version": "v3.50.0", + "version": "v3.51.1", "source": { "type": "git", "url": "https://github.com/swagger-api/swagger-ui.git", - "reference": "91858cc811d3cddb45ef604365e2c88cd96e4ca0" + "reference": "bb21c6df52eb12cd4bdbf8c29feb500795595fa8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/swagger-api/swagger-ui/zipball/91858cc811d3cddb45ef604365e2c88cd96e4ca0", - "reference": "91858cc811d3cddb45ef604365e2c88cd96e4ca0", + "url": "https://api.github.com/repos/swagger-api/swagger-ui/zipball/bb21c6df52eb12cd4bdbf8c29feb500795595fa8", + "reference": "bb21c6df52eb12cd4bdbf8c29feb500795595fa8", "shasum": "" }, "type": "library", @@ -14164,9 +14170,9 @@ ], "support": { "issues": "https://github.com/swagger-api/swagger-ui/issues", - "source": "https://github.com/swagger-api/swagger-ui/tree/v3.50.0" + "source": "https://github.com/swagger-api/swagger-ui/tree/v3.51.1" }, - "time": "2021-06-03T21:00:28+00:00" + "time": "2021-06-30T20:42:58+00:00" }, { "name": "symfony/debug", @@ -14369,16 +14375,16 @@ }, { "name": "symfony/yaml", - "version": "v5.3.0", + "version": "v5.3.3", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "3bbcf262fceb3d8f48175302e6ba0ac96e3a5a11" + "reference": "485c83a2fb5893e2ff21bf4bfc7fdf48b4967229" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/3bbcf262fceb3d8f48175302e6ba0ac96e3a5a11", - "reference": "3bbcf262fceb3d8f48175302e6ba0ac96e3a5a11", + "url": "https://api.github.com/repos/symfony/yaml/zipball/485c83a2fb5893e2ff21bf4bfc7fdf48b4967229", + "reference": "485c83a2fb5893e2ff21bf4bfc7fdf48b4967229", "shasum": "" }, "require": { @@ -14424,7 +14430,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v5.3.0" + "source": "https://github.com/symfony/yaml/tree/v5.3.3" }, "funding": [ { @@ -14440,7 +14446,7 @@ "type": "tidelift" } ], - "time": "2021-05-26T17:43:10+00:00" + "time": "2021-06-24T08:13:00+00:00" }, { "name": "theseer/tokenizer", @@ -14494,16 +14500,16 @@ }, { "name": "vimeo/psalm", - "version": "4.7.3", + "version": "4.8.1", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "38c452ae584467e939d55377aaf83b5a26f19dd1" + "reference": "f73f2299dbc59a3e6c4d66cff4605176e728ee69" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/38c452ae584467e939d55377aaf83b5a26f19dd1", - "reference": "38c452ae584467e939d55377aaf83b5a26f19dd1", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/f73f2299dbc59a3e6c4d66cff4605176e728ee69", + "reference": "f73f2299dbc59a3e6c4d66cff4605176e728ee69", "shasum": "" }, "require": { @@ -14541,10 +14547,10 @@ "phpmyadmin/sql-parser": "5.1.0||dev-master", "phpspec/prophecy": ">=1.9.0", "phpunit/phpunit": "^9.0", - "psalm/plugin-phpunit": "^0.13", + "psalm/plugin-phpunit": "^0.16", "slevomat/coding-standard": "^7.0", "squizlabs/php_codesniffer": "^3.5", - "symfony/process": "^4.3", + "symfony/process": "^4.3 || ^5.0", "weirdan/phpunit-appveyor-reporter": "^1.0.0", "weirdan/prophecy-shim": "^1.0 || ^2.0" }, @@ -14593,9 +14599,9 @@ ], "support": { "issues": "https://github.com/vimeo/psalm/issues", - "source": "https://github.com/vimeo/psalm/tree/4.7.3" + "source": "https://github.com/vimeo/psalm/tree/4.8.1" }, - "time": "2021-05-24T04:09:51+00:00" + "time": "2021-06-20T23:03:20+00:00" }, { "name": "webmozart/path-util", @@ -14649,16 +14655,16 @@ }, { "name": "zircote/swagger-php", - "version": "3.2.1", + "version": "3.2.3", "source": { "type": "git", "url": "https://github.com/zircote/swagger-php.git", - "reference": "eef1dd98e6f6071573908fd7007270510051e5f9" + "reference": "41ed0eb1dacebe2c365623b3f9ab13d1531a03da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zircote/swagger-php/zipball/eef1dd98e6f6071573908fd7007270510051e5f9", - "reference": "eef1dd98e6f6071573908fd7007270510051e5f9", + "url": "https://api.github.com/repos/zircote/swagger-php/zipball/41ed0eb1dacebe2c365623b3f9ab13d1531a03da", + "reference": "41ed0eb1dacebe2c365623b3f9ab13d1531a03da", "shasum": "" }, "require": { @@ -14669,7 +14675,7 @@ "symfony/yaml": ">=3.3" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.16", + "friendsofphp/php-cs-fixer": "^2.17 || ^3.0", "phpunit/phpunit": ">=8" }, "bin": [ @@ -14714,9 +14720,9 @@ ], "support": { "issues": "https://github.com/zircote/swagger-php/issues", - "source": "https://github.com/zircote/swagger-php/tree/3.2.1" + "source": "https://github.com/zircote/swagger-php/tree/3.2.3" }, - "time": "2021-05-20T21:46:24+00:00" + "time": "2021-06-25T04:08:57+00:00" } ], "aliases": [], From 5cf6e9e7c0d4fb60d3a3bb0aad983c0121dc95a2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 10:23:42 +1000 Subject: [PATCH 11/61] Fixes for base driver --- app/PaymentDrivers/BaseDriver.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 23423db6acd6..7a0c7f3b83ab 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -555,7 +555,8 @@ class BaseDriver extends AbstractPaymentDriver 'company_gateway_id' => $this->company_gateway->id, 'client' => $this->client->id, ]); - + } + /* Performs an extra iterate on the gatewayTypes() array and passes back only the enabled gateways*/ public function gatewayTypeEnabled($type) { From 7aed3b0b4096ee803c33d8f35568147cb3a15c94 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 10:24:33 +1000 Subject: [PATCH 12/61] Fixes for base driver --- app/PaymentDrivers/PayFast/CreditCard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index 6167d9ff794b..34c5a115d9eb 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -87,7 +87,7 @@ class CreditCard 'return_url' => route('client.payment_methods.index'), 'cancel_url' => route('client.payment_methods.index'), 'notify_url' => $this->payfast->genericWebhookUrl(), - 'amount' => 1, + 'amount' => 5, 'item_name' => 'pre-auth', 'subscription_type' => 2, 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), From e52f93be7428d1a77b98bea8019887658222e41c Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 10:26:00 +1000 Subject: [PATCH 13/61] Fixes for base driver --- app/Http/Controllers/PaymentNotificationWebhookController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Http/Controllers/PaymentNotificationWebhookController.php b/app/Http/Controllers/PaymentNotificationWebhookController.php index d310899593cc..d9d41618e328 100644 --- a/app/Http/Controllers/PaymentNotificationWebhookController.php +++ b/app/Http/Controllers/PaymentNotificationWebhookController.php @@ -16,10 +16,13 @@ use App\Http\Requests\Payments\PaymentNotificationWebhookRequest; use App\Libraries\MultiDB; use App\Models\Client; use App\Models\CompanyGateway; +use App\Utils\Traits\MakesHash; use Auth; class PaymentNotificationWebhookController extends Controller { + use MakesHash; + public function __invoke(PaymentNotificationWebhookRequest $request, string $company_key, string $company_gateway_id, string $client_hash) { From f8a11232a613fe91b4e99c5ff874959bda501f23 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 10:30:47 +1000 Subject: [PATCH 14/61] Fixes for base driver --- app/PaymentDrivers/BaseDriver.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 7a0c7f3b83ab..d7e2757f0794 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -552,11 +552,11 @@ class BaseDriver extends AbstractPaymentDriver { return route('payment_notification_webhook', [ 'company_key' => $this->client->company->company_key, - 'company_gateway_id' => $this->company_gateway->id, - 'client' => $this->client->id, + 'company_gateway_id' => $this->encodePrimaryKey($this->company_gateway->id), + 'client' => $this->encodePrimaryKey($this->client->id), ]); } - + /* Performs an extra iterate on the gatewayTypes() array and passes back only the enabled gateways*/ public function gatewayTypeEnabled($type) { From 9a73602c09bf457526ecf95bf6a31c7ca1d94244 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 10:32:26 +1000 Subject: [PATCH 15/61] Fixes for base driver --- app/PaymentDrivers/PayFastPaymentDriver.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 8c7b80ce4e7b..7e449bbee6d9 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -19,6 +19,7 @@ use App\Models\SystemLog; use App\PaymentDrivers\PayFast\CreditCard; use App\Utils\Traits\MakesHash; use \PayFastPayment; +use Illuminate\Http\Request; class PayFastPaymentDriver extends BaseDriver { @@ -138,7 +139,7 @@ class PayFastPaymentDriver extends BaseDriver return md5( $getString ); } - public function processWebhookRequest(PaymentWebhookRequest $request, Payment $payment = null) + public function processWebhookRequest(Request $request, Payment $payment = null) { nlog($request->all()); From 552607b35fbc9ff12384876ec47e381b53799531 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 12:54:43 +1000 Subject: [PATCH 16/61] Fixes for payfast card authorization --- app/PaymentDrivers/PayFast/CreditCard.php | 49 ++++++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index 34c5a115d9eb..7c44730c3968 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -100,10 +100,55 @@ class CreditCard return render('gateways.payfast.authorize', $data); } + +/* + 'm_payment_id' => NULL, + 'pf_payment_id' => '1409993', + 'payment_status' => 'COMPLETE', + 'item_name' => 'pre-auth', + 'item_description' => NULL, + 'amount_gross' => '5.00', + 'amount_fee' => '-2.53', + 'amount_net' => '2.47', + 'custom_str1' => NULL, + 'custom_str2' => NULL, + 'custom_str3' => NULL, + 'custom_str4' => NULL, + 'custom_str5' => NULL, + 'custom_int1' => NULL, + 'custom_int2' => NULL, + 'custom_int3' => NULL, + 'custom_int4' => NULL, + 'custom_int5' => NULL, + 'name_first' => NULL, + 'name_last' => NULL, + 'email_address' => NULL, + 'merchant_id' => '10023100', + 'token' => '34b66bc2-3c54-9590-03ea-42ee8b89922a', + 'billing_date' => '2021-07-05', + 'signature' => 'ebdb4ca937d0e3f43462841c0afc6ad9', + 'q' => '/payment_notification_webhook/EhbnVYyzJZyccY85hcHIkIzNPI2rtHzznAyyyG73oSxZidAdN9gf8BvAKDomqeHp/4openRe7Az/WPe99p3eLy', +) + */ public function authorizeResponse($request) { - - + $data = $request->all(); + + $cgt = []; + $cgt['token'] = $data['token']; + $cgt['payment_method_id'] = GatewayType::CREDIT_CARD; + + $payment_meta = new \stdClass; + $payment_meta->exp_month = 'xx'; + $payment_meta->exp_year = 'xx'; + $payment_meta->brand = 'CC'; + $payment_meta->last4 = 'xxxx'; + $payment_meta->type = GatewayType::CREDIT_CARD; + + $cgt['payment_meta'] = $payment_meta + + $this->payfast->storeGatewayToken($cgt, []); + } From d9516d723a155872bbb228a87e12b85c49ac8837 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 13:01:30 +1000 Subject: [PATCH 17/61] Fixes for base driver --- app/PaymentDrivers/PayFast/CreditCard.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index 7c44730c3968..e9214168cc24 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -145,10 +145,10 @@ class CreditCard $payment_meta->last4 = 'xxxx'; $payment_meta->type = GatewayType::CREDIT_CARD; - $cgt['payment_meta'] = $payment_meta + $cgt['payment_meta'] = $payment_meta; $this->payfast->storeGatewayToken($cgt, []); - + } From 6d2430d086919266589f2bb71bb5830926abb35a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 13:36:12 +1000 Subject: [PATCH 18/61] Fixes for base driver --- app/PaymentDrivers/PayFast/CreditCard.php | 66 +++++++++++---------- app/PaymentDrivers/PayFastPaymentDriver.php | 9 +++ config/logging.php | 1 - 3 files changed, 44 insertions(+), 32 deletions(-) diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index e9214168cc24..5ba86898f59d 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -89,6 +89,8 @@ class CreditCard 'notify_url' => $this->payfast->genericWebhookUrl(), 'amount' => 5, 'item_name' => 'pre-auth', + 'item_description' => 'cc_auth', + 'custom_str1' => 'cc_auth', 'subscription_type' => 2, 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), ]; @@ -100,36 +102,34 @@ class CreditCard return render('gateways.payfast.authorize', $data); } - -/* - 'm_payment_id' => NULL, - 'pf_payment_id' => '1409993', - 'payment_status' => 'COMPLETE', - 'item_name' => 'pre-auth', - 'item_description' => NULL, - 'amount_gross' => '5.00', - 'amount_fee' => '-2.53', - 'amount_net' => '2.47', - 'custom_str1' => NULL, - 'custom_str2' => NULL, - 'custom_str3' => NULL, - 'custom_str4' => NULL, - 'custom_str5' => NULL, - 'custom_int1' => NULL, - 'custom_int2' => NULL, - 'custom_int3' => NULL, - 'custom_int4' => NULL, - 'custom_int5' => NULL, - 'name_first' => NULL, - 'name_last' => NULL, - 'email_address' => NULL, - 'merchant_id' => '10023100', - 'token' => '34b66bc2-3c54-9590-03ea-42ee8b89922a', - 'billing_date' => '2021-07-05', - 'signature' => 'ebdb4ca937d0e3f43462841c0afc6ad9', - 'q' => '/payment_notification_webhook/EhbnVYyzJZyccY85hcHIkIzNPI2rtHzznAyyyG73oSxZidAdN9gf8BvAKDomqeHp/4openRe7Az/WPe99p3eLy', -) - */ + /* + 'm_payment_id' => NULL, + 'pf_payment_id' => '1409993', + 'payment_status' => 'COMPLETE', + 'item_name' => 'pre-auth', + 'item_description' => NULL, + 'amount_gross' => '5.00', + 'amount_fee' => '-2.53', + 'amount_net' => '2.47', + 'custom_str1' => NULL, + 'custom_str2' => NULL, + 'custom_str3' => NULL, + 'custom_str4' => NULL, + 'custom_str5' => NULL, + 'custom_int1' => NULL, + 'custom_int2' => NULL, + 'custom_int3' => NULL, + 'custom_int4' => NULL, + 'custom_int5' => NULL, + 'name_first' => NULL, + 'name_last' => NULL, + 'email_address' => NULL, + 'merchant_id' => '10023100', + 'token' => '34b66bc2-3c54-9590-03ea-42ee8b89922a', + 'billing_date' => '2021-07-05', + 'signature' => 'ebdb4ca937d0e3f43462841c0afc6ad9', + 'q' => '/payment_notification_webhook/EhbnVYyzJZyccY85hcHIkIzNPI2rtHzznAyyyG73oSxZidAdN9gf8BvAKDomqeHp/4openRe7Az/WPe99p3eLy', + */ public function authorizeResponse($request) { $data = $request->all(); @@ -147,7 +147,11 @@ class CreditCard $cgt['payment_meta'] = $payment_meta; - $this->payfast->storeGatewayToken($cgt, []); + $token = $this->payfast->storeGatewayToken($cgt, []); + + nlog($token); + + return response()->json([], 200); } diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 7e449bbee6d9..d1e131e841ef 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -141,8 +141,17 @@ class PayFastPaymentDriver extends BaseDriver public function processWebhookRequest(Request $request, Payment $payment = null) { + $this->init(); nlog($request->all()); + $data = $request->all(); + + if(array_key_exists('custom_str1', $data) && $data['custom_str1'] == 'cc_auth') + { + return $this->setPaymentMethod(GatewayType::CREDIT_CARD) + ->authorizeResponse($request); + } + return response()->json([], 200); } diff --git a/config/logging.php b/config/logging.php index cfa68f0e57a7..b45e098a40fd 100644 --- a/config/logging.php +++ b/config/logging.php @@ -108,7 +108,6 @@ return [ 'gelf' => [ 'driver' => 'custom', - 'via' => \Hedii\LaravelGelfLogger\GelfLoggerFactory::class, // This optional option determines the processors that should be From e6986d045d68cff4008904995306bb39b3f731f1 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 13:41:49 +1000 Subject: [PATCH 19/61] Fixes for base driver --- app/PaymentDrivers/PayFast/CreditCard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index 5ba86898f59d..8edfedf8ce6d 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -90,7 +90,7 @@ class CreditCard 'amount' => 5, 'item_name' => 'pre-auth', 'item_description' => 'cc_auth', - 'custom_str1' => 'cc_auth', + // 'custom_str1' => 'cc_auth', 'subscription_type' => 2, 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), ]; From b53fe63858efba3ce08d63cdfed5a21d400f5107 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 13:42:37 +1000 Subject: [PATCH 20/61] Fixes for base driver --- app/PaymentDrivers/PayFast/CreditCard.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index 8edfedf8ce6d..2d2b49990bdc 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -89,8 +89,8 @@ class CreditCard 'notify_url' => $this->payfast->genericWebhookUrl(), 'amount' => 5, 'item_name' => 'pre-auth', - 'item_description' => 'cc_auth', - // 'custom_str1' => 'cc_auth', + // 'item_description' => 'cc_auth', + 'custom_str1' => 'cc_auth', 'subscription_type' => 2, 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), ]; @@ -151,7 +151,7 @@ class CreditCard nlog($token); - return response()->json([], 200); + return response()->json([], 200); } From 659d742477b2a4cacfe3672f2fc3fb41054057fa Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 13:47:45 +1000 Subject: [PATCH 21/61] Fixes for base driver --- app/PaymentDrivers/PayFast/CreditCard.php | 6 ++++-- app/PaymentDrivers/PayFastPaymentDriver.php | 14 +++++++++++--- app/Utils/PhantomJS/Phantom.php | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index 2d2b49990bdc..51d48e5f6875 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -21,6 +21,7 @@ use App\Models\PaymentType; use App\Models\SystemLog; use App\PaymentDrivers\PayFastPaymentDriver; use Illuminate\Support\Str; +use Illuminate\Support\Facades\Cache; class CreditCard { @@ -81,6 +82,8 @@ class CreditCard public function authorizeView($data) { + $hash = Cache::put(Str::random(32), 'cc_auth', 300); + $data = [ 'merchant_id' => $this->payfast->company_gateway->getConfigField('merchantId'), 'merchant_key' => $this->payfast->company_gateway->getConfigField('merchantKey'), @@ -88,9 +91,8 @@ class CreditCard 'cancel_url' => route('client.payment_methods.index'), 'notify_url' => $this->payfast->genericWebhookUrl(), 'amount' => 5, + 'm_payment_id' => $hash, 'item_name' => 'pre-auth', - // 'item_description' => 'cc_auth', - 'custom_str1' => 'cc_auth', 'subscription_type' => 2, 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), ]; diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index d1e131e841ef..9c17acb43bcf 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -20,6 +20,7 @@ use App\PaymentDrivers\PayFast\CreditCard; use App\Utils\Traits\MakesHash; use \PayFastPayment; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Cache; class PayFastPaymentDriver extends BaseDriver { @@ -146,10 +147,17 @@ class PayFastPaymentDriver extends BaseDriver nlog($request->all()); $data = $request->all(); - if(array_key_exists('custom_str1', $data) && $data['custom_str1'] == 'cc_auth') + if(array_key_exists('m_payment_id', $data)) { - return $this->setPaymentMethod(GatewayType::CREDIT_CARD) - ->authorizeResponse($request); + + $hash = Cache::get($data['m_payment_id']); + + if($hash == 'cc_auth') + { + return $this->setPaymentMethod(GatewayType::CREDIT_CARD) + ->authorizeResponse($request); + } + } return response()->json([], 200); diff --git a/app/Utils/PhantomJS/Phantom.php b/app/Utils/PhantomJS/Phantom.php index ca957ffe9bee..57495c8411a2 100644 --- a/app/Utils/PhantomJS/Phantom.php +++ b/app/Utils/PhantomJS/Phantom.php @@ -26,9 +26,9 @@ use App\Utils\CurlUtils; use App\Utils\HtmlEngine; use App\Utils\Traits\MakesHash; use Illuminate\Support\Facades\App; -use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Response; use Illuminate\Support\Facades\Storage; +use Illuminate\Support\Facades\Cache; use Illuminate\Support\Str; class Phantom From bc46ab86a2209d7cabe502bdcbd9a172a0754d2f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 13:48:52 +1000 Subject: [PATCH 22/61] Fixes for base driver --- app/PaymentDrivers/PayFast/CreditCard.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index 51d48e5f6875..f704ee04bfb1 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -91,7 +91,6 @@ class CreditCard 'cancel_url' => route('client.payment_methods.index'), 'notify_url' => $this->payfast->genericWebhookUrl(), 'amount' => 5, - 'm_payment_id' => $hash, 'item_name' => 'pre-auth', 'subscription_type' => 2, 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), From 1ca4eaba7b07538a5437ff7ec1a5922b9c1605ce Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 13:51:03 +1000 Subject: [PATCH 23/61] Fixes for base driver --- app/PaymentDrivers/PayFast/CreditCard.php | 3 ++- app/PaymentDrivers/PayFastPaymentDriver.php | 16 ++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index f704ee04bfb1..b7da94eab112 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -82,7 +82,7 @@ class CreditCard public function authorizeView($data) { - $hash = Cache::put(Str::random(32), 'cc_auth', 300); + // $hash = Cache::put(Str::random(32), 'cc_auth', 300); $data = [ 'merchant_id' => $this->payfast->company_gateway->getConfigField('merchantId'), @@ -92,6 +92,7 @@ class CreditCard 'notify_url' => $this->payfast->genericWebhookUrl(), 'amount' => 5, 'item_name' => 'pre-auth', + 'item_description' => 'Pre authorization', 'subscription_type' => 2, 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), ]; diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 9c17acb43bcf..6ec63540eaa8 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -20,7 +20,6 @@ use App\PaymentDrivers\PayFast\CreditCard; use App\Utils\Traits\MakesHash; use \PayFastPayment; use Illuminate\Http\Request; -use Illuminate\Support\Facades\Cache; class PayFastPaymentDriver extends BaseDriver { @@ -146,18 +145,11 @@ class PayFastPaymentDriver extends BaseDriver nlog($request->all()); $data = $request->all(); - - if(array_key_exists('m_payment_id', $data)) + + if(array_key_exists('m_payment_id', $data) && $data['m_payment_id'] == 'pre-auth') { - - $hash = Cache::get($data['m_payment_id']); - - if($hash == 'cc_auth') - { - return $this->setPaymentMethod(GatewayType::CREDIT_CARD) - ->authorizeResponse($request); - } - + return $this->setPaymentMethod(GatewayType::CREDIT_CARD) + ->authorizeResponse($request); } return response()->json([], 200); From c19d088bd9706620b3183299e07748b359a27343 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 13:56:38 +1000 Subject: [PATCH 24/61] Fixes for base driver --- app/PaymentDrivers/PayFast/CreditCard.php | 2 +- app/PaymentDrivers/PayFastPaymentDriver.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index b7da94eab112..d4eb05134659 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -92,12 +92,12 @@ class CreditCard 'notify_url' => $this->payfast->genericWebhookUrl(), 'amount' => 5, 'item_name' => 'pre-auth', - 'item_description' => 'Pre authorization', 'subscription_type' => 2, 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), ]; $data['signature'] = $this->payfast->generateSignature($data); + nlog($data['signature']); $data['gateway'] = $this->payfast; $data['payment_endpoint_url'] = $this->payfast->endpointUrl(); diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 6ec63540eaa8..0685f8a8b948 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -136,6 +136,7 @@ class PayFastPaymentDriver extends BaseDriver if( $passPhrase !== null ) { $getString .= '&passphrase='. urlencode( trim( $passPhrase ) ); } + nlog($getString); return md5( $getString ); } @@ -145,7 +146,7 @@ class PayFastPaymentDriver extends BaseDriver nlog($request->all()); $data = $request->all(); - + if(array_key_exists('m_payment_id', $data) && $data['m_payment_id'] == 'pre-auth') { return $this->setPaymentMethod(GatewayType::CREDIT_CARD) From 29c013191e97569f5567b131e221a3d77200d628 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 14:07:43 +1000 Subject: [PATCH 25/61] Fixes for base driver --- app/PaymentDrivers/PayFast/CreditCard.php | 6 +- app/PaymentDrivers/PayFastPaymentDriver.php | 83 +++++++++++++++++---- 2 files changed, 72 insertions(+), 17 deletions(-) diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index d4eb05134659..fc78cc2f7db3 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -82,7 +82,9 @@ class CreditCard public function authorizeView($data) { - // $hash = Cache::put(Str::random(32), 'cc_auth', 300); + $hash = Str::random(32); + + Cache::put($hash, 'cc_auth', 300); $data = [ 'merchant_id' => $this->payfast->company_gateway->getConfigField('merchantId'), @@ -91,7 +93,9 @@ class CreditCard 'cancel_url' => route('client.payment_methods.index'), 'notify_url' => $this->payfast->genericWebhookUrl(), 'amount' => 5, + 'm_payment_id' => $hash, 'item_name' => 'pre-auth', + 'item_description' => 'Credit Card Pre Authorization', 'subscription_type' => 2, 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), ]; diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 0685f8a8b948..148a7a228603 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -20,6 +20,7 @@ use App\PaymentDrivers\PayFast\CreditCard; use App\Utils\Traits\MakesHash; use \PayFastPayment; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Cache; class PayFastPaymentDriver extends BaseDriver { @@ -122,24 +123,67 @@ class PayFastPaymentDriver extends BaseDriver return $this->payment_method->yourTokenBillingImplmentation(); //this is your custom implementation from here } - public function generateSignature($data, $passPhrase = null) + // public function generateSignature($data, $passPhrase = null) + // { + // // Create parameter string + // $pfOutput = ''; + // foreach( $data as $key => $val ) { + // if($val !== '') { + // $pfOutput .= $key .'='. urlencode( trim( $val ) ) .'&'; + // } + // } + // // Remove last ampersand + // $getString = substr( $pfOutput, 0, -1 ); + // if( $passPhrase !== null ) { + // $getString .= '&passphrase='. urlencode( trim( $passPhrase ) ); + // } + // nlog($getString); + // return md5( $getString ); + // } + + + protected function generateSignature($data, $passPhrase = null) { - // Create parameter string - $pfOutput = ''; - foreach( $data as $key => $val ) { - if($val !== '') { - $pfOutput .= $key .'='. urlencode( trim( $val ) ) .'&'; + $fields = array(); + + // specific order required by PayFast + // @see https://developers.payfast.co.za/documentation/#checkout-page + foreach (array('merchant_id', 'merchant_key', 'return_url', 'cancel_url', 'notify_url', 'name_first', + 'name_last', 'email_address', 'cell_number', + /** + * Transaction Details + */ + 'm_payment_id', 'amount', 'item_name', 'item_description', + /** + * Custom return data + */ + 'custom_int1', 'custom_int2', 'custom_int3', 'custom_int4', 'custom_int5', + 'custom_str1', 'custom_str2', 'custom_str3', 'custom_str4', 'custom_str5', + /** + * Email confirmation + */ + 'email_confirmation', 'confirmation_address', + /** + * Payment Method + */ + 'payment_method', + /** + * Subscriptions + */ + 'subscription_type', 'billing_date', 'recurring_amount', 'frequency', 'cycles', + /** + * Passphrase for md5 signature generation + */ + 'passphrase') as $key) { + if (!empty($data[$key])) { + $fields[$key] = $data[$key]; } } - // Remove last ampersand - $getString = substr( $pfOutput, 0, -1 ); - if( $passPhrase !== null ) { - $getString .= '&passphrase='. urlencode( trim( $passPhrase ) ); - } - nlog($getString); - return md5( $getString ); + + return md5(http_build_query($fields)); } + public function processWebhookRequest(Request $request, Payment $payment = null) { $this->init(); @@ -147,10 +191,17 @@ class PayFastPaymentDriver extends BaseDriver nlog($request->all()); $data = $request->all(); - if(array_key_exists('m_payment_id', $data) && $data['m_payment_id'] == 'pre-auth') + if(array_key_exists('m_payment_id', $data)) { - return $this->setPaymentMethod(GatewayType::CREDIT_CARD) - ->authorizeResponse($request); + + $hash = Cache::get($data['m_payment_id']); + + if($hash == 'cc_auth') + { + return $this->setPaymentMethod(GatewayType::CREDIT_CARD) + ->authorizeResponse($request); + } + } return response()->json([], 200); From d79443b90a745e152239787c589ce9011d820b86 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 14:08:09 +1000 Subject: [PATCH 26/61] Fixes for base driver --- app/PaymentDrivers/PayFastPaymentDriver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 148a7a228603..582420256a0e 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -142,7 +142,7 @@ class PayFastPaymentDriver extends BaseDriver // } - protected function generateSignature($data, $passPhrase = null) + public function generateSignature($data, $passPhrase = null) { $fields = array(); From cc193c059dad34364c5770aad03bea7d0d76bd7f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 14:10:09 +1000 Subject: [PATCH 27/61] Fixes for base driver --- app/PaymentDrivers/PayFastPaymentDriver.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 582420256a0e..65e18e08bae6 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -180,6 +180,8 @@ class PayFastPaymentDriver extends BaseDriver } } + nlog(md5(http_build_query($fields))); + return md5(http_build_query($fields)); } @@ -193,7 +195,7 @@ class PayFastPaymentDriver extends BaseDriver if(array_key_exists('m_payment_id', $data)) { - + $hash = Cache::get($data['m_payment_id']); if($hash == 'cc_auth') From becdb7c8c960c1ae9bc6a5f4bd130dcdba2a2567 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 14:11:39 +1000 Subject: [PATCH 28/61] Fixes for base driver --- app/PaymentDrivers/PayFastPaymentDriver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 65e18e08bae6..3c346c0ed534 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -142,7 +142,7 @@ class PayFastPaymentDriver extends BaseDriver // } - public function generateSignature($data, $passPhrase = null) + public function generateSignature($data) { $fields = array(); From 812b2450ee91a73d43697f5f4985ea1550ecfefe Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 14:19:17 +1000 Subject: [PATCH 29/61] Fixes for base driver --- app/PaymentDrivers/PayFast/CreditCard.php | 2 +- .../views/portal/ninja2020/gateways/payfast/authorize.blade.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index fc78cc2f7db3..eb430ff78ec2 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -92,8 +92,8 @@ class CreditCard 'return_url' => route('client.payment_methods.index'), 'cancel_url' => route('client.payment_methods.index'), 'notify_url' => $this->payfast->genericWebhookUrl(), - 'amount' => 5, 'm_payment_id' => $hash, + 'amount' => 5, 'item_name' => 'pre-auth', 'item_description' => 'Credit Card Pre Authorization', 'subscription_type' => 2, diff --git a/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php b/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php index 06cdd2dc56ba..5dbba361c5a1 100644 --- a/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php +++ b/resources/views/portal/ninja2020/gateways/payfast/authorize.blade.php @@ -12,8 +12,10 @@ + + From a6494a68c2c52d56cfbd12488a949e603995b2a7 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 14:29:38 +1000 Subject: [PATCH 30/61] Fixes for base driver --- app/PaymentDrivers/PayFastPaymentDriver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 3c346c0ed534..07e6c0e55ada 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -188,7 +188,7 @@ class PayFastPaymentDriver extends BaseDriver public function processWebhookRequest(Request $request, Payment $payment = null) { - $this->init(); + // $this->init(); nlog($request->all()); $data = $request->all(); @@ -201,7 +201,7 @@ class PayFastPaymentDriver extends BaseDriver if($hash == 'cc_auth') { return $this->setPaymentMethod(GatewayType::CREDIT_CARD) - ->authorizeResponse($request); + ->authorizeResponse($request); } } From a7076be7465d3d925c2181afd51a0ab52bf4f128 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 15:13:04 +1000 Subject: [PATCH 31/61] Payment Payment --- app/PaymentDrivers/PayFast/CreditCard.php | 28 ++++++-- app/PaymentDrivers/PayFastPaymentDriver.php | 8 +-- app/PaymentDrivers/WePay/CreditCard.php | 1 - .../ninja2020/gateways/payfast/pay.blade.php | 72 +++++++++++++++++++ 4 files changed, 98 insertions(+), 11 deletions(-) create mode 100644 resources/views/portal/ninja2020/gateways/payfast/pay.blade.php diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index eb430ff78ec2..ae5968eddda7 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -101,7 +101,6 @@ class CreditCard ]; $data['signature'] = $this->payfast->generateSignature($data); - nlog($data['signature']); $data['gateway'] = $this->payfast; $data['payment_endpoint_url'] = $this->payfast->endpointUrl(); @@ -155,14 +154,35 @@ class CreditCard $token = $this->payfast->storeGatewayToken($cgt, []); - nlog($token); - - return response()->json([], 200); + return response()->json([], 200); } + public function paymentView($data) + { + $data = [ + 'merchant_id' => $this->payfast->company_gateway->getConfigField('merchantId'), + 'merchant_key' => $this->payfast->company_gateway->getConfigField('merchantKey'), + 'return_url' => route('client.payment_methods.index'), + 'cancel_url' => route('client.payment_methods.index'), + 'notify_url' => $this->payfast->genericWebhookUrl(), + 'm_payment_id' => $data['hash'], + 'amount' => $data['amount_with_fee'], + 'item_name' => 'purchase', + 'item_description' => ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number'), + 'subscription_type' => 2, + 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), + ]; + + $data['signature'] = $this->payfast->generateSignature($data); + $data['gateway'] = $this->payfast; + $data['payment_endpoint_url'] = $this->payfast->endpointUrl(); + + return render('gateways.payfast.authorize', $data); + + } } diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 07e6c0e55ada..3f93ced230dd 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -95,12 +95,12 @@ class PayFastPaymentDriver extends BaseDriver public function authorizeView(array $data) { - return $this->payment_method->authorizeView($data); //this is your custom implementation from here + return $this->payment_method->authorizeView($data); } public function authorizeResponse($request) { - return $this->payment_method->authorizeResponse($request); //this is your custom implementation from here + return $this->payment_method->authorizeResponse($request); } public function processPaymentView(array $data) @@ -180,17 +180,13 @@ class PayFastPaymentDriver extends BaseDriver } } - nlog(md5(http_build_query($fields))); - return md5(http_build_query($fields)); } public function processWebhookRequest(Request $request, Payment $payment = null) { - // $this->init(); - nlog($request->all()); $data = $request->all(); if(array_key_exists('m_payment_id', $data)) diff --git a/app/PaymentDrivers/WePay/CreditCard.php b/app/PaymentDrivers/WePay/CreditCard.php index a943800e4a28..8e6a155ddc43 100644 --- a/app/PaymentDrivers/WePay/CreditCard.php +++ b/app/PaymentDrivers/WePay/CreditCard.php @@ -117,7 +117,6 @@ use WePayCommon; nlog("authorize the card first!"); $response = $this->wepay_payment_driver->wepay->request('credit_card/authorize', array( - // 'callback_uri' => route('payment_webhook', ['company_key' => $this->wepay_payment_driver->company_gateway->company->company_key, 'company_gateway_id' => $this->wepay_payment_driver->company_gateway->hashed_id]), 'client_id' => config('ninja.wepay.client_id'), 'client_secret' => config('ninja.wepay.client_secret'), 'credit_card_id' => (int)$request->input('credit_card_id'), diff --git a/resources/views/portal/ninja2020/gateways/payfast/pay.blade.php b/resources/views/portal/ninja2020/gateways/payfast/pay.blade.php new file mode 100644 index 000000000000..5cde9b5fca75 --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/payfast/pay.blade.php @@ -0,0 +1,72 @@ +@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.includes.payment_details') + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.pay_with')]) + @if(count($tokens) > 0) + @foreach($tokens as $token) + + @endforeach + @endisset + + + @endcomponent + + @include('portal.ninja2020.gateways.includes.save_card') + + @include('portal.ninja2020.gateways.wepay.includes.credit_card') + + @include('portal.ninja2020.gateways.includes.pay_now') + +
+@endsection + +@section('gateway_footer') + +@endsection From 6d8aba49d721a638cb693a80edc3b9896ff3386e Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 15:47:27 +1000 Subject: [PATCH 32/61] Payfast payments --- app/PaymentDrivers/PayFast/CreditCard.php | 2 +- .../views/portal/ninja2020/gateways/payfast/pay.blade.php | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index ae5968eddda7..f97c6c333a1e 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -169,7 +169,7 @@ class CreditCard 'return_url' => route('client.payment_methods.index'), 'cancel_url' => route('client.payment_methods.index'), 'notify_url' => $this->payfast->genericWebhookUrl(), - 'm_payment_id' => $data['hash'], + 'm_payment_id' => $data['payment_hash'], 'amount' => $data['amount_with_fee'], 'item_name' => 'purchase', 'item_description' => ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number'), diff --git a/resources/views/portal/ninja2020/gateways/payfast/pay.blade.php b/resources/views/portal/ninja2020/gateways/payfast/pay.blade.php index 5cde9b5fca75..9f2146badd32 100644 --- a/resources/views/portal/ninja2020/gateways/payfast/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/payfast/pay.blade.php @@ -20,11 +20,6 @@ - - @if(!Request::isSecure()) -

{{ ctrans('texts.https_required') }}

- @endif - @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.method')]) From 178e732b46fa713e8459f3bfc7d241e61aeb9e62 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 16:06:25 +1000 Subject: [PATCH 33/61] Working on Payment response from offline gateway --- app/PaymentDrivers/PayFastPaymentDriver.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 3f93ced230dd..3e7869c89a81 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -188,18 +188,26 @@ class PayFastPaymentDriver extends BaseDriver { $data = $request->all(); + nlog($data); if(array_key_exists('m_payment_id', $data)) { $hash = Cache::get($data['m_payment_id']); - if($hash == 'cc_auth') + switch ($hash) { - return $this->setPaymentMethod(GatewayType::CREDIT_CARD) - ->authorizeResponse($request); + case 'cc_auth': + return $this->setPaymentMethod(GatewayType::CREDIT_CARD) + ->authorizeResponse($request); + break; + + default: + // code... + break; } + } return response()->json([], 200); From a033ba706cf2f27cf09276ea392ddd4de2bea9e1 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 16:07:14 +1000 Subject: [PATCH 34/61] Working on Payment response from offline gateway --- app/PaymentDrivers/PayFastPaymentDriver.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 3e7869c89a81..8ae40105516b 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -204,6 +204,8 @@ class PayFastPaymentDriver extends BaseDriver default: // code... + // + //otherwise we processs a payment response here break; } From 552afe33747fb2fdbaa6e6cbf5107773112f5dfa Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 20:45:00 +1000 Subject: [PATCH 35/61] Minor fixes --- app/Listeners/Payment/PaymentNotification.php | 1 - app/Models/User.php | 2 ++ app/PaymentDrivers/PayFast/CreditCard.php | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Listeners/Payment/PaymentNotification.php b/app/Listeners/Payment/PaymentNotification.php index a5aa1f07c8bc..d1a7a7b94748 100644 --- a/app/Listeners/Payment/PaymentNotification.php +++ b/app/Listeners/Payment/PaymentNotification.php @@ -71,7 +71,6 @@ class PaymentNotification implements ShouldQueue } - /*Google Analytics Track Revenue*/ if (isset($payment->company->google_analytics_key)) { $this->trackRevenue($event); diff --git a/app/Models/User.php b/app/Models/User.php index 8c6ad83f8df9..8533c211784c 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -161,6 +161,8 @@ class User extends Authenticatable implements MustVerifyEmail public function setCompany($company) { $this->company = $company; + + return $this; } /** diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index f97c6c333a1e..d3267fe041d5 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -22,6 +22,7 @@ use App\Models\SystemLog; use App\PaymentDrivers\PayFastPaymentDriver; use Illuminate\Support\Str; use Illuminate\Support\Facades\Cache; +use Illuminate\Http\Request; class CreditCard { @@ -184,5 +185,10 @@ class CreditCard return render('gateways.payfast.authorize', $data); } + + public function processPaymentResponse(Request $request) + { + + } } From 1dd4f1e3797acd9bd2c899d465db74e6b4f542d5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 20:47:59 +1000 Subject: [PATCH 36/61] Payment response --- app/PaymentDrivers/PayFastPaymentDriver.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 8ae40105516b..54affcae8845 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -199,13 +199,13 @@ class PayFastPaymentDriver extends BaseDriver { case 'cc_auth': return $this->setPaymentMethod(GatewayType::CREDIT_CARD) - ->authorizeResponse($request); + ->authorizeResponse($request); break; default: - // code... - // - //otherwise we processs a payment response here + + return $this->setPaymentMethod(GatewayType::CREDIT_CARD) + ->processPaymentResponse($request); break; } From d24047374b8d479eef3eb93d21bb200ec02c75dd Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 20:50:02 +1000 Subject: [PATCH 37/61] Minor fixes --- app/PaymentDrivers/PayFast/CreditCard.php | 3 +-- .../views/portal/ninja2020/gateways/payfast/pay.blade.php | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index d3267fe041d5..ff93cc812480 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -174,7 +174,6 @@ class CreditCard 'amount' => $data['amount_with_fee'], 'item_name' => 'purchase', 'item_description' => ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number'), - 'subscription_type' => 2, 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), ]; @@ -182,7 +181,7 @@ class CreditCard $data['gateway'] = $this->payfast; $data['payment_endpoint_url'] = $this->payfast->endpointUrl(); - return render('gateways.payfast.authorize', $data); + return render('gateways.payfast.pay', $data); } diff --git a/resources/views/portal/ninja2020/gateways/payfast/pay.blade.php b/resources/views/portal/ninja2020/gateways/payfast/pay.blade.php index 9f2146badd32..633c684baeba 100644 --- a/resources/views/portal/ninja2020/gateways/payfast/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/payfast/pay.blade.php @@ -16,7 +16,6 @@ - From 712ff6b88119ca9f300998341a2ad2f707698f76 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 20:55:01 +1000 Subject: [PATCH 38/61] Payment response --- app/PaymentDrivers/PayFast/CreditCard.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index ff93cc812480..635b9dd9e65c 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -164,7 +164,7 @@ class CreditCard public function paymentView($data) { - $data = [ + $payfast_data = [ 'merchant_id' => $this->payfast->company_gateway->getConfigField('merchantId'), 'merchant_key' => $this->payfast->company_gateway->getConfigField('merchantKey'), 'return_url' => route('client.payment_methods.index'), @@ -177,17 +177,17 @@ class CreditCard 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), ]; - $data['signature'] = $this->payfast->generateSignature($data); - $data['gateway'] = $this->payfast; - $data['payment_endpoint_url'] = $this->payfast->endpointUrl(); + $payfast_data['signature'] = $this->payfast->generateSignature($payfast_data); + $payfast_data['gateway'] = $this->payfast; + $payfast_data['payment_endpoint_url'] = $this->payfast->endpointUrl(); - return render('gateways.payfast.pay', $data); + return render('gateways.payfast.pay', array_merge($data, $payfast_data)); } public function processPaymentResponse(Request $request) { - + dd($request->all()); } } From 71cb3b5a7aee5063336661b99e9537280df0ee75 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 21:15:35 +1000 Subject: [PATCH 39/61] Payment response --- .../views/portal/ninja2020/gateways/payfast/pay.blade.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/resources/views/portal/ninja2020/gateways/payfast/pay.blade.php b/resources/views/portal/ninja2020/gateways/payfast/pay.blade.php index 633c684baeba..9b3c4a889c3b 100644 --- a/resources/views/portal/ninja2020/gateways/payfast/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/payfast/pay.blade.php @@ -62,5 +62,13 @@ @endsection @section('gateway_footer') + @endsection + From 3d8cf7881c537b5307b75991b798e521c468dc02 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 21:20:57 +1000 Subject: [PATCH 40/61] Payment response --- app/PaymentDrivers/PayFast/CreditCard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index 635b9dd9e65c..44e9f2329ad5 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -185,7 +185,7 @@ class CreditCard } - public function processPaymentResponse(Request $request) + public function paymentResponse(Request $request) { dd($request->all()); } From 3e2a19fe5328442c6134c83acb05838d652b194f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 21:57:59 +1000 Subject: [PATCH 41/61] Fixes for payfast --- app/Console/Kernel.php | 2 +- app/PaymentDrivers/PayFast/CreditCard.php | 140 +++++++++++++++++++- app/PaymentDrivers/PayFastPaymentDriver.php | 4 +- 3 files changed, 143 insertions(+), 3 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 7c777677086e..a97b90b1730c 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -64,7 +64,7 @@ class Kernel extends ConsoleKernel $schedule->job(new AutoBillCron)->dailyAt('00:30')->withoutOverlapping(); - $schedule->job(new SchedulerCheck)->everyFiveMinutes(); + $schedule->job(new SchedulerCheck)->daily()->withoutOverlapping(); /* Run hosted specific jobs */ if (Ninja::isHosted()) { diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index 44e9f2329ad5..33bbbb9e3ac8 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -185,9 +185,147 @@ class CreditCard } + /* + [2021-07-05 11:21:24] local.INFO: array ( + 'm_payment_id' => 'B7G9Q2vPhqkLEoMwwY1paXvPGuFxpbDe', + 'pf_payment_id' => '1410364', + 'payment_status' => 'COMPLETE', + 'item_name' => 'purchase', + 'item_description' => 'Invoices: ["0001"]', + 'amount_gross' => '100.00', + 'amount_fee' => '-2.30', + 'amount_net' => '97.70', + 'custom_str1' => NULL, + 'custom_str2' => NULL, + 'custom_str3' => NULL, + 'custom_str4' => NULL, + 'custom_str5' => NULL, + 'custom_int1' => NULL, + 'custom_int2' => NULL, + 'custom_int3' => NULL, + 'custom_int4' => NULL, + 'custom_int5' => NULL, + 'name_first' => NULL, + 'name_last' => NULL, + 'email_address' => NULL, + 'merchant_id' => '10023100', + 'signature' => '3ed27638479fd65cdffb0f4910679d10', + 'q' => '/payment_notification_webhook/EhbnVYyzJZyccY85hcHIkIzNPI2rtHzznAyyyG73oSxZidAdN9gf8BvAKDomqeHp/4openRe7Az/WPe99p3eLy', + ) + + */ public function paymentResponse(Request $request) { - dd($request->all()); + $response_array = $request->all(); + + $state = [ + 'server_response' => $request->all(), + 'payment_hash' => $request->input('m_payment_id'), + ]; + + $this->payfast->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, $state); + $this->payfast->payment_hash->save(); + + if($response_array['payment_status'] == 'COMPLETE') { + + $this->payfast->logSuccessfulGatewayResponse(['response' => json_decode($response_array), 'data' => $this->payfast->payment_hash], SystemLog::TYPE_PAYFAST); + + return $this->processSuccessfulPayment(); + } + else { + $this->processUnsuccessfulPayment($response_array); + } } } + + +private function processSuccessfulPayment() + { + $stripe_method = $this->stripe->getStripePaymentMethod($this->stripe->payment_hash->data->server_response->payment_method); + + $data = [ + 'payment_method' => $this->stripe->payment_hash->data->server_response->payment_method, + 'payment_type' => PaymentType::parseCardType(strtolower($stripe_method->card->brand)), + 'amount' => $this->stripe->convertFromStripeAmount($this->stripe->payment_hash->data->server_response->amount, $this->stripe->client->currency()->precision, $this->stripe->client->currency()), + 'transaction_reference' => optional($this->stripe->payment_hash->data->payment_intent->charges->data[0])->id, + 'gateway_type_id' => GatewayType::CREDIT_CARD, + ]; + + $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['amount' => $data['amount']]); + $this->stripe->payment_hash->save(); + + if ($this->stripe->payment_hash->data->store_card) { + $customer = new \stdClass; + $customer->id = $this->stripe->payment_hash->data->customer; + + $this->stripe->attach($this->stripe->payment_hash->data->server_response->payment_method, $customer); + + $stripe_method = $this->stripe->getStripePaymentMethod($this->stripe->payment_hash->data->server_response->payment_method); + + $this->storePaymentMethod($stripe_method, $this->stripe->payment_hash->data->payment_method_id, $customer); + } + + $payment = $this->stripe->createPayment($data, Payment::STATUS_COMPLETED); + + SystemLogger::dispatch( + ['response' => $this->stripe->payment_hash->data->server_response, 'data' => $data], + SystemLog::CATEGORY_GATEWAY_RESPONSE, + SystemLog::EVENT_GATEWAY_SUCCESS, + SystemLog::TYPE_STRIPE, + $this->stripe->client, + $this->stripe->client->company, + ); + + return redirect()->route('client.payments.show', ['payment' => $this->stripe->encodePrimaryKey($payment->id)]); + } + + private function processUnsuccessfulPayment($server_response) + { + PaymentFailureMailer::dispatch($this->stripe->client, $server_response->cancellation_reason, $this->stripe->client->company, $server_response->amount); + + PaymentFailureMailer::dispatch( + $this->stripe->client, + $server_response, + $this->stripe->client->company, + $server_response->amount + ); + + $message = [ + 'server_response' => $server_response, + 'data' => $this->stripe->payment_hash->data, + ]; + + SystemLogger::dispatch( + $message, + SystemLog::CATEGORY_GATEWAY_RESPONSE, + SystemLog::EVENT_GATEWAY_FAILURE, + SystemLog::TYPE_STRIPE, + $this->stripe->client, + $this->stripe->client->company, + ); + + throw new PaymentFailed('Failed to process the payment.', 500); + } + + private function storePaymentMethod(PaymentMethod $method, $payment_method_id, $customer) + { + try { + $payment_meta = new \stdClass; + $payment_meta->exp_month = (string) $method->card->exp_month; + $payment_meta->exp_year = (string) $method->card->exp_year; + $payment_meta->brand = (string) $method->card->brand; + $payment_meta->last4 = (string) $method->card->last4; + $payment_meta->type = GatewayType::CREDIT_CARD; + + $data = [ + 'payment_meta' => $payment_meta, + 'token' => $method->id, + 'payment_method_id' => $payment_method_id, + ]; + + $this->stripe->storeGatewayToken($data, ['gateway_customer_reference' => $customer->id]); + } catch (\Exception $e) { + return $this->stripe->processInternallyFailedPayment($this->stripe, $e); + } + } diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 54affcae8845..058d4113291b 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -203,8 +203,10 @@ class PayFastPaymentDriver extends BaseDriver break; default: - + + $payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$hash])->first(); return $this->setPaymentMethod(GatewayType::CREDIT_CARD) + ->setPaymentHash($payment_hash) ->processPaymentResponse($request); break; } From fc00d3a6142d5621cfa0851f3f4fb90a8448b470 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 23:00:12 +1000 Subject: [PATCH 42/61] Payment response --- app/PaymentDrivers/PayFast/CreditCard.php | 85 +++++------------------ 1 file changed, 18 insertions(+), 67 deletions(-) diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index 33bbbb9e3ac8..85961205e24d 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -230,102 +230,53 @@ class CreditCard $this->payfast->logSuccessfulGatewayResponse(['response' => json_decode($response_array), 'data' => $this->payfast->payment_hash], SystemLog::TYPE_PAYFAST); - return $this->processSuccessfulPayment(); + return $this->processSuccessfulPayment($response_array); } else { $this->processUnsuccessfulPayment($response_array); } } -} - - -private function processSuccessfulPayment() + private function processSuccessfulPayment($response_array) { - $stripe_method = $this->stripe->getStripePaymentMethod($this->stripe->payment_hash->data->server_response->payment_method); - $data = [ - 'payment_method' => $this->stripe->payment_hash->data->server_response->payment_method, - 'payment_type' => PaymentType::parseCardType(strtolower($stripe_method->card->brand)), - 'amount' => $this->stripe->convertFromStripeAmount($this->stripe->payment_hash->data->server_response->amount, $this->stripe->client->currency()->precision, $this->stripe->client->currency()), - 'transaction_reference' => optional($this->stripe->payment_hash->data->payment_intent->charges->data[0])->id, - 'gateway_type_id' => GatewayType::CREDIT_CARD, - ]; + $payment_record = []; + $payment_record['amount'] = $response_array['amount_gross']; + $payment_record['payment_type'] = PaymentType::CREDIT_CARD_OTHER; + $payment_record['gateway_type_id'] = GatewayType::CREDIT_CARD; + $payment_record['transaction_reference'] = $response_array['pf_payment_id']; - $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['amount' => $data['amount']]); - $this->stripe->payment_hash->save(); + $payment = $this->payfast->createPayment($payment_record, Payment::STATUS_COMPLETED); - if ($this->stripe->payment_hash->data->store_card) { - $customer = new \stdClass; - $customer->id = $this->stripe->payment_hash->data->customer; - - $this->stripe->attach($this->stripe->payment_hash->data->server_response->payment_method, $customer); - - $stripe_method = $this->stripe->getStripePaymentMethod($this->stripe->payment_hash->data->server_response->payment_method); - - $this->storePaymentMethod($stripe_method, $this->stripe->payment_hash->data->payment_method_id, $customer); - } - - $payment = $this->stripe->createPayment($data, Payment::STATUS_COMPLETED); - - SystemLogger::dispatch( - ['response' => $this->stripe->payment_hash->data->server_response, 'data' => $data], - SystemLog::CATEGORY_GATEWAY_RESPONSE, - SystemLog::EVENT_GATEWAY_SUCCESS, - SystemLog::TYPE_STRIPE, - $this->stripe->client, - $this->stripe->client->company, - ); - - return redirect()->route('client.payments.show', ['payment' => $this->stripe->encodePrimaryKey($payment->id)]); + return redirect()->route('client.payments.show', ['payment' => $this->payfast->encodePrimaryKey($payment->id)]); } private function processUnsuccessfulPayment($server_response) { - PaymentFailureMailer::dispatch($this->stripe->client, $server_response->cancellation_reason, $this->stripe->client->company, $server_response->amount); + PaymentFailureMailer::dispatch($this->payfast->client, $server_response->cancellation_reason, $this->payfast->client->company, $server_response->amount); PaymentFailureMailer::dispatch( - $this->stripe->client, + $this->payfast->client, $server_response, - $this->stripe->client->company, - $server_response->amount + $this->payfast->client->company, + $server_response['amount_gross'] ); $message = [ 'server_response' => $server_response, - 'data' => $this->stripe->payment_hash->data, + 'data' => $this->payfast->payment_hash->data, ]; SystemLogger::dispatch( $message, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, - SystemLog::TYPE_STRIPE, - $this->stripe->client, - $this->stripe->client->company, + SystemLog::TYPE_PAYFAST, + $this->payfast->client, + $this->payfast->client->company, ); throw new PaymentFailed('Failed to process the payment.', 500); } - private function storePaymentMethod(PaymentMethod $method, $payment_method_id, $customer) - { - try { - $payment_meta = new \stdClass; - $payment_meta->exp_month = (string) $method->card->exp_month; - $payment_meta->exp_year = (string) $method->card->exp_year; - $payment_meta->brand = (string) $method->card->brand; - $payment_meta->last4 = (string) $method->card->last4; - $payment_meta->type = GatewayType::CREDIT_CARD; - - $data = [ - 'payment_meta' => $payment_meta, - 'token' => $method->id, - 'payment_method_id' => $payment_method_id, - ]; - - $this->stripe->storeGatewayToken($data, ['gateway_customer_reference' => $customer->id]); - } catch (\Exception $e) { - return $this->stripe->processInternallyFailedPayment($this->stripe, $e); - } - } +} \ No newline at end of file From e1e7a3ffc82016d1da79552ffc114442cd4b3f25 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 23:04:17 +1000 Subject: [PATCH 43/61] Payment response --- app/PaymentDrivers/PayFastPaymentDriver.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 058d4113291b..1ba03887ff2a 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -204,7 +204,8 @@ class PayFastPaymentDriver extends BaseDriver default: - $payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$hash])->first(); + $payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$data['m_payment_id']])->first(); + return $this->setPaymentMethod(GatewayType::CREDIT_CARD) ->setPaymentHash($payment_hash) ->processPaymentResponse($request); From 2d044eee8ec9ff6add54e758f657e01cfabaa390 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 23:05:30 +1000 Subject: [PATCH 44/61] Payment response --- app/PaymentDrivers/PayFast/CreditCard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index 85961205e24d..90e7c2958ba3 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -223,7 +223,7 @@ class CreditCard 'payment_hash' => $request->input('m_payment_id'), ]; - $this->payfast->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, $state); + $this->payfast->payment_hash->data = array_merge((array) $this->payfast->payment_hash->data, $state); $this->payfast->payment_hash->save(); if($response_array['payment_status'] == 'COMPLETE') { From 2abd0f9cbec412b583f6302f13dabb7aa46d133f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 23:06:25 +1000 Subject: [PATCH 45/61] Payment response --- app/PaymentDrivers/PayFast/CreditCard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index 90e7c2958ba3..b749d800e4f4 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -167,7 +167,7 @@ class CreditCard $payfast_data = [ 'merchant_id' => $this->payfast->company_gateway->getConfigField('merchantId'), 'merchant_key' => $this->payfast->company_gateway->getConfigField('merchantKey'), - 'return_url' => route('client.payment_methods.index'), + 'return_url' => route('client.payments.index'), 'cancel_url' => route('client.payment_methods.index'), 'notify_url' => $this->payfast->genericWebhookUrl(), 'm_payment_id' => $data['payment_hash'], From 4db53cb48d4bca0c0535f0bbe1e48fdab6309255 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Jul 2021 23:07:30 +1000 Subject: [PATCH 46/61] Payment response --- app/PaymentDrivers/PayFast/CreditCard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index b749d800e4f4..fd99322a84fd 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -228,7 +228,7 @@ class CreditCard if($response_array['payment_status'] == 'COMPLETE') { - $this->payfast->logSuccessfulGatewayResponse(['response' => json_decode($response_array), 'data' => $this->payfast->payment_hash], SystemLog::TYPE_PAYFAST); + $this->payfast->logSuccessfulGatewayResponse(['response' => $response_array, 'data' => $this->payfast->payment_hash], SystemLog::TYPE_PAYFAST); return $this->processSuccessfulPayment($response_array); } From 82b423442f18956f03ee6e507a9897452775fcd9 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 6 Jul 2021 20:02:47 +1000 Subject: [PATCH 47/61] Token Billing with PayFast. --- app/PaymentDrivers/PayFast/CreditCard.php | 8 +- app/PaymentDrivers/PayFast/Token.php | 178 ++++++++++++++++++++ app/PaymentDrivers/PayFastPaymentDriver.php | 5 +- tests/Unit/CentConversionTest.php | 67 ++++++++ 4 files changed, 252 insertions(+), 6 deletions(-) create mode 100644 app/PaymentDrivers/PayFast/Token.php create mode 100644 tests/Unit/CentConversionTest.php diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index fd99322a84fd..ea5caebb56de 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -15,14 +15,16 @@ namespace App\PaymentDrivers\PayFast; use App\Exceptions\PaymentFailed; use App\Jobs\Mail\PaymentFailureMailer; use App\Jobs\Util\SystemLogger; +use App\Models\ClientGatewayToken; use App\Models\GatewayType; use App\Models\Payment; +use App\Models\PaymentHash; use App\Models\PaymentType; use App\Models\SystemLog; use App\PaymentDrivers\PayFastPaymentDriver; -use Illuminate\Support\Str; -use Illuminate\Support\Facades\Cache; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Str; class CreditCard { @@ -159,8 +161,6 @@ class CreditCard } - - public function paymentView($data) { diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php new file mode 100644 index 000000000000..05daa204d2ff --- /dev/null +++ b/app/PaymentDrivers/PayFast/Token.php @@ -0,0 +1,178 @@ +payfast = $payfast; + } + + // Attributes + // merchant-id + // integer, 8 char | REQUIRED + // Header, the Merchant ID as given by the PayFast system. + // version + // string | REQUIRED + // Header, the PayFast API version (i.e. v1). + // timestamp + // ISO-8601 date and time | REQUIRED + // Header, the current timestamp (YYYY-MM-DDTHH:MM:SS[+HH:MM]). + // signature + // string | REQUIRED + // Header, MD5 hash of the alphabetised submitted header and body variables, as well as the passphrase. Characters must be in lower case. + // amount + // integer | REQUIRED + // Body, the amount which the buyer must pay, in cents (ZAR), no decimals. + // item_name + // string, 100 char | REQUIRED + // Body, the name of the item being charged for. + // item_description + // string, 255 char | OPTIONAL + // Body, the description of the item being charged for. + // itn + // boolean | OPTIONAL + // Body, specify whether an ITN must be sent for the tokenization payment (true by default). + // m_payment_id + // string, 100 char | OPTIONAL + // Body, unique payment ID on the merchant’s system. + // cc_cvv + // numeric | OPTIONAL + + + public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash) + { + + $amount = array_sum(array_column($payment_hash->invoices(), 'amount')) + $payment_hash->fee_total; + $amount = round(($amount * pow(10, $this->payfast->client->currency()->precision)),0); + + $header =[ + 'merchant-id' => $this->payfast->company_gateway->getConfigField('merchantId'), + 'timestamp' => now()->format('c'), + 'version' => 'v1', + ]; + + $body = [ + 'amount' => $amount, + 'item_name' => 'purchase', + 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), + 'm_payment_id' => $payment_hash->hash, + 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), + ]; + + $header['signature'] = $this->payfast->genSig(array_merge($header, $body)); + + $result = $this->send($header, $body, $cgt->token); + + nlog($result); + + // /*Refactor and push to BaseDriver*/ + // if ($data['response'] != null && $data['response']->getMessages()->getResultCode() == 'Ok') { + + // $response = $data['response']; + + // $this->storePayment($payment_hash, $data); + + // $vars = [ + // 'invoices' => $payment_hash->invoices(), + // 'amount' => $amount, + // ]; + + // $logger_message = [ + // 'server_response' => $response->getTransactionResponse()->getTransId(), + // 'data' => $this->formatGatewayResponse($data, $vars), + // ]; + + // SystemLogger::dispatch($logger_message, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_SUCCESS, SystemLog::TYPE_AUTHORIZE, $this->authorize->client, $this->authorize->client->company); + + // return true; + // } else { + + // $vars = [ + // 'invoices' => $payment_hash->invoices(), + // 'amount' => $amount, + // ]; + + // $logger_message = [ + // 'server_response' => $response->getTransactionResponse()->getTransId(), + // 'data' => $this->formatGatewayResponse($data, $vars), + // ]; + + // PaymentFailureMailer::dispatch($this->authorize->client, $response->getTransactionResponse()->getTransId(), $this->authorize->client->company, $amount); + + // SystemLogger::dispatch($logger_message, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_AUTHORIZE, $this->authorize->client, $this->authorize->client->company); + + // return false; + // } + } + + private function genSig($data) + { + $fields = []; + + ksort($data); + + foreach($data as $key => $value) + { + if (!empty($data[$key])) { + $fields[$key] = $data[$key]; + } + } + + return md5(http_build_query($fields)); + } + + private function send($headers, $body, $token) + { + $client = new \GuzzleHttp\Client( + [ + 'headers' => $headers, + ]); + + try { + $response = $client->post("https://api.payfast.co.za/subscriptions/{$token}/adhoc",[ + RequestOptions::JSON => ['body' => $body], RequestOptions::ALLOW_REDIRECTS => false + ]); + + return json_decode($response->getBody(),true); + } + catch(\Exception $e) + { + + nlog($e->getMessage()); + + } + } +} + diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 1ba03887ff2a..b6ec14e1c32d 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -17,10 +17,11 @@ use App\Models\Payment; use App\Models\PaymentHash; use App\Models\SystemLog; use App\PaymentDrivers\PayFast\CreditCard; +use App\PaymentDrivers\PayFast\Token; use App\Utils\Traits\MakesHash; -use \PayFastPayment; use Illuminate\Http\Request; use Illuminate\Support\Facades\Cache; +use \PayFastPayment; class PayFastPaymentDriver extends BaseDriver { @@ -120,7 +121,7 @@ class PayFastPaymentDriver extends BaseDriver public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash) { - return $this->payment_method->yourTokenBillingImplmentation(); //this is your custom implementation from here + return (new Token($this))->tokenBilling($cgt, $payment_hash); } // public function generateSignature($data, $passPhrase = null) diff --git a/tests/Unit/CentConversionTest.php b/tests/Unit/CentConversionTest.php new file mode 100644 index 000000000000..4823f6c788a1 --- /dev/null +++ b/tests/Unit/CentConversionTest.php @@ -0,0 +1,67 @@ +assertEquals(1020, $amount); + + $amount = 2; + $amount = round(($amount * pow(10, $precision)),0); + + $this->assertEquals(200, $amount); + + $amount = 2.12; + $amount = round(($amount * pow(10, $precision)),0); + + $this->assertEquals(212, $amount); + } + + + public function testBcMathWay() + { + + $amount = 64.99; + $amount = bcmul($amount, 100); + + $this->assertEquals(6499, $amount); + + $amount = 2; + $amount = bcmul($amount, 100); + + $this->assertEquals(200, $amount); + + $amount = 2.12; + $amount = bcmul($amount, 100); + + $this->assertEquals(212, $amount); + } +} From fd136a93abd47f1a35d8539a7de7b014f0c80064 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 10 Jul 2021 16:11:58 +1000 Subject: [PATCH 48/61] Minor fixes for Payfast --- app/PaymentDrivers/PayFast/Token.php | 2 +- app/PaymentDrivers/PayFastPaymentDriver.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 05daa204d2ff..06d8cae17e3c 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -91,7 +91,7 @@ class Token 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), ]; - $header['signature'] = $this->payfast->genSig(array_merge($header, $body)); + $header['signature'] = $this->genSig(array_merge($header, $body)); $result = $this->send($header, $body, $cgt->token); diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index b6ec14e1c32d..4e855c909344 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -72,6 +72,7 @@ class PayFastPaymentDriver extends BaseDriver { try{ + $this->payfast = new PayFastPayment( [ 'merchantId' => $this->company_gateway->getConfigField('merchantId'), @@ -80,8 +81,11 @@ class PayFastPaymentDriver extends BaseDriver 'testMode' => $this->company_gateway->getConfigField('testMode') ] ); + } catch(Exception $e) { + echo '##PAYFAST## There was an exception: '.$e->getMessage(); + } return $this; From f5c927db1aa6bcfd93fc0145c0208a089a9430e1 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 10 Jul 2021 16:13:20 +1000 Subject: [PATCH 49/61] Minor fixes for Payfast --- app/PaymentDrivers/PayFastPaymentDriver.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 4e855c909344..65d0c030d7e2 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -85,7 +85,7 @@ class PayFastPaymentDriver extends BaseDriver } catch(Exception $e) { echo '##PAYFAST## There was an exception: '.$e->getMessage(); - + } return $this; @@ -125,6 +125,8 @@ class PayFastPaymentDriver extends BaseDriver public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash) { + $this->init(); + return (new Token($this))->tokenBilling($cgt, $payment_hash); } From 94d7e58f30161337e108f20426e91f7aaeb6cf4e Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 10 Jul 2021 16:14:08 +1000 Subject: [PATCH 50/61] Minor fixes for Payfast --- app/PaymentDrivers/PayFastPaymentDriver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 65d0c030d7e2..32cd2643edc4 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -21,7 +21,7 @@ use App\PaymentDrivers\PayFast\Token; use App\Utils\Traits\MakesHash; use Illuminate\Http\Request; use Illuminate\Support\Facades\Cache; -use \PayFastPayment; +use PayFastPayment; class PayFastPaymentDriver extends BaseDriver { @@ -126,7 +126,7 @@ class PayFastPaymentDriver extends BaseDriver public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash) { $this->init(); - + return (new Token($this))->tokenBilling($cgt, $payment_hash); } From fdd71166df3665dcbcc5ff74e702826460d7e441 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 10 Jul 2021 16:26:06 +1000 Subject: [PATCH 51/61] 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); - - } + + } } From 2ef7a973dc57e635439fdddefba4921e25990e7e Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 10 Jul 2021 16:27:21 +1000 Subject: [PATCH 52/61] Minor fixes for Payfast --- app/PaymentDrivers/PayFast/Token.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 06d8cae17e3c..9f48644ec413 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -83,6 +83,8 @@ class Token 'version' => 'v1', ]; + nlog($header); + $body = [ 'amount' => $amount, 'item_name' => 'purchase', From d774e81ca040c0847e6a4ee12f96e9909a7e88f2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 10 Jul 2021 16:34:44 +1000 Subject: [PATCH 53/61] Minor fixes for Payfast --- app/PaymentDrivers/PayFast/Token.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 9f48644ec413..d1557b9d6884 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -78,7 +78,7 @@ class Token $amount = round(($amount * pow(10, $this->payfast->client->currency()->precision)),0); $header =[ - 'merchant-id' => $this->payfast->company_gateway->getConfigField('merchantId'), + 'merchant_id' => $this->payfast->company_gateway->getConfigField('merchantId'), 'timestamp' => now()->format('c'), 'version' => 'v1', ]; From 1e03070e9e31f697ed769196ca1206f77e0f03b2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 10 Jul 2021 16:39:14 +1000 Subject: [PATCH 54/61] Minor fixes for Payfast --- app/PaymentDrivers/PayFast/Token.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index d1557b9d6884..a7397cdddd52 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -78,7 +78,7 @@ class Token $amount = round(($amount * pow(10, $this->payfast->client->currency()->precision)),0); $header =[ - 'merchant_id' => $this->payfast->company_gateway->getConfigField('merchantId'), + 'merchant-id' => $this->payfast->company_gateway->getConfigField('merchantId'), 'timestamp' => now()->format('c'), 'version' => 'v1', ]; @@ -163,7 +163,7 @@ class Token ]); try { - $response = $client->post("https://api.payfast.co.za/subscriptions/{$token}/adhoc",[ + $response = $client->post("https://sandbox.payfast.co.za/subscriptions/{$token}/adhoc",[ RequestOptions::JSON => ['body' => $body], RequestOptions::ALLOW_REDIRECTS => false ]); From 24b8233a2f557954462686ea2a6059022727902a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 10 Jul 2021 16:48:20 +1000 Subject: [PATCH 55/61] Minor fixes for Payfast --- app/PaymentDrivers/PayFast/Token.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index a7397cdddd52..68e942c7b5ae 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -163,7 +163,7 @@ class Token ]); try { - $response = $client->post("https://sandbox.payfast.co.za/subscriptions/{$token}/adhoc",[ + $response = $client->post("https://api.payfast.co.za/subscriptions/{$token}/adhoc?testing=true",[ RequestOptions::JSON => ['body' => $body], RequestOptions::ALLOW_REDIRECTS => false ]); From d7e39cff14a5a8fb8ecd8d81a3271df3e5881bdf Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 10 Jul 2021 17:01:12 +1000 Subject: [PATCH 56/61] Minor fixes for Payfast --- app/PaymentDrivers/PayFast/Token.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/PaymentDrivers/PayFast/Token.php b/app/PaymentDrivers/PayFast/Token.php index 68e942c7b5ae..fc1235a0d3cc 100644 --- a/app/PaymentDrivers/PayFast/Token.php +++ b/app/PaymentDrivers/PayFast/Token.php @@ -95,6 +95,10 @@ class Token $header['signature'] = $this->genSig(array_merge($header, $body)); + nlog($header['signature']); + nlog($header['timestamp']); + nlog($this->payfast->company_gateway->getConfigField('merchantId')); + $result = $this->send($header, $body, $cgt->token); nlog($result); From 9c2e02d47ed74c5825ccccfc441a3642ef46ba41 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 10 Jul 2021 18:59:19 +1000 Subject: [PATCH 57/61] Activate payfast payment driver --- app/PaymentDrivers/PayFastPaymentDriver.php | 30 +++---------------- ...085821_activate_payfast_payment_driver.php | 29 ++++++++++++++++++ 2 files changed, 33 insertions(+), 26 deletions(-) create mode 100644 database/migrations/2021_07_10_085821_activate_payfast_payment_driver.php diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index 2ed0a070f0b0..8e274eb8cfaf 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -26,9 +26,9 @@ class PayFastPaymentDriver extends BaseDriver { use MakesHash; - public $refundable = true; //does this gateway support refunds? + public $refundable = false; //does this gateway support refunds? - public $token_billing = true; //does this gateway support token billing? + public $token_billing = false; //does this gateway support token billing? public $can_authorise_credit_card = true; //does this gateway support authorizations? @@ -42,15 +42,14 @@ class PayFastPaymentDriver extends BaseDriver const SYSTEM_LOG_TYPE = SystemLog::TYPE_PAYFAST; - //developer resources //https://sandbox.payfast.co.za/ - public function gatewayTypes(): array { $types = []; + if($this->client->currency()->code == 'ZAR') $types[] = GatewayType::CREDIT_CARD; return $types; @@ -116,35 +115,14 @@ class PayFastPaymentDriver extends BaseDriver public function refund(Payment $payment, $amount, $return_client_response = false) { - return $this->payment_method->yourRefundImplementationHere(); //this is your custom implementation from here + return false; } public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash) { - $this->init(); - return (new Token($this))->tokenBilling($cgt, $payment_hash); } - // public function generateSignature($data, $passPhrase = null) - // { - // // Create parameter string - // $pfOutput = ''; - // foreach( $data as $key => $val ) { - // if($val !== '') { - // $pfOutput .= $key .'='. urlencode( trim( $val ) ) .'&'; - // } - // } - // // Remove last ampersand - // $getString = substr( $pfOutput, 0, -1 ); - // if( $passPhrase !== null ) { - // $getString .= '&passphrase='. urlencode( trim( $passPhrase ) ); - // } - // nlog($getString); - // return md5( $getString ); - // } - - public function generateSignature($data) { $fields = array(); diff --git a/database/migrations/2021_07_10_085821_activate_payfast_payment_driver.php b/database/migrations/2021_07_10_085821_activate_payfast_payment_driver.php new file mode 100644 index 000000000000..b66c5c64aae4 --- /dev/null +++ b/database/migrations/2021_07_10_085821_activate_payfast_payment_driver.php @@ -0,0 +1,29 @@ +update(['visible' => 1]); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} From 87902783503ac377e66aed789b3e68a641c8912d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 10 Jul 2021 19:06:18 +1000 Subject: [PATCH 58/61] Update lock file --- composer.lock | 130 ++++++++++---------------------------------------- 1 file changed, 25 insertions(+), 105 deletions(-) diff --git a/composer.lock b/composer.lock index 22111d9d46e7..99a3b5134fb9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,11 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], -<<<<<<< HEAD - "content-hash": "16a38ffa3774d9d28a9f4c49366baac0", -======= - "content-hash": "26f6cde504d8ed4276289151e695250e", ->>>>>>> payfast + "content-hash": "25a0cbf18fc238305c7ea640c49ba89a", "packages": [ { "name": "asm/php-ansible", @@ -163,29 +159,16 @@ }, { "name": "aws/aws-sdk-php", -<<<<<<< HEAD - "version": "3.185.7", + "version": "3.185.10", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "7c0cd260e749374b5df247c4768c8f33f9a604e4" + "reference": "667a83e4a18cb75db3ce74162efc97123da96261" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/7c0cd260e749374b5df247c4768c8f33f9a604e4", - "reference": "7c0cd260e749374b5df247c4768c8f33f9a604e4", -======= - "version": "3.185.6", - "source": { - "type": "git", - "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "35310302912fdc3b4a0e829b84424c41e3fd9727" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/35310302912fdc3b4a0e829b84424c41e3fd9727", - "reference": "35310302912fdc3b4a0e829b84424c41e3fd9727", ->>>>>>> payfast + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/667a83e4a18cb75db3ce74162efc97123da96261", + "reference": "667a83e4a18cb75db3ce74162efc97123da96261", "shasum": "" }, "require": { @@ -260,15 +243,9 @@ "support": { "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", "issues": "https://github.com/aws/aws-sdk-php/issues", -<<<<<<< HEAD - "source": "https://github.com/aws/aws-sdk-php/tree/3.185.7" + "source": "https://github.com/aws/aws-sdk-php/tree/3.185.10" }, - "time": "2021-07-06T18:16:14+00:00" -======= - "source": "https://github.com/aws/aws-sdk-php/tree/3.185.6" - }, - "time": "2021-07-02T18:13:18+00:00" ->>>>>>> payfast + "time": "2021-07-09T19:21:22+00:00" }, { "name": "bacon/bacon-qr-code", @@ -2315,7 +2292,6 @@ }, { "name": "google/apiclient-services", -<<<<<<< HEAD "version": "v0.202.0", "source": { "type": "git", @@ -2326,18 +2302,6 @@ "type": "zip", "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/c72cb04fde47a2cc3336c1f513f9ff5db27ccc35", "reference": "c72cb04fde47a2cc3336c1f513f9ff5db27ccc35", -======= - "version": "v0.201.1", - "source": { - "type": "git", - "url": "https://github.com/googleapis/google-api-php-client-services.git", - "reference": "ee1072221acf7c32e3de9b18e11fec3ab23ec38f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/ee1072221acf7c32e3de9b18e11fec3ab23ec38f", - "reference": "ee1072221acf7c32e3de9b18e11fec3ab23ec38f", ->>>>>>> payfast "shasum": "" }, "require": { @@ -2366,15 +2330,9 @@ ], "support": { "issues": "https://github.com/googleapis/google-api-php-client-services/issues", -<<<<<<< HEAD "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.202.0" }, "time": "2021-07-03T11:20:23+00:00" -======= - "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.201.1" - }, - "time": "2021-06-27T11:20:22+00:00" ->>>>>>> payfast }, { "name": "google/auth", @@ -3226,7 +3184,6 @@ }, { "name": "laravel/framework", -<<<<<<< HEAD "version": "v8.49.2", "source": { "type": "git", @@ -3237,18 +3194,6 @@ "type": "zip", "url": "https://api.github.com/repos/laravel/framework/zipball/d9b43ee080b4d51344b2e578aa667f85040471a2", "reference": "d9b43ee080b4d51344b2e578aa667f85040471a2", -======= - "version": "v8.49.1", - "source": { - "type": "git", - "url": "https://github.com/laravel/framework.git", - "reference": "62aee1bfeefd82f160c7aa3b4c63cb2f053215c0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/62aee1bfeefd82f160c7aa3b4c63cb2f053215c0", - "reference": "62aee1bfeefd82f160c7aa3b4c63cb2f053215c0", ->>>>>>> payfast "shasum": "" }, "require": { @@ -3403,11 +3348,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, -<<<<<<< HEAD "time": "2021-07-06T14:06:38+00:00" -======= - "time": "2021-07-02T16:50:12+00:00" ->>>>>>> payfast }, { "name": "laravel/slack-notification-channel", @@ -4172,16 +4113,16 @@ }, { "name": "league/oauth1-client", - "version": "v1.9.0", + "version": "v1.9.1", "source": { "type": "git", "url": "https://github.com/thephpleague/oauth1-client.git", - "reference": "1e7e6be2dc543bf466236fb171e5b20e1b06aee6" + "reference": "19a3ce488bb1547c906209e8293199ec34eaa5b1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/oauth1-client/zipball/1e7e6be2dc543bf466236fb171e5b20e1b06aee6", - "reference": "1e7e6be2dc543bf466236fb171e5b20e1b06aee6", + "url": "https://api.github.com/repos/thephpleague/oauth1-client/zipball/19a3ce488bb1547c906209e8293199ec34eaa5b1", + "reference": "19a3ce488bb1547c906209e8293199ec34eaa5b1", "shasum": "" }, "require": { @@ -4241,9 +4182,9 @@ ], "support": { "issues": "https://github.com/thephpleague/oauth1-client/issues", - "source": "https://github.com/thephpleague/oauth1-client/tree/v1.9.0" + "source": "https://github.com/thephpleague/oauth1-client/tree/v1.9.1" }, - "time": "2021-01-20T01:40:53+00:00" + "time": "2021-07-07T22:54:46+00:00" }, { "name": "league/omnipay", @@ -4310,16 +4251,16 @@ }, { "name": "livewire/livewire", - "version": "v2.5.1", + "version": "v2.5.3", "source": { "type": "git", "url": "https://github.com/livewire/livewire.git", - "reference": "a4ffb135693e7982e5b982ca203f5dc7a7ae1126" + "reference": "1ca6757c78dbead4db7f52a72dabb8b27efcb3f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/livewire/livewire/zipball/a4ffb135693e7982e5b982ca203f5dc7a7ae1126", - "reference": "a4ffb135693e7982e5b982ca203f5dc7a7ae1126", + "url": "https://api.github.com/repos/livewire/livewire/zipball/1ca6757c78dbead4db7f52a72dabb8b27efcb3f6", + "reference": "1ca6757c78dbead4db7f52a72dabb8b27efcb3f6", "shasum": "" }, "require": { @@ -4370,7 +4311,7 @@ "description": "A front-end framework for Laravel.", "support": { "issues": "https://github.com/livewire/livewire/issues", - "source": "https://github.com/livewire/livewire/tree/v2.5.1" + "source": "https://github.com/livewire/livewire/tree/v2.5.3" }, "funding": [ { @@ -4378,7 +4319,7 @@ "type": "github" } ], - "time": "2021-06-15T13:24:48+00:00" + "time": "2021-07-08T13:58:45+00:00" }, { "name": "maennchen/zipstream-php", @@ -4690,7 +4631,6 @@ }, { "name": "myclabs/php-enum", -<<<<<<< HEAD "version": "1.8.3", "source": { "type": "git", @@ -4701,18 +4641,6 @@ "type": "zip", "url": "https://api.github.com/repos/myclabs/php-enum/zipball/b942d263c641ddb5190929ff840c68f78713e937", "reference": "b942d263c641ddb5190929ff840c68f78713e937", -======= - "version": "1.8.2", - "source": { - "type": "git", - "url": "https://github.com/myclabs/php-enum.git", - "reference": "8bef486e885cae67ced6e43257300e8acc3f06ad" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/myclabs/php-enum/zipball/8bef486e885cae67ced6e43257300e8acc3f06ad", - "reference": "8bef486e885cae67ced6e43257300e8acc3f06ad", ->>>>>>> payfast "shasum": "" }, "require": { @@ -4747,11 +4675,7 @@ ], "support": { "issues": "https://github.com/myclabs/php-enum/issues", -<<<<<<< HEAD "source": "https://github.com/myclabs/php-enum/tree/1.8.3" -======= - "source": "https://github.com/myclabs/php-enum/tree/1.8.2" ->>>>>>> payfast }, "funding": [ { @@ -4763,11 +4687,7 @@ "type": "tidelift" } ], -<<<<<<< HEAD "time": "2021-07-05T08:18:36+00:00" -======= - "time": "2021-07-04T17:44:39+00:00" ->>>>>>> payfast }, { "name": "nesbot/carbon", @@ -7450,16 +7370,16 @@ }, { "name": "stripe/stripe-php", - "version": "v7.87.0", + "version": "v7.88.0", "source": { "type": "git", "url": "https://github.com/stripe/stripe-php.git", - "reference": "9392f03cb8d8803bf8273378ce42d5cbbf1e24fc" + "reference": "7203d00ba9b09830c0c5d5c06a9558db43b8e0ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/stripe/stripe-php/zipball/9392f03cb8d8803bf8273378ce42d5cbbf1e24fc", - "reference": "9392f03cb8d8803bf8273378ce42d5cbbf1e24fc", + "url": "https://api.github.com/repos/stripe/stripe-php/zipball/7203d00ba9b09830c0c5d5c06a9558db43b8e0ea", + "reference": "7203d00ba9b09830c0c5d5c06a9558db43b8e0ea", "shasum": "" }, "require": { @@ -7505,9 +7425,9 @@ ], "support": { "issues": "https://github.com/stripe/stripe-php/issues", - "source": "https://github.com/stripe/stripe-php/tree/v7.87.0" + "source": "https://github.com/stripe/stripe-php/tree/v7.88.0" }, - "time": "2021-06-30T18:22:47+00:00" + "time": "2021-07-09T20:01:03+00:00" }, { "name": "swiftmailer/swiftmailer", From ad0b2b8ec32eef3de6c9352f003cbf498716cb9c Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 11 Jul 2021 10:16:27 +1000 Subject: [PATCH 59/61] Prevent ninja company from being deleted --- app/Factory/ExpenseCategoryFactory.php | 2 +- app/Factory/TaskStatusFactory.php | 2 +- app/Http/Controllers/CompanyController.php | 4 ++++ app/Http/Controllers/MigrationController.php | 6 ++++++ app/Http/Middleware/UrlSetDb.php | 7 ++++++- app/Http/Requests/Expense/StoreExpenseRequest.php | 2 +- .../ExpenseCategory/StoreExpenseCategoryRequest.php | 2 +- .../ExpenseCategory/UpdateExpenseCategoryRequest.php | 2 +- app/Http/Requests/Project/StoreProjectRequest.php | 2 +- app/Http/Requests/Project/UpdateProjectRequest.php | 2 +- app/Http/Requests/Task/UpdateTaskRequest.php | 2 +- app/Http/Requests/TaskStatus/StoreTaskStatusRequest.php | 2 +- app/Http/Requests/TaskStatus/UpdateTaskStatusRequest.php | 2 +- tests/Unit/CreditBalanceTest.php | 4 ++++ 14 files changed, 30 insertions(+), 11 deletions(-) diff --git a/app/Factory/ExpenseCategoryFactory.php b/app/Factory/ExpenseCategoryFactory.php index a2bd3d0bd407..cd7254ba8ee7 100644 --- a/app/Factory/ExpenseCategoryFactory.php +++ b/app/Factory/ExpenseCategoryFactory.php @@ -22,7 +22,7 @@ class ExpenseCategoryFactory $expense->company_id = $company_id; $expense->name = ''; $expense->is_deleted = false; - $expense->color = '#fff'; + $expense->color = ''; return $expense; } diff --git a/app/Factory/TaskStatusFactory.php b/app/Factory/TaskStatusFactory.php index 8d9b4742341e..aa5ea60d4714 100644 --- a/app/Factory/TaskStatusFactory.php +++ b/app/Factory/TaskStatusFactory.php @@ -21,7 +21,7 @@ class TaskStatusFactory $task_status->user_id = $user_id; $task_status->company_id = $company_id; $task_status->name = ''; - $task_status->color = '#fff'; + $task_status->color = ''; $task_status->status_order = 9999; return $task_status; diff --git a/app/Http/Controllers/CompanyController.php b/app/Http/Controllers/CompanyController.php index b85793ffe940..a22091a218bf 100644 --- a/app/Http/Controllers/CompanyController.php +++ b/app/Http/Controllers/CompanyController.php @@ -474,6 +474,10 @@ class CompanyController extends BaseController */ public function destroy(DestroyCompanyRequest $request, Company $company) { + + if(Ninja::isHosted() && config('ninja.ninja_default_company_id') == $company->id) + return response()->json(['message' => 'Cannot purge this company'], 400); + $company_count = $company->account->companies->count(); $account = $company->account; $account_key = $account->key; diff --git a/app/Http/Controllers/MigrationController.php b/app/Http/Controllers/MigrationController.php index 370dd080d403..94ab88c5123d 100644 --- a/app/Http/Controllers/MigrationController.php +++ b/app/Http/Controllers/MigrationController.php @@ -82,6 +82,9 @@ class MigrationController extends BaseController */ public function purgeCompany(Company $company) { + if(Ninja::isHosted() && config('ninja.ninja_default_company_id') == $company->id) + return response()->json(['message' => 'Cannot purge this company'], 400); + $account = $company->account; $company_id = $company->id; @@ -102,6 +105,9 @@ class MigrationController extends BaseController private function purgeCompanyWithForceFlag(Company $company) { + if(Ninja::isHosted() && config('ninja.ninja_default_company_id') == $company->id) + return response()->json(['message' => 'Cannot purge this company'], 400); + $account = $company->account; $company_id = $company->id; diff --git a/app/Http/Middleware/UrlSetDb.php b/app/Http/Middleware/UrlSetDb.php index 9e9fe306d323..e93ac08440ab 100644 --- a/app/Http/Middleware/UrlSetDb.php +++ b/app/Http/Middleware/UrlSetDb.php @@ -30,17 +30,22 @@ class UrlSetDb */ public function handle($request, Closure $next) { + if (config('ninja.db.multi_db_enabled')) { - $hashids = new Hashids('', 10); //decoded output is _always_ an array. + $hashids = new Hashids(config('ninja.hash_salt'), 10); //parse URL hash and set DB $segments = explode('-', $request->route('confirmation_code')); + if(!is_array($segments)) + return response()->json(['message' => 'Invalid confirmation code'], 403); + $hashed_db = $hashids->decode($segments[0]); MultiDB::setDB(MultiDB::DB_PREFIX.str_pad($hashed_db[0], 2, '0', STR_PAD_LEFT)); } return $next($request); + } } diff --git a/app/Http/Requests/Expense/StoreExpenseRequest.php b/app/Http/Requests/Expense/StoreExpenseRequest.php index 926ae7886d7d..1cb2e64624f8 100644 --- a/app/Http/Requests/Expense/StoreExpenseRequest.php +++ b/app/Http/Requests/Expense/StoreExpenseRequest.php @@ -59,7 +59,7 @@ class StoreExpenseRequest extends Request } if(array_key_exists('color', $input) && is_null($input['color'])) - $input['color'] = '#fff'; + $input['color'] = ''; $this->replace($input); } diff --git a/app/Http/Requests/ExpenseCategory/StoreExpenseCategoryRequest.php b/app/Http/Requests/ExpenseCategory/StoreExpenseCategoryRequest.php index b09a903bdbad..a896e8388927 100644 --- a/app/Http/Requests/ExpenseCategory/StoreExpenseCategoryRequest.php +++ b/app/Http/Requests/ExpenseCategory/StoreExpenseCategoryRequest.php @@ -43,7 +43,7 @@ class StoreExpenseCategoryRequest extends Request $input = $this->decodePrimaryKeys($input); if(array_key_exists('color', $input) && is_null($input['color'])) - $input['color'] = '#fff'; + $input['color'] = ''; $this->replace($input); } diff --git a/app/Http/Requests/ExpenseCategory/UpdateExpenseCategoryRequest.php b/app/Http/Requests/ExpenseCategory/UpdateExpenseCategoryRequest.php index 2b8e5a7449a7..921c5b14de3a 100644 --- a/app/Http/Requests/ExpenseCategory/UpdateExpenseCategoryRequest.php +++ b/app/Http/Requests/ExpenseCategory/UpdateExpenseCategoryRequest.php @@ -47,7 +47,7 @@ class UpdateExpenseCategoryRequest extends Request $input = $this->all(); if(array_key_exists('color', $input) && is_null($input['color'])) - $input['color'] = '#fff'; + $input['color'] = ''; $this->replace($input); } diff --git a/app/Http/Requests/Project/StoreProjectRequest.php b/app/Http/Requests/Project/StoreProjectRequest.php index 9cc666e76c2d..b42dda0f62b5 100644 --- a/app/Http/Requests/Project/StoreProjectRequest.php +++ b/app/Http/Requests/Project/StoreProjectRequest.php @@ -51,7 +51,7 @@ class StoreProjectRequest extends Request if(array_key_exists('color', $input) && is_null($input['color'])) - $input['color'] = '#fff'; + $input['color'] = ''; $this->replace($input); } diff --git a/app/Http/Requests/Project/UpdateProjectRequest.php b/app/Http/Requests/Project/UpdateProjectRequest.php index d5fa2f0f52ea..0217de8264b1 100644 --- a/app/Http/Requests/Project/UpdateProjectRequest.php +++ b/app/Http/Requests/Project/UpdateProjectRequest.php @@ -49,7 +49,7 @@ class UpdateProjectRequest extends Request } if(array_key_exists('color', $input) && is_null($input['color'])) - $input['color'] = '#fff'; + $input['color'] = ''; $this->replace($input); } diff --git a/app/Http/Requests/Task/UpdateTaskRequest.php b/app/Http/Requests/Task/UpdateTaskRequest.php index 4b62444bd623..03f87b52a199 100644 --- a/app/Http/Requests/Task/UpdateTaskRequest.php +++ b/app/Http/Requests/Task/UpdateTaskRequest.php @@ -51,7 +51,7 @@ class UpdateTaskRequest extends Request } if(array_key_exists('color', $input) && is_null($input['color'])) - $input['color'] = '#fff'; + $input['color'] = ''; $this->replace($input); } diff --git a/app/Http/Requests/TaskStatus/StoreTaskStatusRequest.php b/app/Http/Requests/TaskStatus/StoreTaskStatusRequest.php index 8e476c5bb0a1..d3ba8750dab0 100644 --- a/app/Http/Requests/TaskStatus/StoreTaskStatusRequest.php +++ b/app/Http/Requests/TaskStatus/StoreTaskStatusRequest.php @@ -33,7 +33,7 @@ class StoreTaskStatusRequest extends Request $input = $this->all(); if(array_key_exists('color', $input) && is_null($input['color'])) - $input['color'] = '#fff'; + $input['color'] = ''; $this->replace($input); } diff --git a/app/Http/Requests/TaskStatus/UpdateTaskStatusRequest.php b/app/Http/Requests/TaskStatus/UpdateTaskStatusRequest.php index cbde21ac4e81..817e48d6a3e4 100644 --- a/app/Http/Requests/TaskStatus/UpdateTaskStatusRequest.php +++ b/app/Http/Requests/TaskStatus/UpdateTaskStatusRequest.php @@ -46,7 +46,7 @@ class UpdateTaskStatusRequest extends Request $input = $this->all(); if(array_key_exists('color', $input) && is_null($input['color'])) - $input['color'] = '#fff'; + $input['color'] = ''; $this->replace($input); } diff --git a/tests/Unit/CreditBalanceTest.php b/tests/Unit/CreditBalanceTest.php index 307a50f45370..84c941c75742 100644 --- a/tests/Unit/CreditBalanceTest.php +++ b/tests/Unit/CreditBalanceTest.php @@ -16,6 +16,7 @@ use App\Models\Company; use App\Models\Credit; use App\Models\CreditInvitation; use App\Models\User; +use App\Utils\Traits\AppSetup; use Tests\MockUnitData; use Tests\TestCase; @@ -25,6 +26,7 @@ use Tests\TestCase; class CreditBalanceTest extends TestCase { use MockUnitData; + use AppSetup; public function setUp() :void { @@ -35,6 +37,8 @@ class CreditBalanceTest extends TestCase }); $this->makeTestData(); + + $this->buildCache(true); } public function testCreditBalance() From 75d012af069ef8d2d50b4d397e9655971a1846f6 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 11 Jul 2021 10:21:24 +1000 Subject: [PATCH 60/61] Set date on credit generated from an invoice reversal --- app/Services/Invoice/HandleReversal.php | 3 ++- app/Services/Subscription/SubscriptionService.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Services/Invoice/HandleReversal.php b/app/Services/Invoice/HandleReversal.php index 40db69ad2d40..469597f242e9 100644 --- a/app/Services/Invoice/HandleReversal.php +++ b/app/Services/Invoice/HandleReversal.php @@ -71,7 +71,8 @@ class HandleReversal extends AbstractService $credit = CreditFactory::create($this->invoice->company_id, $this->invoice->user_id); $credit->client_id = $this->invoice->client_id; $credit->invoice_id = $this->invoice->id; - + $credit->date = now(); + $item = InvoiceItemFactory::create(); $item->quantity = 1; $item->cost = (float) $total_paid; diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index 348b0573938e..e83e69dbc721 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -77,7 +77,8 @@ class SubscriptionService $recurring_invoice->next_send_date = now(); $recurring_invoice = $recurring_invoice_repo->save([], $recurring_invoice); $recurring_invoice->next_send_date = $recurring_invoice->nextSendDate(); - + $recurring_invoice->auto_bill = $this->subscription->auto_bill; + /* Start the recurring service */ $recurring_invoice->service() ->start() From a2d0965ed53bbaf74a61e113c0bac9202a260286 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 11 Jul 2021 14:54:57 +1000 Subject: [PATCH 61/61] Fixes for plan_expires type casting --- app/Http/Controllers/LicenseController.php | 3 ++- app/Jobs/Util/VersionCheck.php | 3 ++- app/Models/Account.php | 7 ++++++- app/Models/Presenters/UserPresenter.php | 4 ++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/LicenseController.php b/app/Http/Controllers/LicenseController.php index 68d4ac407e00..3d601f43c8ba 100644 --- a/app/Http/Controllers/LicenseController.php +++ b/app/Http/Controllers/LicenseController.php @@ -16,6 +16,7 @@ use App\Utils\CurlUtils; use Illuminate\Http\Request; use Illuminate\Http\Response; use stdClass; +use Carbon\Carbon; class LicenseController extends BaseController { @@ -152,7 +153,7 @@ class LicenseController extends BaseController { $account = auth()->user()->company()->account; - if($account->plan == 'white_label' && $account->plan_expires->lt(now())){ + if($account->plan == 'white_label' && Carbon::parse($account->plan_expires)->lt(now())){ $account->plan = null; $account->plan_expires = null; $account->save(); diff --git a/app/Jobs/Util/VersionCheck.php b/app/Jobs/Util/VersionCheck.php index cf57babc1a75..32dc7a2ac674 100644 --- a/app/Jobs/Util/VersionCheck.php +++ b/app/Jobs/Util/VersionCheck.php @@ -18,6 +18,7 @@ use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; +use Carbon\Carbon; class VersionCheck implements ShouldQueue { @@ -49,7 +50,7 @@ class VersionCheck implements ShouldQueue if(!$account) return; - if($account->plan == 'white_label' && $account->plan_expires && $account->plan_expires->lt(now())){ + if($account->plan == 'white_label' && $account->plan_expires && Carbon::parse($account->plan_expires)->lt(now())){ $account->plan = null; $account->plan_expires = null; $account->save(); diff --git a/app/Models/Account.php b/app/Models/Account.php index c062ef6dbf54..5984d1f15e9d 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -55,7 +55,7 @@ class Account extends BaseModel 'promo_expires', 'discount_expires', 'trial_started', - 'plan_expires' + // 'plan_expires' ]; const PLAN_FREE = 'free'; @@ -120,6 +120,11 @@ class Account extends BaseModel return $this->hasMany(CompanyUser::class); } + public function owner() + { + return $this->hasMany(CompanyUser::class)->where('is_owner', true)->first() ? $this->hasMany(CompanyUser::class)->where('is_owner', true)->first()->user : false; + } + public function getPlan() { return $this->plan ?: ''; diff --git a/app/Models/Presenters/UserPresenter.php b/app/Models/Presenters/UserPresenter.php index dd5f079db5ac..bf45ef5870f4 100644 --- a/app/Models/Presenters/UserPresenter.php +++ b/app/Models/Presenters/UserPresenter.php @@ -21,6 +21,10 @@ class UserPresenter extends EntityPresenter */ public function name() { + + if(!$this->entity) + return "No User Object Available"; + $first_name = isset($this->entity->first_name) ? $this->entity->first_name : ''; $last_name = isset($this->entity->last_name) ? $this->entity->last_name : '';