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

@@ -19,7 +19,7 @@ class CardOrderRepository
/** @var \App\Modules\Branch\Models\Branch */
$branch = $record->branch;
return OnlinePaymentRepository::make(relatedModel: $record)
return OnlinePaymentRepository::make(relatedModel: $record, apiClient: 'billing')
->setPaymentProvider(
HalkbankOnlinePaymentRepository::make()
->setUsername($branch->billingUsername())

View File

@@ -23,16 +23,16 @@ class HalkbankOnlinePaymentRepository implements PaymentProviderContract
protected string $returnUrl = '',
protected string $description = '',
) {
$this->username = $username === '' ? config()->string('module.halkbank-online-payment.username') : $username;
$this->password = $password === '' ? config()->string('module.halkbank-online-payment.password') : $password;
$this->username = $username !== '' ? $username : config()->string('module.halkbank-online-payment.username');
$this->password = $password !== '' ? $password : config()->string('module.halkbank-online-payment.password');
$this->amount = $amount;
$this->orderNumber = $orderNumber === '' ? $this->generateOrderNumber() : $orderNumber;
$this->orderNumber = $orderNumber !== '' ? $orderNumber : $this->generateOrderNumber();
$this->returnUrl = $returnUrl === '' ? config()->string('module.halkbank-online-payment.returnUrl') : $returnUrl;
$this->description = $description === '' ? __('Payment') : $description;
$this->returnUrl = $returnUrl !== '' ? $returnUrl : config()->string('module.halkbank-online-payment.returnUrl');
$this->description = $description !== '' ? $description : __('Payment');
}
/**

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)');
}

View File

@@ -4,7 +4,6 @@ namespace App\Modules\VisaMasterPaymentOrder\Filament\Actions;
use App\Modules\CurrencyRate\Models\CurrencyRate;
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder;
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterSettings;
use App\Modules\VisaMasterPaymentOrder\Repositories\VisaMasterPaymentOrderRepository;
use Filament\Actions\Action;
use Filament\Forms\Components\TextInput;
@@ -142,7 +141,6 @@ class PayVisaMasterPaymentAction
$total_amount = $formData['payment_amount'] + $visaMasterPaymentOrderRepository->bankFee() + $visaMasterPaymentOrderRepository->gbusFee();
$onlinePaymentRepository = $visaMasterPaymentOrderRepository->createOnlinePaymentOrder($record, $total_amount);
if ($onlinePaymentRepository->failed()) {

View File

@@ -87,7 +87,7 @@ class VisaMasterPaymentOrderRepository
/** @var \App\Modules\Branch\Models\Branch */
$branch = $record->branch;
return OnlinePaymentRepository::make(relatedModel: $record)
return OnlinePaymentRepository::make(relatedModel: $record, apiClient: 'billing_visa_master')
->setPaymentProvider(
HalkbankOnlinePaymentRepository::make(
username: $branch->billing_visa_master_username,