mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Payfast custom notify URL
This commit is contained in:
parent
c961d32c81
commit
95bbc4108c
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\Payments\PaymentNotificationWebhookRequest;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Client;
|
||||
use App\Models\CompanyGateway;
|
||||
use Auth;
|
||||
|
||||
class PaymentNotificationWebhookController extends Controller
|
||||
{
|
||||
public function __invoke(PaymentNotificationWebhookRequest $request, string $company_key, string $company_gateway_id, string $client_hash)
|
||||
{
|
||||
|
||||
$company_gateway = CompanyGateway::find($this->decodePrimaryKey($company_gateway_id));
|
||||
$client = Client::find($this->decodePrimaryKey($client_hash));
|
||||
|
||||
return $company_gateway
|
||||
->driver($client)
|
||||
->processWebhookRequest($request);
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Http\Requests\Payments;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Client;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyGateway;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentHash;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
|
||||
class PaymentNotificationWebhookRequest extends Request
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
public function authorize()
|
||||
{
|
||||
MultiDB::findAndSetDbByCompanyKey($this->company_key);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
}
|
@ -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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -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'),
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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');
|
||||
|
Loading…
Reference in New Issue
Block a user