diff --git a/app/Http/Controllers/Gateways/Checkout3dsController.php b/app/Http/Controllers/Gateways/Checkout3dsController.php index af6a4217f3f1..4dbada72ad86 100644 --- a/app/Http/Controllers/Gateways/Checkout3dsController.php +++ b/app/Http/Controllers/Gateways/Checkout3dsController.php @@ -19,6 +19,22 @@ class Checkout3dsController extends Controller { public function index(Checkout3dsRequest $request, string $company_key, string $company_gateway_id, string $hash) { + if (!$request->getCompany()) { + return response()->json(['message' => 'Company record not found.', 'company_key' => $company_key]); + } + + if (!$request->getCompanyGateway()) { + return response()->json(['message' => 'Company gateway record not found.', 'company_gateway_id' => $company_gateway_id]); + } + + if (!$request->getPaymentHash()) { + return response()->json(['message' => 'Hash record not found.', 'hash' => $hash]); + } + + if (!$request->getClient()) { + return response()->json(['message' => 'Client record not found.']); + } + return $request->getCompanyGateway() ->driver($request->getClient()) ->process3dsConfirmation($request); diff --git a/app/Http/Requests/Gateways/Checkout3ds/Checkout3dsRequest.php b/app/Http/Requests/Gateways/Checkout3ds/Checkout3dsRequest.php index 3b218f50548c..021379542094 100644 --- a/app/Http/Requests/Gateways/Checkout3ds/Checkout3dsRequest.php +++ b/app/Http/Requests/Gateways/Checkout3ds/Checkout3dsRequest.php @@ -3,6 +3,7 @@ namespace App\Http\Requests\Gateways\Checkout3ds; use App\Models\Client; +use App\Models\Company; use App\Models\CompanyGateway; use App\Models\PaymentHash; use App\Utils\Traits\MakesHash; @@ -34,18 +35,23 @@ class Checkout3dsRequest extends FormRequest ]; } + public function getCompany() + { + return Company::where('company_key', $this->company_key)->first(); + } + public function getCompanyGateway() { - return CompanyGateway::findOrFail($this->decodePrimaryKey($this->company_gateway_id)); + return CompanyGateway::find($this->decodePrimaryKey($this->company_gateway_id)); } public function getPaymentHash() { - return PaymentHash::where('hash', $this->hash)->firstOrFail(); + return PaymentHash::where('hash', $this->hash)->first(); } public function getClient() { - return Client::findOrFail($this->getPaymentHash()->data->client_id); + return Client::find($this->getPaymentHash()->data->client_id); } }