stan errros
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Modules\Branch\Interfaces;
|
|||||||
/**
|
/**
|
||||||
* @property int $id
|
* @property int $id
|
||||||
* @property int $branch_id
|
* @property int $branch_id
|
||||||
|
* @property \App\Modules\Branch\Models\Branch $branch
|
||||||
*
|
*
|
||||||
* @phpstan-require-extends \Illuminate\Database\Eloquent\Model
|
* @phpstan-require-extends \Illuminate\Database\Eloquent\Model
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ use Spatie\Translatable\HasTranslations;
|
|||||||
/**
|
/**
|
||||||
* @property int $id
|
* @property int $id
|
||||||
* @property string $unique_code
|
* @property string $unique_code
|
||||||
* @property array<string, string> $name
|
* @property string $name
|
||||||
* @property array<string, string>|null $address
|
* @property string|null $address
|
||||||
* @property string $region
|
* @property string $region
|
||||||
* @property int|null $province_id
|
* @property int|null $province_id
|
||||||
* @property array<string, string>|null $phone_numbers
|
* @property array<string, string>|null $phone_numbers
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ class HalkbankOnlinePaymentRepository implements PaymentProviderContract
|
|||||||
return new Response(new GuzzleResponse(
|
return new Response(new GuzzleResponse(
|
||||||
503,
|
503,
|
||||||
['Content-Type' => 'application/json'],
|
['Content-Type' => 'application/json'],
|
||||||
sprintf('{"errorCode":"99","errorMessage":"FAILED_REQUEST"}', $e->getMessage())
|
'{"errorCode":"99","errorMessage":"FAILED_REQUEST"}'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -186,11 +186,12 @@ class OnlinePaymentRepository
|
|||||||
/**
|
/**
|
||||||
* Check payment
|
* 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
|
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();
|
$paymentHistory = OnlinePayment::where('orderId', $orderId)->first();
|
||||||
|
|
||||||
// Resolve related resource model dynamically
|
// Resolve related resource model dynamically
|
||||||
@@ -209,12 +210,12 @@ class OnlinePaymentRepository
|
|||||||
return $this->paymentFailed('(RESOURCE NOT FOUND)');
|
return $this->paymentFailed('(RESOURCE NOT FOUND)');
|
||||||
}
|
}
|
||||||
|
|
||||||
$relatedResource->load('branch');
|
$relatedResource->loadMissing('branch');
|
||||||
|
|
||||||
/** @var \App\Modules\Branch\Models\Branch */
|
/** @var \App\Modules\Branch\Models\Branch */
|
||||||
$bankBranch = $relatedResource->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)');
|
return $this->paymentFailed('(BRANCH NOT FOUND)');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,17 +227,17 @@ class OnlinePaymentRepository
|
|||||||
return $this->paymentFailed('(REQUEST FAILURE)');
|
return $this->paymentFailed('(REQUEST FAILURE)');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response['paymentAmountInfo']['depositedAmount'] > 0
|
return $response['paymentAmountInfo']['depositedAmount'] > 0 // @phpstan-ignore-line
|
||||||
? $this->paymentSuccessful($relatedResource, $paymentHistory, $bankBranch)
|
? $this->paymentSuccessful($relatedResource, $paymentHistory, $bankBranch->name)
|
||||||
: $this->paymentFailed(__('Payment has failed'), $paymentHistory, $bankBranch);
|
: $this->paymentFailed(__('Payment has failed'), $paymentHistory, $bankBranch->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Successful payment
|
* 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([
|
$relatedResource->update([
|
||||||
'paid' => true,
|
'paid' => true,
|
||||||
@@ -249,7 +250,7 @@ class OnlinePaymentRepository
|
|||||||
return $this->paymentCheckResponseTemplate(
|
return $this->paymentCheckResponseTemplate(
|
||||||
success: true,
|
success: true,
|
||||||
pnr: $paymentHistory->online_paymantable_id,
|
pnr: $paymentHistory->online_paymantable_id,
|
||||||
branch_name: $bankBranch->name,
|
branch_name: $branchName,
|
||||||
price_amount: $paymentHistory->amount.' TMT'
|
price_amount: $paymentHistory->amount.' TMT'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -257,9 +258,9 @@ class OnlinePaymentRepository
|
|||||||
/**
|
/**
|
||||||
* Failed payment
|
* 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) {
|
if ($paymentHistory) {
|
||||||
$paymentHistory->update([
|
$paymentHistory->update([
|
||||||
@@ -269,7 +270,7 @@ class OnlinePaymentRepository
|
|||||||
return $this->paymentCheckResponseTemplate(
|
return $this->paymentCheckResponseTemplate(
|
||||||
success: false,
|
success: false,
|
||||||
pnr: $paymentHistory->online_paymantable_id,
|
pnr: $paymentHistory->online_paymantable_id,
|
||||||
branch_name: $bankBranch->name,
|
branch_name: $branchName,
|
||||||
price_amount: $paymentHistory->amount.' TMT'
|
price_amount: $paymentHistory->amount.' TMT'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -280,14 +281,14 @@ class OnlinePaymentRepository
|
|||||||
/**
|
/**
|
||||||
* Check payment response
|
* 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(
|
public function paymentCheckResponseTemplate(
|
||||||
bool $success,
|
bool $success,
|
||||||
string $title = '',
|
string $title = '',
|
||||||
string $pnr = '',
|
int|string $pnr = '',
|
||||||
string $branch_name = '',
|
string $branch_name = '',
|
||||||
string $price_amount = '',
|
int|string $price_amount = '',
|
||||||
string $return_url = ''
|
string $return_url = ''
|
||||||
): array {
|
): array {
|
||||||
return [
|
return [
|
||||||
@@ -303,7 +304,7 @@ class OnlinePaymentRepository
|
|||||||
/**
|
/**
|
||||||
* Show payment status
|
* 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
|
public function paymentStatusView(array $data): View
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user