2020-06-27 15:53:12 +02:00
|
|
|
<?php
|
2020-10-22 08:46:02 +02:00
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
2020-06-27 15:53:12 +02:00
|
|
|
|
|
|
|
namespace App\Http\Requests\Payments;
|
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
use App\Http\Requests\Request;
|
2020-06-27 15:53:12 +02:00
|
|
|
use App\Models\Company;
|
|
|
|
use App\Models\CompanyGateway;
|
|
|
|
|
2020-10-22 08:46:02 +02:00
|
|
|
class PaymentWebhookRequest extends Request
|
2020-06-27 15:53:12 +02:00
|
|
|
{
|
|
|
|
public function authorize()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function rules()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
//
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function company()
|
|
|
|
{
|
2020-09-06 11:38:10 +02:00
|
|
|
if (! $this->company_key) {
|
2020-06-27 17:39:28 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-06-27 15:53:12 +02:00
|
|
|
return Company::query()
|
|
|
|
->where('company_key', $this->company_key)
|
|
|
|
->firstOrFail();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function companyGateway()
|
|
|
|
{
|
2020-09-06 11:38:10 +02:00
|
|
|
if (! $this->gateway_key || ! $this->company_key) {
|
2020-06-27 17:39:28 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-06-27 15:53:12 +02:00
|
|
|
$company = $this->company();
|
|
|
|
|
|
|
|
return CompanyGateway::query()
|
|
|
|
->where('gateway_key', $this->gateway_key)
|
|
|
|
->where('company_id', $company->id)
|
|
|
|
->firstOrFail();
|
|
|
|
}
|
|
|
|
}
|