phpstan 5 errors fixed

This commit is contained in:
2024-11-25 15:34:09 +05:00
parent 2e0cc45e99
commit 0d875acc4e
28 changed files with 463 additions and 248 deletions

View File

@@ -5,6 +5,14 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
/**
* @property int $id
* @property string $currency_from
* @property string $currency_to
* @property string $value
* @property \Illuminate\Support\Carbon $created_at
* @property \Illuminate\Support\Carbon $updated_at
*/
class CurrencyRate extends Model class CurrencyRate extends Model
{ {
use HasFactory; use HasFactory;

View File

@@ -12,6 +12,78 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Laravel\Nova\Actions\Actionable; use Laravel\Nova\Actions\Actionable;
/**
* @property int $id
* @property string $unique_id
* @property int $loan_type
* @property string $region
* @property int $branch_id
* @property string $customer_name
* @property string $customer_surname
* @property string $customer_patronic_name
* @property string $passport_address
* @property string $real_address
* @property string $passport_serie
* @property string $passport_id
* @property string $passport_given_at
* @property string $passport_given_by
* @property string $born_place
* @property string $born_at
* @property string $email
* @property string $phone
* @property string $phone_additional
* @property string $phone_home
* @property string $work_region
* @property int $work_province_id
* @property string $work_company
* @property string $work_company_accountant_number
* @property string $work_started_at
* @property string $work_salary
* @property string $work_position
* @property string $education
* @property string $marriage_status
* @property string $passport_one
* @property string $passport_two
* @property string $passport_three
* @property string $passport_four
* @property string $user_id
* @property string $status
* @property string $notes
* @property string $created_at
* @property string $updated_at
* @property string $deleted_at
* @property string $loan_amount
* @property string $card_number
* @property string $card_name
* @property string $card_month
* @property string $card_year
* @property string $guarantor_name
* @property string $guarantor_surname
* @property string $guarantor_patronic_name
* @property string $guarantor_card_number
* @property string $guarantor_card_name
* @property string $guarantor_card_month
* @property string $guarantor_card_year
* @property string $guarantor_2_name
* @property string $guarantor_2_surname
* @property string $guarantor_2_patronic_name
* @property string $guarantor_2_card_number
* @property string $guarantor_2_card_name
* @property string $guarantor_2_card_month
* @property string $guarantor_2_card_year
* @property string $source
* @property string $guarantor_note
* @property string $guarantor_2_note
* @property string $satisfiable
* @property string $guarantor_passport_serie
* @property string $guarantor_passport_id
* @property string $guarantor_2_passport_serie
* @property string $guarantor_2_passport_id
* @property string $loan_card_number
* @property string $loan_card_name
* @property string $loan_card_month
* @property string $loan_card_yea
*/
class LoanOrder extends Model class LoanOrder extends Model
{ {
use Actionable; use Actionable;

View File

@@ -15,11 +15,4 @@ class OnlinePaymentHistory extends Model
* @var string * @var string
*/ */
protected $table = 'online_payment_histories'; protected $table = 'online_payment_histories';
/**
* Guarded attributes
*
* @var array
*/
protected $guarded = [];
} }

View File

@@ -14,6 +14,21 @@ use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens; use Laravel\Sanctum\HasApiTokens;
use Spatie\Permission\Traits\HasRoles; use Spatie\Permission\Traits\HasRoles;
/**
* @property int $id
* @property string $username
* @property string $name
* @property string $email
* @property string $phone
* @property null|\Illuminate\Support\Carbon $email_verified_at
* @property null|\Illuminate\Support\Carbon $phone_verified_at
* @property string $password
* @property string $locale
* @property bool $active
* @property string $remember_token
* @property \Illuminate\Support\Carbon $created_at
* @property \Illuminate\Support\Carbon $updated_at
*/
class User extends Authenticatable class User extends Authenticatable
{ {
use HasApiTokens; use HasApiTokens;
@@ -153,7 +168,7 @@ class User extends Authenticatable
*/ */
public function ownsLoanOrder(LoanOrder $loanOrder): bool public function ownsLoanOrder(LoanOrder $loanOrder): bool
{ {
return $this->id === $loanOrder->user_id; return $this->id === intval($loanOrder->user_id);
} }
/** /**
@@ -161,7 +176,7 @@ class User extends Authenticatable
*/ */
public function ownsCardOrder(CardOrder $cardOrder): bool public function ownsCardOrder(CardOrder $cardOrder): bool
{ {
return $this->id === $cardOrder->user_id; return $this->id === intval($cardOrder->user_id);
} }
/** /**

View File

@@ -84,7 +84,7 @@ class LoanOrderController extends Controller
public function show(LoanOrder $loanOrder) public function show(LoanOrder $loanOrder)
{ {
if ($loanOrder->user_id === auth()->id()) { if ($loanOrder->user_id === auth()->id()) {
return response()->status(403); return response(status: 403);
} }
return response()->json(new LoanOrderShowResource($loanOrder)); return response()->json(new LoanOrderShowResource($loanOrder));
@@ -104,7 +104,7 @@ class LoanOrderController extends Controller
public function destroy(LoanOrder $loanOrder) public function destroy(LoanOrder $loanOrder)
{ {
if ($loanOrder->user_id === auth()->id()) { if ($loanOrder->user_id === auth()->id()) {
return response()->status(403); return response(status: 403);
} }
$loanOrder->delete(); $loanOrder->delete();

View File

@@ -6,6 +6,9 @@ use App\Repos\Order\OrderRepo;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource; use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin \App\Models\Order\Loan\LoanOrder
*/
class LoanOrderIndexResource extends JsonResource class LoanOrderIndexResource extends JsonResource
{ {
/** /**

View File

@@ -10,6 +10,9 @@ use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource; use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
/**
* @mixin \App\Models\Order\Loan\LoanOrder
*/
class LoanOrderShowResource extends JsonResource class LoanOrderShowResource extends JsonResource
{ {
/** /**

View File

@@ -10,6 +10,28 @@ use Illuminate\Database\Eloquent\SoftDeletes;
use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia; use Spatie\MediaLibrary\InteractsWithMedia;
/**
* @property int $id
* @property string $unique_id
* @property string $type
* @property string $passport_name
* @property string $passport_surname
* @property string $phone
* @property string $email
* @property string $region
* @property int $branch_id
* @property int $user_id
* @property string $address
* @property array $sender_datas
* @property array $payment_reciever
* @property string $documents
* @property string $status
* @property string $notes
* @property \Illuminate\Support\Carbon $created_at
* @property \Illuminate\Support\Carbon $updated_at
* @property bool $paid
* @property \Illuminate\Support\Carbon $deleted_at
*/
class SberPaymentOrder extends Model implements HasMedia class SberPaymentOrder extends Model implements HasMedia
{ {
use InteractsWithMedia; use InteractsWithMedia;

View File

@@ -2,6 +2,7 @@
namespace App\Modules\SberPaymentOrder\Nova\Resources\Concerns; namespace App\Modules\SberPaymentOrder\Nova\Resources\Concerns;
use App\Modules\SberPaymentOrder\Models\SberPaymentOrder;
use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@@ -16,7 +17,9 @@ trait NovaSberPaymentOrderAuth
return; return;
} }
if ($this->resource->user_id == auth()->id()) { /** @var SberPaymentOrder $resource */
$resource = $this->resource;
if ($resource->user_id == auth()->id()) {
return; return;
} }
@@ -44,7 +47,9 @@ trait NovaSberPaymentOrderAuth
return; return;
} }
if ($this->resource->user_id == auth()->id()) { /** @var SberPaymentOrder $resource */
$resource = $this->resource;
if ($resource->user_id == auth()->id()) {
return; return;
} }
@@ -78,6 +83,6 @@ trait NovaSberPaymentOrderAuth
/** Force delete */ /** Force delete */
public function authorizedToForceDelete(Request $request) public function authorizedToForceDelete(Request $request)
{ {
throw_unless(auth()->user()->isMe(), AuthorizationException::class); return auth()->user()->isMe();
} }
} }

View File

@@ -332,7 +332,10 @@ class NovaSberPaymentOrder extends Resource
->icon('credit-card') ->icon('credit-card')
->sole() ->sole()
->canSee(function ($request) { ->canSee(function ($request) {
if (in_array($this->resource->status, [ /** @var \App\Modules\SberPaymentOrder\Models\SberPaymentOrder $resource */
$resource = $this->resource;
if (in_array($resource->status, [
OrderRepo::PENDING, OrderRepo::PENDING,
OrderRepo::CANCELLED, OrderRepo::CANCELLED,
])) { ])) {

View File

@@ -119,129 +119,129 @@ class NovaTuitionPaymentOrder extends Resource
public function fields(NovaRequest $request): array public function fields(NovaRequest $request): array
{ {
return [ return [
Tabs::make('Wizard', [ // Tabs::make('Wizard', [
new Tab(__('Status'), [ // new Tab(__('Status'), [
ID::make() // ID::make()
->hideFromDetail(), // ->hideFromDetail(),
Hidden::make('user_id') // Hidden::make('user_id')
->default(auth()->id()) // ->default(auth()->id())
->hideWhenUpdating(), // ->hideWhenUpdating(),
Text::make(__('ID'), 'unique_id') // Text::make(__('ID'), 'unique_id')
->exceptOnForms(), // ->exceptOnForms(),
Select::make(__('Status'), 'status') // Select::make(__('Status'), 'status')
->displayUsingLabels() // ->displayUsingLabels()
->searchable() // ->searchable()
->options(OrderRepo::statusValues()) // ->options(OrderRepo::statusValues())
->default(OrderRepo::defaultStatus()) // ->default(OrderRepo::defaultStatus())
->fullWidth() // ->fullWidth()
->hideFromDetail() // ->hideFromDetail()
->rules('required') // ->rules('required')
->canSeeWhen('systemUser', $this), // ->canSeeWhen('systemUser', $this),
Badge::make(__('Status'), 'status') // Badge::make(__('Status'), 'status')
->map(OrderRepo::statusClasses()) // ->map(OrderRepo::statusClasses())
->addTypes([ // ->addTypes([
'primary' => 'dark:bg-gray-900 bg-gray-600 text-white', // 'primary' => 'dark:bg-gray-900 bg-gray-600 text-white',
]) // ])
->labels(OrderRepo::statusValues()) // ->labels(OrderRepo::statusValues())
->withIcons() // ->withIcons()
->icons(OrderRepo::statusIcons()), // ->icons(OrderRepo::statusIcons()),
Text::make(__('Note'), 'notes') // Text::make(__('Note'), 'notes')
->fullWidth() // ->fullWidth()
->canSeeWhen('systemUser', $this), // ->canSeeWhen('systemUser', $this),
]), // ]),
new Tab(__('Location'), [ // new Tab(__('Location'), [
Select::make(__('Region'), 'region') // Select::make(__('Region'), 'region')
->fullWidth() // ->fullWidth()
->displayUsingLabels() // ->displayUsingLabels()
->searchable() // ->searchable()
->options(RegionRepo::values()) // ->options(RegionRepo::values())
->default(RegionRepo::default()) // ->default(RegionRepo::default())
->rules('required') // ->rules('required')
->sortable(), // ->sortable(),
Select::make(__('Branch'), 'branch_id') // Select::make(__('Branch'), 'branch_id')
->fullWidth() // ->fullWidth()
->displayUsingLabels() // ->displayUsingLabels()
->searchable() // ->searchable()
->dependsOn('region', NovaRepo::dependsOnRegion('region', Branch::class)) // ->dependsOn('region', NovaRepo::dependsOnRegion('region', Branch::class))
->rules('required') // ->rules('required')
->sortable(), // ->sortable(),
]), // ]),
new Tab(__('Personal data'), [ // new Tab(__('Personal data'), [
Text::make(__('Passport name'), 'passport_name') // Text::make(__('Passport name'), 'passport_name')
->fullWidth() // ->fullWidth()
->rules('required', 'string', 'max:255'), // ->rules('required', 'string', 'max:255'),
Text::make(__('Passport surname'), 'passport_surname') // Text::make(__('Passport surname'), 'passport_surname')
->fullWidth() // ->fullWidth()
->rules('required', 'string', 'max:255'), // ->rules('required', 'string', 'max:255'),
NovaInputmask::make(__('Phone'), 'phone') // NovaInputmask::make(__('Phone'), 'phone')
->fullWidth() // ->fullWidth()
->phonenumber('TM') // ->phonenumber('TM')
->rules('required', 'max:255') // ->rules('required', 'max:255')
->hideFromIndex(), // ->hideFromIndex(),
Text::make(__('Email'), 'email') // Text::make(__('Email'), 'email')
->fullWidth() // ->fullWidth()
->rules('nullable', 'max:255', 'email') // ->rules('nullable', 'max:255', 'email')
->hideFromIndex(), // ->hideFromIndex(),
Text::make(__('Current Residence'), 'address') // Text::make(__('Current Residence'), 'address')
->fullWidth() // ->fullWidth()
->rules('required', 'string', 'max:255') // ->rules('required', 'string', 'max:255')
->hideFromIndex(), // ->hideFromIndex(),
]), // ]),
new Tab(__('Payment'), [ // new Tab(__('Payment'), [
SimpleRepeatable::make(__('Payment sender data'), 'sender_datas', [ // SimpleRepeatable::make(__('Payment sender data'), 'sender_datas', [
Select::make(__('Passport serie'), 'passport_serie') // Select::make(__('Passport serie'), 'passport_serie')
->displayUsingLabels() // ->displayUsingLabels()
->searchable() // ->searchable()
->options(PassportRepo::values()) // ->options(PassportRepo::values())
->rules('required') // ->rules('required')
->sortable(), // ->sortable(),
NovaInputmask::make(__('Passport number'), 'passport_number') // NovaInputmask::make(__('Passport number'), 'passport_number')
->mask('999999') // ->mask('999999')
->rules('required', 'max:255'), // ->rules('required', 'max:255'),
Text::make( // Text::make(
name: sprintf('%s %s %s', __('Name'), __('Surname'), __('Patronic name')), // name: sprintf('%s %s %s', __('Name'), __('Surname'), __('Patronic name')),
attribute: 'full_name' // attribute: 'full_name'
) // )
->rules('required', 'max:255'), // ->rules('required', 'max:255'),
])->minRows(1)->rules('required'), // ])->minRows(1)->rules('required'),
SimpleRepeatable::make(__('Payee information'), 'payment_reciever', [ // SimpleRepeatable::make(__('Payee information'), 'payment_reciever', [
Select::make(__('Passport serie'), 'passport_serie') // Select::make(__('Passport serie'), 'passport_serie')
->displayUsingLabels() // ->displayUsingLabels()
->searchable() // ->searchable()
->options(PassportRepo::values()) // ->options(PassportRepo::values())
->rules('required') // ->rules('required')
->sortable(), // ->sortable(),
NovaInputmask::make(__('Passport number'), 'passport_number') // NovaInputmask::make(__('Passport number'), 'passport_number')
->mask('999999') // ->mask('999999')
->rules('required', 'max:255'), // ->rules('required', 'max:255'),
Text::make( // Text::make(
name: sprintf('%s %s %s', __('Name'), __('Surname'), __('Patronic name')), // name: sprintf('%s %s %s', __('Name'), __('Surname'), __('Patronic name')),
attribute: 'full_name' // attribute: 'full_name'
)->rules('required', 'max:255'), // )->rules('required', 'max:255'),
])->maxRows(1)->minRows(1)->rules('required'), // ])->maxRows(1)->minRows(1)->rules('required'),
]), // ]),
new Tab(__('Reciver files'), TuitionPaymentOrderFileFields::reciverFiles()), // new Tab(__('Reciver files'), TuitionPaymentOrderFileFields::reciverFiles()),
new Tab(__('Sender files'), TuitionPaymentOrderFileFields::senderFiles()), // new Tab(__('Sender files'), TuitionPaymentOrderFileFields::senderFiles()),
], $request)->asWizard(), // ], $request)->asWizard(),
]; ];
} }
} }

View File

@@ -20,17 +20,17 @@ class TuitionPaymentOrderFileFields
->fullWidth() ->fullWidth()
->deletable(false) ->deletable(false)
->creationRules($file['required'] ? 'required' : 'nullable') ->creationRules($file['required'] ? 'required' : 'nullable')
->updateRules('nullable') ->updateRules('nullable');
->store(function (NovaRequest $request, $model) use ($file) { // ->store(function (NovaRequest $request, $model) use ($file) {
return function () use ($model, $file) { // return function () use ($model, $file) {
$model->addMediaFromRequest($file['code']) // $model->addMediaFromRequest($file['code'])
->preservingOriginal() // ->preservingOriginal()
->toMediaCollection($file['code']); // ->toMediaCollection($file['code']);
}; // };
}) // })
->preview(function ($value, $disk, $resource) use ($file) { // ->preview(function ($value, $disk, $resource) use ($file) {
return $resource->getFirstMediaUrl($file['code']); // return $resource->getFirstMediaUrl($file['code']);
}); // });
}) })
->toArray(); ->toArray();
} }
@@ -46,17 +46,17 @@ class TuitionPaymentOrderFileFields
->fullWidth() ->fullWidth()
->deletable(false) ->deletable(false)
->creationRules($file['required'] ? 'required' : 'nullable') ->creationRules($file['required'] ? 'required' : 'nullable')
->updateRules('nullable') ->updateRules('nullable');
->store(function (NovaRequest $request, $model) use ($file) { // ->store(function (NovaRequest $request, $model) use ($file) {
return function () use ($model, $file) { // return function () use ($model, $file) {
$model->addMediaFromRequest($file['code']) // $model->addMediaFromRequest($file['code'])
->preservingOriginal() // ->preservingOriginal()
->toMediaCollection($file['code']); // ->toMediaCollection($file['code']);
}; // };
}) // })
->preview(function ($value, $disk, $resource) use ($file) { // ->preview(function ($value, $disk, $resource) use ($file) {
return $resource->getFirstMediaUrl($file['code']); // return $resource->getFirstMediaUrl($file['code']);
}); // });
}) })
->toArray(); ->toArray();
} }

