update lagi deh
This commit is contained in:
parent
7161d07a65
commit
6ce214315c
|
|
@ -59,7 +59,7 @@ public function process(Request $request)
|
|||
'regex:/(?=.*[Jj]l\.?|.*[Jj]alan)(?=.*[Nn]o\.?)(?=.*[Rr][Tt])(?=.*[Rr][Ww])/'],
|
||||
'city' => 'required|string|max:100',
|
||||
'postal_code' => 'required|string|max:10',
|
||||
'payment_method' => 'required|in:qris,bri,dana,seabank,shopee,cod',
|
||||
'payment_method' => 'required|in:qris,bri,dana,seabank,shopepay,cod',
|
||||
'shipping_cost' => 'required|numeric|min:0',
|
||||
'notes' => 'nullable|string|max:1000',
|
||||
], [
|
||||
|
|
@ -219,4 +219,15 @@ public function success($id)
|
|||
->with('error', 'Terjadi kesalahan: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public function getStatus($id)
|
||||
{
|
||||
$transaksi = Transaksi::find($id);
|
||||
if (!$transaksi) {
|
||||
return response()->json(['error' => 'Not found'], 404);
|
||||
}
|
||||
return response()->json([
|
||||
'payment_status' => $transaksi->payment_status,
|
||||
'order_status' => $transaksi->order_status,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -189,7 +189,7 @@ class="form-control @error('postal_code') is-invalid @enderror"
|
|||
<option value="seabank" {{ old('payment_method') == 'seabank' ? 'selected' : '' }}>
|
||||
🏦 SeaBank
|
||||
</option>
|
||||
<option value="shopee" {{ old('payment_method') == 'shopee' ? 'selected' : '' }}>
|
||||
<option value="shopepay" {{ old('payment_method') == 'shopee' ? 'selected' : '' }}>
|
||||
🛒 ShopeePay
|
||||
</option>
|
||||
<option value="cod" {{ old('payment_method') == 'cod' ? 'selected' : '' }}>
|
||||
|
|
@ -474,7 +474,7 @@ class="border p-2 bg-white"> -->
|
|||
case 'seabank':
|
||||
seabankInfo.style.display = 'block';
|
||||
break;
|
||||
case 'shopee':
|
||||
case 'shopepay':
|
||||
shopeeInfo.style.display = 'block';
|
||||
break;
|
||||
case 'cod':
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@
|
|||
<div class="row">
|
||||
<div class="col-6"><strong>Status Pesanan:</strong></div>
|
||||
<div class="col-6 text-end">
|
||||
<span class="badge bg-warning text-dark">Menunggu Pembayaran</span>
|
||||
<span class="badge bg-warning text-dark" id="statusBadge">Menunggu Pembayaran</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -395,12 +395,30 @@ class="btn btn-success w-100">
|
|||
</div>
|
||||
|
||||
<script>
|
||||
function copyToClipboard(text) {
|
||||
navigator.clipboard.writeText(text).then(function() {
|
||||
alert('Nomor rekening berhasil disalin!');
|
||||
}, function(err) {
|
||||
console.error('Gagal menyalin: ', err);
|
||||
});
|
||||
const transaksiId = {{ $transaksi->id }};
|
||||
const statusBadge = document.getElementById('statusBadge');
|
||||
|
||||
function checkStatus() {
|
||||
fetch(`/checkout/status/${transaksiId}`)
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
const paymentMap = {
|
||||
'pending': { text: 'Menunggu Pembayaran', cls: 'bg-warning text-dark' },
|
||||
'paid': { text: 'Sudah Dibayar ✅', cls: 'bg-success text-white' },
|
||||
'failed': { text: 'Pembayaran Gagal ❌', cls: 'bg-danger text-white' },
|
||||
};
|
||||
const p = paymentMap[data.payment_status] ?? paymentMap['pending'];
|
||||
statusBadge.textContent = p.text;
|
||||
statusBadge.className = 'badge ' + p.cls;
|
||||
|
||||
if (data.payment_status === 'paid' || data.payment_status === 'failed') {
|
||||
clearInterval(pollingInterval);
|
||||
}
|
||||
})
|
||||
.catch(err => console.error('Gagal fetch status:', err));
|
||||
}
|
||||
|
||||
checkStatus();
|
||||
const pollingInterval = setInterval(checkStatus, 10000);
|
||||
</script>
|
||||
@endsection
|
||||
|
|
@ -45,6 +45,7 @@
|
|||
Route::get('/', [CheckoutController::class, 'index'])->name('index');
|
||||
Route::post('/process', [CheckoutController::class, 'process'])->name('process');
|
||||
Route::get('/success/{id}', [CheckoutController::class, 'success'])->name('success');
|
||||
Route::get('/status/{id}', [CheckoutController::class, 'getStatus'])->name('status'); // ✅ hapus /checkout/
|
||||
});
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in New Issue