wip
This commit is contained in:
65
app/Nova/Actions/CheckOnlinePayment.php
Normal file
65
app/Nova/Actions/CheckOnlinePayment.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Nova\Actions;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
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 CheckOnlinePayment 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)
|
||||
{
|
||||
if ($models->count() > 1) {
|
||||
return ActionResponse::danger('Diňä bir resursa barlap bolýar');
|
||||
}
|
||||
|
||||
$onlinePaymentResource = $models->first();
|
||||
|
||||
$relatedResource = (new $onlinePaymentResource->online_paymantable_type)->find(id: $onlinePaymentResource->online_paymantable_id);
|
||||
if (! $relatedResource) {
|
||||
return ActionResponse::danger('Bu resource tapylmady');
|
||||
}
|
||||
|
||||
$relatedResource->load('branch');
|
||||
|
||||
$username = $relatedResource->branch;
|
||||
$password = $relatedResource->branch;
|
||||
|
||||
$response = Http::asForm()->post('https://mpi.gov.tm/payment/rest/getOrderStatus.do', [
|
||||
'language' => 'ru',
|
||||
'orderId' => $onlinePaymentResource->orderId,
|
||||
'userName' => $username,
|
||||
'password' => $password,
|
||||
]);
|
||||
|
||||
$payment_status = $response['ErrorCode'] == '0';
|
||||
|
||||
if ($payment_status) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields available on the action.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function fields(NovaRequest $request)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -161,7 +161,7 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
'formUrl' => $paymentResponse['formUrl'],
|
||||
'successUrl' => route('online-payment-store-visa-master'),
|
||||
'errorUrl' => route('online-payment-store-visa-master'),
|
||||
'api_client' => config('app.url'),
|
||||
'api_client' => 'billing_visa_master_username',
|
||||
'username' => $resource->branch->billing_visa_master_username,
|
||||
'paymentStatus' => OnlinePaymentRepo::PENDING,
|
||||
]);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Nova\Resources\Payment;
|
||||
|
||||
use App\Nova\Actions\CheckOnlinePayment;
|
||||
use App\Nova\Resource;
|
||||
use Illuminate\Http\Request;
|
||||
use Laravel\Nova\Fields\DateTime;
|
||||
@@ -114,6 +115,8 @@ class OnlinePaymentHistoryResource extends Resource
|
||||
*/
|
||||
public function actions(NovaRequest $request)
|
||||
{
|
||||
return [];
|
||||
return [
|
||||
CheckOnlinePayment::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ class OnlinePaymentRepo
|
||||
$onlinePaymentHistory->formUrl = $paymentResponse['formUrl'];
|
||||
$onlinePaymentHistory->successUrl = route('online-payment-store');
|
||||
$onlinePaymentHistory->errorUrl = route('online-payment-store');
|
||||
$onlinePaymentHistory->api_client = config('app.url');
|
||||
$onlinePaymentHistory->api_client = 'billing_username';
|
||||
$onlinePaymentHistory->username = $resource->branch->billing_username;
|
||||
$onlinePaymentHistory->paymentStatus = self::PENDING;
|
||||
$onlinePaymentHistory->save();
|
||||
|
||||
Reference in New Issue
Block a user