mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04: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,
|
$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'),
|
'merchant_key' => $this->payfast->company_gateway->getConfigField('merchantKey'),
|
||||||
'return_url' => route('client.payment_methods.index'),
|
'return_url' => route('client.payment_methods.index'),
|
||||||
'cancel_url' => route('client.payment_methods.index'),
|
'cancel_url' => route('client.payment_methods.index'),
|
||||||
'notify_url' => $this->payfast->company_gateway->webhookUrl(),
|
'notify_url' => $this->payfast->genericWebhookUrl(),
|
||||||
'amount' => 0,
|
'amount' => 1,
|
||||||
'item_name' => 'pre-auth',
|
'item_name' => 'pre-auth',
|
||||||
'subscription_type' => 2,
|
'subscription_type' => 2,
|
||||||
'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'),
|
'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'),
|
||||||
|
@ -40,6 +40,14 @@ class PayFastPaymentDriver extends BaseDriver
|
|||||||
|
|
||||||
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
|
public function gatewayTypes(): array
|
||||||
{
|
{
|
||||||
$types = [];
|
$types = [];
|
||||||
@ -70,7 +78,7 @@ class PayFastPaymentDriver extends BaseDriver
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
echo 'There was an exception: '.$e->getMessage();
|
echo '##PAYFAST## There was an exception: '.$e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -135,5 +143,6 @@ class PayFastPaymentDriver extends BaseDriver
|
|||||||
|
|
||||||
nlog($request->all());
|
nlog($request->all());
|
||||||
return response()->json([], 200);
|
return response()->json([], 200);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,6 +198,10 @@ Route::match(['get', 'post'], 'payment_webhook/{company_key}/{company_gateway_id
|
|||||||
->middleware(['guest'])
|
->middleware(['guest'])
|
||||||
->name('payment_webhook');
|
->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::post('api/v1/postmark_webhook', 'PostMarkController@webhook');
|
||||||
Route::get('token_hash_router', 'OneTimeTokenController@router');
|
Route::get('token_hash_router', 'OneTimeTokenController@router');
|
||||||
Route::get('webcron', 'WebCronController@index');
|
Route::get('webcron', 'WebCronController@index');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user