From 097c9f12eec7b7e63c77e9ffb9f68e7658f49269 Mon Sep 17 00:00:00 2001 From: Bayu Lukman Yusuf Date: Thu, 12 Feb 2026 16:18:16 +0700 Subject: [PATCH] fix waybill, transaction status --- app/Http/Controllers/CheckoutController.php | 4 +-- app/Http/Controllers/OrderController.php | 1 + app/Models/Transaction.php | 13 ++++++++++ app/Models/User.php | 5 ++++ app/ThirdParty/Xendit/Xendit.php | 26 +++++++++++++++++++ lang/en/order.php | 5 ++++ lang/id/order.php | 7 ++++- resources/views/account/info.blade.php | 21 ++++++++------- resources/views/account/orders.blade.php | 26 ++++--------------- .../views/components/order/details.blade.php | 2 +- resources/views/layouts/account.blade.php | 4 +-- routes/web.php | 1 - 12 files changed, 77 insertions(+), 38 deletions(-) diff --git a/app/Http/Controllers/CheckoutController.php b/app/Http/Controllers/CheckoutController.php index e3856a0..c04ba45 100644 --- a/app/Http/Controllers/CheckoutController.php +++ b/app/Http/Controllers/CheckoutController.php @@ -188,8 +188,8 @@ class CheckoutController extends Controller $payment = $item->payments()->where("method_type",'App\Models\XenditLink') - ->where("status",'PENDING') - ->first(); + ->where("status",'PENDING') + ->first(); $invoice_url = $payment ? @$payment->method->invoice_url: ""; return redirect()->to($invoice_url)->withHeaders([ diff --git a/app/Http/Controllers/OrderController.php b/app/Http/Controllers/OrderController.php index 724ed12..cfd28b3 100644 --- a/app/Http/Controllers/OrderController.php +++ b/app/Http/Controllers/OrderController.php @@ -16,4 +16,5 @@ class OrderController extends Controller return view('account.orders', compact('orders')); } + } diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index f9ceebd..6952b33 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -104,6 +104,19 @@ class Transaction extends Model return __('order.status.'.strtolower($this->attributes['status'])); } + public function getStatusColorAttribute() + { + return match($this->attributes['status']) { + 'wait_payment' => 'warning', + 'wait_process' => 'info', + 'on_process' => 'primary', + 'on_delivery' => 'success', + 'closed' => 'success', + 'cancelled' => 'danger', + default => 'secondary', + }; + } + public function getTotalAttribute() { return $this->attributes['subtotal'] + $this->attributes['shipping_price']; diff --git a/app/Models/User.php b/app/Models/User.php index 25328e4..058b7d4 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -61,4 +61,9 @@ class User extends Authenticatable { return $this->hasMany(Address::class); } + + public function getPhotoUrlAttribute() + { + return $this->photo ? env('WMS_ASSET_URL') . '/' . $this->photo : asset('img/photo-placeholder.png'); + } } diff --git a/app/ThirdParty/Xendit/Xendit.php b/app/ThirdParty/Xendit/Xendit.php index 5de8a7a..30283da 100644 --- a/app/ThirdParty/Xendit/Xendit.php +++ b/app/ThirdParty/Xendit/Xendit.php @@ -12,6 +12,11 @@ class Xendit $url = "https://api.xendit.co/v2/invoices"; $key = env("XENDIT_PRIVATE_KEY"); + + + $payload['success_redirect_url'] = route('orders'); + $payload['failure_redirect_url'] = route('orders'); + $res = Http::withBasicAuth($key, "") ->withBody(json_encode($payload), 'application/json') ->post($url); @@ -21,4 +26,25 @@ class Xendit return null; } + + + public function checkInvoiceStatus(string $invoiceId) + { + $url = $this->baseUrl . "/v2/invoices/{$invoiceId}"; + + $res = Http::withBasicAuth($this->key, "") + ->get($url); + + if ($res->successful()) { + return $res->json(); + } + + Log::error("Xendit Check Invoice Failed", [ + 'invoice_id' => $invoiceId, + 'status' => $res->status(), + 'body' => $res->body() + ]); + + return null; + } } diff --git a/lang/en/order.php b/lang/en/order.php index fdd5fb8..0881967 100644 --- a/lang/en/order.php +++ b/lang/en/order.php @@ -1,7 +1,12 @@ 'Orders', 'status' => [ 'wait_payment' => 'Wait Payment', + 'wait_process' => 'Wait Process', + 'on_process' => 'On Process', + 'on_delivery' => 'On Delivery', + 'closed' => 'Closed', ], ]; \ No newline at end of file diff --git a/lang/id/order.php b/lang/id/order.php index a5de538..d582379 100644 --- a/lang/id/order.php +++ b/lang/id/order.php @@ -1,7 +1,12 @@ 'Pesanan', 'status' => [ 'wait_payment' => 'Menunggu Pembayaran', + 'wait_process' => 'Menunggu Diproses', + 'on_process' => 'Sedang Diproses', + 'on_delivery' => 'Sedang Dikirim', + 'closed' => 'Selesai', ], -]; \ No newline at end of file +]; diff --git a/resources/views/account/info.blade.php b/resources/views/account/info.blade.php index a39f976..ee79701 100644 --- a/resources/views/account/info.blade.php +++ b/resources/views/account/info.blade.php @@ -10,19 +10,19 @@
-
+ {{--
  • {{ auth()->user()->name }}
  • {{ auth()->user()->email }}
  • - {{--
  • English
  • --}} +
-
+
--}} -
+
@csrf @@ -36,6 +36,7 @@
+
@if(auth()->user()->photo) {{ auth()->user()->name }} @@ -77,8 +78,8 @@
+ id="phone" name="phone" required="" type="text" placeholder="{{ __('account_info.not_set') }}" + value="{{ auth()->user()->phone ?? '' }}" />
{{ __('account_info.please_enter_phone_number') }}
@@ -131,9 +132,9 @@
- + type="button">{{ __('account_info.close') }} --}}
diff --git a/resources/views/account/orders.blade.php b/resources/views/account/orders.blade.php index 8604fdf..a441a01 100644 --- a/resources/views/account/orders.blade.php +++ b/resources/views/account/orders.blade.php @@ -7,7 +7,7 @@
-