View File

@@ -14,6 +14,28 @@ use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia; use Spatie\MediaLibrary\InteractsWithMedia;
use Spatie\MediaLibrary\MediaCollections\Models\Media; use Spatie\MediaLibrary\MediaCollections\Models\Media;
/**
* @property int $id
* @property string $unique_id
* @property string $type
* @property string $passport_name
* @property string $passport_surname
* @property string $phone
* @property string $email
* @property string $region
* @property int $branch_id
* @property int $user_id
* @property string $address
* @property array $sender_datas
* @property array $payment_reciever
* @property string $documents
* @property string $status
* @property string $notes
* @property \Illuminate\Support\Carbon $created_at
* @property \Illuminate\Support\Carbon $updated_at
* @property bool $paid
* @property \Illuminate\Support\Carbon $deleted_at
*/
class VisaMasterPaymentOrder extends Model implements HasMedia class VisaMasterPaymentOrder extends Model implements HasMedia
{ {
use InteractsWithMedia; use InteractsWithMedia;

View File

@@ -7,6 +7,19 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia; use Spatie\MediaLibrary\InteractsWithMedia;
/**
* @property int $id
* @property int $visa_master_payment_order_id
* @property int $online_payment_history_id
* @property ?string $payer_name
* @property ?string $payer_card
* @property ?string $payment_order_number
* @property string $tmt_payment_amount
* @property string $usd_payment_amount
* @property bool $paid
* @property \Illuminate\Support\Carbon $created_at
* @property \Illuminate\Support\Carbon $updated_at
*/
class VisaMasterPaymentOrderItem extends Model implements HasMedia class VisaMasterPaymentOrderItem extends Model implements HasMedia
{ {
use InteractsWithMedia; use InteractsWithMedia;

View File

@@ -2,6 +2,7 @@
namespace App\Modules\VisaMasterPaymentOrder\Nova\Resources\Concerns; namespace App\Modules\VisaMasterPaymentOrder\Nova\Resources\Concerns;
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder;
use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@@ -16,7 +17,10 @@ trait VisaMasterAuth
return; return;
} }
if ($this->resource->user_id == auth()->id()) { /** @var VisaMasterPaymentOrder $resource */
$resource = $this->resource;
if ($resource->user_id == auth()->id()) {
return; return;
} }
@@ -44,7 +48,10 @@ trait VisaMasterAuth
return; return;
} }
if ($this->resource->user_id == auth()->id()) { /** @var VisaMasterPaymentOrder $resource */
$resource = $this->resource;
if ($resource->user_id == auth()->id()) {
return; return;
} }

