Compare commits
3 Commits
9ba3a6e623
...
68d544b9c3
| Author | SHA1 | Date | |
|---|---|---|---|
| 68d544b9c3 | |||
| b0038d3e94 | |||
| 64dc80e069 |
@@ -4,8 +4,22 @@ namespace App\Filament\Clusters\Cards\CardOrders\Pages;
|
|||||||
|
|
||||||
use App\Filament\Clusters\Cards\CardOrders\CardOrderResource;
|
use App\Filament\Clusters\Cards\CardOrders\CardOrderResource;
|
||||||
use Filament\Resources\Pages\CreateRecord;
|
use Filament\Resources\Pages\CreateRecord;
|
||||||
|
use Illuminate\Support\Facades\URL;
|
||||||
|
|
||||||
class CreateCardOrder extends CreateRecord
|
class CreateCardOrder extends CreateRecord
|
||||||
{
|
{
|
||||||
protected static string $resource = CardOrderResource::class;
|
protected static string $resource = CardOrderResource::class;
|
||||||
|
|
||||||
|
protected function getRedirectUrl(): string
|
||||||
|
{
|
||||||
|
$defaultUrl = $this->getResource()::getUrl('index');
|
||||||
|
|
||||||
|
return $defaultUrl;
|
||||||
|
|
||||||
|
// $payment = (new OnlinePaymentRepo)->payCardOrder($resource);
|
||||||
|
|
||||||
|
// $payment['status'] === 'success'
|
||||||
|
// ? URL::remote($payment['url'])
|
||||||
|
// : $defaultUrl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Filament\Clusters\Cards\CardOrders\Tables;
|
namespace App\Filament\Clusters\Cards\CardOrders\Tables;
|
||||||
|
|
||||||
|
use App\Modules\OrderStatus\Repositories\OrderStatusRepository;
|
||||||
|
use App\Modules\Region\Repositories\RegionRepository;
|
||||||
use Filament\Actions\BulkActionGroup;
|
use Filament\Actions\BulkActionGroup;
|
||||||
use Filament\Actions\DeleteBulkAction;
|
use Filament\Actions\DeleteBulkAction;
|
||||||
use Filament\Actions\EditAction;
|
use Filament\Actions\EditAction;
|
||||||
@@ -19,64 +21,58 @@ class CardOrdersTable
|
|||||||
return $table
|
return $table
|
||||||
->columns([
|
->columns([
|
||||||
TextColumn::make('unique_id')
|
TextColumn::make('unique_id')
|
||||||
|
->label(__('ID'))
|
||||||
->searchable(),
|
->searchable(),
|
||||||
|
|
||||||
TextColumn::make('cardState.name')
|
TextColumn::make('cardState.name')
|
||||||
|
->label(__('Reason'))
|
||||||
->searchable(),
|
->searchable(),
|
||||||
|
|
||||||
TextColumn::make('cardType.name')
|
TextColumn::make('cardType.name')
|
||||||
|
->label(__('Card type'))
|
||||||
->searchable(),
|
->searchable(),
|
||||||
TextColumn::make('region')
|
|
||||||
->searchable(),
|
|
||||||
TextColumn::make('branch.name')
|
|
||||||
->searchable(),
|
|
||||||
TextColumn::make('customer_name')
|
|
||||||
->searchable(),
|
|
||||||
TextColumn::make('customer_surname')
|
|
||||||
->searchable(),
|
|
||||||
TextColumn::make('customer_patronic_name')
|
|
||||||
->searchable(),
|
|
||||||
TextColumn::make('born_at')
|
|
||||||
->date()
|
|
||||||
->sortable(),
|
|
||||||
TextColumn::make('old_surname')
|
|
||||||
->searchable(),
|
|
||||||
TextColumn::make('citizenship')
|
|
||||||
->searchable(),
|
|
||||||
TextColumn::make('passport_serie')
|
|
||||||
->searchable(),
|
|
||||||
TextColumn::make('passport_id')
|
|
||||||
->searchable(),
|
|
||||||
TextColumn::make('passport_given_at')
|
|
||||||
->date()
|
|
||||||
->sortable(),
|
|
||||||
TextColumn::make('passport_given_by')
|
|
||||||
->searchable(),
|
|
||||||
TextColumn::make('born_place')
|
|
||||||
->searchable(),
|
|
||||||
TextColumn::make('job_location')
|
|
||||||
->searchable(),
|
|
||||||
TextColumn::make('passport_address')
|
|
||||||
->searchable(),
|
|
||||||
TextColumn::make('real_address')
|
|
||||||
->searchable(),
|
|
||||||
TextColumn::make('phone')
|
|
||||||
->searchable(),
|
|
||||||
TextColumn::make('phone_additional')
|
|
||||||
->searchable(),
|
|
||||||
TextColumn::make('status')
|
|
||||||
->searchable(),
|
|
||||||
TextColumn::make('user.name')
|
|
||||||
->searchable(),
|
|
||||||
IconColumn::make('paid')
|
|
||||||
->boolean(),
|
|
||||||
TextColumn::make('created_at')
|
TextColumn::make('created_at')
|
||||||
|
->label(__('Created At'))
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable()
|
->sortable(),
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
|
||||||
|
TextColumn::make('region')
|
||||||
|
->label(__('Region'))
|
||||||
|
->formatStateUsing(fn (string $state): string => RegionRepository::label($state))
|
||||||
|
->searchable(),
|
||||||
|
|
||||||
|
TextColumn::make('branch.name')
|
||||||
|
->label(__('Branch'))
|
||||||
|
->searchable(),
|
||||||
|
|
||||||
|
TextColumn::make('customer_name')
|
||||||
|
->label(__('Name'))
|
||||||
|
->searchable(),
|
||||||
|
|
||||||
|
TextColumn::make('customer_surname')
|
||||||
|
->label(__('Surname'))
|
||||||
|
->searchable(),
|
||||||
|
|
||||||
|
IconColumn::make('paid')
|
||||||
|
->label(__('Paid'))
|
||||||
|
->boolean(),
|
||||||
|
|
||||||
|
TextColumn::make('phone')
|
||||||
|
->label(__('Phone'))
|
||||||
|
->searchable(),
|
||||||
|
|
||||||
|
TextColumn::make('status')
|
||||||
|
->formatStateUsing(fn (string $state) => OrderStatusRepository::statusFormatted($state))
|
||||||
|
->searchable(),
|
||||||
|
|
||||||
TextColumn::make('updated_at')
|
TextColumn::make('updated_at')
|
||||||
|
->label(__('Updated At'))
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
TextColumn::make('deleted_at')
|
TextColumn::make('deleted_at')
|
||||||
|
->label(__('Deleted At'))
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Filament\Clusters\Cards\Cards;
|
namespace App\Filament\Clusters\Cards\Cards;
|
||||||
|
|
||||||
use App\Filament\Clusters\Cards\CardsCluster;
|
|
||||||
use App\Filament\Clusters\Cards\Cards\Pages\ManageCards;
|
use App\Filament\Clusters\Cards\Cards\Pages\ManageCards;
|
||||||
|
use App\Filament\Clusters\Cards\CardsCluster;
|
||||||
use App\Modules\AppHelpers\Repositories\DateHelper;
|
use App\Modules\AppHelpers\Repositories\DateHelper;
|
||||||
|
use App\Modules\Card\Models\Card;
|
||||||
use App\Modules\CardBalance\Repositories\CardBalanceRepository;
|
use App\Modules\CardBalance\Repositories\CardBalanceRepository;
|
||||||
use App\Modules\CardRequisite\Repositories\CardRequisiteRepository;
|
use App\Modules\CardRequisite\Repositories\CardRequisiteRepository;
|
||||||
use App\Modules\CardTransaction\Repositories\CardTransactionRepository;
|
use App\Modules\CardTransaction\Repositories\CardTransactionRepository;
|
||||||
use App\Modules\Card\Models\Card;
|
|
||||||
use BackedEnum;
|
use BackedEnum;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Actions\BulkActionGroup;
|
use Filament\Actions\BulkActionGroup;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class UserProfileFields extends Component implements HasForms
|
|||||||
->description(__('Fill your account profile information'))
|
->description(__('Fill your account profile information'))
|
||||||
->schema([
|
->schema([
|
||||||
TextInput::make('first_name')
|
TextInput::make('first_name')
|
||||||
->label(__('First name'))
|
->label(__('Name'))
|
||||||
->string()
|
->string()
|
||||||
->maxLength(255)
|
->maxLength(255)
|
||||||
->default(user()->first_name)
|
->default(user()->first_name)
|
||||||
@@ -51,7 +51,7 @@ class UserProfileFields extends Component implements HasForms
|
|||||||
->required(),
|
->required(),
|
||||||
|
|
||||||
TextInput::make('last_name')
|
TextInput::make('last_name')
|
||||||
->label(__('Last name'))
|
->label(__('Surname'))
|
||||||
->string()
|
->string()
|
||||||
->maxLength(255)
|
->maxLength(255)
|
||||||
->default(user()->last_name)
|
->default(user()->last_name)
|
||||||
@@ -89,6 +89,7 @@ class UserProfileFields extends Component implements HasForms
|
|||||||
->label(__('Email'))
|
->label(__('Email'))
|
||||||
->email()
|
->email()
|
||||||
->default(user()->email)
|
->default(user()->email)
|
||||||
|
->unique(ignoreRecord: false)
|
||||||
->columnSpan(2),
|
->columnSpan(2),
|
||||||
|
|
||||||
Fieldset::make(__('Passport'))
|
Fieldset::make(__('Passport'))
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<?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::create('online_payments', function (Blueprint $table) {
|
||||||
|
$table->string('refunded_amount')->nullable();
|
||||||
|
$table->string('booking_number')->nullable()->index();
|
||||||
|
$table->string('amount')->nullable();
|
||||||
|
$table->string('depositedAmount')->nullable();
|
||||||
|
$table->string('orderNumber')->nullable()->index();
|
||||||
|
$table->string('description')->nullable();
|
||||||
|
|
||||||
|
$table->string('orderId')->nullable()->index();
|
||||||
|
$table->string('cardholderName')->nullable()->index();
|
||||||
|
$table->string('pan')->nullable()->index();
|
||||||
|
|
||||||
|
$table->string('expiration')->nullable();
|
||||||
|
$table->string('formUrl')->nullable();
|
||||||
|
$table->string('successUrl')->nullable();
|
||||||
|
$table->string('errorUrl')->nullable();
|
||||||
|
|
||||||
|
$table->string('paymentStatus')->nullable()->index();
|
||||||
|
$table->string('callbackStatus')->nullable();
|
||||||
|
$table->string('username')->nullable()->index();
|
||||||
|
$table->string('approvalCode')->nullable();
|
||||||
|
|
||||||
|
$table->unsignedBigInteger('online_paymantable_id')->index()->nullable();
|
||||||
|
$table->string('online_paymantable_type')->index()->nullable();
|
||||||
|
|
||||||
|
$table->string('api_client')->nullable()->index();
|
||||||
|
$table->json('api_response')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('online_payments');
|
||||||
|
}
|
||||||
|
};
|
||||||
46
app/Modules/OnlinePayment/Models/OnlinePayment.php
Normal file
46
app/Modules/OnlinePayment/Models/OnlinePayment.php
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\OnlinePayment\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $id
|
||||||
|
* @property string $refunded_amount
|
||||||
|
* @property string $booking_number
|
||||||
|
* @property string $amount
|
||||||
|
* @property string $depositedAmount
|
||||||
|
* @property string $orderNumber
|
||||||
|
* @property string $description
|
||||||
|
* @property string $orderId
|
||||||
|
* @property string $cardholderName
|
||||||
|
* @property string $pan
|
||||||
|
* @property string $approvalCode
|
||||||
|
* @property string $expiration
|
||||||
|
* @property string $formUrl
|
||||||
|
* @property string $successUrl
|
||||||
|
* @property string $errorUrl
|
||||||
|
* @property string $api_client
|
||||||
|
* @property string $paymentStatus
|
||||||
|
* @property string $callbackStatus
|
||||||
|
* @property string $username
|
||||||
|
* @property int $online_paymantable_id
|
||||||
|
* @property string $online_paymantable_type
|
||||||
|
* @property ?array $api_response
|
||||||
|
* @property \Illuminate\Support\Carbon $created_at
|
||||||
|
* @property \Illuminate\Support\Carbon $updated_at
|
||||||
|
*/
|
||||||
|
class OnlinePayment extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the attributes that should be cast.
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'api_response' => 'array',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
64
app/Modules/OnlinePayment/OnlinePaymentModule.php
Normal file
64
app/Modules/OnlinePayment/OnlinePaymentModule.php
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\OnlinePayment;
|
||||||
|
|
||||||
|
use App\Modules\Makeable;
|
||||||
|
use App\Modules\ModuleContract;
|
||||||
|
|
||||||
|
class OnlinePaymentModule implements ModuleContract
|
||||||
|
{
|
||||||
|
use Makeable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module is enabled
|
||||||
|
*/
|
||||||
|
protected bool $enabled = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if is module enabled
|
||||||
|
*/
|
||||||
|
public function isEnabled(): bool
|
||||||
|
{
|
||||||
|
return $this->enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable module
|
||||||
|
*/
|
||||||
|
public function disable(): void
|
||||||
|
{
|
||||||
|
$this->enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable module
|
||||||
|
*/
|
||||||
|
public function enable(): void
|
||||||
|
{
|
||||||
|
$this->enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if module has a filament resource
|
||||||
|
*/
|
||||||
|
public function hasFilamentResource(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get module composer requirements
|
||||||
|
*/
|
||||||
|
public function getComposerRequirements(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get module composer suggestions
|
||||||
|
*/
|
||||||
|
public function getComposerSuggestions(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\OnlinePayment\Repositories;
|
||||||
|
|
||||||
|
use App\Modules\CardOrder\Models\CardOrder;
|
||||||
|
use App\Modules\OnlinePayment\Models\OnlinePayment;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class OnlinePaymentRepository
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Pending online payments
|
||||||
|
*/
|
||||||
|
public const PENDING = 'pending';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Failed online payments
|
||||||
|
*/
|
||||||
|
public const FAILED = 'failed';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Paid online payments
|
||||||
|
*/
|
||||||
|
public const PAID = 'paid';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Status Values
|
||||||
|
*
|
||||||
|
* @return array<null|string, string>
|
||||||
|
*/
|
||||||
|
public static function statusValues(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
null => '-',
|
||||||
|
self::PENDING => __('Pending'),
|
||||||
|
self::PAID => __('Paid'),
|
||||||
|
self::FAILED => __('Cancelled'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set price
|
||||||
|
*/
|
||||||
|
public function getPrice(int|float|string $price): string
|
||||||
|
{
|
||||||
|
return number_format(floatval($price), 2, '', '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pay card order
|
||||||
|
*
|
||||||
|
* @param mixed $resource
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public function payCardOrder()
|
||||||
|
{
|
||||||
|
$orderNumber = $this->generateOrderNumber();
|
||||||
|
|
||||||
|
// $paymentResponse = Http::get('https://mpi.gov.tm/payment/rest/register.do', [
|
||||||
|
// 'orderNumber' => $orderNumber,
|
||||||
|
// 'amount' => $this->getPrice($resource->priceAmount()),
|
||||||
|
// 'currency' => 934,
|
||||||
|
// 'language' => 'ru',
|
||||||
|
// 'userName' => $resource->branch->billing_username,
|
||||||
|
// 'password' => $resource->branch->billing_password,
|
||||||
|
// 'returnUrl' => route('online-payment-store'),
|
||||||
|
// 'pageView' => 'DESKTOP',
|
||||||
|
// 'description' => 'Kart tölegi',
|
||||||
|
// ])->onError(function ($response) {
|
||||||
|
// Log::channel('halkbank_payment_error')
|
||||||
|
// ->error('Payment error', [
|
||||||
|
// 'response' => [
|
||||||
|
// 'body' => $response->body(),
|
||||||
|
// ],
|
||||||
|
// ]);
|
||||||
|
// });
|
||||||
|
|
||||||
|
// if ($paymentResponse->failed()) {
|
||||||
|
// return [
|
||||||
|
// 'status' => 'failed',
|
||||||
|
// 'url' => '',
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $onlinePaymentHistory = new OnlinePayment;
|
||||||
|
// $onlinePaymentHistory->online_paymantable_id = $resource->really();
|
||||||
|
// $onlinePaymentHistory->online_paymantable_type = CardOrder::class;
|
||||||
|
// $onlinePaymentHistory->amount = $resource->priceAmount();
|
||||||
|
// $onlinePaymentHistory->orderNumber = $orderNumber;
|
||||||
|
// $onlinePaymentHistory->description = 'Kart tölegi';
|
||||||
|
// $onlinePaymentHistory->orderId = $paymentResponse['orderId'];
|
||||||
|
// $onlinePaymentHistory->formUrl = $paymentResponse['formUrl'];
|
||||||
|
// $onlinePaymentHistory->successUrl = route('online-payment-store');
|
||||||
|
// $onlinePaymentHistory->errorUrl = route('online-payment-store');
|
||||||
|
// $onlinePaymentHistory->api_client = 'billing_username';
|
||||||
|
// $onlinePaymentHistory->username = $resource->branch->billing_username;
|
||||||
|
// $onlinePaymentHistory->paymentStatus = self::PENDING;
|
||||||
|
// $onlinePaymentHistory->save();
|
||||||
|
|
||||||
|
// return [
|
||||||
|
// 'status' => 'success',
|
||||||
|
// 'url' => $paymentResponse['formUrl'],
|
||||||
|
// ];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate order number for payment
|
||||||
|
*/
|
||||||
|
public function generateOrderNumber(): string
|
||||||
|
{
|
||||||
|
return date('dmyHis');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -85,7 +85,6 @@ class WorkPanelProvider extends PanelProvider
|
|||||||
])
|
])
|
||||||
->spa()
|
->spa()
|
||||||
->databaseTransactions()
|
->databaseTransactions()
|
||||||
->breadcrumbs(false)
|
|
||||||
->colors([
|
->colors([
|
||||||
'danger' => Color::Rose,
|
'danger' => Color::Rose,
|
||||||
'gray' => Color::Gray,
|
'gray' => Color::Gray,
|
||||||
|
|||||||
Reference in New Issue
Block a user