This commit is contained in:
2024-10-14 16:12:51 +05:00
parent fa99b965c1
commit 00de426a85
2 changed files with 28 additions and 8 deletions

View File

@@ -46,8 +46,8 @@ class OnlinePaymentController extends Controller
$response = Http::asForm()->post('https://mpi.gov.tm/payment/rest/getOrderStatus.do', [ $response = Http::asForm()->post('https://mpi.gov.tm/payment/rest/getOrderStatus.do', [
'language' => 'ru', 'language' => 'ru',
'orderId' => $request->orderId, 'orderId' => $request->orderId,
'userName' => $resource->branch->billing_username, 'userName' => $resource->branch->billing_visa_master_username,
'password' => $resource->branch->billing_password, 'password' => $resource->branch->billing_visa_master_password,
]); ]);
$payment_status = $response['ErrorCode'] == '0'; $payment_status = $response['ErrorCode'] == '0';

View File

@@ -8,6 +8,7 @@ use App\Repos\Payment\OnlinePaymentRepo;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Rule; 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.'); 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' return $payment['status'] === 'success'
? ActionResponse::openInNewTab($payment['url']) ? ActionResponse::openInNewTab($payment['url'])
@@ -75,7 +78,11 @@ class MakePaymentNovaVisaMaster extends Action
$max_value = number_format($usd_to_tmt->value * 250, 2); $max_value = number_format($usd_to_tmt->value * 250, 2);
return [ return [
Heading::make('1 USD = ' . $usd_to_tmt->value . ' TMT'), Heading::make(Blade::render(<<<HTML
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">1 USD = $usd_to_tmt->value TMT</h3>
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">Bankyň tutumy: 20 TMT</h3>
<h3 class="uppercase tracking-wide font-bold text-xs" dusk="heading">GBÜS tutumy: 3 TMT</h3>
HTML))->asHtml(),
Text::make(sprintf('%s (%s)', __('Töleg möçberi'), __('TMT')), 'payment_amount') Text::make(sprintf('%s (%s)', __('Töleg möçberi'), __('TMT')), 'payment_amount')
->fullWidth() ->fullWidth()
@@ -92,6 +99,19 @@ class MakePaymentNovaVisaMaster extends Action
} else { } else {
$field->setValue(''); $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 * Order a payment page
*/ */
public function order($resource, $paymentMethod) public function order($resource, $amount)
{ {
$onlinePaymentRepo = OnlinePaymentRepo::make(); $onlinePaymentRepo = OnlinePaymentRepo::make();
@@ -107,11 +127,11 @@ class MakePaymentNovaVisaMaster extends Action
$paymentResponse = Http::get('https://mpi.gov.tm/payment/rest/register.do', [ $paymentResponse = Http::get('https://mpi.gov.tm/payment/rest/register.do', [
'orderNumber' => $orderNumber, 'orderNumber' => $orderNumber,
'amount' => $onlinePaymentRepo->getPrice($paymentMethod == 'usd' ? '90238' : '105860'), 'amount' => number_format($amount, 2, '', ''),
'currency' => 934, 'currency' => 934,
'language' => 'ru', 'language' => 'ru',
'userName' => $resource->branch->billing_username, 'userName' => $resource->branch->billing_visa_master_username,
'password' => $resource->branch->billing_password, 'password' => $resource->branch->billing_visa_master_password,
'returnUrl' => route('online-payment-store-visa-master'), 'returnUrl' => route('online-payment-store-visa-master'),
'pageView' => 'DESKTOP', 'pageView' => 'DESKTOP',
'description' => 'Visa/Master tölegi', 'description' => 'Visa/Master tölegi',