NASER add jibit and send admin messages to bale
This commit is contained in:
@@ -10,8 +10,11 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
|||||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||||
use Illuminate\Routing\Controller as BaseController;
|
use Illuminate\Routing\Controller as BaseController;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Controller extends BaseController
|
class Controller extends BaseController
|
||||||
@@ -69,7 +72,10 @@ class Controller extends BaseController
|
|||||||
"telegram" => [
|
"telegram" => [
|
||||||
"token" => self::Config('telegram_bot_token')
|
"token" => self::Config('telegram_bot_token')
|
||||||
],
|
],
|
||||||
|
"bale" => [
|
||||||
|
"token" => self::Config('bale_bot_token')
|
||||||
|
// "token" => Setting::where('key', 'bale_bot_token')->where('is_active', true)->first()->value ?? null
|
||||||
|
],
|
||||||
"sms" => [
|
"sms" => [
|
||||||
'user_name' => 'ysms1362',
|
'user_name' => 'ysms1362',
|
||||||
'password' => 'tL4w0PfNy2()',
|
'password' => 'tL4w0PfNy2()',
|
||||||
@@ -79,7 +85,7 @@ class Controller extends BaseController
|
|||||||
$platforms = [];
|
$platforms = [];
|
||||||
$send_sms = true;
|
$send_sms = true;
|
||||||
$user = User::where('mobile', $to)->first() ?: Customer::where('mobile', $to)->first();
|
$user = User::where('mobile', $to)->first() ?: Customer::where('mobile', $to)->first();
|
||||||
// if ($user) {
|
if ($user) {
|
||||||
//
|
//
|
||||||
// // Telegram
|
// // Telegram
|
||||||
// if (isset($credentials['telegram']) && $user->telegram) {
|
// if (isset($credentials['telegram']) && $user->telegram) {
|
||||||
@@ -98,20 +104,20 @@ class Controller extends BaseController
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// // Bale
|
// Bale
|
||||||
// if (isset($credentials['bale']) && $user->bale) {
|
if (isset($credentials['bale']) && $user->bale) {
|
||||||
// try {
|
try {
|
||||||
// Http::get("https://api.wwwapp.ir/bale_send.php", [
|
Http::withoutVerifying()->get("https://tapi.bale.ai/{$credentials['bale']['token']}/sendMessage", [
|
||||||
// 'botToken' => $credentials['bale']['token'],
|
'chat_id' => $user->bale,
|
||||||
// 'chatId' => $user->bale,
|
'text' => "جناب {$user->name} {$msg}",
|
||||||
// 'message' => "جناب {$user->name} {$msg}",
|
]);
|
||||||
// ]);
|
$platforms[] = "bale:{$user->bale}";
|
||||||
// $platforms[] = "bale:{$user->bale}";
|
$send_sms = false;
|
||||||
// $send_sms = false;
|
} catch (\Exception $e) {
|
||||||
// } catch (\Exception $e) {
|
return $e->getMessage();
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
//SMS
|
//SMS
|
||||||
if ($send_sms or $force_method=="sms") {
|
if ($send_sms or $force_method=="sms") {
|
||||||
@@ -170,4 +176,32 @@ class Controller extends BaseController
|
|||||||
//
|
//
|
||||||
// return $settingValue;
|
// return $settingValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function jibit($method, $p1 = null, $p2 = null, $p3 = null)
|
||||||
|
{
|
||||||
|
$apiData['refresh'] = Http::withoutVerifying()->withoutVerifying()->withToken(Storage::get('refreshTokenGibit'))
|
||||||
|
->post("https://napi.jibit.ir/ide/v1/tokens/generate", ['apiKey' => "J5WxrPxPOg", 'secretKey' => "7dgeE70xQXsQL7r36j3wif6X9",])->json();
|
||||||
|
Storage::put('accessTokenGibit', $apiData['refresh']['accessToken']);
|
||||||
|
|
||||||
|
if (!Storage::exists('accessTokenGibit') || !Storage::exists('refreshTokenGibit')) {
|
||||||
|
Storage::put('accessTokenGibit', 'توکن اولیه');
|
||||||
|
Storage::put('refreshTokenGibit', 'توکن رفرش اولیه');
|
||||||
|
}
|
||||||
|
|
||||||
|
$apiData['cartMatching'] = Http::withoutVerifying()->withToken(Storage::get('accessTokenGibit'))->get("https://napi.jibit.ir/ide/v1/services/matching?cardNumber=$p1&nationalCode=$p2&birthDate=$p3")->json();
|
||||||
|
if ((isset($apiData['cartMatching']['code'])) and $apiData['cartMatching']['code'] == "forbidden") {
|
||||||
|
$apiData['refresh'] = Http::withoutVerifying()->withToken(Storage::get('refreshTokenGibit'))
|
||||||
|
->post("https://napi.jibit.ir/ide/v1/tokens/generate", ['apiKey' => "J5WxrPxPOg", 'secretKey' => "7dgeE70xQXsQL7r36j3wif6X9",])->json();
|
||||||
|
Storage::put('accessTokenGibit', $apiData['refresh']['accessToken']);
|
||||||
|
Storage::put('refreshTokenGibit', $apiData['refresh']['refreshToken']);
|
||||||
|
$apiData['cartMatching'] = Http::withoutVerifying()->withToken(Storage::get('accessTokenGibit'))->get("https://napi.jibit.ir/ide/v1/services/matching?cardNumber=$p1&nationalCode=$p2&birthDate=$p3")->json();
|
||||||
|
}
|
||||||
|
if (isset( $apiData['cartMatching']['matched']) and $apiData['cartMatching']['matched'] == true) {
|
||||||
|
$apiData['cartData'] = Http::withoutVerifying()->withToken(Storage::get('accessTokenGibit'))->get("https://napi.jibit.ir/ide/v1/cards?number=$p1&iban=true")->json();
|
||||||
|
return $apiData;
|
||||||
|
} else {
|
||||||
|
throw new UnprocessableEntityHttpException($apiData['cartMatching']['message']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ use App\Models\BankAccount;
|
|||||||
use App\Models\Customer;
|
use App\Models\Customer;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Morilog\Jalali\Jalalian;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use App\Models\Log;
|
||||||
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
||||||
|
|
||||||
class BankAccountController extends SuperController
|
class BankAccountController extends SuperController
|
||||||
@@ -36,9 +39,70 @@ class BankAccountController extends SuperController
|
|||||||
}
|
}
|
||||||
public function StoreBankAccount(Request $request)
|
public function StoreBankAccount(Request $request)
|
||||||
{
|
{
|
||||||
if (empty($request->shaba_number) || empty($request->bank_name) ){
|
if (strlen($request->cart_number) != 16) {
|
||||||
// || empty($request->cart_number) || empty($request->account_number)) {
|
throw new UnprocessableEntityHttpException('شماره کارت اشتباه میباشد.');
|
||||||
throw new UnprocessableEntityHttpException('اطلاعات کارت را کامل وارد کنید.');
|
}
|
||||||
|
if (BankAccount::where('cart_number', $request->cart_number)->exists()) {
|
||||||
|
throw new UnprocessableEntityHttpException('شماره کارت تکراری میباشد.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = auth()->guard('customer')->user();
|
||||||
|
if ($user->n_code === null || $user->n_code === '') {
|
||||||
|
throw new UnprocessableEntityHttpException('لطفا شماره ملی خود را در پروفایل کاربری وارد کنید سپس اقدام به ثبت کارت بانکی کنید.');
|
||||||
|
}
|
||||||
|
if($user->birth_date == null && !isset($request->birth_date)){
|
||||||
|
throw new UnprocessableEntityHttpException('لطفا تاریخ تولد خود را در پروفایل کاربری وارد کنید سپس اقدام به ثبت کارت بانکی کنید.');
|
||||||
|
}
|
||||||
|
|
||||||
|
//with verification in jibit
|
||||||
|
if($this->Config('jibit_verification') == 'true') {
|
||||||
|
$p1 = $apiData['iban'] = preg_replace('/\D/', '', $request->cart_number);
|
||||||
|
$p2 = $apiData['nationalCode'] = $user->n_code;
|
||||||
|
$p3 = $apiData['birthDate'] = Jalalian::fromCarbon(Carbon::parse($request->birth_date ?? $user->birth_date))->format('Ymd');
|
||||||
|
// dd($p3);
|
||||||
|
// [$apiData['iban'],$apiData['nationalCode'],$apiData['birthDate']];
|
||||||
|
|
||||||
|
$apiData['r'] = $this->jibit('cartMatching', $apiData['iban'], $apiData['nationalCode'], $apiData['birthDate']);
|
||||||
|
try {
|
||||||
|
$log = new Log();
|
||||||
|
$log->customer_id = auth('customer')->id();
|
||||||
|
$log->data = json_encode($apiData['r'], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||||
|
$log->save();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $e->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($apiData['r']['cartData'])) {
|
||||||
|
$BA = BankAccount::create([
|
||||||
|
'customer_id' => $user->id,
|
||||||
|
'cart_number' => $apiData['r']['cartData']['number'],
|
||||||
|
'bank_name' => $apiData['r']['cartData']['ibanInfo']['bank'],
|
||||||
|
'account_number' => $apiData['r']['cartData']['ibanInfo']['depositNumber'],
|
||||||
|
'shaba_number' => $apiData['r']['cartData']['ibanInfo']['iban'],
|
||||||
|
'first_name' => $apiData['r']['cartData']['ibanInfo']['owners'][0]['firstName'],
|
||||||
|
'last_name' => $apiData['r']['cartData']['ibanInfo']['owners'][0]['lastName'],
|
||||||
|
'cart_status' => $apiData['r']['cartData']['ibanInfo']['status'],
|
||||||
|
'sts' => 2,
|
||||||
|
]);
|
||||||
|
Customer::where('id', $user->id)->update(['birth_date' => $request->birth_date ?? $user->birth_date]);
|
||||||
|
$data = ['success' => true, 'bankAccount' => $BA];
|
||||||
|
return response()->json($data);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$message = "احرازهویت برای شماره کارت کاربر " . $user->name . " توسط جیبیت انجام نشد. لطفا از پنل ادمین اقدام کنید. ";
|
||||||
|
User::where('send_sms', 1)->get()->each(function ($admin) use ($message) {
|
||||||
|
$this->SendMessage($admin->mobile, $message);
|
||||||
|
});
|
||||||
|
$BA = BankAccount::create([
|
||||||
|
'customer_id' => $user->id,
|
||||||
|
'cart_number' => $request->cart_number,
|
||||||
|
'first_name' => $user->fname,
|
||||||
|
'last_name' => $user->lname,
|
||||||
|
'sts' => 1,
|
||||||
|
]);
|
||||||
|
throw new UnprocessableEntityHttpException('شماره کارت شما برای ادمین ارسال شد و پس از تایید قابل استفاده می باشد.');
|
||||||
|
return $apiData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$customer = Customer::find(auth('customer')->id());
|
$customer = Customer::find(auth('customer')->id());
|
||||||
$message = "کارت جدیدی برای $customer->name ساخته شد منتظر تایید شما هستیم.";
|
$message = "کارت جدیدی برای $customer->name ساخته شد منتظر تایید شما هستیم.";
|
||||||
|
|||||||
+3
-1
@@ -12,7 +12,9 @@
|
|||||||
"laravel/framework": "^8.75",
|
"laravel/framework": "^8.75",
|
||||||
"laravel/sanctum": "^2.11",
|
"laravel/sanctum": "^2.11",
|
||||||
"laravel/tinker": "^2.5",
|
"laravel/tinker": "^2.5",
|
||||||
"tymon/jwt-auth": "^1.0"},
|
"morilog/jalali": "^3.5",
|
||||||
|
"tymon/jwt-auth": "^1.0"
|
||||||
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"facade/ignition": "^2.5",
|
"facade/ignition": "^2.5",
|
||||||
"fakerphp/faker": "^1.9.1",
|
"fakerphp/faker": "^1.9.1",
|
||||||
|
|||||||
Generated
+133
-3
@@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "b54cf60d425ecf4c236afb86b8d7732a",
|
"content-hash": "5f478ca0e6f98ed82d66539664823b62",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "asm89/stack-cors",
|
"name": "asm89/stack-cors",
|
||||||
@@ -62,6 +62,72 @@
|
|||||||
},
|
},
|
||||||
"time": "2023-11-14T13:51:46+00:00"
|
"time": "2023-11-14T13:51:46+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "beberlei/assert",
|
||||||
|
"version": "v3.3.3",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/beberlei/assert.git",
|
||||||
|
"reference": "b5fd8eacd8915a1b627b8bfc027803f1939734dd"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://mirror2.chabokan.net/composer/p/beberlei/assert/v3.3.3",
|
||||||
|
"reference": "b5fd8eacd8915a1b627b8bfc027803f1939734dd",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-ctype": "*",
|
||||||
|
"ext-json": "*",
|
||||||
|
"ext-mbstring": "*",
|
||||||
|
"ext-simplexml": "*",
|
||||||
|
"php": "^7.1 || ^8.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"friendsofphp/php-cs-fixer": "*",
|
||||||
|
"phpstan/phpstan": "*",
|
||||||
|
"phpunit/phpunit": ">=6.0.0",
|
||||||
|
"yoast/phpunit-polyfills": "^0.1.0"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-intl": "Needed to allow Assertion::count(), Assertion::isCountable(), Assertion::minCount(), and Assertion::maxCount() to operate on ResourceBundles"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"lib/Assert/functions.php"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Assert\\": "lib/Assert"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"license": [
|
||||||
|
"BSD-2-Clause"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Benjamin Eberlei",
|
||||||
|
"role": "Lead Developer",
|
||||||
|
"email": "kontakt@beberlei.de"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Richard Quadling",
|
||||||
|
"role": "Collaborator",
|
||||||
|
"email": "rquadling@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Thin assertion library for input validation in business models.",
|
||||||
|
"keywords": [
|
||||||
|
"assert",
|
||||||
|
"assertion",
|
||||||
|
"validation"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/beberlei/assert/issues",
|
||||||
|
"source": "https://github.com/beberlei/assert/tree/v3.3.3"
|
||||||
|
},
|
||||||
|
"time": "2024-07-15T13:18:35+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "brick/math",
|
"name": "brick/math",
|
||||||
"version": "0.12.1",
|
"version": "0.12.1",
|
||||||
@@ -2094,6 +2160,70 @@
|
|||||||
],
|
],
|
||||||
"time": "2024-04-12T20:52:51+00:00"
|
"time": "2024-04-12T20:52:51+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "morilog/jalali",
|
||||||
|
"version": "v3.5.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/morilog/jalali.git",
|
||||||
|
"reference": "40b906c405b72edd20e73797b40be1e650e872c1"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://mirror2.chabokan.net/composer/p/morilog/jalali/v3.5.0",
|
||||||
|
"reference": "40b906c405b72edd20e73797b40be1e650e872c1",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"beberlei/assert": "^3.0",
|
||||||
|
"nesbot/carbon": "^1.21 || ^2.0 || ^3.0",
|
||||||
|
"php": "^7.1 | ^8.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": ">4.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"src/helpers.php"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Morilog\\Jalali\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Milad Rey",
|
||||||
|
"email": "miladr@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Morteza Parvini",
|
||||||
|
"email": "m.parvini@outlook.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "This Package helps developers to easily work with Jalali (Shamsi or Iranian) dates in PHP applications, based on Jalali (Shamsi) DateTime class.",
|
||||||
|
"keywords": [
|
||||||
|
"Jalali",
|
||||||
|
"date",
|
||||||
|
"datetime",
|
||||||
|
"laravel",
|
||||||
|
"morilog"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/morilog/jalali/issues",
|
||||||
|
"source": "https://github.com/morilog/jalali/tree/v3.5.0"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://issuehunt.io/r/morilog",
|
||||||
|
"type": "issuehunt"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2025-12-25T07:12:28+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "namshi/jose",
|
"name": "namshi/jose",
|
||||||
"version": "7.2.3",
|
"version": "7.2.3",
|
||||||
@@ -8288,12 +8418,12 @@
|
|||||||
],
|
],
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"stability-flags": [],
|
"stability-flags": {},
|
||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
"platform": {
|
"platform": {
|
||||||
"php": "^7.3|^8.0"
|
"php": "^7.3|^8.0"
|
||||||
},
|
},
|
||||||
"platform-dev": [],
|
"platform-dev": {},
|
||||||
"plugin-api-version": "2.6.0"
|
"plugin-api-version": "2.6.0"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user