84 lines
2.4 KiB
PHP
84 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Nova\Actions\Sber;
|
|
|
|
use App\Models\Payment\OnlinePaymentHistory;
|
|
use App\Nova\Actions\CheckOnlinePayment;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Support\Collection;
|
|
use Laravel\Nova\Actions\Action;
|
|
use Laravel\Nova\Actions\ActionResponse;
|
|
use Laravel\Nova\Fields\ActionFields;
|
|
use Laravel\Nova\Http\Requests\NovaRequest;
|
|
|
|
class SyncWithSystem extends Action
|
|
{
|
|
use InteractsWithQueue, Queueable;
|
|
|
|
/**
|
|
* Name.
|
|
*/
|
|
public function name(): string
|
|
{
|
|
return __('Sync with system');
|
|
}
|
|
|
|
/**
|
|
* 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\Modules\SberPaymentOrder\Models\SberPaymentOrderItem $item */
|
|
$item = $models->first();
|
|
|
|
/** @var \App\Models\Payment\OnlinePaymentHistory $onlinePaymentResource */
|
|
$onlinePaymentResource = OnlinePaymentHistory::find($item->online_payment_history_id);
|
|
|
|
if (! $onlinePaymentResource) {
|
|
return ActionResponse::danger('Online payment resource tapylmady');
|
|
}
|
|
|
|
$relatedResource = (new $onlinePaymentResource->online_paymantable_type)
|
|
->find(id: $onlinePaymentResource->online_paymantable_id);
|
|
|
|
if (! $relatedResource) {
|
|
return ActionResponse::danger('Bu resource tapylmady');
|
|
}
|
|
|
|
$username = $relatedResource->branch->billing_sber_username;
|
|
$password = $relatedResource->branch->billing_sber_password;
|
|
|
|
if ($username == '') {
|
|
return Action::modal('modal-response', [
|
|
'title' => 'HALKBANK API',
|
|
'body' => 'Ulanyjy ady bilen açar sözi gabat gelmedi',
|
|
]);
|
|
}
|
|
|
|
$response = checkOnlinePayment($onlinePaymentResource->orderId, $username, $password);
|
|
|
|
// syncWithBankSystem();
|
|
|
|
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 [];
|
|
}
|
|
}
|