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 @@