Compare commits
87 Commits
014da27f66
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| aaacac26d6 | |||
| 377acc18cf | |||
| c05a6972b8 | |||
| 1b27664780 | |||
| 03c692adbb | |||
| 2bd2c45ddb | |||
| e98674aa26 | |||
| d0d49d6517 | |||
| 45ca714b17 | |||
| 924ed64527 | |||
| ca2112d0e6 | |||
| 395e400b7f | |||
| 4d562baacd | |||
| 3e7d246273 | |||
| e6488343c1 | |||
| e5b600df5b | |||
| db3800921e | |||
| 2b2704f6d2 | |||
| 8ecf58de7c | |||
| f81acada2c | |||
| c336af2b6f | |||
| 9fc7d5c1e4 | |||
| 3c3d74ec34 | |||
| 33ec2e11e6 | |||
| 475c21af85 | |||
| fa41d7b9b0 | |||
| 328c2829f7 | |||
| 9b961ef647 | |||
| e736b8501d | |||
| 07a6679e9f | |||
| 50996ddacd | |||
| ef7c30a235 | |||
| 7ca24207fb | |||
| e64cf34c90 | |||
| 673042dd32 | |||
| 84348a1807 | |||
| 9f22e506b2 | |||
| 067ae91c2e | |||
| 82c17b41f6 | |||
| 4b0334fc48 | |||
| 5245f484a0 | |||
| 19f87050dd | |||
| 23ee71f4a4 | |||
| 5896fe4d56 | |||
| 76f6f1c3a3 | |||
| a622f7651a | |||
| a1521ace7a | |||
| d157c21883 | |||
| 6dab1a38c6 | |||
| a5e086237e | |||
| 44613f944e | |||
| 4ff92fe530 | |||
| 051ec52547 | |||
| 9cecd6c465 | |||
| 71e0f1c18d | |||
| 741de26eea | |||
| 574176e4b2 | |||
| 8d7633048b | |||
| 3a6a871c2f | |||
| bf21918a5a | |||
| f138a6c7cb | |||
| f2a94c3c49 | |||
| 4d4a499a56 | |||
| d89f86a534 | |||
| b8bdea33cb | |||
| 5a4759a137 | |||
| 161f993099 | |||
| d4a4c3d3f4 | |||
| 146266226b | |||
| 2e82b19563 | |||
| fc95d6c9f9 | |||
| 2368ea2a50 | |||
| 6aa44e3fa5 | |||
| f610474328 | |||
| 4f1dd64fba | |||
| 6abfc4ac48 | |||
| 7617e08632 | |||
| 84c0e99004 | |||
| 548d1040bb | |||
| df2f2979b5 | |||
| 5c6aff312a | |||
| 7513d6a9a9 | |||
| ffd43d32c2 | |||
| b5e57bccc8 | |||
| 1c00a28744 | |||
| c0dd8f269a | |||
| b3ed503742 |
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use App\Jobs\SendSberToSystem;
|
||||
use App\Jobs\SendVisaToSystem;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
@@ -12,7 +14,11 @@ class Kernel extends ConsoleKernel
|
||||
*/
|
||||
protected function schedule(Schedule $schedule): void
|
||||
{
|
||||
$schedule->command('backup:run')->saturdays();
|
||||
$schedule->job(new SendSberToSystem)
|
||||
->everyMinute();
|
||||
|
||||
$schedule->job(new SendVisaToSystem)
|
||||
->everyMinute();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,6 +5,7 @@ use App\Models\Payment\OnlinePaymentHistory;
|
||||
use App\Models\System\Roles\Permission;
|
||||
use App\Models\System\Verification;
|
||||
use App\Modules\SberPaymentOrder\Models\SberPaymentOrderItem;
|
||||
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrderItem;
|
||||
use App\Nova\Resources\Order\Card\CardTransaction\Actions\DownloadCardTransaction;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Psr7\Request as GuzzleRequest;
|
||||
@@ -70,7 +71,7 @@ function isTurkmenIp(string $ip = ''): bool
|
||||
}
|
||||
|
||||
/**
|
||||
* Un mask phone from "+(993)-xx-xx-xx-xx"
|
||||
* Un mask phone
|
||||
*/
|
||||
function unMaskPhone(string|int $phone): string
|
||||
{
|
||||
@@ -146,7 +147,7 @@ function storeAuthEvent(string $name, Request $request): void
|
||||
$request->getPort(),
|
||||
isLocalIp($request->ip())
|
||||
? 'TM'
|
||||
: Location::get($request->ip())?->countryCode ?? 'TM',
|
||||
: Location::get('95.85.34.23')?->countryCode ?? 'TM',
|
||||
$request->user()->id ?? '-',
|
||||
));
|
||||
}
|
||||
@@ -314,7 +315,7 @@ function view_loan_order_permission_id(): int
|
||||
*/
|
||||
function vp_fetch_ClientInfoAll($model, $start_date, $end_date)
|
||||
{
|
||||
$response = DownloadCardTransaction::make()->fetchApi(
|
||||
return fetchCardTransactionFromAzat(
|
||||
passport_serie: $model->passport_serie,
|
||||
passport_id: $model->passport_id,
|
||||
card_number_masked: Str::mask($model->card_number, '*', 6, 6),
|
||||
@@ -322,6 +323,11 @@ function vp_fetch_ClientInfoAll($model, $start_date, $end_date)
|
||||
start_date: $start_date,
|
||||
end_date: $end_date,
|
||||
);
|
||||
}
|
||||
|
||||
function fetchCardTransactionFromAzat($passport_serie, $passport_id, $card_number_masked, $card_expire_date, $start_date, $end_date)
|
||||
{
|
||||
$response = DownloadCardTransaction::make()->fetchApi($passport_serie, $passport_id, $card_number_masked, $card_expire_date, $start_date, $end_date);
|
||||
|
||||
return Str::isJson($response)
|
||||
? json_decode($response)
|
||||
@@ -447,37 +453,35 @@ function syncWithBankSystem(
|
||||
$amount = $online_payment_tmt_amount;
|
||||
$payPurpose = $pay_purpose;
|
||||
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => 'http://10.3.158.102:8888/api/paytrn/new',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS => sprintf('{
|
||||
"ecomId": "%s",
|
||||
"agentId": "%s",
|
||||
"eposId": "%s",
|
||||
"account": "%s",
|
||||
"rrn": "%s",
|
||||
"amount": "%s",
|
||||
"payPurpose": "%s"
|
||||
}', $ecomId, $agentId, $eposId, $account, $rrn, $amount, $payPurpose),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Authorization: Basic YWRtaW46UUFad3N4MTIz',
|
||||
'Content-Type: application/json',
|
||||
],
|
||||
$client = new Client([
|
||||
'timeout' => 5, // seconds before it fails
|
||||
'connect_timeout' => 1, // seconds to wait for connection
|
||||
]);
|
||||
$headers = [
|
||||
'Content-Type' => 'application/json',
|
||||
'Authorization' => 'Basic YWRtaW46UUFad3N4MTIz',
|
||||
];
|
||||
$body = sprintf('{
|
||||
"ecomId": "%s",
|
||||
"agentId": "%s",
|
||||
"eposId": "%s",
|
||||
"account": "%s",
|
||||
"rrn": "%s",
|
||||
"amount": "%s",
|
||||
"payPurpose": "%s"
|
||||
}', $ecomId, $agentId, $eposId, $account, $rrn, $amount, $payPurpose);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$request = new GuzzleRequest('POST', 'http://10.3.158.102:8888/api/paytrn/new', $headers, $body);
|
||||
|
||||
curl_close($curl);
|
||||
try {
|
||||
$res = $client->sendAsync($request)->wait();
|
||||
|
||||
return $response;
|
||||
return (string) $res->getBody();
|
||||
} catch (Exception $e) {
|
||||
info([$e->getMessage(), $e->getTraceAsString()]);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -522,3 +526,233 @@ function getSberCredentials(SberPaymentOrderItem $item): array
|
||||
'relatedResource' => $relatedResource,
|
||||
];
|
||||
}
|
||||
|
||||
function syncSberWithAzatAPI(SberPaymentOrderItem $orderItem): array
|
||||
{
|
||||
$result = getSberCredentials($orderItem);
|
||||
|
||||
if (isset($result['error'])) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
/** @var \App\Models\Payment\OnlinePaymentHistory $onlinePaymentResource */
|
||||
$onlinePaymentResource = $result['onlinePaymentResource'];
|
||||
|
||||
/** @var \App\Modules\SberPaymentOrder\Models\SberPaymentOrder $sberPaymentOrder */
|
||||
$sberPaymentOrder = $result['relatedResource'];
|
||||
|
||||
$response = checkOnlinePayment($onlinePaymentResource->orderId, $result['username'], $result['password']);
|
||||
|
||||
if ($response['errorCode'] != 0) {
|
||||
return [
|
||||
'error' => $response['errorMessage'],
|
||||
'type' => 'modal',
|
||||
];
|
||||
}
|
||||
|
||||
if (! isset($response['authRefNum'])) {
|
||||
warn('missing-authRefNum', $onlinePaymentResource->orderId);
|
||||
ignoreSberPayment('missing-authRefNum', $orderItem);
|
||||
|
||||
return [
|
||||
'error' => 'authRefNum missing',
|
||||
'type' => 'modal',
|
||||
];
|
||||
}
|
||||
|
||||
$systemRawResponse = syncWithBankSystem(
|
||||
online_payment_order_uuid: $onlinePaymentResource->orderId,
|
||||
bank_unique_code: $sberPaymentOrder->branch->unique_code,
|
||||
online_payment_terminal_id: $response['terminalId'],
|
||||
user_deposit_account: number_format($sberPaymentOrder->sender_deposit_account, 0, '', ''),
|
||||
online_payment_auth_ref_num: $response['authRefNum'],
|
||||
online_payment_tmt_amount: $orderItem->tmt_payment_amount,
|
||||
pay_purpose: $orderItem->created_at->translatedFormat('F').' '.$orderItem->created_at->format('Y')
|
||||
);
|
||||
|
||||
if ($systemRawResponse == null) {
|
||||
return [
|
||||
'error' => 'Connection issue to SYSTEM',
|
||||
'type' => 'modal',
|
||||
];
|
||||
}
|
||||
|
||||
$systemResponse = json_decode($systemRawResponse);
|
||||
|
||||
$success = false;
|
||||
if (is_object($systemResponse)) {
|
||||
$success = $systemResponse->errCode == 0;
|
||||
}
|
||||
|
||||
if (! $success) {
|
||||
$message = 'Error';
|
||||
|
||||
if (isset($systemResponse->msgSys)) {
|
||||
$message .= ' '.$systemResponse->msgSys;
|
||||
}
|
||||
|
||||
return [
|
||||
'error' => $message,
|
||||
'type' => 'modal',
|
||||
];
|
||||
}
|
||||
|
||||
$orderItem->update([
|
||||
'synced_with_system' => true,
|
||||
]);
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'type' => 'modal',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Sber credentials for a given payment item.
|
||||
*
|
||||
* @param SberPaymentOrderItem $item
|
||||
* @return array{username?: string, password?: string, onlinePaymentResource?: OnlinePaymentHistory, relatedResource?: mixed, error?: string, type?: 'danger'|'modal'}
|
||||
*/
|
||||
function getVisaCredentials(VisaMasterPaymentOrderItem $item): array
|
||||
{
|
||||
/** @var \App\Models\Payment\OnlinePaymentHistory|null $onlinePaymentResource */
|
||||
$onlinePaymentResource = OnlinePaymentHistory::find($item->online_payment_history_id);
|
||||
|
||||
if (! $onlinePaymentResource) {
|
||||
return ['error' => 'Online payment resource tapylmady', 'type' => 'danger'];
|
||||
}
|
||||
|
||||
$relatedResource = (new $onlinePaymentResource->online_paymantable_type)
|
||||
->find(id: $onlinePaymentResource->online_paymantable_id);
|
||||
|
||||
if (! $relatedResource) {
|
||||
return ['error' => 'Bu resource tapylmady', 'type' => 'danger'];
|
||||
}
|
||||
|
||||
$relatedResource->loadMissing(['branch']);
|
||||
|
||||
if (! $relatedResource->branch) {
|
||||
return ['error' => 'Şahamça bilen birikdirilmedik', 'type' => 'danger'];
|
||||
}
|
||||
|
||||
$username = $relatedResource->branch->billing_visa_master_username;
|
||||
$password = $relatedResource->branch->billing_visa_master_password;
|
||||
|
||||
if (empty($username) || empty($password)) {
|
||||
return ['error' => 'Ulanyjy ady bilen açar sözi gabat gelmedi', 'type' => 'modal'];
|
||||
}
|
||||
|
||||
return [
|
||||
'username' => $username,
|
||||
'password' => $password,
|
||||
'onlinePaymentResource' => $onlinePaymentResource,
|
||||
'relatedResource' => $relatedResource,
|
||||
];
|
||||
}
|
||||
|
||||
function syncVisaWithAzatAPI(VisaMasterPaymentOrderItem $orderItem): array
|
||||
{
|
||||
$result = getVisaCredentials($orderItem);
|
||||
|
||||
if (isset($result['error'])) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
/** @var \App\Models\Payment\OnlinePaymentHistory $onlinePaymentResource */
|
||||
$onlinePaymentResource = $result['onlinePaymentResource'];
|
||||
|
||||
/** @var \App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder $sberPaymentOrder */
|
||||
$visaPaymentOrder = $result['relatedResource'];
|
||||
|
||||
$response = checkOnlinePayment($onlinePaymentResource->orderId, $result['username'], $result['password']);
|
||||
|
||||
if ($response['errorCode'] != 0) {
|
||||
return [
|
||||
'error' => $response['errorMessage'],
|
||||
'type' => 'modal',
|
||||
];
|
||||
}
|
||||
|
||||
if (! isset($response['authRefNum'])) {
|
||||
warn('missing-authRefNum', $onlinePaymentResource->orderId);
|
||||
ignoreVisaPayment('missing-authRefNum', $orderItem);
|
||||
|
||||
return [
|
||||
'error' => 'authRefNum missing',
|
||||
'type' => 'modal',
|
||||
];
|
||||
}
|
||||
|
||||
$systemRawResponse = syncWithBankSystem(
|
||||
online_payment_order_uuid: $onlinePaymentResource->orderId,
|
||||
bank_unique_code: $visaPaymentOrder->branch->unique_code,
|
||||
online_payment_terminal_id: $response['terminalId'],
|
||||
user_deposit_account: number_format($visaPaymentOrder->sender_deposit_account, 0, '', ''),
|
||||
online_payment_auth_ref_num: $response['authRefNum'],
|
||||
online_payment_tmt_amount: $orderItem->tmt_payment_amount,
|
||||
pay_purpose: $orderItem->created_at->translatedFormat('F').' '.$orderItem->created_at->format('Y')
|
||||
);
|
||||
|
||||
if ($systemRawResponse == null) {
|
||||
return [
|
||||
'error' => 'Connection issue to SYSTEM',
|
||||
'type' => 'modal',
|
||||
];
|
||||
}
|
||||
|
||||
$systemResponse = json_decode($systemRawResponse);
|
||||
|
||||
$success = false;
|
||||
if (is_object($systemResponse)) {
|
||||
$success = $systemResponse->errCode == 0;
|
||||
}
|
||||
|
||||
if (! $success) {
|
||||
$message = 'Error';
|
||||
|
||||
if (isset($systemResponse->msgSys)) {
|
||||
$message .= ' '.$systemResponse->msgSys;
|
||||
}
|
||||
|
||||
return [
|
||||
'error' => $message,
|
||||
'type' => 'modal',
|
||||
];
|
||||
}
|
||||
|
||||
$orderItem->update([
|
||||
'synced_with_system' => true,
|
||||
]);
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'type' => 'modal',
|
||||
];
|
||||
}
|
||||
|
||||
function warn($message, $content) {
|
||||
DB::table('warnings')->insert([
|
||||
'message' => $message,
|
||||
'content' => $content,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
function ignoreVisaPayment($message, $item) {
|
||||
DB::table('ignore_visa_payments')->insert([
|
||||
'message' => $message,
|
||||
'payment_id' => $item->id,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
function ignoreSberPayment($message, $item) {
|
||||
DB::table('ignore_sber_payments')->insert([
|
||||
'message' => $message,
|
||||
'payment_id' => $item->id,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -12,11 +12,67 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
#[Group('Sargytlar - Kart - Kart hereketleri')]
|
||||
class CardTransactionsController extends Controller
|
||||
{
|
||||
/**
|
||||
* This month transactions on card
|
||||
*/
|
||||
public function lastMonth(): JsonResponse
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
$start_date = today()->subDays(10)->format('d.m.Y');
|
||||
$end_date = today()->format('d.m.Y');
|
||||
$passport_serie = $user->getOption('passport_serie');
|
||||
$passport_id = $user->getOption('passport_id');
|
||||
$card_number = $user->getOption('card_number');
|
||||
$card_month = $user->getOption('card_month');
|
||||
$card_year = $user->getOption('card_year');
|
||||
|
||||
if (
|
||||
is_null($passport_serie) || $passport_serie === '' ||
|
||||
is_null($passport_id) || $passport_id === '' ||
|
||||
is_null($card_number) || $card_number === '' ||
|
||||
is_null($card_month) || $card_month === '' ||
|
||||
is_null($card_year) || $card_year === ''
|
||||
) {
|
||||
return response()->rest([
|
||||
'status' => false,
|
||||
'message' => 'Profile data needed',
|
||||
'data' => '',
|
||||
]);
|
||||
}
|
||||
|
||||
$card_month = str_pad($card_month, 2, '0', STR_PAD_LEFT);
|
||||
|
||||
$response = fetchCardTransactionFromAzat(
|
||||
passport_serie: $passport_serie,
|
||||
passport_id: $passport_id,
|
||||
card_number_masked: Str::mask($card_number, '*', 6, 6),
|
||||
card_expire_date: $card_month.'/'.substr($card_year, 2),
|
||||
start_date: $start_date,
|
||||
end_date: $end_date,
|
||||
);
|
||||
|
||||
if ($response->errCode != 0) {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => $response->message,
|
||||
'data' => [],
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'message' => 'a',
|
||||
'data' => $response,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* LIST*
|
||||
*/
|
||||
|
||||
@@ -25,27 +25,6 @@ class OnlinePaymentController extends Controller
|
||||
{
|
||||
$data = OnlinePaymentRepo::checkPaymentVisaMaster($request);
|
||||
|
||||
/** @var \App\Models\Payment\OnlinePaymentHistory */
|
||||
$paymentHistory = $data['paymentHistory'];
|
||||
|
||||
/** @var \App\Models\Branch\Branch */
|
||||
$bank = $data['bank_branch'];
|
||||
|
||||
/** @var \App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrderItem */
|
||||
$resource = $data['resource'];
|
||||
|
||||
if ($data['success'] && $paymentHistory && is_array($paymentHistory->api_response)) {
|
||||
info(OnlinePaymentRepo::syncWithBilling(
|
||||
uuid: $paymentHistory->orderId,
|
||||
bank_code: $bank->unique_code,
|
||||
terminal_id: $paymentHistory->api_response['terminalId'],
|
||||
account_number: $resource->parent->sender_datas[0]['deposit_account'],
|
||||
rrn: $paymentHistory->api_response['authRefNum'],
|
||||
amount: $resource->tmt_payment_amount,
|
||||
pay_purpose: $resource->created_at->translatedFormat('F').' '.$resource->created_at->format('Y'),
|
||||
));
|
||||
}
|
||||
|
||||
return view(OnlinePaymentRepo::statusView(), $data);
|
||||
}
|
||||
|
||||
@@ -56,21 +35,6 @@ class OnlinePaymentController extends Controller
|
||||
{
|
||||
$data = OnlinePaymentRepo::checkPaymentSber($request);
|
||||
|
||||
/** @var \App\Models\Payment\OnlinePaymentHistory */
|
||||
$paymentHistory = $data['paymentHistory'];
|
||||
|
||||
/** @var \App\Models\Branch\Branch */
|
||||
$bank = $data['bank_branch'];
|
||||
|
||||
/** @var \App\Modules\SberPaymentOrder\Models\SberPaymentOrderItem */
|
||||
$resource = $data['resource'];
|
||||
|
||||
$response = $data['response'];
|
||||
|
||||
// if ($data['success'] && $paymentHistory) {
|
||||
// $this->runActions($paymentHistory, $bank, $response, $resource);
|
||||
// }
|
||||
|
||||
return view(OnlinePaymentRepo::statusView(), $data);
|
||||
}
|
||||
}
|
||||
|
||||
64
app/Jobs/SendSberToSystem.php
Normal file
64
app/Jobs/SendSberToSystem.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Modules\SberPaymentOrder\Models\SberPaymentOrderItem;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SendSberToSystem implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* The number of seconds the job can run before timing out.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 5;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$ignore = DB::table('ignore_sber_payments')->pluck('payment_id');
|
||||
|
||||
$orderItems = SberPaymentOrderItem::query()
|
||||
->where('paid', true)
|
||||
->where('synced_with_system', false)
|
||||
->whereDate('created_at', '>', '2025-09-05')
|
||||
->whereIntegerNotInRaw('id', $ignore)
|
||||
->limit(2)
|
||||
->get()
|
||||
->each(function ($orderItem) {
|
||||
if (! $orderItem) {
|
||||
return;
|
||||
}
|
||||
|
||||
$result = syncSberWithAzatAPI($orderItem);
|
||||
|
||||
if (isset($result['error'])) {
|
||||
ignoreSberPayment($result['error'], $orderItem);
|
||||
|
||||
Log::channel('sber_job')->error(json_encode([
|
||||
'error' => $result['error'],
|
||||
'orderItem' => $orderItem,
|
||||
]));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
50
app/Jobs/SendVisaToSystem.php
Normal file
50
app/Jobs/SendVisaToSystem.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrderItem;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SendVisaToSystem implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$ignore = DB::table('ignore_visa_payments')->pluck('payment_id');
|
||||
|
||||
$orderItems = VisaMasterPaymentOrderItem::query()
|
||||
->where('paid', true)
|
||||
->where('synced_with_system', false)
|
||||
->whereDate('created_at', '>', '2025-09-05')
|
||||
->whereIntegerNotInRaw('id', $ignore)
|
||||
->limit(2)
|
||||
->get()
|
||||
->each(function ($orderItem) {
|
||||
if (! $orderItem) {
|
||||
return;
|
||||
}
|
||||
|
||||
$result = syncVisaWithAzatAPI($orderItem);
|
||||
|
||||
if (isset($result['error'])) {}
|
||||
});
|
||||
}
|
||||
}
|
||||
11
app/Models/IgnoreSberPayment.php
Normal file
11
app/Models/IgnoreSberPayment.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class IgnoreSberPayment extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
11
app/Models/IgnoreVisaPayment.php
Normal file
11
app/Models/IgnoreVisaPayment.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class IgnoreVisaPayment extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
@@ -158,7 +158,7 @@ class CardOrder extends Model
|
||||
/**
|
||||
* Price for order
|
||||
*/
|
||||
public function priceAmount(): float
|
||||
public function priceAmount(): string|int|float
|
||||
{
|
||||
return $this->cardState->price ?? 32;
|
||||
}
|
||||
|
||||
11
app/Models/Warning.php
Normal file
11
app/Models/Warning.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Warning extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
@@ -9,6 +9,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Laravel\Nova\Actions\Actionable;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
|
||||
@@ -40,6 +41,7 @@ use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
*/
|
||||
class SberPaymentOrder extends Model implements HasMedia
|
||||
{
|
||||
use Actionable;
|
||||
use InteractsWithMedia;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ trait NovaSberPaymentOrderAuth
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->isMe() || $user->isSuperAdmin()) {
|
||||
if ($user->isSystemUser()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -43,11 +43,7 @@ trait NovaSberPaymentOrderAuth
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->isMe() || $user->isSuperAdmin()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/** View */
|
||||
@@ -55,7 +51,7 @@ trait NovaSberPaymentOrderAuth
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->isMe() || $user->isSuperAdmin()) {
|
||||
if ($user->isSystemUser()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -73,7 +69,7 @@ trait NovaSberPaymentOrderAuth
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->isMe() || $user->isSuperAdmin()) {
|
||||
if ($user->isSystemUser()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -85,7 +81,7 @@ trait NovaSberPaymentOrderAuth
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->isMe()) {
|
||||
if ($user->isSystemUser()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -99,11 +95,11 @@ trait NovaSberPaymentOrderAuth
|
||||
}
|
||||
|
||||
/** Delete button */
|
||||
public function authorizedToDelete(Request $request)
|
||||
public function authorizedToDelete(Request $request): bool
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->isMe() || $user->isSuperAdmin()) {
|
||||
if ($user->isSystemUser()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -115,7 +111,7 @@ trait NovaSberPaymentOrderAuth
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->isMe() || $user->isSuperAdmin()) {
|
||||
if ($user->isSystemUser()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,12 +40,6 @@ trait NovaSberPaymentOrderItemAuth
|
||||
/** Delete button */
|
||||
public function authorizedToDelete(Request $request)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Force delete */
|
||||
public function authorizedToForceDelete(Request $request)
|
||||
{
|
||||
return auth()->user()->isMe() ? true : false;
|
||||
return auth()->user()->isMe();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ class NovaSberPaymentOrder extends Resource
|
||||
name: __('Goýum hasaby'),
|
||||
attribute: 'sender_deposit_account'
|
||||
)->fullWidth()
|
||||
->rules('required', 'string', 'max:255')
|
||||
->rules('required', 'digits:15')
|
||||
->fillUsing(function ($request, $model, $attribute) {
|
||||
$model->sender_deposit_account = strval($request->sender_deposit_account);
|
||||
}),
|
||||
@@ -350,22 +350,22 @@ class NovaSberPaymentOrder extends Resource
|
||||
public function actions(NovaRequest $request): array
|
||||
{
|
||||
return [
|
||||
MakeSberPaymentAction::make()
|
||||
->icon('credit-card')
|
||||
->sole()
|
||||
->canSee(function ($request) {
|
||||
/** @var \App\Modules\SberPaymentOrder\Models\SberPaymentOrder $resource */
|
||||
$resource = $this->resource;
|
||||
// MakeSberPaymentAction::make()
|
||||
// ->icon('credit-card')
|
||||
// ->sole()
|
||||
// ->canSee(function ($request) {
|
||||
// /** @var \App\Modules\SberPaymentOrder\Models\SberPaymentOrder $resource */
|
||||
// $resource = $this->resource;
|
||||
|
||||
if (in_array($resource->status, [
|
||||
OrderRepo::PENDING,
|
||||
OrderRepo::CANCELLED,
|
||||
])) {
|
||||
return false;
|
||||
}
|
||||
// if (in_array($resource->status, [
|
||||
// OrderRepo::PENDING,
|
||||
// OrderRepo::CANCELLED,
|
||||
// ])) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
return true;
|
||||
}),
|
||||
// return true;
|
||||
// }),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -174,12 +174,18 @@ class NovaSberPaymentOrderItem extends Resource
|
||||
]);
|
||||
})->icon('server')
|
||||
->sole()
|
||||
->withoutConfirmation(),
|
||||
->withoutConfirmation()
|
||||
->canSee(function ($request) {
|
||||
return auth()->user()->isSystemUser();
|
||||
}),
|
||||
|
||||
SyncWithSystem::make()
|
||||
->icon('cloud')
|
||||
->sole()
|
||||
->withoutConfirmation(),
|
||||
->withoutConfirmation()
|
||||
->canSee(function ($request) {
|
||||
return auth()->user()->isAdmin();
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,6 +120,8 @@ class NovaVisaMasterPaymentOrderItem extends Resource
|
||||
Text::make('Amalyň referensi', fn ($model) => $model->payment_order_number),
|
||||
|
||||
Boolean::make(__('Paid'), 'paid'),
|
||||
|
||||
Boolean::make(__('Synced with system'), 'synced_with_system'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
]);
|
||||
}
|
||||
|
||||
$total_amount = floatval(number_format($payment_amount, 2, '.', '')) + 23;
|
||||
$total_amount = floatval(number_format($payment_amount, 2, '.', '')) + 115;
|
||||
|
||||
$payment = $this->order($resource, $total_amount);
|
||||
|
||||
@@ -126,8 +126,8 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
return [
|
||||
Heading::make(Blade::render(<<<HTML
|
||||
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">1 USD = $usd_to_tmt TMT</h3>
|
||||
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">Bankyň tutumy: 20 TMT</h3>
|
||||
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">GBÜS tutumy: 3 TMT</h3>
|
||||
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">Bankyň tutumy: 100 TMT</h3>
|
||||
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">GBÜS tutumy: 15 TMT</h3>
|
||||
HTML))->asHtml(),
|
||||
|
||||
Text::make(__('Töleg aý'), 'month')
|
||||
@@ -173,7 +173,7 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
|
||||
if ($payment_amount) {
|
||||
$field->setValue(
|
||||
floatval(number_format($payment_amount, 2, '.', '')) + 23
|
||||
floatval(number_format($payment_amount, 2, '.', '')) + 115
|
||||
);
|
||||
} else {
|
||||
$field->setValue('');
|
||||
|
||||
@@ -34,36 +34,13 @@ class SyncWithSystem extends Action
|
||||
/** @var \App\Modules\SberPaymentOrder\Models\SberPaymentOrderItem $orderItem */
|
||||
$orderItem = $models->first();
|
||||
|
||||
$result = getSberCredentials($orderItem);
|
||||
$result = syncSberWithAzatAPI($orderItem);
|
||||
|
||||
if (isset($result['error'])) {
|
||||
$this->handleError($result);
|
||||
return $this->handleError($result);
|
||||
}
|
||||
|
||||
/** @var \App\Models\Payment\OnlinePaymentHistory $onlinePaymentResource */
|
||||
$onlinePaymentResource = $result['onlinePaymentResource'];
|
||||
|
||||
/** @var \App\Modules\SberPaymentOrder\Models\SberPaymentOrder $sberPaymentOrder */
|
||||
$sberPaymentOrder = $result['relatedResource'];
|
||||
|
||||
$response = checkOnlinePayment($onlinePaymentResource->orderId, $result['username'], $result['password']);
|
||||
|
||||
$systemResponse = syncWithBankSystem(
|
||||
online_payment_order_uuid: $onlinePaymentResource->orderId,
|
||||
bank_unique_code: $sberPaymentOrder->branch->unique_code,
|
||||
online_payment_terminal_id: $response['terminalId'],
|
||||
user_deposit_account: number_format($sberPaymentOrder->sender_deposit_account, 0, '', ''),
|
||||
online_payment_auth_ref_num: $response['authRefNum'],
|
||||
online_payment_tmt_amount: $orderItem->tmt_payment_amount,
|
||||
pay_purpose: $sberPaymentOrder->created_at->translatedFormat('F').' '.$sberPaymentOrder->created_at->format('Y')
|
||||
);
|
||||
|
||||
info($systemResponse);
|
||||
|
||||
return Action::modal('modal-response', [
|
||||
'title' => 'SYSTEM API',
|
||||
'html' => "<>",
|
||||
]);
|
||||
return ActionResponse::message('Sync with system success');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -127,7 +127,7 @@ class CardOrder extends Resource
|
||||
return $query;
|
||||
}
|
||||
|
||||
if ($user->isOperator() && count($user->branches()->pluck('branches.id')) < 1) {
|
||||
if ($user->isOperator()) {
|
||||
return $query->whereIn('branch_id', $user->branches()->pluck('branches.id'));
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class RouteServiceProvider extends ServiceProvider
|
||||
public function boot(): void
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||
return Limit::perMinute(300)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
|
||||
$this->routes(function () {
|
||||
|
||||
@@ -53,13 +53,13 @@ trait HandlesCardOrderPayments
|
||||
'paymentStatus' => OnlinePaymentRepo::PAID,
|
||||
]);
|
||||
|
||||
return static::successfulPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL);
|
||||
return static::successfulPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL, $response);
|
||||
}
|
||||
|
||||
$paymentHistory->update([
|
||||
'paymentStatus' => OnlinePaymentRepo::FAILED,
|
||||
]);
|
||||
|
||||
return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL);
|
||||
return static::failedPaymentResponse($paymentHistory, $bank_branch, $resource, $returnURL, $response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ trait HandlesVisaMasterPayments
|
||||
$payment_status = $response['paymentAmountInfo']['depositedAmount'] > 0;
|
||||
|
||||
$cardholderName = $response['cardAuthInfo']['cardholderName'] ?? '-';
|
||||
$cardPan = $response['cardAuthInfo']['Pan'] ?? '-';
|
||||
$cardPan = $response['cardAuthInfo']['pan'] ?? '-';
|
||||
|
||||
if ($payment_status) {
|
||||
$resource->update([
|
||||
|
||||
@@ -161,6 +161,20 @@ return [
|
||||
'level' => env('LOG_LEVEL', 'error'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'sber_job' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/sber_job.log'),
|
||||
'level' => env('LOG_LEVEL', 'error'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'visa_job' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/visa_job.log'),
|
||||
'level' => env('LOG_LEVEL', 'error'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
@@ -15,6 +15,10 @@ return new class extends PulseMigration
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::dropIfExists('pulse_values');
|
||||
Schema::dropIfExists('pulse_entries');
|
||||
Schema::dropIfExists('pulse_aggregates');
|
||||
|
||||
Schema::create('pulse_values', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedInteger('timestamp');
|
||||
|
||||
@@ -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('visa_master_payment_order_items', function (Blueprint $table) {
|
||||
$table->boolean('synced_with_system')->nullable()->default(false);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('visa_master_payment_order_items', function (Blueprint $table) {
|
||||
$table->dropColumn('synced_with_system');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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('warnings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('message');
|
||||
$table->text('content');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('warnings');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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('ignore_visa_payments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('message')->index();
|
||||
$table->unsignedBigInteger('payment_id')->index();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ignore_visa_payments');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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('ignore_sber_payments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('message')->index();
|
||||
$table->unsignedBigInteger('payment_id')->index();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ignore_sber_payments');
|
||||
}
|
||||
};
|
||||
@@ -49,7 +49,7 @@ async function login(event) {
|
||||
id="username"
|
||||
type="text"
|
||||
name="username"
|
||||
placeholder="+99365999990 {{ __('or') }} ulanyjy_ady"
|
||||
placeholder="65999990 {{ __('or') }} ulanyjy_ady"
|
||||
autofocus=""
|
||||
value="{{ old('username') }}"
|
||||
>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
<div class="mt-8 leading-normal text-xs text-gray-500 space-y-1">
|
||||
<p class="text-center">Powered by <a class="link-default" target="_blank" href="https://webulgam.com">Web Ulgam,</a></p>
|
||||
<p class="text-center">© {{ date('Y') }} TBBANK.GOV.TM.</p>
|
||||
</div>
|
||||
|
||||
@@ -108,6 +108,7 @@ Route::middleware(['auth:sanctum', 'not_banned'])->group(function () {
|
||||
Route::delete('card-order/{cardOrder}', [CardOrderController::class, 'destroy']);
|
||||
|
||||
// Card transactions... [tested fully]
|
||||
Route::get('card-transactions-last-month', [CardTransactionsController::class, 'lastMonth']);
|
||||
Route::get('card-transactions', [CardTransactionsController::class, 'index']);
|
||||
Route::get('card-transactions/{order}', [CardTransactionsController::class, 'show']);
|
||||
Route::get('card-transactions-download/{order}', [CardTransactionsController::class, 'download']);
|
||||
|
||||
Reference in New Issue
Block a user