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

@@ -5,7 +5,6 @@ namespace App\Filament\Clusters\VisaMasterPayments\Resources\VisaMasterPaymentOr
use App\Filament\Clusters\VisaMasterPayments\Resources\VisaMasterPaymentOrders\Pages\CreateVisaMasterPaymentOrder; use App\Filament\Clusters\VisaMasterPayments\Resources\VisaMasterPaymentOrders\Pages\CreateVisaMasterPaymentOrder;
use App\Filament\Clusters\VisaMasterPayments\Resources\VisaMasterPaymentOrders\Pages\EditVisaMasterPaymentOrder; use App\Filament\Clusters\VisaMasterPayments\Resources\VisaMasterPaymentOrders\Pages\EditVisaMasterPaymentOrder;
use App\Filament\Clusters\VisaMasterPayments\Resources\VisaMasterPaymentOrders\Pages\ListVisaMasterPaymentOrders; use App\Filament\Clusters\VisaMasterPayments\Resources\VisaMasterPaymentOrders\Pages\ListVisaMasterPaymentOrders;
use App\Filament\Clusters\VisaMasterPayments\Resources\VisaMasterPaymentOrders\Pages\ViewVisaMasterPaymentOrder;
use App\Filament\Clusters\VisaMasterPayments\Resources\VisaMasterPaymentOrders\Schemas\VisaMasterPaymentOrderForm; use App\Filament\Clusters\VisaMasterPayments\Resources\VisaMasterPaymentOrders\Schemas\VisaMasterPaymentOrderForm;
use App\Filament\Clusters\VisaMasterPayments\Resources\VisaMasterPaymentOrders\Tables\VisaMasterPaymentOrdersTable; use App\Filament\Clusters\VisaMasterPayments\Resources\VisaMasterPaymentOrders\Tables\VisaMasterPaymentOrdersTable;
use App\Filament\Clusters\VisaMasterPayments\VisaMasterPaymentsCluster; use App\Filament\Clusters\VisaMasterPayments\VisaMasterPaymentsCluster;

View File

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

View File

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

View File

@@ -50,6 +50,11 @@ class OnlinePaymentRepository
*/ */
protected OnlinePayment $onlinePayment; protected OnlinePayment $onlinePayment;
/**
* API client
*/
protected string $apiClient;
/** /**
* If payment is successful * If payment is successful
*/ */
@@ -70,9 +75,10 @@ class OnlinePaymentRepository
*/ */
protected string $paymentLink; protected string $paymentLink;
public function __construct(?Model $relatedModel = null) public function __construct(?Model $relatedModel = null, string $apiClient = '')
{ {
$this->relatedModel = $relatedModel; $this->relatedModel = $relatedModel;
$this->apiClient = $apiClient;
} }
/** /**
@@ -253,19 +259,17 @@ class OnlinePaymentRepository
/** @var \App\Modules\Branch\Models\Branch */ /** @var \App\Modules\Branch\Models\Branch */
$bankBranch = $relatedResource->branch; $bankBranch = $relatedResource->branch;
if (! $bankBranch || is_null($bankBranch->billing_username) || is_null($bankBranch->billing_password)) { // @phpstan-ignore-line $username = $bankBranch->offsetExists($this->apiClient.'_username') ? $bankBranch->{$this->apiClient.'_username'} : '';
return $this->paymentFailed('(BRANCH NOT FOUND)'); $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->setUsername($username);
$this->provider->setPassword($bankBranch->billing_password); $this->provider->setPassword($password);
$response = $this->provider->checkPayment($orderId); $response = $this->provider->checkPayment($orderId);
info([
'response' => $response,
'body' => $response->body(),
]);
if ($response['errorCode'] == '99') { if ($response['errorCode'] == '99') {
return $this->paymentFailed('(REQUEST FAILURE)'); 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\CurrencyRate\Models\CurrencyRate;
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder; use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder;
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterSettings;
use App\Modules\VisaMasterPaymentOrder\Repositories\VisaMasterPaymentOrderRepository; use App\Modules\VisaMasterPaymentOrder\Repositories\VisaMasterPaymentOrderRepository;
use Filament\Actions\Action; use Filament\Actions\Action;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
@@ -142,7 +141,6 @@ class PayVisaMasterPaymentAction
$total_amount = $formData['payment_amount'] + $visaMasterPaymentOrderRepository->bankFee() + $visaMasterPaymentOrderRepository->gbusFee(); $total_amount = $formData['payment_amount'] + $visaMasterPaymentOrderRepository->bankFee() + $visaMasterPaymentOrderRepository->gbusFee();
$onlinePaymentRepository = $visaMasterPaymentOrderRepository->createOnlinePaymentOrder($record, $total_amount); $onlinePaymentRepository = $visaMasterPaymentOrderRepository->createOnlinePaymentOrder($record, $total_amount);
if ($onlinePaymentRepository->failed()) { if ($onlinePaymentRepository->failed()) {

View File

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