wip
This commit is contained in:
@@ -153,12 +153,12 @@ class OnlinePaymentRepository
|
|||||||
/**
|
/**
|
||||||
* Check payment
|
* Check payment
|
||||||
*/
|
*/
|
||||||
public function checkPayment(string $orderId)
|
public function checkPayment(string $orderId): array
|
||||||
{
|
{
|
||||||
/** @var \App\Modules\OnlinePayment\Models\OnlinePayment Find payment order from history */
|
/** @var \App\Modules\OnlinePayment\Models\OnlinePayment Find payment order from history */
|
||||||
$paymentHistory = OnlinePayment::where('orderId', $orderId)->first();
|
$paymentHistory = OnlinePayment::where('orderId', $orderId)->first();
|
||||||
|
|
||||||
/** @var \App\Modules\CardOrder\Models\CardOrder Find related resource */
|
/** @var \Illuminate\Database\Eloquent\Model Find related resource */
|
||||||
$relatedResource = (new $paymentHistory->online_paymantable_type)->find(id: $paymentHistory->online_paymantable_id);
|
$relatedResource = (new $paymentHistory->online_paymantable_type)->find(id: $paymentHistory->online_paymantable_id);
|
||||||
|
|
||||||
// Check if resource could not be found or does not exist
|
// Check if resource could not be found or does not exist
|
||||||
@@ -183,17 +183,9 @@ class OnlinePaymentRepository
|
|||||||
return $this->paymentFailed('(REQUEST FAILURE)');
|
return $this->paymentFailed('(REQUEST FAILURE)');
|
||||||
}
|
}
|
||||||
|
|
||||||
$payment_status = $response['ErrorCode'] == '0';
|
return $response['ErrorCode'] == '0'
|
||||||
|
? $this->paymentSuccessful($relatedResource, $paymentHistory, $bankBranch)
|
||||||
if ($payment_status) {
|
: $this->paymentFailed(__('Payment has failed'), $paymentHistory, $bankBranch);
|
||||||
return $this->paymentSuccessful($relatedResource, $paymentHistory, $bankBranch);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->paymentFailed(
|
|
||||||
title: __('Payment has failed'),
|
|
||||||
paymentHistory: $paymentHistory,
|
|
||||||
bankBranch: $bankBranch,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user