1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Refactor PaymentWebhookController

This commit is contained in:
Benjamin Beganović 2021-08-04 15:44:43 +02:00
parent 3ca8b88f3f
commit 6740e348a1
2 changed files with 6 additions and 18 deletions

View File

@ -13,26 +13,14 @@
namespace App\Http\Controllers;
use App\Http\Requests\Payments\PaymentWebhookRequest;
use App\Libraries\MultiDB;
use Auth;
class PaymentWebhookController extends Controller
{
public function __invoke(PaymentWebhookRequest $request, string $company_key, string $company_gateway_id)
public function __invoke(PaymentWebhookRequest $request)
{
$payment = $request->getPayment();
if(!$payment)
return response()->json(['message' => 'Payment record not found.'], 400);
$client = is_null($payment) ? $request->getClient() : $payment->client;
if(!$client)
return response()->json(['message' => 'Client record not found.'], 400);
return $request->getCompanyGateway()
->driver($client)
->processWebhookRequest($request, $payment);
return $request
->getCompanyGateway()
->driver()
->processWebhookRequest($request);
}
}

View File

@ -118,7 +118,7 @@ class CompanyGateway extends BaseModel
}
/* This is the public entry point into the payment superclass */
public function driver(Client $client)
public function driver(Client $client = null)
{
$class = static::driver_class();