From 94cc0e2d19f3abde4629e224b078f9f879fd8ab6 Mon Sep 17 00:00:00 2001 From: Nurmuhammet Allanov Date: Mon, 14 Oct 2024 20:35:30 +0500 Subject: [PATCH] Online payment --- app/Models/Payment/OnlinePaymentHistory.php | 27 +------- .../Actions/MakePaymentNovaVisaMaster.php | 4 +- app/Policies/OnlinePaymentHistoryPolicy.php | 66 +++++++++++++++++++ app/Providers/AuthServiceProvider.php | 5 ++ 4 files changed, 76 insertions(+), 26 deletions(-) create mode 100644 app/Policies/OnlinePaymentHistoryPolicy.php diff --git a/app/Models/Payment/OnlinePaymentHistory.php b/app/Models/Payment/OnlinePaymentHistory.php index 8899e8f..bcdd222 100644 --- a/app/Models/Payment/OnlinePaymentHistory.php +++ b/app/Models/Payment/OnlinePaymentHistory.php @@ -17,30 +17,9 @@ class OnlinePaymentHistory extends Model protected $table = 'online_payment_histories'; /** - * The attributes that are mass assignable. + * Guarded attributes * - * @var array + * @var array */ - protected $fillable = [ - 'refunded_amount', - 'booking_number', - 'amount', - 'depositedAmount', - 'orderNumber', - 'description', - 'orderId', - 'cardholderName', - 'pan', - 'approvalCode', - 'expiration', - 'formUrl', - 'successUrl', - 'errorUrl', - 'api_client', - 'paymentStatus', - 'callbackStatus', - 'username', - 'online_paymantable_id', - 'online_paymantable_type', - ]; + protected $guarded = []; } diff --git a/app/Nova/Actions/MakePaymentNovaVisaMaster.php b/app/Nova/Actions/MakePaymentNovaVisaMaster.php index dd32008..98fec64 100644 --- a/app/Nova/Actions/MakePaymentNovaVisaMaster.php +++ b/app/Nova/Actions/MakePaymentNovaVisaMaster.php @@ -154,7 +154,7 @@ class MakePaymentNovaVisaMaster extends Action OnlinePaymentHistory::create([ 'online_paymantable_id' => $resource->id, 'online_paymantable_type' => '\App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder', - 'amount' => $onlinePaymentRepo->getPrice($paymentMethod == 'usd' ? '902.38' : '1058,60'), + 'amount' => number_format($amount, 2, '', ''), 'orderNumber' => $orderNumber, 'description' => 'Visa/Master tölegi', 'orderId' => $paymentResponse['orderId'], @@ -162,7 +162,7 @@ class MakePaymentNovaVisaMaster extends Action 'successUrl' => route('online-payment-store-visa-master'), 'errorUrl' => route('online-payment-store-visa-master'), 'api_client' => config('app.url'), - 'username' => $resource->branch->billing_username, + 'username' => $resource->branch->billing_visa_master_username, 'paymentStatus' => OnlinePaymentRepo::PENDING, ]); diff --git a/app/Policies/OnlinePaymentHistoryPolicy.php b/app/Policies/OnlinePaymentHistoryPolicy.php new file mode 100644 index 0000000..d653687 --- /dev/null +++ b/app/Policies/OnlinePaymentHistoryPolicy.php @@ -0,0 +1,66 @@ +isAdmin(); + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, OnlinePaymentHistory $onlinePaymentHistory): bool + { + return $user->isAdmin(); + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return false; + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, OnlinePaymentHistory $onlinePaymentHistory): bool + { + return false; + } + + /** + * Determine whether the user can delete the model. + */ + public function delete(User $user, OnlinePaymentHistory $onlinePaymentHistory): bool + { + return false; + } + + /** + * Determine whether the user can restore the model. + */ + public function restore(User $user, OnlinePaymentHistory $onlinePaymentHistory): bool + { + return false; + } + + /** + * Determine whether the user can permanently delete the model. + */ + public function forceDelete(User $user, OnlinePaymentHistory $onlinePaymentHistory): bool + { + return false; + } +} diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index bbcd1fa..29e5e4b 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -7,12 +7,14 @@ use App\Models\Order\Card\CardState; use App\Models\Order\Card\CardType; use App\Models\Order\Loan\LoanOrder; use App\Models\Order\Loan\LoanType; +use App\Models\Payment\OnlinePaymentHistory; use App\Models\System\Locale\LocaleManager; use App\Models\System\Location\Province; use App\Models\System\Roles\Permission; use App\Models\System\Roles\Role; use App\Models\User; use App\Policies\Branch\BranchPolicy; +use App\Policies\OnlinePaymentHistoryPolicy; use App\Policies\Order\Card\CardStatePolicy; use App\Policies\Order\Card\CardTypePolicy; use App\Policies\Order\Loan\LoanOrderPolicy; @@ -61,6 +63,9 @@ class AuthServiceProvider extends ServiceProvider // ActionsEvents... ActionEvent::class => ActionEventPolicy::class, + + // Online payment history... + OnlinePaymentHistory::class => OnlinePaymentHistoryPolicy::class, ]; /**