View File

@@ -4,6 +4,7 @@ namespace App\Modules\VisaMasterPaymentOrder\Nova\Resources;
use App\Models\Branch\Branch; use App\Models\Branch\Branch;
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder; use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder;
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder as VisaMasterPaymentOrderModel;
use App\Modules\VisaMasterPaymentOrder\Nova\Resources\Concerns\VisaMasterAuth; use App\Modules\VisaMasterPaymentOrder\Nova\Resources\Concerns\VisaMasterAuth;
use App\Modules\VisaMasterPaymentOrder\Nova\Resources\Concerns\VisaMasterPaymentOrderFieldsForDetail; use App\Modules\VisaMasterPaymentOrder\Nova\Resources\Concerns\VisaMasterPaymentOrderFieldsForDetail;
use App\Modules\VisaMasterPaymentOrder\Nova\Resources\Concerns\VisaMasterPaymentOrderFieldsForIndex; use App\Modules\VisaMasterPaymentOrder\Nova\Resources\Concerns\VisaMasterPaymentOrderFieldsForIndex;
@@ -358,7 +359,10 @@ class NovaVisaMasterPaymentOrder extends Resource
->icon('credit-card') ->icon('credit-card')
->sole() ->sole()
->canSee(function ($request) { ->canSee(function ($request) {
if (in_array($this->resource->status, [ /** @var VisaMasterPaymentOrderModel $order */
$order = $this->resource;
if (in_array($order->status, [
OrderRepo::PENDING, OrderRepo::PENDING,
OrderRepo::CANCELLED, OrderRepo::CANCELLED,
])) { ])) {

View File

@@ -4,11 +4,12 @@ namespace App\Modules\VisaMasterPaymentOrder\Nova\Resources;
use App\Models\Branch\Branch; use App\Models\Branch\Branch;
use App\Models\Payment\OnlinePaymentHistory; use App\Models\Payment\OnlinePaymentHistory;
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrderItem as VisaMasterPaymentOrderItemModel;
use App\Modules\VisaMasterPaymentOrder\Nova\Resources\Item\NovaVisaMasterPaymentOrderItemAuth; use App\Modules\VisaMasterPaymentOrder\Nova\Resources\Item\NovaVisaMasterPaymentOrderItemAuth;
use App\Nova\Actions\CheckOnlinePayment; use App\Nova\Actions\CheckOnlinePayment;
use App\Nova\Resource; use App\Nova\Resource;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use Laravel\Nova\Actions\Action; use Laravel\Nova\Actions\Action;
use Laravel\Nova\Actions\ActionResponse; use Laravel\Nova\Actions\ActionResponse;
@@ -19,7 +20,7 @@ use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest; use Laravel\Nova\Http\Requests\NovaRequest;
/** /**
* @template TModel of \App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder * @template TModel of \App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrderItem
*/ */
class NovaVisaMasterPaymentOrderItem extends Resource class NovaVisaMasterPaymentOrderItem extends Resource
{ {
@@ -28,7 +29,7 @@ class NovaVisaMasterPaymentOrderItem extends Resource
/** /**
* The model the resource corresponds to. * The model the resource corresponds to.
* *
* @var class-string<\App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder> * @var class-string<\App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrderItem>
*/ */
public static $model = \App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrderItem::class; public static $model = \App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrderItem::class;
@@ -107,16 +108,16 @@ class NovaVisaMasterPaymentOrderItem extends Resource
Text::make('Amaly geçiren raýatyň kart belgisi (mask)', 'payer_card'), Text::make('Amaly geçiren raýatyň kart belgisi (mask)', 'payer_card'),
Text::make('Töleg ýyly', fn () => $this->created_at->format('Y')), Text::make('Töleg ýyly', fn ($model) => $model->format('Y')),
Text::make('Töleg aýy', fn () => $this->created_at->translatedFormat('F')), Text::make('Töleg aýy', fn ($model) => $model->created_at->translatedFormat('F')),
Text::make('Amalyň geçirilen wagty', fn () => $this->created_at->format('H:i, d.m.Y')), Text::make('Amalyň geçirilen wagty', fn ($model) => $model->created_at->format('H:i, d.m.Y')),
Text::make('Amalyň möçberi', fn () => $this->usd_payment_amount.' USD'), Text::make('Amalyň möçberi', fn ($model) => $model->usd_payment_amount.' USD'),
Text::make('Amalyň manat möçberi', fn () => $this->tmt_payment_amount.' TMT'), Text::make('Amalyň manat möçberi', fn ($model) => $model->tmt_payment_amount.' TMT'),
Text::make('Amalyň referensi', fn () => $this->payment_order_number), Text::make('Amalyň referensi', fn ($model) => $model->payment_order_number),
Boolean::make(__('Paid'), 'paid'), Boolean::make(__('Paid'), 'paid'),
]; ];
@@ -126,7 +127,8 @@ class NovaVisaMasterPaymentOrderItem extends Resource
{ {
return [ return [
Action::using('HALKBANK töleg barla', function (ActionFields $fields, Collection $models) { Action::using('HALKBANK töleg barla', function (ActionFields $fields, Collection $models) {
$item = $onlinePaymentResource = $models->first(); /** @var VisaMasterPaymentOrderItemModel $item */
$item = $models->first();
$onlinePaymentResource = OnlinePaymentHistory::find($item->online_payment_history_id); $onlinePaymentResource = OnlinePaymentHistory::find($item->online_payment_history_id);

View File

@@ -4,6 +4,9 @@ namespace App\Modules\VisaMasterSettings\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
/**
* @property string $value
*/
class VisaMasterSettings extends Model class VisaMasterSettings extends Model
{ {
protected $table = 'visa_master_settings'; protected $table = 'visa_master_settings';

View File

@@ -43,7 +43,7 @@ class MakePaymentNovaVisaMaster extends Action
*/ */
public function handle(ActionFields $fields, Collection $models) public function handle(ActionFields $fields, Collection $models)
{ {
if (is_null($fields->payment_amount) || is_null($fields->usd_payment)) { if (! property_exists($fields, 'payment_amount') || ! property_exists($fields, 'usd_payment')) {
return Action::modal('modal-response', [ return Action::modal('modal-response', [
'title' => 'Töleg maglumatlary ýok!', 'title' => 'Töleg maglumatlary ýok!',
'body' => 'Töleg maglumatlary girizilmedik', 'body' => 'Töleg maglumatlary girizilmedik',
@@ -108,7 +108,7 @@ class MakePaymentNovaVisaMaster extends Action
*/ */
public function fields(NovaRequest $request): array public function fields(NovaRequest $request): array
{ {
$usd_to_tmt = CurrencyRate::where('currency_from', 'USD')->where('currency_to', 'TMT')->first('value'); $usd_to_tmt = floatval(CurrencyRate::where('currency_from', 'USD')->where('currency_to', 'TMT')->first('value')?->value);
$payment_warning_text = VisaMasterSettings::where('name', 'payment_warning_text')->first(); $payment_warning_text = VisaMasterSettings::where('name', 'payment_warning_text')->first();
@@ -116,11 +116,11 @@ class MakePaymentNovaVisaMaster extends Action
return []; return [];
} }
$max_value = number_format($usd_to_tmt->value * 250, 2); $max_value = number_format($usd_to_tmt * 250, 2);
return [ return [
Heading::make(Blade::render(<<<HTML Heading::make(Blade::render(<<<HTML
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">1 USD = $usd_to_tmt->value TMT</h3> <h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">1 USD = $usd_to_tmt TMT</h3>
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">Bankyň tutumy: 20 TMT</h3> <h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">Bankyň tutumy: 20 TMT</h3>
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">GBÜS tutumy: 3 TMT</h3> <h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">GBÜS tutumy: 3 TMT</h3>
HTML))->asHtml(), HTML))->asHtml(),
@@ -140,8 +140,8 @@ class MakePaymentNovaVisaMaster extends Action
->fullWidth() ->fullWidth()
->readonly() ->readonly()
->dependsOn('payment_amount', function ($field, $request, $formData) use ($usd_to_tmt) { ->dependsOn('payment_amount', function ($field, $request, $formData) use ($usd_to_tmt) {
if ($formData->payment_amount) { if (property_exists($formData, 'payment_amount')) {
$field->setValue(number_format($formData->payment_amount / $usd_to_tmt->value, 2, '.', '')); $field->setValue(number_format($formData->payment_amount / $usd_to_tmt, 2, '.', ''));
} else { } else {
$field->setValue(''); $field->setValue('');
} }
@@ -149,8 +149,8 @@ class MakePaymentNovaVisaMaster extends Action
Hidden::make('usd_payment') Hidden::make('usd_payment')
->dependsOn('payment_amount', function ($field, $request, $formData) use ($usd_to_tmt) { ->dependsOn('payment_amount', function ($field, $request, $formData) use ($usd_to_tmt) {
if ($formData->payment_amount) { if (property_exists($formData, 'payment_amount')) {
$field->setValue(number_format($formData->payment_amount / $usd_to_tmt->value, 2, '.', '')); $field->setValue(number_format($formData->payment_amount / $usd_to_tmt, 2, '.', ''));
} else { } else {
$field->setValue(''); $field->setValue('');
} }
@@ -160,7 +160,7 @@ class MakePaymentNovaVisaMaster extends Action
->fullWidth() ->fullWidth()
->readonly() ->readonly()
->dependsOn('payment_amount', function ($field, $request, $formData) { ->dependsOn('payment_amount', function ($field, $request, $formData) {
if (is_numeric($formData->payment_amount)) { if (property_exists($formData, 'payment_amount')) {
$field->setValue( $field->setValue(
floatval(number_format($formData->payment_amount, 2, '.', '')) + 23 floatval(number_format($formData->payment_amount, 2, '.', '')) + 23
); );
@@ -265,6 +265,7 @@ class MakePaymentNovaVisaMaster extends Action
// Condition 1: Check if today is the last day of the month // Condition 1: Check if today is the last day of the month
if ($today->format('Y-m-d') === $lastDay->format('Y-m-d')) { if ($today->format('Y-m-d') === $lastDay->format('Y-m-d')) {
info('check 1'); info('check 1');
return false; return false;
} }
@@ -276,6 +277,7 @@ class MakePaymentNovaVisaMaster extends Action
$forbiddenDays = ['Friday', 'Saturday', 'Sunday']; $forbiddenDays = ['Friday', 'Saturday', 'Sunday'];
if (in_array($today->format('l'), $forbiddenDays)) { if (in_array($today->format('l'), $forbiddenDays)) {
info('check 2'); info('check 2');
return false; return false;
} }
} }
@@ -283,6 +285,7 @@ class MakePaymentNovaVisaMaster extends Action
// Condition 3: If the last day is Saturday, disallow Friday // Condition 3: If the last day is Saturday, disallow Friday
if ($lastDayOfWeek === 'Saturday' && $today->format('l') === 'Friday') { if ($lastDayOfWeek === 'Saturday' && $today->format('l') === 'Friday') {
info('check 3'); info('check 3');
return false; return false;
} }

View File

@@ -5,6 +5,7 @@ namespace App\Nova\Actions;
use App\Models\CurrencyRate; use App\Models\CurrencyRate;
use App\Models\Payment\OnlinePaymentHistory; use App\Models\Payment\OnlinePaymentHistory;
use App\Modules\SberPaymentOrder\Models\SberPaymentOrder; use App\Modules\SberPaymentOrder\Models\SberPaymentOrder;
use App\Nova\Actions\Sber\SberActionFields;
use App\Repos\Payment\OnlinePaymentRepo; use App\Repos\Payment\OnlinePaymentRepo;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
@@ -14,7 +15,6 @@ use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Laravel\Nova\Actions\Action; use Laravel\Nova\Actions\Action;
use Laravel\Nova\Actions\ActionResponse; use Laravel\Nova\Actions\ActionResponse;
use Laravel\Nova\Fields\ActionFields;
use Laravel\Nova\Fields\Heading; use Laravel\Nova\Fields\Heading;
use Laravel\Nova\Fields\Text; use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest; use Laravel\Nova\Http\Requests\NovaRequest;
@@ -25,16 +25,13 @@ class MakeSberPaymentAction extends Action
/** /**
* Perform the action on the given models. * Perform the action on the given models.
*
* @param \Laravel\Nova\Fields\ActionFields $fields
* @param \Illuminate\Support\Collection $models
* @return mixed
*/ */
public function handle(ActionFields $fields, Collection $models) public function handle(SberActionFields $fields, Collection $models): mixed
{ {
$usd_to_tmt = CurrencyRate::where('currency_from', 'USD')->where('currency_to', 'TMT')->first('value'); $usd_to_tmt = CurrencyRate::where('currency_from', 'USD')->where('currency_to', 'TMT')->first('value');
$payment_amount = floatval($fields->payment_amount);
if (! $usd_to_tmt) { if (! $usd_to_tmt || ! $payment_amount) {
return ActionResponse::danger('Walýuta hasaby girizilmedik, operator bilen habarlaşmagyňyzy haýyş edýärin.'); return ActionResponse::danger('Walýuta hasaby girizilmedik, operator bilen habarlaşmagyňyzy haýyş edýärin.');
} }
@@ -44,9 +41,9 @@ class MakeSberPaymentAction extends Action
return ActionResponse::danger('Şahamça sber tölegi kabul edip bilmeýär.'); return ActionResponse::danger('Şahamça sber tölegi kabul edip bilmeýär.');
} }
$tvebTaxTMT = $usd_to_tmt->value * 18; $tvebTaxTMT = floatval($usd_to_tmt->value) * 18;
$bankTax = 120.75; $bankTax = 120.75;
$total_amount = number_format($fields->payment_amount + $tvebTaxTMT + $bankTax, 2, '.', ''); $total_amount = number_format($payment_amount + $tvebTaxTMT + $bankTax, 2, '.', '');
$payment = $this->order($resource, $total_amount); $payment = $this->order($resource, $total_amount);
@@ -63,21 +60,21 @@ class MakeSberPaymentAction extends Action
*/ */
public function fields(NovaRequest $request) public function fields(NovaRequest $request)
{ {
$usd_to_tmt = CurrencyRate::where('currency_from', 'USD')->where('currency_to', 'TMT')->first('value'); $usd_to_tmt = floatval(CurrencyRate::where('currency_from', 'USD')->where('currency_to', 'TMT')->first('value')?->value);
$usd_to_rub = CurrencyRate::where('currency_from', 'USD')->where('currency_to', 'RUB')->first('value')?->value; $usd_to_rub = floatval(CurrencyRate::where('currency_from', 'USD')->where('currency_to', 'RUB')->first('value')?->value);
$rub_to_tmt = CurrencyRate::where('currency_from', 'RUB')->where('currency_to', 'TMT')->first('value')?->value; $rub_to_tmt = floatval(CurrencyRate::where('currency_from', 'RUB')->where('currency_to', 'TMT')->first('value')?->value);
if (! $usd_to_tmt || ! $usd_to_rub || ! $rub_to_tmt) { if (! $usd_to_tmt || ! $usd_to_rub || ! $rub_to_tmt) {
return []; return [];
} }
$max_value = number_format($usd_to_rub * 250 * $rub_to_tmt, 2, '.', ''); $max_value = number_format($usd_to_rub * 250 * $rub_to_tmt, 2, '.', '');
$tvebTaxTMT = $usd_to_tmt->value * 18; $tvebTaxTMT = $usd_to_tmt * 18;
$bankTax = 120.75; $bankTax = 120.75;
return [ return [
Heading::make(Blade::render(<<<HTML Heading::make(Blade::render(<<<HTML
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">1 USD = $usd_to_tmt->value TMT</h3> <h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">1 USD = $usd_to_tmt TMT</h3>
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">1 RUB = $rub_to_tmt TMT</h3> <h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">1 RUB = $rub_to_tmt TMT</h3>
<br> <br>
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">TVEB USD tutumy: 18 USD</h3> <h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">TVEB USD tutumy: 18 USD</h3>
@@ -96,7 +93,7 @@ class MakeSberPaymentAction extends Action
->fullWidth() ->fullWidth()
->readonly() ->readonly()
->dependsOn('payment_amount', function ($field, $request, $formData) use ($usd_to_rub, $rub_to_tmt) { ->dependsOn('payment_amount', function ($field, $request, $formData) use ($usd_to_rub, $rub_to_tmt) {
if ($formData->payment_amount) { if (property_exists($formData, 'payment_amount')) {
$usdValue = number_format($formData->payment_amount / ($usd_to_rub * $rub_to_tmt), 2, '.', ''); $usdValue = number_format($formData->payment_amount / ($usd_to_rub * $rub_to_tmt), 2, '.', '');
$field->setValue($usdValue); $field->setValue($usdValue);
@@ -109,7 +106,7 @@ class MakeSberPaymentAction extends Action
->fullWidth() ->fullWidth()
->readonly() ->readonly()
->dependsOn('payment_amount', function ($field, $request, $formData) use ($tvebTaxTMT, $bankTax) { ->dependsOn('payment_amount', function ($field, $request, $formData) use ($tvebTaxTMT, $bankTax) {
if (is_numeric($formData->payment_amount)) { if (property_exists($formData, 'payment_amount')) {
$field->setValue( $field->setValue(
number_format($formData->payment_amount + $tvebTaxTMT + $bankTax, 2, '.', '') number_format($formData->payment_amount + $tvebTaxTMT + $bankTax, 2, '.', '')
); );

View File

@@ -0,0 +1,10 @@
<?php
namespace App\Nova\Actions\Sber;
use Laravel\Nova\Fields\ActionFields;
/**
* @property string $payment_amount
*/
class SberActionFields extends ActionFields {}

View File

@@ -40,10 +40,6 @@ trait CurrencyRateAuth
return; return;
} }
if ($this->resource->user_id == auth()->id()) {
return;
}
throw new AuthorizationException; throw new AuthorizationException;
} }
@@ -74,6 +70,6 @@ trait CurrencyRateAuth
/** Force delete */ /** Force delete */
public function authorizedToForceDelete(Request $request) public function authorizedToForceDelete(Request $request)
{ {
throw_unless(auth()->user()->isMe(), AuthorizationException::class); return auth()->user()->isMe();
} }
} }

View File

@@ -12,7 +12,7 @@ class NovaVisaMasterSetting extends Resource
/** /**
* The model the resource corresponds to. * The model the resource corresponds to.
* *
* @var class-string<\App\Models\Resources\NovaVisaMasterSetting> * @var class-string<\App\Modules\VisaMasterSettings\Models\VisaMasterSettings>
*/ */
public static $model = \App\Modules\VisaMasterSettings\Models\VisaMasterSettings::class; public static $model = \App\Modules\VisaMasterSettings\Models\VisaMasterSettings::class;

View File

@@ -2,6 +2,7 @@
namespace App\Nova; namespace App\Nova;
use App\Models\User as UserModel;
use App\Nova\Resources\Branch\Branch; use App\Nova\Resources\Branch\Branch;
use App\Nova\Resources\System\Roles\Permission; use App\Nova\Resources\System\Roles\Permission;
use App\Nova\Resources\System\Roles\Role; use App\Nova\Resources\System\Roles\Role;
@@ -107,8 +108,9 @@ class User extends Resource
Boolean::make(__('Phone verified'), 'phone_verified_at') Boolean::make(__('Phone verified'), 'phone_verified_at')
->default(false) ->default(false)
->fillUsing(function ($request, $model, $attribute, $requestAttribute) { ->fillUsing(function (NovaRequest $request, $model, string $attribute, string $requestAttribute) {
if ($request->boolean('phone_verified_at')) { if ($request->boolean('phone_verified_at')) {
/** @var UserModel $model */
$model->phone_verified_at = now(); $model->phone_verified_at = now();
} }
}) })

View File

@@ -26,6 +26,7 @@ class AppServiceProvider extends ServiceProvider
*/ */
public function boot(): void public function boot(): void
{ {
Model::unguard();
Model::shouldBeStrict(! app()->isProduction()); Model::shouldBeStrict(! app()->isProduction());
Event::listen( Event::listen(

View File

@@ -3,14 +3,14 @@
namespace App\Repos\Payment; namespace App\Repos\Payment;
use App\Models\Payment\OnlinePaymentHistory; use App\Models\Payment\OnlinePaymentHistory;
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrderItem; use App\Repos\Payment\VisaMaster\HandlesVisaMasterPayments;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Laravel\Nova\Makeable; use Laravel\Nova\Makeable;
class OnlinePaymentRepo class OnlinePaymentRepo
{ {
use HandlesVisaMasterPayments;
use Makeable; use Makeable;
/** /**
@@ -156,63 +156,6 @@ class OnlinePaymentRepo
return 'orders.cards.online-payment.status'; return 'orders.cards.online-payment.status';
} }
public static function checkPaymentVisaMaster(Request $request)
{
// Find order from history
$paymentHistory = OnlinePaymentHistory::where('orderId', $request->orderId)->first();
// Find related resource
$resource = VisaMasterPaymentOrderItem::where('online_payment_history_id', $paymentHistory->id)->first();
// If resource could not be found or does not exist, then inform it via logs
if (! $resource) {
static::logResourceNotFound($request, $paymentHistory);
return static::resourceNotFound();
}
$bank_branch = $resource->parent->branch;
$response = Http::asForm()->post('https://mpi.gov.tm/payment/rest/getOrderStatus.do', [
'language' => 'ru',
'orderId' => $request->orderId,
'userName' => $bank_branch->billing_visa_master_username,
'password' => $bank_branch->billing_visa_master_password,
]);
$payment_status = $response['ErrorCode'] == '0';
if ($payment_status) {
$resource->update([
'payer_name' => $response['cardholderName'],
'payer_card' => $response['Pan'],
'paid' => true,
]);
$paymentHistory->update([
'paymentStatus' => OnlinePaymentRepo::PAID,
]);
} else {
$resource->update([
'payer_name' => $response['cardholderName'] ?? '-',
'payer_card' => $response['Pan'] ?? '-',
]);
$paymentHistory->update([
'paymentStatus' => OnlinePaymentRepo::FAILED,
]);
}
return [
'success' => $payment_status,
'title' => $payment_status ? __('Payment is successful') : __('Payment has failed'),
'pnr' => $paymentHistory->orderNumber,
'branch_name' => $bank_branch->name,
'price_amount' => convertToOriginalFormat($paymentHistory->amount).' TMT',
'return_url' => url('/work-place/resources/nova-visa-master-payment-orders/'.$resource->visa_master_payment_order_id),
];
}
protected static function logResourceNotFound($request, $paymentHistory): void protected static function logResourceNotFound($request, $paymentHistory): void
{ {
Log::channel('halkbank_payment_check_error') Log::channel('halkbank_payment_check_error')
@@ -226,6 +169,30 @@ class OnlinePaymentRepo
]); ]);
} }
public static function successfulPaymentResponse($paymentHistory, $bank_branch, $resource)
{
return [
'success' => true,
'title' => __('Payment is successful'),
'pnr' => $paymentHistory->orderNumber,
'branch_name' => $bank_branch->name,
'price_amount' => convertToOriginalFormat($paymentHistory->amount).' TMT',
'return_url' => url('/work-place/resources/nova-visa-master-payment-orders/'.$resource->visa_master_payment_order_id),
];
}
public static function failedPaymentResponse($paymentHistory, $bank_branch, $resource)
{
return [
'success' => false,
'title' => __('Payment is successful'),
'pnr' => $paymentHistory->orderNumber,
'branch_name' => $bank_branch->name,
'price_amount' => convertToOriginalFormat($paymentHistory->amount).' TMT',
'return_url' => url('/work-place/resources/nova-visa-master-payment-orders/'.$resource->visa_master_payment_order_id),
];
}
protected static function resourceNotFound(): array protected static function resourceNotFound(): array
{ {
return [ return [

View File

@@ -0,0 +1,64 @@
<?php
namespace App\Repos\Payment\VisaMaster;
use App\Models\Payment\OnlinePaymentHistory;
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrderItem;
use App\Repos\Payment\OnlinePaymentRepo;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
trait HandlesVisaMasterPayments
{
public static function checkPaymentVisaMaster(Request $request)
{
// Find order from history
$paymentHistory = OnlinePaymentHistory::where('orderId', $request->orderId)->first();
// Find related resource
$resource = VisaMasterPaymentOrderItem::where('online_payment_history_id', $paymentHistory->id)->first();
// If resource could not be found or does not exist, then inform it via logs
if (! $resource) {
static::logResourceNotFound($request, $paymentHistory);
return static::resourceNotFound();
}
$bank_branch = $resource->parent->branch;
$response = Http::asForm()->post('https://mpi.gov.tm/payment/rest/getOrderStatus.do', [
'language' => 'ru',
'orderId' => $request->orderId,
'userName' => $bank_branch->billing_visa_master_username,
'password' => $bank_branch->billing_visa_master_password,
]);
$payment_status = $response['ErrorCode'] == '0';
if ($payment_status) {
$resource->update([
'payer_name' => $response['cardholderName'],
'payer_card' => $response['Pan'],
'paid' => true,
]);
$paymentHistory->update([
'paymentStatus' => OnlinePaymentRepo::PAID,
]);
return static::successfulPaymentResponse($paymentHistory, $bank_branch, $resource);
}
$resource->update([
'payer_name' => $response['cardholderName'] ?? '-',
'payer_card' => $response['Pan'] ?? '-',
]);
$paymentHistory->update([
'paymentStatus' => OnlinePaymentRepo::FAILED,
]);
return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource);
}
}

View File

@@ -7,12 +7,12 @@ parameters:
- app/ - app/
# Level 9 is the highest level # Level 9 is the highest level
level: 9 level: 5
# ignoreErrors: # ignoreErrors:
# - '#PHPDoc tag @var#' # - '#PHPDoc tag @var#'
# #
# excludePaths: excludePaths:
# - ./*/*/FileToBeExcluded.php - ./app/Http/Controllers/Auth/LoginController.php
# #
# checkMissingIterableValueType: false # checkMissingIterableValueType: false