This commit is contained in:
2024-11-23 13:17:50 +05:00
parent fdf0455dc1
commit e49dbfe450

View File

@@ -44,13 +44,33 @@ class MakePaymentNovaVisaMaster extends Action
public function handle(ActionFields $fields, Collection $models)
{
if (is_null($fields->payment_amount) || is_null($fields->usd_payment)) {
return ActionResponse::danger('Töleg maglumatlary ýok!');
return Action::modal('modal-response', [
'title' => 'Töleg maglumatlary ýok!',
'body' => 'Töleg maglumatlary girizilmedik',
]);
}
$resource = $models->first();
$hasBeenPaid = false;
$resource->items->each(function ($item) use ($hasBeenPaid) {
if (boolval($item->paid) && now()->format('m Y') == $item->created_at->format('m Y')) {
$hasBeenPaid = true;
}
});
if (! $hasBeenPaid) {
return Action::modal('modal-response', [
'title' => 'Bul aý töleg edildi!',
'body' => 'Bul aý töleg edildi.',
]);
}
if (! $resource->branch || ! $resource->branch->billing_visa_master_username) {
return ActionResponse::danger('Şahamça visa/master tölegi kabul edip bilmeýär.');
return Action::modal('modal-response', [
'title' => 'Billing maglumatlary şahamçada ýok!',
'body' => 'Şahamça visa/master tölegi kabul edip bilmeýär.',
]);
}
$total_amount = floatval(number_format($fields->payment_amount, 2, '.', '')) + 23;
@@ -62,7 +82,10 @@ class MakePaymentNovaVisaMaster extends Action
$payment = $this->order($resource, $total_amount);
if ($payment['status'] !== 'success') {
return ActionResponse::danger('Töleg ýerinde näsazlyk!');
return Action::modal('modal-response', [
'title' => 'Töleg ýerinde näsazlyk!',
'body' => 'Halkbank apida mesele bar.',
]);
}
$this->createPaymentRecord($payment, $resource, $total_amount, $fields->usd_payment);