fix pargar and login

This commit is contained in:
2026-08-01 14:04:01 +03:30
parent 6e75b9632b
commit 87f0e2beed
9 changed files with 248 additions and 38 deletions
+26 -11
View File
@@ -33,17 +33,29 @@ class MontzarService
public function montzarLogin(): string
{
$response = Http::timeout(10)
->acceptJson()
->post($this->endpoint('/server/auth/login'), [
'mobile' => $this->config()->Config('montzar_mobile'),
'password' => $this->config()->Config('montzar_password'),
'provider' => 'customer',
'type_app' => 'client',
])
->json();
try {
$response = Http::timeout(10)
->acceptJson()
->post($this->endpoint('/server/auth/login'), [
'mobile' => $this->config()->Config('montzar_mobile'),
'password' => $this->config()->Config('montzar_password'),
'provider' => 'customer',
'type_app' => 'client',
])
->json();
} catch (\Throwable $e) {
Log::error('Montzar login request failed', [
'base_url' => $this->baseUrl(),
'error' => $e->getMessage(),
]);
throw new UnprocessableEntityHttpException(
'سرویس موقتا در دسترس نیست، لطفاً با پشتیبانی تماس بگیرید.'
);
}
$token = $response['access_token'] ?? $response['token'] ?? null;
$token = is_array($response)
? ($response['access_token'] ?? $response['token'] ?? null)
: null;
if (!$token) {
Log::error('Montzar login failed', [
@@ -51,7 +63,10 @@ class MontzarService
'mobile' => $this->config()->Config('montzar_mobile'),
'response' => $response,
]);
throw new \Exception('Montzar login failed: ' . json_encode($response, JSON_UNESCAPED_UNICODE));
// 422 تا فرانت toast نشان دهد؛ جزئیات فنی فقط در لاگ می‌ماند
throw new UnprocessableEntityHttpException(
'سرویس موقتا در دسترس نیست، لطفاً با پشتیبانی تماس بگیرید.'
);
}
Setting::updateOrCreate(