added cursor pointer into trolley at homepage that redirect to trolley page

This commit is contained in:
hafifierahman
2024-12-09 00:21:04 +08:00
parent 09e0afbd84
commit 6919f75abf
5 changed files with 109 additions and 20 deletions
+43 -4
View File
@@ -62,7 +62,7 @@ class BayaranController extends Controller
return view('includes.bayaran.pembayaransag', compact('list_pkb','list_koop'));
}
public function PembayaranEngine(Request $request, BillplzService $billplzService)
public function PembayaranEngine(Request $request)
{
['email' => $customerEmail, 'notel' => $customerPhoneNumber, 'name' => $customerName, 'icno' => $customerIcno] = auth()->user()->toArray();
@@ -100,6 +100,7 @@ class BayaranController extends Controller
};
$company = strtoupper($request->txtcompany);
$billplzService = new BillplzService($company);
$bill = $billplzService->createBill([$customerEmail, $customerPhoneNumber, $customerName, $getPaymentSum()],$company);
Session::put('company', $company);
@@ -217,8 +218,9 @@ class BayaranController extends Controller
return view('pembayaran.resit.resitportal', compact('customer_details', 'payment_details', 'cawangan_detail', 'nama_cawangan', 'gadai'));
}
public function callback(Request $request, BillplzService $billplzService)
public function callback(Request $request)
{
$billplzService = new BillplzService(Session::get('company'));
$data = $billplzService->webhook($request->toArray());
$isBillUnpaid = $data['paid'] !== true;
@@ -239,11 +241,25 @@ class BayaranController extends Controller
'paid_at' => $data['paid_at']->format('Y-m-d H:i:s'),
]);
$column_updated = (Session::get('company') == 'PKB') ? 'status_pkb' : 'status_koop';
$value_paid = 'PAID';
$exist_carts = PersonalCarts::where('ic_no', Auth::user()->icno)
->where('user_id', Auth::user()->id)
->where(function ($query) {
$query->where('status_pkb', 'PENDING')
->orWhere('status_koop', 'PENDING');
})
->update([
$column_updated => $value_paid,
]);
return response(200);
}
public function response(Request $request, BillplzService $billplzService)
public function response(Request $request)
{
$billplzService = new BillplzService(Session::get('company'));
$data = $billplzService->redirect($request->toArray());
$this->serviceCallHttp($billplzService->company);
$isBillUnpaid = $data['paid'] !== true;
@@ -270,6 +286,19 @@ class BayaranController extends Controller
'paid_at' => $data['paid_at']->format('Y-m-d H:i:s'),
]);
$column_updated = (Session::get('company') == 'PKB') ? 'status_pkb' : 'status_koop';
$value_paid = 'PAID';
$exist_carts = PersonalCarts::where('ic_no', Auth::user()->icno)
->where('user_id', Auth::user()->id)
->where(function ($query) {
$query->where('status_pkb', 'PENDING')
->orWhere('status_koop', 'PENDING');
})
->update([
$column_updated => $value_paid,
]);
$transactionOnline = $this->CallableHttp
->get('/api/transaction/online/login', [
'billplz_id' => $data['id'],
@@ -300,7 +329,17 @@ class BayaranController extends Controller
$transactionOnline,
);
return view('pembayaran.result.berjayaportal', compact('transactionOnline', 'arraycawangan', 'arraygadai'));
$exist_carts = PersonalCarts::where('ic_no', Auth::user()->icno)
->where('user_id', Auth::user()->id)
->where(function ($query) {
$query->where('status_pkb', 'PENDING')
->orWhere('status_koop', 'PENDING');
})
->first();
$exist_carts = optional($exist_carts)->toArray();
return view('pembayaran.result.berjayaportal', compact('transactionOnline', 'arraycawangan', 'arraygadai','exist_carts'));
}
public function failedPayment()
+4
View File
@@ -54,6 +54,10 @@ class PaymentRequest extends FormRequest
public function getPembiayaanFromNorujukan()
{
if(null !== $this->input('redirect_trolley') && $this->input('redirect_trolley') == 'trolley'){
return [];
}
$norujukanList = json_decode($this->totalSagInCartInput);
$syarikatList = json_decode($this->listSyarikatinCartInput);
+2 -14
View File
@@ -33,10 +33,6 @@ class BillplzService
public function createBill(array $data,string $company)
{
Session::put('company',$company);
$this->setCompany($company);
$this->setupBillplzClient($company);
// dd($company,$this->config);
$composed_data = [
$this->config['collection_id'],
@@ -74,8 +70,6 @@ class BillplzService
public function redirect($request)
{
$this->setCompany(Session::get('company'));
$this->setupBillplzClient($this->company);
try{
$response = $this->client->bill()->redirect($request);
@@ -93,8 +87,8 @@ class BillplzService
public function webhook($request)
{
$this->setCompany(Session::get('company'));
$this->setupBillplzClient($this->company);
// $this->setCompany(Session::get('company'));
// $this->setupBillplzClient($this->company);
try {
$response = $this->client->webhook($request);
@@ -267,8 +261,6 @@ class BillplzService
? ($billplzEnvironments[$company] ?? config('services.billplz.production'))
: ($billplzEnvironments[$company] ?? config('services.billplz.sandbox'));
Log::info($company);
Log::info($this->isBase64($billplzConfig['x_signature']));
$client = Client::make($billplzConfig['api_key'], ($this->isBase64($billplzConfig['x_signature'])) ? $billplzConfig['x_signature'] : base64_encode($billplzConfig['x_signature']));
$client->useVersion('v4');
@@ -285,10 +277,6 @@ class BillplzService
$this->callbackUrl = route('pay.callback');
$this->redirectUrl = ['redirect_url' => route('pay.paymentStatus')];
}
protected function setCompany($company = 'PKB'){
$this->company = $company;
}
protected function isBase64($string) {
if (preg_match('/^[A-Za-z0-9+\/=]+$/', $string)) {
@@ -109,10 +109,32 @@
</a>
</li>
<li class="nav-item ms-lg-auto">
<a class="nav-link nav-link-icon me-2" href="">
<a class="nav-link nav-link-icon me-2 cursor-pointer" onclick="redirectTrolley()">
<i class="fa fa-shopping-cart"></i>
<p class="d-inline text-sm z-index-1 font-weight-bold" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Troli">Troli</p>
</a>
<script>
function redirectTrolley(){
let form = document.createElement('form');
form.method = 'POST';
form.action = '{{ route("payment.action") }}';
let csrfInput = document.createElement('input');
csrfInput.type = 'hidden';
csrfInput.name = '_token';
csrfInput.value = '{{ csrf_token() }}';
form.appendChild(csrfInput);
let redirectInput = document.createElement('input');
redirectInput.type = 'hidden';
redirectInput.name = 'redirect_trolley';
redirectInput.value = 'trolley';
form.appendChild(redirectInput);
document.body.appendChild(form);
form.submit();
}
</script>
</li>
<li class="nav-item my-auto ms-3 ms-lg-0">
<a href="{{ route('logout') }}" class="btn btn-sm bg-white border mb-0 me-1 mt-2 mt-md-0" onclick="event.preventDefault();document.getElementById('logout-form').submit();">
@@ -36,10 +36,46 @@
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<center>
<span class="far fa-check-circle fa-6x" style="color:green;"></span>
<h4 class="text-success mt-1 mb-1">Pembayaran Berjaya</h4>
@if($exist_carts)
<span class="text-dark">
Terima kasih atas pembayaran! Anda akan dibawa ke troli dalam masa <span id="remaining">10</span> saat.
</span>
<script>
let remainingElement = document.getElementById('remaining');
let remainingSeconds = parseInt(remainingElement.textContent, 10);
const remaining_countdown = () => {
if (remainingSeconds > 0) {
remainingSeconds--;
remainingElement.textContent = remainingSeconds;
} else {
clearInterval(interval);
let form = document.createElement('form');
form.method = 'POST';
form.action = '{{ route("payment.action") }}';
let csrfInput = document.createElement('input');
csrfInput.type = 'hidden';
csrfInput.name = '_token';
csrfInput.value = '{{ csrf_token() }}';
form.appendChild(csrfInput);
let redirectInput = document.createElement('input');
redirectInput.type = 'hidden';
redirectInput.name = 'redirect_trolley';
redirectInput.value = 'trolley';
form.appendChild(redirectInput);
document.body.appendChild(form);
form.submit();
}
};
const interval = setInterval(remaining_countdown, 1000);
</script>
@endif
<div class="row mb-4" style="margin-top:10px;">
<div class="col-12 text-dark"><small>*Sebarang pembayaran akan dikemaskini selepas <b>1 Jam</b></small></div>
</div>