This commit is contained in:
2025-11-02 19:26:39 +05:00
parent e27aa026fd
commit 45fbde31c7
2 changed files with 7 additions and 7 deletions

View File

@@ -75,7 +75,7 @@ class HalkbankOnlinePaymentRepository implements PaymentProviderContract
public function checkPayment(string $orderId): Response public function checkPayment(string $orderId): Response
{ {
try { try {
$paymentCheckResponse = Http::asForm()->post('https://mpi.gov.tm/payment/rest/getOrderStatus.do', [ $paymentCheckResponse = Http::asForm()->post('https://mpi.gov.tm/payment/rest/getOrderStatusExtended.do', [
'language' => 'ru', 'language' => 'ru',
'orderId' => $orderId, 'orderId' => $orderId,
'userName' => $this->username, 'userName' => $this->username,
@@ -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":"%s"}', $e->getMessage()) sprintf('{"errorCode":"99","errorMessage":"FAILED_REQUEST"}', $e->getMessage())
)); ));
} }

View File

@@ -194,15 +194,15 @@ class OnlinePaymentRepository
$paymentHistory = OnlinePayment::where('orderId', $orderId)->first(); $paymentHistory = OnlinePayment::where('orderId', $orderId)->first();
// Resolve related resource model dynamically // Resolve related resource model dynamically
/** @var \Illuminate\Database\Eloquent\Model Find related resource */
$modelClass = $paymentHistory->online_paymantable_type; $modelClass = $paymentHistory->online_paymantable_type;
$modelId = $paymentHistory->online_paymantable_id; $modelId = $paymentHistory->online_paymantable_id;
if (! class_exists($modelClass)) { if (! class_exists($modelClass)) {
return $this->paymentFailed('(INVALID RESOURCE TYPE)'); return $this->paymentFailed('(RELATED RESOURCE CLASS NOT FOUND)');
} }
/** @var \Illuminate\Database\Eloquent\Model Find related resource */ $relatedResource = (new $modelClass)->find(id: $modelId);
$relatedResource = $modelClass::find($modelId);
// Check if resource could not be found or does not exist // Check if resource could not be found or does not exist
if (! $relatedResource) { if (! $relatedResource) {
@@ -222,11 +222,11 @@ class OnlinePaymentRepository
$this->provider->setPassword($bankBranch->billing_password); $this->provider->setPassword($bankBranch->billing_password);
$response = $this->provider->checkPayment($orderId); $response = $this->provider->checkPayment($orderId);
if ($response['ErrorCode'] == '99') { if ($response['errorCode'] == '99') {
return $this->paymentFailed('(REQUEST FAILURE)'); return $this->paymentFailed('(REQUEST FAILURE)');
} }
return $response['ErrorCode'] == '0' return $response['paymentAmountInfo']['depositedAmount'] > 0
? $this->paymentSuccessful($relatedResource, $paymentHistory, $bankBranch) ? $this->paymentSuccessful($relatedResource, $paymentHistory, $bankBranch)
: $this->paymentFailed(__('Payment has failed'), $paymentHistory, $bankBranch); : $this->paymentFailed(__('Payment has failed'), $paymentHistory, $bankBranch);
} }