This commit is contained in:
2025-11-16 18:04:18 +05:00
parent 6428c9e20c
commit 19abe08a90
6 changed files with 23 additions and 22 deletions

View File

@@ -50,6 +50,11 @@ class OnlinePaymentRepository
*/
protected OnlinePayment $onlinePayment;
/**
* API client
*/
protected string $apiClient;
/**
* If payment is successful
*/
@@ -70,9 +75,10 @@ class OnlinePaymentRepository
*/
protected string $paymentLink;
public function __construct(?Model $relatedModel = null)
public function __construct(?Model $relatedModel = null, string $apiClient = '')
{
$this->relatedModel = $relatedModel;
$this->apiClient = $apiClient;
}
/**
@@ -253,19 +259,17 @@ class OnlinePaymentRepository
/** @var \App\Modules\Branch\Models\Branch */
$bankBranch = $relatedResource->branch;
if (! $bankBranch || is_null($bankBranch->billing_username) || is_null($bankBranch->billing_password)) { // @phpstan-ignore-line
return $this->paymentFailed('(BRANCH NOT FOUND)');
$username = $bankBranch->offsetExists($this->apiClient.'_username') ? $bankBranch->{$this->apiClient.'_username'} : '';
$password = $bankBranch->offsetExists($this->apiClient.'_password') ? $bankBranch->{$this->apiClient.'_password'} : '';
if ($username === '' || $password === '') {
return $this->paymentFailed('(USERNAME OR PASSWORD NOT FOUND)');
}
$this->provider->setUsername($bankBranch->billing_username);
$this->provider->setPassword($bankBranch->billing_password);
$this->provider->setUsername($username);
$this->provider->setPassword($password);
$response = $this->provider->checkPayment($orderId);
info([
'response' => $response,
'body' => $response->body(),
]);
if ($response['errorCode'] == '99') {
return $this->paymentFailed('(REQUEST FAILURE)');
}