From 00de426a85191d77556b7602054ce41851972776 Mon Sep 17 00:00:00 2001 From: Nurmuhammet Allanov Date: Mon, 14 Oct 2024 16:12:51 +0500 Subject: [PATCH] wip --- .../Controllers/OnlinePaymentController.php | 4 +-- .../Actions/MakePaymentNovaVisaMaster.php | 32 +++++++++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/OnlinePaymentController.php b/app/Http/Controllers/OnlinePaymentController.php index b995747..317bcc7 100644 --- a/app/Http/Controllers/OnlinePaymentController.php +++ b/app/Http/Controllers/OnlinePaymentController.php @@ -46,8 +46,8 @@ class OnlinePaymentController extends Controller $response = Http::asForm()->post('https://mpi.gov.tm/payment/rest/getOrderStatus.do', [ 'language' => 'ru', 'orderId' => $request->orderId, - 'userName' => $resource->branch->billing_username, - 'password' => $resource->branch->billing_password, + 'userName' => $resource->branch->billing_visa_master_username, + 'password' => $resource->branch->billing_visa_master_password, ]); $payment_status = $response['ErrorCode'] == '0'; diff --git a/app/Nova/Actions/MakePaymentNovaVisaMaster.php b/app/Nova/Actions/MakePaymentNovaVisaMaster.php index c6bd0a1..dd32008 100644 --- a/app/Nova/Actions/MakePaymentNovaVisaMaster.php +++ b/app/Nova/Actions/MakePaymentNovaVisaMaster.php @@ -8,6 +8,7 @@ use App\Repos\Payment\OnlinePaymentRepo; use Illuminate\Bus\Queueable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Support\Collection; +use Illuminate\Support\Facades\Blade; use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Log; use Illuminate\Validation\Rule; @@ -51,7 +52,9 @@ class MakePaymentNovaVisaMaster extends Action return ActionResponse::danger('Şahamça visa/master tölegi kabul edip bilmeýär.'); } - $payment = $this->order($resource, $fields->payment_method); + $total_amount = floatval(number_format($fields->payment_amount, 2)) + 23; + + $payment = $this->order($resource, $total_amount); return $payment['status'] === 'success' ? ActionResponse::openInNewTab($payment['url']) @@ -75,7 +78,11 @@ class MakePaymentNovaVisaMaster extends Action $max_value = number_format($usd_to_tmt->value * 250, 2); return [ - Heading::make('1 USD = ' . $usd_to_tmt->value . ' TMT'), + Heading::make(Blade::render(<<1 USD = $usd_to_tmt->value TMT +

Bankyň tutumy: 20 TMT

+

GBÜS tutumy: 3 TMT

+ HTML))->asHtml(), Text::make(sprintf('%s (%s)', __('Töleg möçberi'), __('TMT')), 'payment_amount') ->fullWidth() @@ -92,6 +99,19 @@ class MakePaymentNovaVisaMaster extends Action } else { $field->setValue(''); } + }), + + Text::make(__('Jemi (TMT)'), 'total_amount') + ->fullWidth() + ->readonly() + ->dependsOn('payment_amount', function ($field, $request, $formData) use ($usd_to_tmt) { + if ($formData->payment_amount) { + $field->setValue( + floatval(number_format($formData->payment_amount, 2)) + 23 + ); + } else { + $field->setValue(''); + } }) ]; } @@ -99,7 +119,7 @@ class MakePaymentNovaVisaMaster extends Action /** * Order a payment page */ - public function order($resource, $paymentMethod) + public function order($resource, $amount) { $onlinePaymentRepo = OnlinePaymentRepo::make(); @@ -107,11 +127,11 @@ class MakePaymentNovaVisaMaster extends Action $paymentResponse = Http::get('https://mpi.gov.tm/payment/rest/register.do', [ 'orderNumber' => $orderNumber, - 'amount' => $onlinePaymentRepo->getPrice($paymentMethod == 'usd' ? '90238' : '105860'), + 'amount' => number_format($amount, 2, '', ''), 'currency' => 934, 'language' => 'ru', - 'userName' => $resource->branch->billing_username, - 'password' => $resource->branch->billing_password, + 'userName' => $resource->branch->billing_visa_master_username, + 'password' => $resource->branch->billing_visa_master_password, 'returnUrl' => route('online-payment-store-visa-master'), 'pageView' => 'DESKTOP', 'description' => 'Visa/Master tölegi',