Compare commits

...

25 Commits

Author SHA1 Message Date
98b9d5cbca add trancactions report 2026-07-06 14:02:27 +03:30
8002679ca2 check status | sync status 2026-07-04 15:52:01 +03:30
1f8bd224a3 stage 2026-06-07 21:36:06 +03:30
08b0cd4cca Merge pull request 'add authorization to all fib services' (#31) from feature/FibDTO into develop
Reviewed-on: #31
2026-06-02 10:34:11 +00:00
6db74f557b add authorization to all fib services 2026-06-02 14:03:58 +03:30
4eec548b83 Merge pull request 'add three column in user_gateways and use them in controller' (#30) from feature/GetClient into develop
Reviewed-on: #30
2026-06-01 13:06:13 +00:00
675d2bdbad fix clied password nd fix rote for expert 2026-06-01 16:36:02 +03:30
69ffe322ce fix migration 2026-06-01 15:34:54 +03:30
a1466d8f57 fix migration 2026-06-01 15:33:06 +03:30
392fca8635 add three column in user_gateways and use them in controller 2026-06-01 15:26:09 +03:30
9a01a83370 Merge pull request 'feature/payment_creation_phase_1' (#28) from feature/payment_creation_phase_1 into develop
Reviewed-on: #28
2026-05-28 13:30:34 +00:00
8438655f8c Merge pull request 'feature/FixLogin' (#27) from feature/FixLogin into develop
Reviewed-on: #27
2026-05-25 12:48:50 +00:00
5040299efc fix user resource and profil 2026-05-25 16:18:08 +03:30
26a0f79a6d fix enum for gateway managment 2026-05-25 16:12:14 +03:30
1b5d339a53 fix login code in3 point 2026-05-25 15:00:44 +03:30
c73d50d096 Merge pull request 'change show province' (#26) from feature/GetCity into develop
Reviewed-on: #26
2026-05-23 13:08:23 +00:00
8be89d350f change show province 2026-05-23 16:36:40 +03:30
d31c641216 Merge pull request 'create seeder for city and province' (#25) from feature/ProvinceAndCitySeeder into develop
Reviewed-on: #25
2026-05-23 11:54:56 +00:00
aa363d1695 Merge pull request 'feature/CreateSeedrStatus' (#24) from feature/CreateSeedrStatus into develop
Reviewed-on: #24
2026-05-23 11:51:20 +00:00
ca2ec66fb5 resolve the conflicts 2026-05-23 15:21:15 +03:30
5c757e1823 create seeder for city and province 2026-05-23 15:13:12 +03:30
d9f895c382 create seeder for city and province 2026-05-23 14:55:00 +03:30
9ad3d6cea0 create show for city and province 2026-05-23 14:03:10 +03:30
8554f4cc55 create list for city and province 2026-05-23 13:49:09 +03:30
5e48777e1c create list for city and province 2026-05-23 13:45:05 +03:30
41 changed files with 993 additions and 253 deletions

View File

@@ -16,19 +16,6 @@ class AuthController extends Controller
{
use ApiResponse;
public function register(RegisterRequest $request): JsonResponse
{
Expert::query()->create([
'username' => $request->username,
'email' => $request->email,
'password' => Hash::make($request->password),
]);
$request->session()->regenerate();
return $this->successResponse();
}
public function login(LoginRequest $request): JsonResponse
{
$credentials = ['password' => $request->password];
@@ -39,8 +26,7 @@ class AuthController extends Controller
$credentials['username'] = $request->login;
}
if (Auth::attempt($credentials))
{
if (Auth::guard('expert')->attempt($credentials)) {
$request->session()->regenerate();
return $this->successResponse();

View File

@@ -41,7 +41,7 @@ enum BusinessTypeEnum: int
};
}
public function name($id): string
public static function name($id): string
{
$mapArray = [
1 => 'medical',

View File

@@ -2,22 +2,28 @@
namespace App\Enums;
enum PaymentStatusEnum:int
enum PaymentStatusEnum: int
{
case Unpaid = 0;
case UNPAID = 0;
case Cancelled = 1;
case Expired = 2;
case Paid = 3;
case Refunded = 4;
case PAID = 3;
case REFUNDED = 4;
case PendingVerification = 5;
case REFUND_REQUESTED = 6;
public function label(): string
{
return match ($this) {
self::Unpaid => 'unpaid',
self::Cancelled => 'cancelled',
self::Expired => 'expired',
self::Paid => 'paid',
self::Refunded => 'refunded',
self::UNPAID => 'UNPAID',
self::Cancelled => 'CANCELLED',
self::Expired => 'EXPIRED',
self::PAID => 'PAID',
self::REFUNDED => 'REFUNDED',
self::REFUND_REQUESTED => 'REFUND_REQUESTED',
self::PendingVerification => 'PENDING_VERIFICATION',
};
}
}

View File

@@ -5,17 +5,19 @@ namespace App\Models;
use Database\Factories\ExpertFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Spatie\Permission\Traits\HasRoles;
/**
* @method roles()
* @method permissions()
*/
class Expert extends Model
class Expert extends Authenticatable
{
/** @use HasFactory<ExpertFactory> */
use HasFactory;
use HasRoles;
use Notifiable,HasFactory,HasRoles;
protected $guarded = ['id'];
protected string $guard_name = 'web';

View File

@@ -4,6 +4,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class FibTransaction extends Model
{
@@ -11,4 +12,14 @@ class FibTransaction extends Model
use HasFactory;
protected $guarded = ['id'];
public function transaction(): BelongsTo
{
return $this->belongsTo(Transaction::class);
}
public function payment(): BelongsTo
{
return $this->belongsTo(Payment::class);
}
}

View File

@@ -5,6 +5,7 @@ namespace App\Models;
use Database\Factories\TransactionFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Transaction extends Model
{
@@ -12,4 +13,9 @@ class Transaction extends Model
use HasFactory;
protected $guarded = ['id'];
public function payment(): BelongsTo
{
return $this->belongsTo(Payment::class);
}
}

View File

@@ -24,7 +24,7 @@ class User extends Authenticatable
public function documents(): MorphToMany
{
return $this->morphToMany(Document::class, 'documentable');
return $this->morphToMany(Document::class, 'documents');
}
public function validateForPassportPasswordGrant(string $password): bool

View File

@@ -11,21 +11,13 @@ class CancelPaymentService
{
protected string $url;
protected string $channelName;
protected string $accessToken;
protected array $headers;
protected AuthorizationService $authorizationService;
public function __construct()
public function __construct(AuthorizationService $authorizationService)
{
$this->url = config('fib.cancelPayment.url');
$this->channelName = '';
}
public function setHeaders(): void
{
$this->headers = [
'Authorization' => 'Bearer ' . $this->accessToken,
'Content-Type' => 'application/json',
];
$this->authorizationService = $authorizationService;
}
/**
@@ -50,13 +42,26 @@ class CancelPaymentService
/**
* @throws ConnectionException
* @throws Exception
*/
public function sendRequest(): array
{
return Http::withHeaders($this->headers)
return Http::withHeaders([
'Authorization' => 'Bearer ' . $this->getToken(),
'Content-Type' => 'application/json',
])
->throw()
->withoutVerifying()
->post($this->url)
->json();
}
/**
* @throws Exception
*/
public function getToken(): string
{
$data = $this->authorizationService->run();
return $data['access_token'];
}
}

View File

@@ -11,41 +11,56 @@ class CheckPaymentStatusService
{
protected string $url;
protected string $channelName;
protected AuthorizationService $authorization_service;
public function __construct()
public function __construct(AuthorizationService $authorization_service)
{
$this->url = config('fib.checkPaymentStatus.url');
$this->channelName = '';
$this->url = 'https://fib-stage.fib.iq/protected/v1/payments/';
$this->channelName = 'fib_status';
$this->authorization_service = $authorization_service;
}
/**
* @throws Exception
*/
public function run(): array
public function run(string $fib_payment_id): array
{
try {
return $this->sendRequest();
}
catch (Exception $e) {
return $this->sendRequest($fib_payment_id);
} catch (Exception $e) {
Log::channel($this->channelName)
->error(get_class($this),
[
'message' => $e->getMessage(),
]
);
throw $e;
}
}
/**
* @throws ConnectionException
* @throws Exception
*/
public function sendRequest(): array
public function sendRequest(string $fib_payment_id): array
{
return Http::throw()
$url = rtrim($this->url, '/') . "/{$fib_payment_id}/status";
return Http::withHeaders([
'Authorization' => 'Bearer ' . $this->getToken(),
'Accept' => 'application/json',
])
->throw()
->withoutVerifying()
->post($this->url)
->get($url)
->json();
}
/**
* @throws Exception
*/
public function getToken(): string
{
$data = $this->authorization_service->run();
return $data['access_token'];
}
}

View File

@@ -11,27 +11,14 @@ class CreatePaymentService
{
protected string $url;
protected string $channelName;
protected string $accessToken;
protected array $headers;
protected array $inputParameters;
protected AuthorizationService $authorizationService;
public function __construct()
public function __construct(AuthorizationService $authorizationService)
{
$this->url = config('fib.createPayment.url');
$this->channelName = '';
}
public function setAccessToken(string $accessToken): void
{
$this->accessToken = $accessToken;
}
public function setHeaders(): void
{
$this->headers = [
'Authorization' => 'Bearer ' . $this->accessToken,
'Content-Type' => 'application/json',
];
$this->channelName = 'fib_create_payment';
$this->authorizationService = $authorizationService;
}
public function setInputParameters(array $inputParameters): void
@@ -61,13 +48,26 @@ class CreatePaymentService
/**
* @throws ConnectionException
* @throws Exception
*/
public function sendRequest(): array
{
return Http::withHeaders($this->headers)
return Http::withHeaders([
'Authorization' => 'Bearer ' . $this->getToken(),
'Content-Type' => 'application/json',
])
->throw()
->withoutVerifying()
->post($this->url, $this->inputParameters)
->json();
}
/**
* @throws Exception
*/
public function getToken(): string
{
$data = $this->authorizationService->run();
return $data['access_token'];
}
}

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Services\Payments\DTO;
namespace App\Services\FIB\DTO;
class FIBPaymentCreateDTO
{
@@ -26,13 +26,13 @@ class FIBPaymentCreateDTO
public static function fromResponse($data): FIBPaymentCreateDTO
{
return new self([
'paymentId' => $data->paymentId,
'readableCode' => $data->readableCode,
'qrCode' => $data->qrCode,
'validUntil' => $data->validUntil,
'personalAppLink' => $data->personalAppLink,
'businessAppLink' => $data->businessAppLink,
'corporateAppLink' => $data->corporateAppLink,
'paymentId' => $data['paymentId'],
'readableCode' => $data['readableCode'],
'qrCode' => $data['qrCode'],
'validUntil' => $data['validUntil'],
'personalAppLink' => $data['personalAppLink'],
'businessAppLink' => $data['businessAppLink'],
'corporateAppLink' => $data['corporateAppLink'],
]);
}
}

View File

@@ -1,86 +0,0 @@
<?php
namespace App\Services\FIB;
use Illuminate\Support\Facades\Http;
class FIBClient
{
public $auth_service;
public $create_payment_service;
public function __construct()
{
}
public function client()
{
return Http::acceptJson()
->contentType('application/json')
->withToken($this->getAccessToken())
->timeout(30);
}
public function getAccessToken()
{
try {
if ($this->isNotProduction()) {
return json_decode(
file_get_contents(storage_path('app/mock/fib/token.json'))
);
}
$response = Http::withOptions([
'proxy' => 'http://host.docker.internal:10808',
])->asForm()->post('https://fib-stage.fib.iq/auth/realms/fib-online-shop/protocol/openid-connect/token', [
'grant_type' => 'client_credentials',
'client_id' => 'ipay-test-payment',
'client_secret' => '8dae3180-f39c-448e-8b45-a01c8f4c8c15',
]);
if ($response->failed()) {
throw new \Exception(
'Unable to authenticate with FIB: ' .
$response->body()
);
}
$data = $response->json();
if (!isset($data['access_token'])) {
throw new \Exception('FIB token missing in response');
}
return $data['access_token'];
} catch (\Exception $exception) {
return $exception->getMessage();
}
}
public function createPaymentService()
{
if ($this->isNotProduction()) {
return json_decode(
file_get_contents(storage_path('app/mock/fib/payment_create_success.json'))
);
}
$response = $this->client()->post("https://fib-stage.fib.iq/protected/v1/payments");
if ($response->failed()) {
throw new \Exception(
'Unable to authenticate with FIB: ' .
$response->body()
);
}
$data = $response->json();
if (!isset($data['paymentId'])) {
throw new \Exception('FIB paymentId missing in response');
}
return $data;
}
public function isNotProduction()
{
return env('APP_ENV') === 'local';
}
}

View File

@@ -11,21 +11,13 @@ class RefundService
{
protected string $url;
protected string $channelName;
protected string $accessToken;
protected array $headers;
protected AuthorizationService $authorizationService;
public function __construct()
public function __construct(AuthorizationService $authorizationService)
{
$this->url = config('fib.refund.url');
$this->channelName = '';
}
public function setHeaders(): void
{
$this->headers = [
'Authorization' => 'Bearer ' . $this->accessToken,
'Content-Type' => 'application/json',
];
$this->channelName = 'fib_refund';
$this->authorizationService = $authorizationService;
}
/**
@@ -50,13 +42,26 @@ class RefundService
/**
* @throws ConnectionException
* @throws Exception
*/
public function sendRequest(): array
{
return Http::withHeaders($this->headers)
return Http::withHeaders([
'Authorization' => 'Bearer ' . $this->getToken(),
'Content-Type' => 'application/json',
])
->throw()
->withoutVerifying()
->post($this->url)
->json();
}
/**
* @throws Exception
*/
public function getToken(): string
{
$data = $this->authorizationService->run();
return $data['access_token'];
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Services\Payments\Commands;
use App\Models\FibTransaction;
use App\Services\Payments\SyncFibPaymentStatusService;
use Illuminate\Console\Command;
class SyncFibPaymentStatuses extends Command
{
protected $signature = 'payments:sync-fib-statuses';
protected $description = 'Poll FIB for status updates on all pending payments';
public function handle(SyncFibPaymentStatusService $service)
{
$this->info('Syncing FIB payment statuses...');
$service->run();
$this->info('Done.');
}
}

View File

@@ -0,0 +1,40 @@
<?php
namespace App\Services\Payments\Controllers;
use App\Http\Controllers\Controller;
use App\Services\FIB\CheckPaymentStatusService;
use App\Services\Payments\DTO\PaymentCreateDTO;
use App\Services\Payments\PaymentService;
use App\Traits\ApiResponse;
use App\User\Requests\Payment\FIB\InquiryRequest;
use App\User\Requests\Payment\FIB\StoreRequest;
use App\User\Resources\Payment\InquiryResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Js;
class FIBTempController extends Controller
{
use ApiResponse;
public $check_status_service;
public function __construct(CheckPaymentStatusService $check_status_service)
{
$this->check_status_service = $check_status_service;
}
public function checkStatus(Request $request): JsonResponse
{
try {
$result = $this->check_status_service->run('8a6e8f4d-b9fb-44f4-b086-12450939bf5c');
return $this->successResponse($result);
} catch (\Exception $exception) {
throw $exception;
}
}
}

View File

@@ -9,7 +9,6 @@ class PaymentCreateDTO
public string $username;
public int $user_id;
public string $track_id;
public string $amount;
public string $currency;
public string $callback_url;
@@ -21,7 +20,6 @@ class PaymentCreateDTO
{
$this->username = $data['username'];
$this->user_id = $data['user_id'];
$this->track_id = $data['track_id'];
$this->amount = $data['amount'];
$this->currency = $data['currency'];
$this->callback_url = $data['callback_url'];
@@ -35,7 +33,6 @@ class PaymentCreateDTO
return new self([
'username' => $request->username,
'user_id' => '2',
'track_id' => uuid_create(),
'amount' => $request->amount,
'currency' => $request->currency,
'callback_url' => $request->callback_url,

View File

@@ -6,36 +6,66 @@ use App\Enums\PaymentStatusEnum;
use App\Models\FibTransaction;
use App\Models\Payment;
use App\Models\Transaction;
use App\Services\FIB\FIBClient;
use App\Services\Payments\DTO\FIBPaymentCreateDTO;
use App\Models\UserGateway;
use App\Services\FIB\CheckPaymentStatusService;
use App\Services\FIB\CreatePaymentService;
use App\Services\FIB\DTO\FIBPaymentCreateDTO;
use App\Services\Payments\DTO\PaymentCreateDTO;
use Exception;
use Illuminate\Support\Facades\DB;
use Throwable;
class PaymentService
{
public $fib_client;
protected CreatePaymentService $create_payment_service;
protected CheckPaymentStatusService $check_payment_status_service;
public function __construct()
public function __construct(
CreatePaymentService $create_payment_service,
CheckPaymentStatusService $check_payment_status_service
)
{
$this->fib_client = new FibClient();
$this->create_payment_service = $create_payment_service;
$this->check_payment_status_service = $check_payment_status_service;
}
/**
* @throws Exception
* @throws Throwable
*/
public function createPayment(PaymentCreateDTO $dto)
{
try {
$gateway = UserGateway::query()
->where('id', $dto->user_gateway_id)
->where('user_id', $dto->user_id)
->firstOrFail();
return DB::transaction(function () use ($dto, $gateway) {
$payment = Payment::query()->create([
'user_id' => $dto->user_id,
'username' => $dto->username,
'track_id' => $dto->track_id,
'track_id' => $this->generateTrackId(),
'amount' => $dto->amount,
'currency' => $dto->currency,
'callback_url' => $dto->callback_url,
'status_id' => PaymentStatusEnum::Unpaid->value,
'status_name' => PaymentStatusEnum::Unpaid->name,
'callback_url' => 'https://user_callback',
'status_id' => PaymentStatusEnum::UNPAID->value,
'status_name' => PaymentStatusEnum::UNPAID->name,
'ip' => $dto->ip,
'user_gateway_id' => $dto->user_gateway_id,
'user_gateway_id' => $gateway->id,
]);
$response = $this->fib_client->createPaymentService();
$this->create_payment_service->setInputParameters([
'monetaryValue' => [
'amount' => $dto->amount,
'currency' => $dto->currency,
],
'statusCallbackUrl' => 'https://ipay/api/fib_callback',
'description' => $dto->description ?? "Payment #{$payment->track_id}",
]);
$response = $this->create_payment_service->run();
$fib_response_dto = FIBPaymentCreateDTO::fromResponse($response);
$transaction = Transaction::query()->create([
@@ -43,15 +73,15 @@ class PaymentService
'amount' => $payment->amount,
'currency' => $payment->currency,
'callback_url' => $payment->callback_url,
// 'description' => '',
// 'expires_in' => '',
// 'description' => '',
// 'expires_in' => '',
'payment_id' => $payment->id,
'payment_track_id' => $payment->track_id,
'user_gateway_id' => $payment->user_gateway_id,
// 'status' => '',
// 'status' => '',
]);
$fib_transactions = FibTransaction::query()->create([
FibTransaction::query()->create([
'transaction_id' => $transaction->id,
'qrcode' => $fib_response_dto->qrCode,
'readable_code' => $fib_response_dto->readableCode,
@@ -61,12 +91,86 @@ class PaymentService
'paymentId' => $fib_response_dto->paymentId,
'paymentMethod' => 'fib',
'validUntil' => $fib_response_dto->validUntil,
'status_id' => PaymentStatusEnum::Unpaid->value,
'status_name' => PaymentStatusEnum::Unpaid->name,
'status_id' => PaymentStatusEnum::UNPAID->value,
'status_name' => PaymentStatusEnum::UNPAID->name,
]);
return $payment;
} catch (\Exception $exception) {
throw new \Exception($exception->getMessage());
}
return [
'payment_id' => $payment->id,
'track_id' => $payment->track_id,
'qr_code' => $fib_response_dto->qrCode,
'readable_code' => $fib_response_dto->readableCode,
'personal_app_link' => $fib_response_dto->personalAppLink,
'business_app_link' => $fib_response_dto->businessAppLink,
'corporate_app_link' => $fib_response_dto->corporateAppLink,
'valid_until' => $fib_response_dto->validUntil,
'status' => PaymentStatusEnum::UNPAID->name,
];
});
}
private function generateTrackId(): string
{
do {
$id = uuid_create();
} while (Payment::query()->where('track_id', $id)->exists());
return $id;
}
public function checkPaymentStatus($track_id)
{
$user_id = auth()->id() ?? 2;
return Payment::query()->where('track_id', $track_id)
->where('user_id', $user_id)
->firstOrFail();
}
public function verifyPayment($track_id)
{
$user_id = auth()->id();
return DB::transaction(function () use ($track_id, $user_id) {
$payment = Payment::query()
->where('track_id', $track_id)
->where('user_id', $user_id)
->lockForUpdate()
->firstOrFail();
if ($payment->status_id == PaymentStatusEnum::PAID->value) {
return [
'status' => 'already_verified',
'paid' => true,
];
}
if ($payment->status_id !== PaymentStatusEnum::PendingVerification->value) {
return [
'status' => $payment->status_name,
'paid' => false,
];
}
$payment->update([
'status_id' => PaymentStatusEnum::PAID->value,
'status_name' => PaymentStatusEnum::PAID->name,
]);
Transaction::query()
->where('payment_id', $payment->id)
->update([
'status_id' => PaymentStatusEnum::PAID->value,
'status_name' => PaymentStatusEnum::PAID->name,
]);
return [
'status' => 'verified',
'paid' => true,
'track_id' => $payment->track_id,
'amount' => $payment->amount,
'currency' => $payment->currency,
];
});
}
}

View File

@@ -0,0 +1,113 @@
<?php
namespace App\Services\Payments;
use App\Enums\PaymentStatusEnum;
use App\Models\FibTransaction;
use App\Models\Payment;
use App\Models\Transaction;
use App\Services\FIB\CheckPaymentStatusService;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class SyncFibPaymentStatusService
{
public function __construct(
protected CheckPaymentStatusService $checkPaymentStatusService
)
{
}
public function run(): void
{
$fib_transactions = FibTransaction::query()
->whereIn('status_id', [
PaymentStatusEnum::UNPAID->value,
])
->with('transaction.payment')
->get();
foreach ($fib_transactions as $fib_transaction) {
try {
$this->syncOne($fib_transaction);
} catch (\Exception $e) {
Log::channel('fib_status')->error('Failed to sync fib transaction', [
'fib_transaction_id' => $fib_transaction->id,
'fib_payment_id' => $fib_transaction->paymentId,
'error' => $e->getMessage(),
]);
}
}
}
public function syncOne(FibTransaction $fib_transaction)
{
$fib_status_response = $this->checkPaymentStatusService->run($fib_transaction->paymentId);
if (!$fib_status_response['status']) {
Log::error('No status feild in fib ', []);
return false;
}
$mapped_status = $this->mapFibStatus($fib_status_response['status']);
// if ($mapped_status->value == $fib_transaction->status) {
// return;
// }
return DB::transaction(function () use ($fib_transaction, $fib_status_response, $mapped_status) {
$transaction = $fib_transaction->transaction;
$payment = $transaction->payment;
$fib_transaction->update([
'status_id' => $mapped_status->value,
'status_name' => $fib_transaction->status,
'paidAt' => $fib_status_response['paidAt'] ?? null,
'paidAmount' => $fib_status_response['amount']['amount'] ?? null,
'paidCurrency' => $fib_status_response['amount']['currency'] ?? null,
'decliningReason' => $fib_status_response['decliningReason'] ?? null,
'declinedAt' => $fib_status_response['declinedAt'] ?? null,
'paidByName' => $fib_status_response['paidBy']['name'] ?? null,
'paidByIban' => $fib_status_response['paidBy']['iban'] ?? null,
]);
$transaction->update([
'status_id' => $mapped_status->value,
'status_name' => $mapped_status->label(),
]);
if ($mapped_status === PaymentStatusEnum::PAID) {
$payment->update([
'status_id' => PaymentStatusEnum::PendingVerification->value,
'status_name' => PaymentStatusEnum::PendingVerification->label(),
'payment_method' => 'FIB',
'paid_currency' => $fib_transaction->paidCurrency,
'paid_amount' => $fib_transaction->paidAmount,
'paid_at' => $fib_transaction->paidAt,
]);
#------ has to implement ------
// $this->notifyMerchant($payment);
} else {
$payment->update([
'status_id' => $mapped_status->value,
'status_name' => $mapped_status->label(),
'paid_currency' => $fib_transaction->paidCurrency,
'paid_amount' => $fib_transaction->paidAmount,
'paid_at' => $fib_transaction->paidAt,
]);
}
return $payment;
});
}
protected function mapFibStatus(string $fib_status_response): PaymentStatusEnum
{
return match (strtoupper($fib_status_response)) {
'PAID' => PaymentStatusEnum::PAID,
'UNPAID' => PaymentStatusEnum::UNPAID,
'DECLINED' => PaymentStatusEnum::Cancelled,
'EXPIRED' => PaymentStatusEnum::Expired,
'REFUNDED' => PaymentStatusEnum::REFUNDED,
'REFUND_REQUESTED' => PaymentStatusEnum::REFUND_REQUESTED,
default => PaymentStatusEnum::UNPAID,
};
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace App\User\Controllers;
use App\Http\Controllers\Controller;
use App\Models\City;
use App\Models\Province;
use App\Traits\ApiResponse;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class CityController extends Controller
{
use ApiResponse;
public function list(Request $request): JsonResponse
{
$cities = City::query()
->where('province_id', '=', $request->query('province_id'))
->get(['id', 'name']);
return $this->successResponse($cities);
}
}

View File

@@ -14,6 +14,7 @@ use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Laravel\Passport\ClientRepository;
use Throwable;
class GatewayManagementController extends Controller
@@ -23,11 +24,11 @@ class GatewayManagementController extends Controller
public function index(Request $request)
{
return DataTableFacade::run(
UserGateway::query()->where('user_id', '=', Auth::guard('web')->id()),
UserGateway::query()->where('user_id', '=', Auth::guard('web')->user()->id),
$request,
allowedFilters: ['*'],
allowedSortings: ['*'],
allowedSelects: ['id', 'name', 'domain', 'tax_id', 'bank_name', 'account_holder', 'iban', 'business_type_id', 'business_type_name'],
allowedSelects: ['*'],
);
}
@@ -38,9 +39,15 @@ class GatewayManagementController extends Controller
{
$user = Auth::guard('web')->user();
$logo = $request->has('logo') ? FileFacade::save($request->file('logo'), "{$user->id}") : null;
$logo = $request->hasFile('logo')
? FileFacade::save($request->file('logo'), "{$user->id}")
: null;
$passportClient = DB::transaction(function () use ($user, $logo, $request) {
$clientName = "Gateway {$request->name} - User {$user->id}";
$client = app(ClientRepository::class)->createPasswordGrantClient($clientName, 'users');
DB::transaction(function () use ($user, $logo, $request) {
UserGateway::query()->create([
'user_id' => $user->id,
'username' => $user->username,
@@ -53,15 +60,20 @@ class GatewayManagementController extends Controller
'business_type_id' => $request->business_type_id,
'business_type_name' => BusinessTypeEnum::name($request->business_type_id),
'logo' => $logo,
'client_id' => $client->id,
'client_secret' => $client->secret,
]);
$user->update(['authority_level' => 1]);
return $client;
});
return $this->successResponse();
return $this->successResponse([
'client_id' => $passportClient->id,
'client_secret' => $passportClient->secret,
]);
}
public function show(UserGateway $gateway): JsonResponse
{
return $this->successResponse($gateway);

View File

@@ -6,9 +6,12 @@ use App\Http\Controllers\Controller;
use App\Services\Payments\DTO\PaymentCreateDTO;
use App\Services\Payments\PaymentService;
use App\Traits\ApiResponse;
use App\User\Requests\Payment\FIB\InquiryRequest;
use App\User\Requests\Payment\FIB\StoreRequest;
use App\User\Resources\Payment\InquiryResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Js;
class PaymentController extends Controller
@@ -32,4 +35,20 @@ class PaymentController extends Controller
throw $exception;
}
}
public function InquiryTransaction(InquiryRequest $request): JsonResponse
{
try {
$result = $this->payment_service->checkPaymentStatus($request->track_id);
return $this->successResponse(new InquiryResource($result));
} catch (\Exception $exception) {
throw $exception;
}
}
public function verify()
{
}
}

View File

@@ -46,7 +46,7 @@ class ProfileController extends Controller
$user->update([
'first_name' => $request->first_name,
'last_name' => $request->last_name,
'national_id' => $request->national_id,
'national_id' => $user->kyc_status == 0 ? $request->national_id : $user->national_id,
'address' => $request->address,
'postal_code' => $request->postal_code,
'phone_number' => $request->phone_number,

View File

@@ -0,0 +1,17 @@
<?php
namespace App\User\Controllers;
use App\Http\Controllers\Controller;
use App\Models\Province;
use App\Traits\ApiResponse;
use Illuminate\Http\JsonResponse;
class ProvinceController extends Controller
{
use ApiResponse;
public function list(): JsonResponse
{
return $this->successResponse(Province::all(['id', 'name']));
}
}

View File

@@ -0,0 +1,117 @@
<?php
namespace App\User\Controllers\Transactions;
use App\Enums\PaymentStatusEnum;
use App\Facades\DataTable\DataTableFacade;
use App\Http\Controllers\Controller;
use App\Models\Payment;
use App\Models\Transaction;
use App\Traits\ApiResponse;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class MerchantTransactionController extends Controller
{
use ApiResponse;
public function index(Request $request)
{
$merchantId = Auth::id();
$query = Transaction::query()
->select([
'transactions.id',
'transactions.amount',
'transactions.currency',
'transactions.status_id',
'transactions.created_at',
'payments.id',
'payments.payment_method',
'payments.paid_amount',
'payments.paid_currency',
'payments.paid_at',
'payments.status_name as payment_status',
'payments.status_id as payment_status_id',
'payments.verified_at',
'payments.refunded_at',
'payments.refund_reason',
'payments.track_id',
'user_gateways.name',
])
->join(
'payments',
'payments.id',
'=',
'transactions.payment_id'
)
->leftJoin(
'user_gateways',
'user_gateways.id',
'=',
'transactions.user_gateway_id'
)
->where('transactions.user_id', $merchantId);
return DataTableFacade::run(
$query,
$request,
allowedFilters: ['*'],
allowedSortings: ['*'],
allowedSelects: ['payments.id as payment_id', 'payments.track_id', 'payments.status_id as payment_status_id',
'payments.status_name as payment_status',
'payment_method', 'paid_amount', 'paid_currency', 'paid_at', 'payment_track_id',
'transactions.amount',
'transactions.currency',
'user_gateways.name as gateway_name',
'payments.verified_at',
'payments.refunded_at',
'payments.refund_reason',
]
);
}
public function stats(): JsonResponse
{
$merchantId = Auth::id();
$data = [
'total_transactions' => Payment::query()->where(
'user_id',
$merchantId
)->count(),
'successful_transactions' => Payment::query()->where(
'user_id',
$merchantId
)
->where('status_id', PaymentStatusEnum::PAID->value)
->count(),
'failed_transactions' => Payment::query()->where(
'user_id',
$merchantId
)
->whereIn('status_id', [
PaymentStatusEnum::Cancelled->value,
PaymentStatusEnum::Expired->value
])
->count(),
'total_paid_amount' => Payment::query()
->where('user_id', $merchantId)
->where(
'status_id',
PaymentStatusEnum::PendingVerification->value
)
->selectRaw('SUM(CAST(paid_amount AS DECIMAL(20,2))) as total')
->value('total'),
];
return $this->successResponse($data);
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\User\Requests\Payment\FIB;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
class InquiryRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array|string>
*/
public function rules(): array
{
return [
'track_id' => ['required', 'uuid'],
];
}
}

View File

@@ -25,12 +25,12 @@ class StoreRequest extends FormRequest
public function rules(): array
{
return [
'username' => ['required'],
'track_id' => ['required'],
'username' => ['required', 'string'],
'amount' => ['required'],
'currency' => ['required'],
'currency' => ['required', 'string'],
'callback_url' => ['required'],
'user_gateway_id' => ['required'],
'user_gateway_id' => ['required', 'integer', 'exists:user_gateways,id'],
'description' => ['nullable', 'string', 'max:500'],
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\User\Resources\Payment;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class InquiryResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
"track_id" => $this->track_id,
"amount" => $this->amount,
"currency" => $this->currency,
"status_id" => $this->status_id,
"status_name" => $this->status_name,
'payment_method' => $this->payment_method,
'paid_currency' => $this->paid_currency,
'paid_amount' => $this->paid_amount,
'paid_at' => $this->paid_at,
'verified_at' => $this->verified_at,
];
}
}

View File

@@ -24,12 +24,13 @@ class UserResource extends JsonResource
'address' => $this->address,
'postal_code' => $this->postal_code,
'phone_number' => $this->phone_number,
'province_id' => $this->provonce_id,
'province_id' => $this->province_id,
'province_name' => $this->province_name,
'city_id' => $this->city_id,
'city_name' => $this->city_name,
'birth_date' => $this->birth_date,
'kyc_status' => $this->kyc_status,
'authority_level' => $this->authority_level,
];
}
}

View File

@@ -3,12 +3,13 @@
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
use Illuminate\Support\Facades\Route;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
api: __DIR__.'/../routes/api.php',
commands: __DIR__.'/../routes/console.php',
web: __DIR__ . '/../routes/web.php',
api: __DIR__ . '/../routes/api.php',
commands: __DIR__ . '/../routes/console.php',
health: '/up',
then: function () {
Route::middleware('web')
@@ -23,6 +24,9 @@ return Application::configure(basePath: dirname(__DIR__))
->withExceptions(function (Exceptions $exceptions): void {
//
})
->withCommands([
__DIR__ . '/../app/Services/Payments/Commands',
])
->withEvents(discover: [
__DIR__.'/../app/User/Listeners',
__DIR__ . '/../app/User/Listeners',
])->create();

View File

@@ -1,5 +1,6 @@
<?php
use App\Models\Expert;
use App\Models\User;
return [

View File

@@ -133,6 +133,24 @@ return [
'level' => 'error',
],
'fib_create_payment' => [
'driver' => 'single',
'path' => storage_path('logs/fib/createPayment.log'),
'level' => 'error',
],
'fib_status' => [
'driver' => 'single',
'path' => storage_path('logs/fib/status.log'),
'level' => 'error',
],
'fib_refund' => [
'driver' => 'single',
'path' => storage_path('logs/fib/refund.log'),
'level' => 'error',
],
],
];

View File

@@ -0,0 +1,30 @@
<?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('user_gateways', function (Blueprint $table) {
$table->string('client_id')->nullable();
$table->string('client_secret')->nullable();
$table->integer('status')->default(0);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('user_gateways', function (Blueprint $table) {
$table->dropColumn(['client_id', 'client_secret','status']);
});
}
};

View File

@@ -0,0 +1,34 @@
<?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('payments', function (Blueprint $table) {
$table->string('payment_method')->nullable();
$table->string('paid_currency')->nullable();
$table->string('paid_amount')->nullable();
$table->timestamp('paid_at')->nullable();
$table->timestamp('verified_at')->nullable();
$table->timestamp('refunded_at')->nullable();
$table->string('refund_reason')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('payments', function (Blueprint $table) {
$table->dropColumn(['payment_method', 'paid_currency', 'paid_amount',
'paid_at', 'verified_at', 'refunded_at', 'refund_reason',]);
});
}
};

View File

@@ -4,6 +4,7 @@ namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class CitySeeder extends Seeder
{
@@ -12,6 +13,125 @@ class CitySeeder extends Seeder
*/
public function run(): void
{
//
DB::table('cities')->insert([
// Baghdad
['province_id' => 1, 'name' => 'Baghdad', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 1, 'name' => 'Sadr City', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 1, 'name' => 'Kadhimiya', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 1, 'name' => 'Adhamiyah', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 1, 'name' => 'Abu Ghraib', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 1, 'name' => 'Mahmudiya', 'created_at' => now(), 'updated_at' => now()],
// Basra
['province_id' => 2, 'name' => 'Basra', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 2, 'name' => 'Al-Zubair', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 2, 'name' => 'Umm Qasr', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 2, 'name' => 'Al-Qurnah', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 2, 'name' => 'Shatt Al-Arab', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 2, 'name' => 'Abu Al-Khaseeb', 'created_at' => now(), 'updated_at' => now()],
// Nineveh
['province_id' => 3, 'name' => 'Mosul', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 3, 'name' => 'Tal Afar', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 3, 'name' => 'Sinjar', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 3, 'name' => 'Al-Hamdaniya', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 3, 'name' => 'Bashiqa', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 3, 'name' => 'Qayyarah', 'created_at' => now(), 'updated_at' => now()],
// Erbil
['province_id' => 4, 'name' => 'Erbil', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 4, 'name' => 'Shaqlawa', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 4, 'name' => 'Soran', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 4, 'name' => 'Koya', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 4, 'name' => 'Makhmur', 'created_at' => now(), 'updated_at' => now()],
// Sulaymaniyah
['province_id' => 5, 'name' => 'Sulaymaniyah', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 5, 'name' => 'Halabja', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 5, 'name' => 'Ranya', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 5, 'name' => 'Kalar', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 5, 'name' => 'Chamchamal', 'created_at' => now(), 'updated_at' => now()],
// Duhok
['province_id' => 6, 'name' => 'Duhok', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 6, 'name' => 'Zakho', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 6, 'name' => 'Amedi', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 6, 'name' => 'Akre', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 6, 'name' => 'Semel', 'created_at' => now(), 'updated_at' => now()],
// Kirkuk
['province_id' => 7, 'name' => 'Kirkuk', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 7, 'name' => 'Hawija', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 7, 'name' => 'Dibis', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 7, 'name' => 'Daquq', 'created_at' => now(), 'updated_at' => now()],
// Diyala
['province_id' => 8, 'name' => 'Baqubah', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 8, 'name' => 'Khanaqin', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 8, 'name' => 'Muqdadiyah', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 8, 'name' => 'Balad Ruz', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 8, 'name' => 'Jalawla', 'created_at' => now(), 'updated_at' => now()],
// Anbar
['province_id' => 9, 'name' => 'Ramadi', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 9, 'name' => 'Fallujah', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 9, 'name' => 'Haditha', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 9, 'name' => 'Hit', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 9, 'name' => 'Al-Qaim', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 9, 'name' => 'Rutba', 'created_at' => now(), 'updated_at' => now()],
// Salah al-Din
['province_id' => 10, 'name' => 'Tikrit', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 10, 'name' => 'Samarra', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 10, 'name' => 'Balad', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 10, 'name' => 'Baiji', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 10, 'name' => 'Tuz Khurmatu', 'created_at' => now(), 'updated_at' => now()],
// Karbala
['province_id' => 11, 'name' => 'Karbala', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 11, 'name' => 'Al-Hindiya', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 11, 'name' => 'Ain Al-Tamur', 'created_at' => now(), 'updated_at' => now()],
// Najaf
['province_id' => 12, 'name' => 'Najaf', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 12, 'name' => 'Kufa', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 12, 'name' => 'Al-Manathera', 'created_at' => now(), 'updated_at' => now()],
// Babil
['province_id' => 13, 'name' => 'Hillah', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 13, 'name' => 'Al-Mahawil', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 13, 'name' => 'Al-Musayyib', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 13, 'name' => 'Hashimiya', 'created_at' => now(), 'updated_at' => now()],
// Wasit
['province_id' => 14, 'name' => 'Kut', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 14, 'name' => 'Al-Hayy', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 14, 'name' => 'Al-Numaniyah', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 14, 'name' => 'Badra', 'created_at' => now(), 'updated_at' => now()],
// Maysan
['province_id' => 15, 'name' => 'Amarah', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 15, 'name' => 'Ali Al-Sharqi', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 15, 'name' => 'Al-Majarr Al-Kabir', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 15, 'name' => 'Qalat Saleh', 'created_at' => now(), 'updated_at' => now()],
// Dhi Qar
['province_id' => 16, 'name' => 'Nasiriyah', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 16, 'name' => 'Al-Shatrah', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 16, 'name' => 'Suq Al-Shuyukh', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 16, 'name' => 'Rifai', 'created_at' => now(), 'updated_at' => now()],
// Muthanna
['province_id' => 17, 'name' => 'Samawah', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 17, 'name' => 'Rumaitha', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 17, 'name' => 'Al-Khidhir', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 17, 'name' => 'Salman', 'created_at' => now(), 'updated_at' => now()],
// Al-Qadisiyyah
['province_id' => 18, 'name' => 'Diwaniyah', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 18, 'name' => 'Afak', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 18, 'name' => 'Al-Shamiya', 'created_at' => now(), 'updated_at' => now()],
['province_id' => 18, 'name' => 'Hamza', 'created_at' => now(), 'updated_at' => now()],
]);
}
}

View File

@@ -22,5 +22,9 @@ class DatabaseSeeder extends Seeder
'email' => 'test@example.com',
'password' => 'password123@',
]);
$this->call([
ProvinceSeeder::class,
CitySeeder::class,
]);
}
}

View File

@@ -6,7 +6,7 @@ use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class PaymentStatusSeeder extends Seeder
class PaymentStatusSeeder extends Seeder
{
/**
* Run the database seeds.
@@ -14,11 +14,13 @@ class PaymentStatusSeeder extends Seeder
public function run(): void
{
DB::table('payment_statuses')->insert([
['id' => 0, 'name' => 'unpaid', 'created_at' => now(), 'updated_at' => now(),],
['id' => 1, 'name' => 'cancelled', 'created_at' => now(), 'updated_at' => now(),],
['id' => 2, 'name' => 'expired', 'created_at' => now(), 'updated_at' => now(),],
['id' => 3, 'name' => 'paid', 'created_at' => now(), 'updated_at' => now(),],
['id' => 4, 'name' => 'refunded', 'created_at' => now(), 'updated_at' => now(),],
['id' => 0, 'name' => 'UNPAID', 'created_at' => now(), 'updated_at' => now(),],
['id' => 1, 'name' => 'CANCELLED', 'created_at' => now(), 'updated_at' => now(),],
['id' => 2, 'name' => 'EXPIRED', 'created_at' => now(), 'updated_at' => now(),],
['id' => 3, 'name' => 'PAID', 'created_at' => now(), 'updated_at' => now(),],
['id' => 4, 'name' => 'REFUNDED', 'created_at' => now(), 'updated_at' => now(),],
['id' => 5, 'name' => 'PENDING_VERIFICATION', 'created_at' => now(), 'updated_at' => now(),],
['id' => 6, 'name' => 'REFUND_REQUESTED', 'created_at' => now(), 'updated_at' => now(),],
]);
}
}

View File

@@ -4,6 +4,7 @@ namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class ProvinceSeeder extends Seeder
{
@@ -12,6 +13,25 @@ class ProvinceSeeder extends Seeder
*/
public function run(): void
{
//
DB::table('provinces')->insert([
['id' => 1, 'name' => 'Baghdad', 'created_at' => now(), 'updated_at' => now()],
['id' => 2, 'name' => 'Basra', 'created_at' => now(), 'updated_at' => now()],
['id' => 3, 'name' => 'Nineveh', 'created_at' => now(), 'updated_at' => now()],
['id' => 4, 'name' => 'Erbil', 'created_at' => now(), 'updated_at' => now()],
['id' => 5, 'name' => 'Sulaymaniyah', 'created_at' => now(), 'updated_at' => now()],
['id' => 6, 'name' => 'Duhok', 'created_at' => now(), 'updated_at' => now()],
['id' => 7, 'name' => 'Kirkuk', 'created_at' => now(), 'updated_at' => now()],
['id' => 8, 'name' => 'Diyala', 'created_at' => now(), 'updated_at' => now()],
['id' => 9, 'name' => 'Anbar', 'created_at' => now(), 'updated_at' => now()],
['id' => 10, 'name' => 'Salah al-Din', 'created_at' => now(), 'updated_at' => now()],
['id' => 11, 'name' => 'Karbala', 'created_at' => now(), 'updated_at' => now()],
['id' => 12, 'name' => 'Najaf', 'created_at' => now(), 'updated_at' => now()],
['id' => 13, 'name' => 'Babil', 'created_at' => now(), 'updated_at' => now()],
['id' => 14, 'name' => 'Wasit', 'created_at' => now(), 'updated_at' => now()],
['id' => 15, 'name' => 'Maysan', 'created_at' => now(), 'updated_at' => now()],
['id' => 16, 'name' => 'Dhi Qar', 'created_at' => now(), 'updated_at' => now()],
['id' => 17, 'name' => 'Muthanna', 'created_at' => now(), 'updated_at' => now()],
['id' => 18, 'name' => 'Al-Qadisiyyah', 'created_at' => now(), 'updated_at' => now()],
]);
}
}

View File

@@ -11,9 +11,12 @@ Route::get('/user', function (Request $request) {
Route::prefix('v1')->group(function () {
Route::prefix('payment')
// ->middleware('auth:api')
->group(function () {
Route::post('/create_payment', [PaymentController::class, 'createPayment'])->name('create_payment');
Route::post('/inquiry', [PaymentController::class, 'InquiryTransaction'])->name('inquiry');
Route::post('/verify', [PaymentController::class, 'checkPaymentStatus'])->name('verify');
Route::get('check_fib_status', [\App\Services\Payments\Controllers\FIBTempController::class, 'checkStatus']);
});
});

View File

@@ -2,7 +2,13 @@
use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Schedule;
use App\Services\Payments\Commands\SyncFibPaymentStatuses;
Artisan::command('inspire', function () {
$this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote');
Schedule::command(SyncFibPaymentStatuses::class)->everyMinute();

View File

@@ -7,15 +7,15 @@ use App\Admin\Controllers\PermissionManagementController;
use App\Admin\Controllers\ProfileController;
use App\Admin\Controllers\RoleManagementController;
use App\Admin\Controllers\UserManagementController;
use Illuminate\Support\Facades\Route;
Route::prefix('auth')
->name('auth.')
->controller(AuthController::class)
->group(function () {
Route::post('register', 'register')->name('register');
Route::post('login', 'login')->name('login');
Route::post('logout', 'logout')->name('logout');
});
});
Route::prefix('documents')
->name('documents.')
@@ -34,10 +34,10 @@ Route::prefix('user_management')
->controller(UserManagementController::class)
->group(function () {
Route::get('/', 'index')->name('index');
Route::post('/', 'store')->name('store');
Route::get('/{user}', 'show')->name('show');
Route::post('/{user}', 'update')->name('update');
Route::delete('/{user}', 'destroy')->name('destroy');
Route::post('/store', 'store')->name('store');
Route::get('{user}', 'show')->name('show');
Route::post('/update/{user}', 'update')->name('update');
Route::delete('/delete/{user}', 'destroy')->name('destroy');
});
Route::prefix('roles')
@@ -46,10 +46,10 @@ Route::prefix('roles')
->controller(RoleManagementController::class)
->group(function () {
Route::get('/', 'index')->name('index');
Route::post('/', 'store')->name('store');
Route::get('/{role}', 'show')->name('show');
Route::post('/{role}', 'update')->name('update');
Route::delete('/{role}', 'destroy')->name('destroy');
Route::post('/store', 'store')->name('store');
Route::get('{role}', 'show')->name('show');
Route::post('/update/{role}', 'update')->name('update');
Route::delete('/delete/{role}', 'destroy')->name('destroy');
});
Route::prefix('permissions')
@@ -58,27 +58,27 @@ Route::prefix('permissions')
->controller(PermissionManagementController::class)
->group(function () {
Route::get('/', 'index')->name('index');
Route::post('/', 'store')->name('store');
Route::get('/{permission}', 'show')->name('show');
Route::post('/{permission}', 'update')->name('update');
Route::delete('/{permission}', 'destroy')->name('destroy');
Route::post('/store', 'store')->name('store');
Route::get('{permission}', 'show')->name('show');
Route::post('/update/{permission}', 'update')->name('update');
Route::delete('/delete/{permission}', 'destroy')->name('destroy');
});
Route::prefix('expert')
Route::prefix('expert_manage')
->name('expert.')
->middleware(['auth:expert', 'permission:expert-management'])
->controller(ExpertManagementController::class)
->group(function () {
Route::get('/', 'index')->name('index');
Route::post('/', 'store')->name('store');
Route::get('/{expert}', 'show')->name('show');
Route::post('/{expert}', 'update')->name('update');
Route::delete('/{expert}', 'destroy')->name('destroy');
Route::post('/stores', 'store')->name('store');
Route::get('{expert}', 'show')->name('show');
Route::post('/update/{expert}', 'update')->name('update');
Route::delete('/delete/{expert}', 'destroy')->name('destroy');
});
Route::prefix('profile')
->name('profile.')
->middleware('auth')
->middleware('auth:expert')
->controller(ProfileController::class)
->group(function () {
Route::get('info', 'info')->name('info');

View File

@@ -1,13 +1,13 @@
<?php
use App\Admin\Controllers\ExpertManagementController;
use App\Admin\Controllers\PermissionManagementController;
use App\Admin\Controllers\RoleManagementController;
use App\Admin\Controllers\UserManagementController;
use App\User\Controllers\AuthController;
use App\User\Controllers\GatewayManagementController;
use App\User\Controllers\CityController;
use App\User\Controllers\ProfileController;
use App\User\Controllers\ProvinceController;
use Illuminate\Support\Facades\Route;
use App\User\Controllers\Transactions\MerchantTransactionController;
Route::prefix('auth')
->name('Auth.')
@@ -39,3 +39,27 @@ Route::prefix('user_gateway')
Route::post('/{gateway}', 'update')->name('update');
Route::delete('/{gateway}', 'destroy')->name('destroy');
});
Route::prefix('province')
->name('province.')
->controller(ProvinceController::class)
->group(function () {
Route::get('list', 'list')->name('list');
});
Route::prefix('city')
->name('city.')
->controller(CityController::class)
->group(function () {
Route::get('list', 'list')->name('list');
});
Route::prefix('merchant')->group(function () {
Route::prefix('transactions')
->middleware(['auth'])
->group(function () {
Route::get('/list', [MerchantTransactionController::class, 'index'])->name('index');
Route::get('/stats', [MerchantTransactionController::class, 'stats'])->name('stats');
});
});