wip
This commit is contained in:
84
app/Nova/Actions/CheckOnlinePaymentStatus.php
Normal file
84
app/Nova/Actions/CheckOnlinePaymentStatus.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Nova\Actions;
|
||||
|
||||
use App\Models\Payment\OnlinePaymentHistory;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Laravel\Nova\Actions\Action;
|
||||
use Laravel\Nova\Actions\ActionResponse;
|
||||
use Laravel\Nova\Fields\ActionFields;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
|
||||
class CheckOnlinePaymentStatus extends Action
|
||||
{
|
||||
use InteractsWithQueue, Queueable;
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
/** @var \App\Models\Order\Card\CardOrder $item */
|
||||
$item = $models->first();
|
||||
|
||||
$onlinePaymentResource = OnlinePaymentHistory::query()
|
||||
->where('online_paymantable_type', 'App\Models\Order\Card\CardOrder')
|
||||
->where('online_paymantable_id', $item->id)
|
||||
->first();
|
||||
|
||||
if (! $onlinePaymentResource) {
|
||||
return Action::modal('modal-response', [
|
||||
'title' => 'Onlaýn töleg taryhy ýok',
|
||||
'body' => 'Onlaýn töleg taryhy ýok',
|
||||
]);
|
||||
}
|
||||
|
||||
if (! $item->branch) {
|
||||
return Action::modal('modal-response', [
|
||||
'title' => 'Şahamça bilen birikdirilmedik',
|
||||
'body' => 'Şahamça bilen birikdirilmedik',
|
||||
]);
|
||||
}
|
||||
|
||||
$username = $item->branch->billing_username;
|
||||
$password = $item->branch->billing_password;
|
||||
|
||||
if (($username == '' || $password == '') || (is_null($username) || is_null($password))) {
|
||||
return Action::modal('modal-response', [
|
||||
'title' => 'HALKBANK API',
|
||||
'body' => 'Ulanyjy ady bilen açar sözi gabat gelmedi',
|
||||
]);
|
||||
}
|
||||
|
||||
$response = Http::asForm()->post('https://mpi.gov.tm/payment/rest/getOrderStatusExtended.do', [
|
||||
'language' => 'ru',
|
||||
'orderId' => $onlinePaymentResource->orderId,
|
||||
'userName' => $username,
|
||||
'password' => $password,
|
||||
]);
|
||||
|
||||
return Action::modal('modal-response', [
|
||||
'title' => 'HALKBANK API',
|
||||
'html' => CheckOnlinePayment::resultHTML($response),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields available on the action.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function fields(NovaRequest $request)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ namespace App\Nova\Resources\Order\Card;
|
||||
use App\Models\Branch\Branch;
|
||||
use App\Models\Order\Card\CardOrder as CardOrderModel;
|
||||
use App\Modules\CardOrder\Nova\Actions\RetryNovaCardOrderPayment;
|
||||
use App\Nova\Actions\CheckOnlinePaymentStatus;
|
||||
use App\Nova\Filters\RegionFilter;
|
||||
use App\Nova\Filters\StatusFilter;
|
||||
use App\Nova\Forms\NovaForm;
|
||||
@@ -382,6 +383,11 @@ class CardOrder extends Resource
|
||||
->onlyOnDetail()
|
||||
->canSee(fn () => true)
|
||||
->icon('credit-card'),
|
||||
|
||||
(new CheckOnlinePaymentStatus())
|
||||
->sole()
|
||||
->withoutConfirmation()
|
||||
->icon('server'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,11 @@ class LoanTypeRepo
|
||||
*/
|
||||
public static function values(): Collection|array
|
||||
{
|
||||
return LoanType::where('active', true)->pluck('name', 'id');
|
||||
return cached(
|
||||
'loan-types-plucked',
|
||||
LoanType::where('active', true)->pluck('name', 'id'),
|
||||
60 * 60,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -24,7 +28,11 @@ class LoanTypeRepo
|
||||
*/
|
||||
public static function onlyGuarantor(): Collection|array
|
||||
{
|
||||
return LoanType::where('active', true)->where('id', static::loanTypeGuarantorId())->pluck('name', 'id');
|
||||
return cached(
|
||||
'only-guarantor-plucked',
|
||||
LoanType::where('active', true)->where('id', static::loanTypeGuarantorId())->pluck('name', 'id'),
|
||||
60 * 60,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user