This commit is contained in:
2024-11-23 17:19:25 +05:00
parent 2aa8bf9869
commit d8f847346b
7 changed files with 51 additions and 19 deletions

View File

@@ -202,18 +202,21 @@ function localeAppUrl(): string
return config('app.locale_app.url'); return config('app.locale_app.url');
} }
function convertToOriginalFormat($apiPrice) { function convertToOriginalFormat($apiPrice)
{
// Convert to float and divide by 100 // Convert to float and divide by 100
$originalPrice = intval($apiPrice) / 100; $originalPrice = intval($apiPrice) / 100;
return number_format($originalPrice, 2, '.', ''); // Format with 2 decimal places return number_format($originalPrice, 2, '.', ''); // Format with 2 decimal places
} }
function lastDayOfMonth($month, $year) { function lastDayOfMonth($month, $year)
{
// Create a DateTime object for the first day of the given month // Create a DateTime object for the first day of the given month
$date = new DateTime("$year-$month-01"); $date = new DateTime("$year-$month-01");
// Modify the date to the last day of the same month // Modify the date to the last day of the same month
$date->modify('last day of this month'); $date->modify('last day of this month');
// Return the formatted date // Return the formatted date
return $date->format('d'); return $date->format('d');
} }

View File

@@ -79,7 +79,7 @@ class OnlinePaymentController extends Controller
public function visaMaster(OnlinePaymentStoreRequest $request) public function visaMaster(OnlinePaymentStoreRequest $request)
{ {
$data = OnlinePaymentRepo::checkPayment($request); $data = OnlinePaymentRepo::checkPaymentVisaMaster($request);
return view(OnlinePaymentRepo::statusView(), $data); return view(OnlinePaymentRepo::statusView(), $data);
} }

View File

@@ -6,12 +6,14 @@ use App\Models\Branch\Branch;
use App\Repos\Order\Loan\LoanOrderRepo; use App\Repos\Order\Loan\LoanOrderRepo;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia; use Spatie\MediaLibrary\InteractsWithMedia;
class SberPaymentOrder extends Model implements HasMedia class SberPaymentOrder extends Model implements HasMedia
{ {
use InteractsWithMedia; use InteractsWithMedia;
use SoftDeletes;
/** /**
* Table * Table

View File

@@ -330,7 +330,17 @@ class NovaSberPaymentOrder extends Resource
return [ return [
MakeSberPaymentAction::make() MakeSberPaymentAction::make()
->icon('credit-card') ->icon('credit-card')
->sole(), ->sole()
->canSee(function ($request) {
if (in_array($this->resource->status, [
OrderRepo::PENDING,
OrderRepo::CANCELLED,
])) {
return false;
}
return true;
}),
]; ];
} }
} }

View File

@@ -7,17 +7,6 @@ use Illuminate\Http\Request;
trait NovaVisaMasterPaymentOrderItemAuth trait NovaVisaMasterPaymentOrderItemAuth
{ {
/**
* Determine if the current user can view the given resource.
*
* @param \Illuminate\Http\Request $request
* @return bool
*/
public function authorizedToView(Request $request): bool
{
return false;
}
/** Edit button */ /** Edit button */
public function authorizedToUpdate(Request $request): bool public function authorizedToUpdate(Request $request): bool
{ {

View File

@@ -156,7 +156,7 @@ class OnlinePaymentRepo
return 'orders.cards.online-payment.status'; return 'orders.cards.online-payment.status';
} }
public static function checkPayment(Request $request) public static function checkPaymentVisaMaster(Request $request)
{ {
// Find order from history // Find order from history
$paymentHistory = OnlinePaymentHistory::where('orderId', $request->orderId)->first(); $paymentHistory = OnlinePaymentHistory::where('orderId', $request->orderId)->first();
@@ -208,8 +208,8 @@ class OnlinePaymentRepo
'title' => $payment_status ? __('Payment is successful') : __('Payment has failed'), 'title' => $payment_status ? __('Payment is successful') : __('Payment has failed'),
'pnr' => $paymentHistory->orderNumber, 'pnr' => $paymentHistory->orderNumber,
'branch_name' => $bank_branch->name, 'branch_name' => $bank_branch->name,
'price_amount' => convertToOriginalFormat($paymentHistory->amount) . ' TMT', 'price_amount' => convertToOriginalFormat($paymentHistory->amount).' TMT',
'return_url' => url('/work-place/resources/nova-visa-master-payment-orders/' . $resource->visa_master_payment_order_id), 'return_url' => url('/work-place/resources/nova-visa-master-payment-orders/'.$resource->visa_master_payment_order_id),
]; ];
} }

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('sber_payment_orders', function (Blueprint $table) {
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('sber_payment_orders', function (Blueprint $table) {
$table->dropSoftDeletes();
});
}
};