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:
parent
588aeefb35
commit
9119f57a35
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user