fix some bugs from zarin
This commit is contained in:
@@ -1502,7 +1502,9 @@ class ZarinController extends Controller
|
||||
if (!empty($idHesab)) {
|
||||
$customer->moshtari_code = $idHesab;
|
||||
$customer->save();
|
||||
return $idHesab;
|
||||
|
||||
// int برگردان تا با پیام خطای string اشتباه نشود
|
||||
return is_numeric($idHesab) ? (0 + $idHesab) : $idHesab;
|
||||
}
|
||||
|
||||
$detail = $data['msg'] ?? $data['message'] ?? $data['detail'] ?? null;
|
||||
|
||||
@@ -171,21 +171,25 @@ class ZarinSyncService
|
||||
|
||||
$controller = app(ZarinController::class);
|
||||
$result = $controller->createCustomerInZarin($customer->id);
|
||||
|
||||
if (is_string($result)) {
|
||||
return ['ok' => false, 'message' => $result];
|
||||
}
|
||||
|
||||
$customer->refresh();
|
||||
|
||||
if (empty($customer->moshtari_code)) {
|
||||
return ['ok' => false, 'message' => 'ثبت مشتری در زرین ناموفق بود'];
|
||||
// createCustomerInZarin در موفقیت idHesab برمیگرداند (عدد یا رشتهٔ عددی مثل "426")
|
||||
// و در شکست پیام فارسی/خطا — قبلاً is_string همهٔ موفقیتهای رشتهای را خطا میگرفت.
|
||||
if (! empty($customer->moshtari_code) || is_numeric($result)) {
|
||||
$code = $customer->moshtari_code ?: $result;
|
||||
|
||||
return [
|
||||
'ok' => true,
|
||||
'message' => 'مشتری با موفقیت در زرین ثبت شد',
|
||||
'moshtari_code' => $code,
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'ok' => true,
|
||||
'message' => 'مشتری با موفقیت در زرین ثبت شد',
|
||||
'moshtari_code' => $customer->moshtari_code,
|
||||
'ok' => false,
|
||||
'message' => is_string($result) && $result !== ''
|
||||
? $result
|
||||
: 'ثبت مشتری در زرین ناموفق بود',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user