NASER add jibit verification api and jibit counter
This commit is contained in:
@@ -4,9 +4,12 @@ namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\DB\Te\TableEngine;
|
||||
use App\Http\Controllers\SuperController;
|
||||
use App\Models\Cnt;
|
||||
use App\Models\Customer;
|
||||
use App\Models\TransactionsAdmin;
|
||||
use App\Models\Withdraw;
|
||||
use Carbon\Carbon;
|
||||
use Hekmatinasser\Verta\Verta;
|
||||
use Illuminate\Http\Request;
|
||||
use Rooyesh\Wallet\interfaces\TransactionInterface;
|
||||
use Rooyesh\Wallet\interfaces\WalletInterface;
|
||||
@@ -254,4 +257,35 @@ class CustomerController extends SuperController
|
||||
|
||||
return response()->json(true);
|
||||
}
|
||||
|
||||
public function cardChecker(Request $request){
|
||||
|
||||
if (strlen($request->cart_number) != 16) {
|
||||
throw new UnprocessableEntityHttpException('شماره کارت اشتباه میباشد.');
|
||||
}
|
||||
if (empty($request->national_code)) {
|
||||
throw new UnprocessableEntityHttpException('لطفا شماره ملی وارد کنید.');
|
||||
}
|
||||
if(empty($request->birth_date)){
|
||||
throw new UnprocessableEntityHttpException('لطفا تاریخ تولد وارد کنید.');
|
||||
}
|
||||
$birth_date = Verta::instance(Carbon::parse($request->birth_date))->format('Ymd');
|
||||
$card_number = preg_replace('/\D/', '', $request->cart_number);
|
||||
|
||||
// dd("ok");
|
||||
|
||||
$response = $this->jibit("cartMatching", $card_number, $request->national_code, $birth_date);
|
||||
|
||||
if(!empty($response)){
|
||||
if (isset($response['cartData'])) {
|
||||
unset($response['refresh']);
|
||||
return response()->json($response);
|
||||
}elseif(!empty($response['message'])){
|
||||
throw new UnprocessableEntityHttpException($response['message']);
|
||||
}
|
||||
}else{
|
||||
throw new UnprocessableEntityHttpException('ارتباط با سامانه قطع میباشد.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Cnt;
|
||||
use App\Models\User;
|
||||
use App\Models\Customer;
|
||||
use App\Models\Setting;
|
||||
@@ -179,6 +180,14 @@ class Controller extends BaseController
|
||||
|
||||
public static function jibit($method, $p1 = null, $p2 = null, $p3 = null)
|
||||
{
|
||||
$counter = Cnt::where('key', 'jibit_counter')->first();
|
||||
if(empty($counter)){
|
||||
$counter = new Cnt();
|
||||
$counter->key = "jibit_counter";
|
||||
$counter->value = 0;
|
||||
$counter->save();
|
||||
}
|
||||
|
||||
$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']);
|
||||
@@ -196,6 +205,10 @@ class Controller extends BaseController
|
||||
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();
|
||||
}
|
||||
//update jibit counter
|
||||
$counter->value = (int)$counter->value + 1;
|
||||
$counter->save();
|
||||
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user