From c524bc80914e1043e4832435123962b236561499 Mon Sep 17 00:00:00 2001 From: Nurmuhammet Allanov Date: Mon, 14 Oct 2024 21:14:42 +0500 Subject: [PATCH] wip --- app/Nova/Actions/CheckOnlinePayment.php | 65 +++++++++++++++++++ .../Actions/MakePaymentNovaVisaMaster.php | 2 +- .../Payment/OnlinePaymentHistoryResource.php | 5 +- app/Repos/Payment/OnlinePaymentRepo.php | 2 +- 4 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 app/Nova/Actions/CheckOnlinePayment.php diff --git a/app/Nova/Actions/CheckOnlinePayment.php b/app/Nova/Actions/CheckOnlinePayment.php new file mode 100644 index 0000000..d05b929 --- /dev/null +++ b/app/Nova/Actions/CheckOnlinePayment.php @@ -0,0 +1,65 @@ +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 []; + } +} diff --git a/app/Nova/Actions/MakePaymentNovaVisaMaster.php b/app/Nova/Actions/MakePaymentNovaVisaMaster.php index 98fec64..14f2545 100644 --- a/app/Nova/Actions/MakePaymentNovaVisaMaster.php +++ b/app/Nova/Actions/MakePaymentNovaVisaMaster.php @@ -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, ]); diff --git a/app/Nova/Resources/Payment/OnlinePaymentHistoryResource.php b/app/Nova/Resources/Payment/OnlinePaymentHistoryResource.php index 4bb2440..e36204a 100644 --- a/app/Nova/Resources/Payment/OnlinePaymentHistoryResource.php +++ b/app/Nova/Resources/Payment/OnlinePaymentHistoryResource.php @@ -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(), + ]; } } diff --git a/app/Repos/Payment/OnlinePaymentRepo.php b/app/Repos/Payment/OnlinePaymentRepo.php index 28da7e2..a58cd60 100644 --- a/app/Repos/Payment/OnlinePaymentRepo.php +++ b/app/Repos/Payment/OnlinePaymentRepo.php @@ -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();