1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Return JSON response if some of required records wasn't found

This commit is contained in:
Benjamin Beganović 2021-06-01 11:54:15 +02:00
parent 588aeefb35
commit 9119f57a35
2 changed files with 25 additions and 3 deletions

View File

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

View File

@ -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);
}
}