Orders

+

{{ __('order.title') }}

@@ -89,7 +89,7 @@
  • {{ \Carbon\Carbon::parse($order->created_at)->format('d M Y') }}
  • - + {{ $order->status_title }}
  • Rp @@ -136,25 +136,9 @@
- +
+ {{ $orders->links() }} +
@endsection diff --git a/resources/views/components/order/details.blade.php b/resources/views/components/order/details.blade.php index 8079eed..747d5b1 100644 --- a/resources/views/components/order/details.blade.php +++ b/resources/views/components/order/details.blade.php @@ -65,7 +65,7 @@
  • No Resi: - {{ $order?->waybill_number ?? '-' }} + {{ $order?->shipping?->waybill_id ?? '-' }}
  • diff --git a/resources/views/layouts/account.blade.php b/resources/views/layouts/account.blade.php index 22f19cc..795cc4c 100644 --- a/resources/views/layouts/account.blade.php +++ b/resources/views/layouts/account.blade.php @@ -18,13 +18,13 @@ @include('layouts.partials/account-sidebar') - @yield('content') + @yield('content')
  • - @include('layouts.partials/footer') + @include('layouts.partials/footer2') @include('layouts.partials/back-to-top') diff --git a/routes/web.php b/routes/web.php index 2f656e8..bc11f8b 100644 --- a/routes/web.php +++ b/routes/web.php @@ -115,6 +115,5 @@ Route::middleware(['auth'])->prefix('/orders')->group(function () { Route::get('/', [OrderController::class, 'index'])->name('orders'); }); - Route::get('/terms-and-conditions', [TncController::class, 'index'])->name('terms-and-conditions'); Route::get('/help', [HelpController::class, 'index'])->name('help');