wip
This commit is contained in:
@@ -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\EditVisaMasterPaymentOrder;
|
||||
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\Tables\VisaMasterPaymentOrdersTable;
|
||||
use App\Filament\Clusters\VisaMasterPayments\VisaMasterPaymentsCluster;
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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->returnUrl = $returnUrl !== '' ? $returnUrl : config()->string('module.halkbank-online-payment.returnUrl');
|
||||
|
||||
$this->description = $description === '' ? __('Payment') : $description;
|
||||
$this->description = $description !== '' ? $description : __('Payment');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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)');
|
||||
}
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user