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');