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 [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user