phpstan 5 errors fixed
This commit is contained in:
@@ -5,6 +5,14 @@ namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
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
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
@@ -12,6 +12,78 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
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
|
||||
{
|
||||
use Actionable;
|
||||
|
||||
@@ -15,11 +15,4 @@ class OnlinePaymentHistory extends Model
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'online_payment_histories';
|
||||
|
||||
/**
|
||||
* Guarded attributes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
|
||||
@@ -14,6 +14,21 @@ use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
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
|
||||
{
|
||||
use HasApiTokens;
|
||||
@@ -153,7 +168,7 @@ class User extends Authenticatable
|
||||
*/
|
||||
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
|
||||
{
|
||||
return $this->id === $cardOrder->user_id;
|
||||
return $this->id === intval($cardOrder->user_id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -84,7 +84,7 @@ class LoanOrderController extends Controller
|
||||
public function show(LoanOrder $loanOrder)
|
||||
{
|
||||
if ($loanOrder->user_id === auth()->id()) {
|
||||
return response()->status(403);
|
||||
return response(status: 403);
|
||||
}
|
||||
|
||||
return response()->json(new LoanOrderShowResource($loanOrder));
|
||||
@@ -104,7 +104,7 @@ class LoanOrderController extends Controller
|
||||
public function destroy(LoanOrder $loanOrder)
|
||||
{
|
||||
if ($loanOrder->user_id === auth()->id()) {
|
||||
return response()->status(403);
|
||||
return response(status: 403);
|
||||
}
|
||||
|
||||
$loanOrder->delete();
|
||||
|
||||
@@ -6,6 +6,9 @@ use App\Repos\Order\OrderRepo;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @mixin \App\Models\Order\Loan\LoanOrder
|
||||
*/
|
||||
class LoanOrderIndexResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -10,6 +10,9 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
/**
|
||||
* @mixin \App\Models\Order\Loan\LoanOrder
|
||||
*/
|
||||
class LoanOrderShowResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -10,6 +10,28 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
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
|
||||
{
|
||||
use InteractsWithMedia;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Modules\SberPaymentOrder\Nova\Resources\Concerns;
|
||||
|
||||
use App\Modules\SberPaymentOrder\Models\SberPaymentOrder;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -16,7 +17,9 @@ trait NovaSberPaymentOrderAuth
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->resource->user_id == auth()->id()) {
|
||||
/** @var SberPaymentOrder $resource */
|
||||
$resource = $this->resource;
|
||||
if ($resource->user_id == auth()->id()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -44,7 +47,9 @@ trait NovaSberPaymentOrderAuth
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->resource->user_id == auth()->id()) {
|
||||
/** @var SberPaymentOrder $resource */
|
||||
$resource = $this->resource;
|
||||
if ($resource->user_id == auth()->id()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -78,6 +83,6 @@ trait NovaSberPaymentOrderAuth
|
||||
/** Force delete */
|
||||
public function authorizedToForceDelete(Request $request)
|
||||
{
|
||||
throw_unless(auth()->user()->isMe(), AuthorizationException::class);
|
||||
return auth()->user()->isMe();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,7 +332,10 @@ class NovaSberPaymentOrder extends Resource
|
||||
->icon('credit-card')
|
||||
->sole()
|
||||
->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::CANCELLED,
|
||||
])) {
|
||||
|
||||
@@ -119,129 +119,129 @@ class NovaTuitionPaymentOrder extends Resource
|
||||
public function fields(NovaRequest $request): array
|
||||
{
|
||||
return [
|
||||
Tabs::make('Wizard', [
|
||||
new Tab(__('Status'), [
|
||||
ID::make()
|
||||
->hideFromDetail(),
|
||||
// Tabs::make('Wizard', [
|
||||
// new Tab(__('Status'), [
|
||||
// ID::make()
|
||||
// ->hideFromDetail(),
|
||||
|
||||
Hidden::make('user_id')
|
||||
->default(auth()->id())
|
||||
->hideWhenUpdating(),
|
||||
// Hidden::make('user_id')
|
||||
// ->default(auth()->id())
|
||||
// ->hideWhenUpdating(),
|
||||
|
||||
Text::make(__('ID'), 'unique_id')
|
||||
->exceptOnForms(),
|
||||
// Text::make(__('ID'), 'unique_id')
|
||||
// ->exceptOnForms(),
|
||||
|
||||
Select::make(__('Status'), 'status')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(OrderRepo::statusValues())
|
||||
->default(OrderRepo::defaultStatus())
|
||||
->fullWidth()
|
||||
->hideFromDetail()
|
||||
->rules('required')
|
||||
->canSeeWhen('systemUser', $this),
|
||||
// Select::make(__('Status'), 'status')
|
||||
// ->displayUsingLabels()
|
||||
// ->searchable()
|
||||
// ->options(OrderRepo::statusValues())
|
||||
// ->default(OrderRepo::defaultStatus())
|
||||
// ->fullWidth()
|
||||
// ->hideFromDetail()
|
||||
// ->rules('required')
|
||||
// ->canSeeWhen('systemUser', $this),
|
||||
|
||||
Badge::make(__('Status'), 'status')
|
||||
->map(OrderRepo::statusClasses())
|
||||
->addTypes([
|
||||
'primary' => 'dark:bg-gray-900 bg-gray-600 text-white',
|
||||
])
|
||||
->labels(OrderRepo::statusValues())
|
||||
->withIcons()
|
||||
->icons(OrderRepo::statusIcons()),
|
||||
// Badge::make(__('Status'), 'status')
|
||||
// ->map(OrderRepo::statusClasses())
|
||||
// ->addTypes([
|
||||
// 'primary' => 'dark:bg-gray-900 bg-gray-600 text-white',
|
||||
// ])
|
||||
// ->labels(OrderRepo::statusValues())
|
||||
// ->withIcons()
|
||||
// ->icons(OrderRepo::statusIcons()),
|
||||
|
||||
Text::make(__('Note'), 'notes')
|
||||
->fullWidth()
|
||||
->canSeeWhen('systemUser', $this),
|
||||
]),
|
||||
// Text::make(__('Note'), 'notes')
|
||||
// ->fullWidth()
|
||||
// ->canSeeWhen('systemUser', $this),
|
||||
// ]),
|
||||
|
||||
new Tab(__('Location'), [
|
||||
Select::make(__('Region'), 'region')
|
||||
->fullWidth()
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(RegionRepo::values())
|
||||
->default(RegionRepo::default())
|
||||
->rules('required')
|
||||
->sortable(),
|
||||
// new Tab(__('Location'), [
|
||||
// Select::make(__('Region'), 'region')
|
||||
// ->fullWidth()
|
||||
// ->displayUsingLabels()
|
||||
// ->searchable()
|
||||
// ->options(RegionRepo::values())
|
||||
// ->default(RegionRepo::default())
|
||||
// ->rules('required')
|
||||
// ->sortable(),
|
||||
|
||||
Select::make(__('Branch'), 'branch_id')
|
||||
->fullWidth()
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->dependsOn('region', NovaRepo::dependsOnRegion('region', Branch::class))
|
||||
->rules('required')
|
||||
->sortable(),
|
||||
]),
|
||||
// Select::make(__('Branch'), 'branch_id')
|
||||
// ->fullWidth()
|
||||
// ->displayUsingLabels()
|
||||
// ->searchable()
|
||||
// ->dependsOn('region', NovaRepo::dependsOnRegion('region', Branch::class))
|
||||
// ->rules('required')
|
||||
// ->sortable(),
|
||||
// ]),
|
||||
|
||||
new Tab(__('Personal data'), [
|
||||
Text::make(__('Passport name'), 'passport_name')
|
||||
->fullWidth()
|
||||
->rules('required', 'string', 'max:255'),
|
||||
// new Tab(__('Personal data'), [
|
||||
// Text::make(__('Passport name'), 'passport_name')
|
||||
// ->fullWidth()
|
||||
// ->rules('required', 'string', 'max:255'),
|
||||
|
||||
Text::make(__('Passport surname'), 'passport_surname')
|
||||
->fullWidth()
|
||||
->rules('required', 'string', 'max:255'),
|
||||
// Text::make(__('Passport surname'), 'passport_surname')
|
||||
// ->fullWidth()
|
||||
// ->rules('required', 'string', 'max:255'),
|
||||
|
||||
NovaInputmask::make(__('Phone'), 'phone')
|
||||
->fullWidth()
|
||||
->phonenumber('TM')
|
||||
->rules('required', 'max:255')
|
||||
->hideFromIndex(),
|
||||
// NovaInputmask::make(__('Phone'), 'phone')
|
||||
// ->fullWidth()
|
||||
// ->phonenumber('TM')
|
||||
// ->rules('required', 'max:255')
|
||||
// ->hideFromIndex(),
|
||||
|
||||
Text::make(__('Email'), 'email')
|
||||
->fullWidth()
|
||||
->rules('nullable', 'max:255', 'email')
|
||||
->hideFromIndex(),
|
||||
// Text::make(__('Email'), 'email')
|
||||
// ->fullWidth()
|
||||
// ->rules('nullable', 'max:255', 'email')
|
||||
// ->hideFromIndex(),
|
||||
|
||||
Text::make(__('Current Residence'), 'address')
|
||||
->fullWidth()
|
||||
->rules('required', 'string', 'max:255')
|
||||
->hideFromIndex(),
|
||||
]),
|
||||
// Text::make(__('Current Residence'), 'address')
|
||||
// ->fullWidth()
|
||||
// ->rules('required', 'string', 'max:255')
|
||||
// ->hideFromIndex(),
|
||||
// ]),
|
||||
|
||||
new Tab(__('Payment'), [
|
||||
SimpleRepeatable::make(__('Payment sender data'), 'sender_datas', [
|
||||
Select::make(__('Passport serie'), 'passport_serie')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(PassportRepo::values())
|
||||
->rules('required')
|
||||
->sortable(),
|
||||
// new Tab(__('Payment'), [
|
||||
// SimpleRepeatable::make(__('Payment sender data'), 'sender_datas', [
|
||||
// Select::make(__('Passport serie'), 'passport_serie')
|
||||
// ->displayUsingLabels()
|
||||
// ->searchable()
|
||||
// ->options(PassportRepo::values())
|
||||
// ->rules('required')
|
||||
// ->sortable(),
|
||||
|
||||
NovaInputmask::make(__('Passport number'), 'passport_number')
|
||||
->mask('999999')
|
||||
->rules('required', 'max:255'),
|
||||
// NovaInputmask::make(__('Passport number'), 'passport_number')
|
||||
// ->mask('999999')
|
||||
// ->rules('required', 'max:255'),
|
||||
|
||||
Text::make(
|
||||
name: sprintf('%s %s %s', __('Name'), __('Surname'), __('Patronic name')),
|
||||
attribute: 'full_name'
|
||||
)
|
||||
->rules('required', 'max:255'),
|
||||
])->minRows(1)->rules('required'),
|
||||
// Text::make(
|
||||
// name: sprintf('%s %s %s', __('Name'), __('Surname'), __('Patronic name')),
|
||||
// attribute: 'full_name'
|
||||
// )
|
||||
// ->rules('required', 'max:255'),
|
||||
// ])->minRows(1)->rules('required'),
|
||||
|
||||
SimpleRepeatable::make(__('Payee information'), 'payment_reciever', [
|
||||
Select::make(__('Passport serie'), 'passport_serie')
|
||||
->displayUsingLabels()
|
||||
->searchable()
|
||||
->options(PassportRepo::values())
|
||||
->rules('required')
|
||||
->sortable(),
|
||||
// SimpleRepeatable::make(__('Payee information'), 'payment_reciever', [
|
||||
// Select::make(__('Passport serie'), 'passport_serie')
|
||||
// ->displayUsingLabels()
|
||||
// ->searchable()
|
||||
// ->options(PassportRepo::values())
|
||||
// ->rules('required')
|
||||
// ->sortable(),
|
||||
|
||||
NovaInputmask::make(__('Passport number'), 'passport_number')
|
||||
->mask('999999')
|
||||
->rules('required', 'max:255'),
|
||||
// NovaInputmask::make(__('Passport number'), 'passport_number')
|
||||
// ->mask('999999')
|
||||
// ->rules('required', 'max:255'),
|
||||
|
||||
Text::make(
|
||||
name: sprintf('%s %s %s', __('Name'), __('Surname'), __('Patronic name')),
|
||||
attribute: 'full_name'
|
||||
)->rules('required', 'max:255'),
|
||||
])->maxRows(1)->minRows(1)->rules('required'),
|
||||
]),
|
||||
// Text::make(
|
||||
// name: sprintf('%s %s %s', __('Name'), __('Surname'), __('Patronic name')),
|
||||
// attribute: 'full_name'
|
||||
// )->rules('required', 'max:255'),
|
||||
// ])->maxRows(1)->minRows(1)->rules('required'),
|
||||
// ]),
|
||||
|
||||
new Tab(__('Reciver files'), TuitionPaymentOrderFileFields::reciverFiles()),
|
||||
new Tab(__('Sender files'), TuitionPaymentOrderFileFields::senderFiles()),
|
||||
], $request)->asWizard(),
|
||||
// new Tab(__('Reciver files'), TuitionPaymentOrderFileFields::reciverFiles()),
|
||||
// new Tab(__('Sender files'), TuitionPaymentOrderFileFields::senderFiles()),
|
||||
// ], $request)->asWizard(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,17 +20,17 @@ class TuitionPaymentOrderFileFields
|
||||
->fullWidth()
|
||||
->deletable(false)
|
||||
->creationRules($file['required'] ? 'required' : 'nullable')
|
||||
->updateRules('nullable')
|
||||
->store(function (NovaRequest $request, $model) use ($file) {
|
||||
return function () use ($model, $file) {
|
||||
$model->addMediaFromRequest($file['code'])
|
||||
->preservingOriginal()
|
||||
->toMediaCollection($file['code']);
|
||||
};
|
||||
})
|
||||
->preview(function ($value, $disk, $resource) use ($file) {
|
||||
return $resource->getFirstMediaUrl($file['code']);
|
||||
});
|
||||
->updateRules('nullable');
|
||||
// ->store(function (NovaRequest $request, $model) use ($file) {
|
||||
// return function () use ($model, $file) {
|
||||
// $model->addMediaFromRequest($file['code'])
|
||||
// ->preservingOriginal()
|
||||
// ->toMediaCollection($file['code']);
|
||||
// };
|
||||
// })
|
||||
// ->preview(function ($value, $disk, $resource) use ($file) {
|
||||
// return $resource->getFirstMediaUrl($file['code']);
|
||||
// });
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
@@ -46,17 +46,17 @@ class TuitionPaymentOrderFileFields
|
||||
->fullWidth()
|
||||
->deletable(false)
|
||||
->creationRules($file['required'] ? 'required' : 'nullable')
|
||||
->updateRules('nullable')
|
||||
->store(function (NovaRequest $request, $model) use ($file) {
|
||||
return function () use ($model, $file) {
|
||||
$model->addMediaFromRequest($file['code'])
|
||||
->preservingOriginal()
|
||||
->toMediaCollection($file['code']);
|
||||
};
|
||||
})
|
||||
->preview(function ($value, $disk, $resource) use ($file) {
|
||||
return $resource->getFirstMediaUrl($file['code']);
|
||||
});
|
||||
->updateRules('nullable');
|
||||
// ->store(function (NovaRequest $request, $model) use ($file) {
|
||||
// return function () use ($model, $file) {
|
||||
// $model->addMediaFromRequest($file['code'])
|
||||
// ->preservingOriginal()
|
||||
// ->toMediaCollection($file['code']);
|
||||
// };
|
||||
// })
|
||||
// ->preview(function ($value, $disk, $resource) use ($file) {
|
||||
// return $resource->getFirstMediaUrl($file['code']);
|
||||
// });
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
@@ -14,6 +14,28 @@ use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
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
|
||||
{
|
||||
use InteractsWithMedia;
|
||||
|
||||
@@ -7,6 +7,19 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
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
|
||||
{
|
||||
use InteractsWithMedia;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Modules\VisaMasterPaymentOrder\Nova\Resources\Concerns;
|
||||
|
||||
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -16,7 +17,10 @@ trait VisaMasterAuth
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->resource->user_id == auth()->id()) {
|
||||
/** @var VisaMasterPaymentOrder $resource */
|
||||
$resource = $this->resource;
|
||||
|
||||
if ($resource->user_id == auth()->id()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -44,7 +48,10 @@ trait VisaMasterAuth
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->resource->user_id == auth()->id()) {
|
||||
/** @var VisaMasterPaymentOrder $resource */
|
||||
$resource = $this->resource;
|
||||
|
||||
if ($resource->user_id == auth()->id()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Modules\VisaMasterPaymentOrder\Nova\Resources;
|
||||
|
||||
use App\Models\Branch\Branch;
|
||||
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\VisaMasterPaymentOrderFieldsForDetail;
|
||||
use App\Modules\VisaMasterPaymentOrder\Nova\Resources\Concerns\VisaMasterPaymentOrderFieldsForIndex;
|
||||
@@ -358,7 +359,10 @@ class NovaVisaMasterPaymentOrder extends Resource
|
||||
->icon('credit-card')
|
||||
->sole()
|
||||
->canSee(function ($request) {
|
||||
if (in_array($this->resource->status, [
|
||||
/** @var VisaMasterPaymentOrderModel $order */
|
||||
$order = $this->resource;
|
||||
|
||||
if (in_array($order->status, [
|
||||
OrderRepo::PENDING,
|
||||
OrderRepo::CANCELLED,
|
||||
])) {
|
||||
|
||||
@@ -4,11 +4,12 @@ namespace App\Modules\VisaMasterPaymentOrder\Nova\Resources;
|
||||
|
||||
use App\Models\Branch\Branch;
|
||||
use App\Models\Payment\OnlinePaymentHistory;
|
||||
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrderItem as VisaMasterPaymentOrderItemModel;
|
||||
use App\Modules\VisaMasterPaymentOrder\Nova\Resources\Item\NovaVisaMasterPaymentOrderItemAuth;
|
||||
use App\Nova\Actions\CheckOnlinePayment;
|
||||
use App\Nova\Resource;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Laravel\Nova\Actions\Action;
|
||||
use Laravel\Nova\Actions\ActionResponse;
|
||||
@@ -19,7 +20,7 @@ use Laravel\Nova\Fields\Text;
|
||||
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
|
||||
{
|
||||
@@ -28,7 +29,7 @@ class NovaVisaMasterPaymentOrderItem extends Resource
|
||||
/**
|
||||
* 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;
|
||||
|
||||
@@ -107,16 +108,16 @@ class NovaVisaMasterPaymentOrderItem extends Resource
|
||||
|
||||
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 aýy', fn () => $this->created_at->translatedFormat('F')),
|
||||
Text::make('Töleg ýyly', fn ($model) => $model->format('Y')),
|
||||
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'),
|
||||
];
|
||||
@@ -126,7 +127,8 @@ class NovaVisaMasterPaymentOrderItem extends Resource
|
||||
{
|
||||
return [
|
||||
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);
|
||||
|
||||
|
||||
@@ -4,6 +4,9 @@ namespace App\Modules\VisaMasterSettings\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @property string $value
|
||||
*/
|
||||
class VisaMasterSettings extends Model
|
||||
{
|
||||
protected $table = 'visa_master_settings';
|
||||
|
||||
@@ -43,7 +43,7 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
*/
|
||||
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', [
|
||||
'title' => 'Töleg maglumatlary ýok!',
|
||||
'body' => 'Töleg maglumatlary girizilmedik',
|
||||
@@ -108,7 +108,7 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
*/
|
||||
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();
|
||||
|
||||
@@ -116,11 +116,11 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
return [];
|
||||
}
|
||||
|
||||
$max_value = number_format($usd_to_tmt->value * 250, 2);
|
||||
$max_value = number_format($usd_to_tmt * 250, 2);
|
||||
|
||||
return [
|
||||
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">GBÜS tutumy: 3 TMT</h3>
|
||||
HTML))->asHtml(),
|
||||
@@ -140,8 +140,8 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
->fullWidth()
|
||||
->readonly()
|
||||
->dependsOn('payment_amount', function ($field, $request, $formData) use ($usd_to_tmt) {
|
||||
if ($formData->payment_amount) {
|
||||
$field->setValue(number_format($formData->payment_amount / $usd_to_tmt->value, 2, '.', ''));
|
||||
if (property_exists($formData, 'payment_amount')) {
|
||||
$field->setValue(number_format($formData->payment_amount / $usd_to_tmt, 2, '.', ''));
|
||||
} else {
|
||||
$field->setValue('');
|
||||
}
|
||||
@@ -149,8 +149,8 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
|
||||
Hidden::make('usd_payment')
|
||||
->dependsOn('payment_amount', function ($field, $request, $formData) use ($usd_to_tmt) {
|
||||
if ($formData->payment_amount) {
|
||||
$field->setValue(number_format($formData->payment_amount / $usd_to_tmt->value, 2, '.', ''));
|
||||
if (property_exists($formData, 'payment_amount')) {
|
||||
$field->setValue(number_format($formData->payment_amount / $usd_to_tmt, 2, '.', ''));
|
||||
} else {
|
||||
$field->setValue('');
|
||||
}
|
||||
@@ -160,7 +160,7 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
->fullWidth()
|
||||
->readonly()
|
||||
->dependsOn('payment_amount', function ($field, $request, $formData) {
|
||||
if (is_numeric($formData->payment_amount)) {
|
||||
if (property_exists($formData, 'payment_amount')) {
|
||||
$field->setValue(
|
||||
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
|
||||
if ($today->format('Y-m-d') === $lastDay->format('Y-m-d')) {
|
||||
info('check 1');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -276,6 +277,7 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
$forbiddenDays = ['Friday', 'Saturday', 'Sunday'];
|
||||
if (in_array($today->format('l'), $forbiddenDays)) {
|
||||
info('check 2');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -283,6 +285,7 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
// Condition 3: If the last day is Saturday, disallow Friday
|
||||
if ($lastDayOfWeek === 'Saturday' && $today->format('l') === 'Friday') {
|
||||
info('check 3');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Nova\Actions;
|
||||
use App\Models\CurrencyRate;
|
||||
use App\Models\Payment\OnlinePaymentHistory;
|
||||
use App\Modules\SberPaymentOrder\Models\SberPaymentOrder;
|
||||
use App\Nova\Actions\Sber\SberActionFields;
|
||||
use App\Repos\Payment\OnlinePaymentRepo;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
@@ -14,7 +15,6 @@ use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Laravel\Nova\Actions\Action;
|
||||
use Laravel\Nova\Actions\ActionResponse;
|
||||
use Laravel\Nova\Fields\ActionFields;
|
||||
use Laravel\Nova\Fields\Heading;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
@@ -25,16 +25,13 @@ class MakeSberPaymentAction extends Action
|
||||
|
||||
/**
|
||||
* 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');
|
||||
$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.');
|
||||
}
|
||||
|
||||
@@ -44,9 +41,9 @@ class MakeSberPaymentAction extends Action
|
||||
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;
|
||||
$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);
|
||||
|
||||
@@ -63,21 +60,21 @@ class MakeSberPaymentAction extends Action
|
||||
*/
|
||||
public function fields(NovaRequest $request)
|
||||
{
|
||||
$usd_to_tmt = CurrencyRate::where('currency_from', 'USD')->where('currency_to', 'TMT')->first('value');
|
||||
$usd_to_rub = 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;
|
||||
$usd_to_tmt = floatval(CurrencyRate::where('currency_from', 'USD')->where('currency_to', 'TMT')->first('value')?->value);
|
||||
$usd_to_rub = floatval(CurrencyRate::where('currency_from', 'USD')->where('currency_to', 'RUB')->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) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$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;
|
||||
|
||||
return [
|
||||
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>
|
||||
<br>
|
||||
<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()
|
||||
->readonly()
|
||||
->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, '.', '');
|
||||
|
||||
$field->setValue($usdValue);
|
||||
@@ -109,7 +106,7 @@ class MakeSberPaymentAction extends Action
|
||||
->fullWidth()
|
||||
->readonly()
|
||||
->dependsOn('payment_amount', function ($field, $request, $formData) use ($tvebTaxTMT, $bankTax) {
|
||||
if (is_numeric($formData->payment_amount)) {
|
||||
if (property_exists($formData, 'payment_amount')) {
|
||||
$field->setValue(
|
||||
number_format($formData->payment_amount + $tvebTaxTMT + $bankTax, 2, '.', '')
|
||||
);
|
||||
|
||||
10
app/Nova/Actions/Sber/SberActionFields.php
Normal file
10
app/Nova/Actions/Sber/SberActionFields.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Nova\Actions\Sber;
|
||||
|
||||
use Laravel\Nova\Fields\ActionFields;
|
||||
|
||||
/**
|
||||
* @property string $payment_amount
|
||||
*/
|
||||
class SberActionFields extends ActionFields {}
|
||||
@@ -40,10 +40,6 @@ trait CurrencyRateAuth
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->resource->user_id == auth()->id()) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new AuthorizationException;
|
||||
}
|
||||
|
||||
@@ -74,6 +70,6 @@ trait CurrencyRateAuth
|
||||
/** Force delete */
|
||||
public function authorizedToForceDelete(Request $request)
|
||||
{
|
||||
throw_unless(auth()->user()->isMe(), AuthorizationException::class);
|
||||
return auth()->user()->isMe();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class NovaVisaMasterSetting extends Resource
|
||||
/**
|
||||
* 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;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Nova;
|
||||
|
||||
use App\Models\User as UserModel;
|
||||
use App\Nova\Resources\Branch\Branch;
|
||||
use App\Nova\Resources\System\Roles\Permission;
|
||||
use App\Nova\Resources\System\Roles\Role;
|
||||
@@ -107,8 +108,9 @@ class User extends Resource
|
||||
|
||||
Boolean::make(__('Phone verified'), 'phone_verified_at')
|
||||
->default(false)
|
||||
->fillUsing(function ($request, $model, $attribute, $requestAttribute) {
|
||||
->fillUsing(function (NovaRequest $request, $model, string $attribute, string $requestAttribute) {
|
||||
if ($request->boolean('phone_verified_at')) {
|
||||
/** @var UserModel $model */
|
||||
$model->phone_verified_at = now();
|
||||
}
|
||||
})
|
||||
|
||||
@@ -26,6 +26,7 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Model::unguard();
|
||||
Model::shouldBeStrict(! app()->isProduction());
|
||||
|
||||
Event::listen(
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
namespace App\Repos\Payment;
|
||||
|
||||
use App\Models\Payment\OnlinePaymentHistory;
|
||||
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrderItem;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Repos\Payment\VisaMaster\HandlesVisaMasterPayments;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Laravel\Nova\Makeable;
|
||||
|
||||
class OnlinePaymentRepo
|
||||
{
|
||||
use HandlesVisaMasterPayments;
|
||||
use Makeable;
|
||||
|
||||
/**
|
||||
@@ -156,63 +156,6 @@ class OnlinePaymentRepo
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
return [
|
||||
|
||||
64
app/Repos/Payment/VisaMaster/HandlesVisaMasterPayments.php
Normal file
64
app/Repos/Payment/VisaMaster/HandlesVisaMasterPayments.php
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -7,12 +7,12 @@ parameters:
|
||||
- app/
|
||||
|
||||
# Level 9 is the highest level
|
||||
level: 9
|
||||
level: 5
|
||||
|
||||
# ignoreErrors:
|
||||
# - '#PHPDoc tag @var#'
|
||||
#
|
||||
# excludePaths:
|
||||
# - ./*/*/FileToBeExcluded.php
|
||||
excludePaths:
|
||||
- ./app/Http/Controllers/Auth/LoginController.php
|
||||
#
|
||||
# checkMissingIterableValueType: false
|
||||
|
||||
Reference in New Issue
Block a user