stan errros

This commit is contained in:
2025-11-02 19:46:54 +05:00
parent 45fbde31c7
commit 7f394b90fa
4 changed files with 22 additions and 20 deletions

View File

@@ -5,6 +5,7 @@ namespace App\Modules\Branch\Interfaces;
/**
* @property int $id
* @property int $branch_id
* @property \App\Modules\Branch\Models\Branch $branch
*
* @phpstan-require-extends \Illuminate\Database\Eloquent\Model
*/

View File

@@ -12,8 +12,8 @@ use Spatie\Translatable\HasTranslations;
/**
* @property int $id
* @property string $unique_code
* @property array<string, string> $name
* @property array<string, string>|null $address
* @property string $name
* @property string|null $address
* @property string $region
* @property int|null $province_id
* @property array<string, string>|null $phone_numbers

View File

@@ -100,7 +100,7 @@ class HalkbankOnlinePaymentRepository implements PaymentProviderContract
return new Response(new GuzzleResponse(
503,
['Content-Type' => 'application/json'],
sprintf('{"errorCode":"99","errorMessage":"FAILED_REQUEST"}', $e->getMessage())
'{"errorCode":"99","errorMessage":"FAILED_REQUEST"}'
));
}

View File

@@ -186,11 +186,12 @@ class OnlinePaymentRepository
/**
* Check payment
*
* @return array{success: bool, title: string, pnr: string, branch_name: string, price_amount: string, return_url: string}
* @return array<string, string|bool|int>
*/
public function checkPayment(string $orderId): array
{
/** @var \App\Modules\OnlinePayment\Models\OnlinePayment Find payment order from history */
// Find payment order from history
/** @var \App\Modules\OnlinePayment\Models\OnlinePayment */
$paymentHistory = OnlinePayment::where('orderId', $orderId)->first();
// Resolve related resource model dynamically
@@ -209,12 +210,12 @@ class OnlinePaymentRepository
return $this->paymentFailed('(RESOURCE NOT FOUND)');
}
$relatedResource->load('branch');
$relatedResource->loadMissing('branch');
/** @var \App\Modules\Branch\Models\Branch */
$bankBranch = $relatedResource->branch;
if (! $bankBranch) {
if (! $bankBranch || is_null($bankBranch->billing_username) || is_null($bankBranch->billing_password)) { // @phpstan-ignore-line
return $this->paymentFailed('(BRANCH NOT FOUND)');
}
@@ -226,17 +227,17 @@ class OnlinePaymentRepository
return $this->paymentFailed('(REQUEST FAILURE)');
}
return $response['paymentAmountInfo']['depositedAmount'] > 0
? $this->paymentSuccessful($relatedResource, $paymentHistory, $bankBranch)
: $this->paymentFailed(__('Payment has failed'), $paymentHistory, $bankBranch);
return $response['paymentAmountInfo']['depositedAmount'] > 0 // @phpstan-ignore-line
? $this->paymentSuccessful($relatedResource, $paymentHistory, $bankBranch->name)
: $this->paymentFailed(__('Payment has failed'), $paymentHistory, $bankBranch->name);
}
/**
* Successful payment
*
* @return array{success: bool, title: string, pnr: string, branch_name: string, price_amount: string, return_url: string}
* @return array<string, string|bool|int>
*/
public function paymentSuccessful($relatedResource, $paymentHistory, $bankBranch): array
public function paymentSuccessful(Model $relatedResource, OnlinePayment $paymentHistory, string $branchName = ''): array
{
$relatedResource->update([
'paid' => true,
@@ -249,7 +250,7 @@ class OnlinePaymentRepository
return $this->paymentCheckResponseTemplate(
success: true,
pnr: $paymentHistory->online_paymantable_id,
branch_name: $bankBranch->name,
branch_name: $branchName,
price_amount: $paymentHistory->amount.' TMT'
);
}
@@ -257,9 +258,9 @@ class OnlinePaymentRepository
/**
* Failed payment
*
* @return array{success: bool, title: string, pnr: string, branch_name: string, price_amount: string, return_url: string}
* @return array<string, string|bool|int>
*/
public function paymentFailed(string $title = '', $paymentHistory = null, $bankBranch = null): array
public function paymentFailed(string $title = '', ?OnlinePayment $paymentHistory = null, string $branchName = ''): array
{
if ($paymentHistory) {
$paymentHistory->update([
@@ -269,7 +270,7 @@ class OnlinePaymentRepository
return $this->paymentCheckResponseTemplate(
success: false,
pnr: $paymentHistory->online_paymantable_id,
branch_name: $bankBranch->name,
branch_name: $branchName,
price_amount: $paymentHistory->amount.' TMT'
);
}
@@ -280,14 +281,14 @@ class OnlinePaymentRepository
/**
* Check payment response
*
* @return array{success: bool, title: string, pnr: string, branch_name: string, price_amount: string, return_url: string}
* @return array<string, string|bool|int>
*/
public function paymentCheckResponseTemplate(
bool $success,
string $title = '',
string $pnr = '',
int|string $pnr = '',
string $branch_name = '',
string $price_amount = '',
int|string $price_amount = '',
string $return_url = ''
): array {
return [
@@ -303,7 +304,7 @@ class OnlinePaymentRepository
/**
* Show payment status
*
* @param array{success: bool, title: string, pnr: string, branch_name: string, price_amount: string, return_url: string} $data
* @param array<string, string|bool|int> $data
*/
public function paymentStatusView(array $data): View
{