Currency rates

This commit is contained in:
2024-10-14 13:16:48 +05:00
parent 95b15350a0
commit 5cd8123286
7 changed files with 363 additions and 15 deletions

View File

@@ -12,13 +12,21 @@ use Illuminate\Support\Facades\Log;
use Laravel\Nova\Actions\Action;
use Laravel\Nova\Actions\ActionResponse;
use Laravel\Nova\Fields\ActionFields;
use Laravel\Nova\Fields\Select;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;
class MakePaymentNovaVisaMaster extends Action
{
use InteractsWithQueue, Queueable;
/**
* Action name
*/
public function name(): string
{
return __('Send payment');
}
/**
* Perform the action on the given models.
*
@@ -30,12 +38,12 @@ class MakePaymentNovaVisaMaster extends Action
{
$resource = $models->first();
$payment = $this->order($resource, $fields->payment_method);
if (! $resource->branch) {
if (! $resource->branch || ! $resource->branch->billing_visa_master_username) {
return ActionResponse::danger('Şahamça visa/master tölegi kabul edip bilmeýär.');
}
$payment = $this->order($resource, $fields->payment_method);
return $payment['status'] === 'success'
? ActionResponse::openInNewTab($payment['url'])
: ActionResponse::danger('Töleg ýerinde näsazlyk!');
@@ -50,15 +58,10 @@ class MakePaymentNovaVisaMaster extends Action
public function fields(NovaRequest $request): array
{
return [
Select::make(__('Select payment method'), 'payment_method')
->displayUsingLabels()
->searchable()
->options([
'usd' => __('USD'),
'rubl' => __('RUBL'),
])
->rules('required')
->fullWidth(),
Text::make(__('Töleg möçberi'), 'payment_amount')
->fullWidth()
->required()
->rules('required', 'rules:250'),
];
}
@@ -73,7 +76,7 @@ class MakePaymentNovaVisaMaster extends Action
$paymentResponse = Http::get('https://mpi.gov.tm/payment/rest/register.do', [
'orderNumber' => $orderNumber,
'amount' => $onlinePaymentRepo->getPrice($paymentMethod == 'usd' ? '902.38' : '1058,60'),
'amount' => $onlinePaymentRepo->getPrice($paymentMethod == 'usd' ? '90238' : '105860'),
'currency' => 934,
'language' => 'ru',
'userName' => $resource->branch->billing_username,