@extends('layouts.app') @section('title', 'Assisted Purchase') @push('styles') @endpush @section('content')
Loading...

Loading...

Assisted Purchase

Let our AI-powered shopping assistant help you purchase items from any Indian e-commerce store.

@if(request('submitted') == '1')
@endif
Fetch Product Details from URL
@foreach(\App\Support\AssistedStoreIcon::sites() as $site) {{ $site['label'] }} {{ $site['label'] }} @endforeach
Upload Product Image or Screenshot

Upload a product image, screenshot, or photo. Our AI will extract product name, price, brand, and details from the image. You can upload screenshots from your phone, computer, or any product photo.

Supported: Screenshots (PNG, JPG), Photos (JPG, PNG, WebP) - Max 10MB
Preview

Create New Purchase Request
This field will be automatically filled after fetching product details
This field will be automatically filled after fetching product details
This field will be automatically filled after fetching product details
Price is required. Please fetch product details first. Submit cannot be completed without price.
Overhead percentage will be calculated based on price
Final amount including overhead
Pending Purchases
A delivery suite is required before you continue.
@php $pendingRequests = collect(); if (!empty($requests) && is_iterable($requests)) { foreach ($requests as $item) { $queueMeta = is_array($item->meta) ? $item->meta : []; $queuePathway = $queueMeta['checkout_pathway'] ?? ''; if (isset($item->status) && strtolower(trim($item->status)) === 'pending' && $queuePathway === '') { $pendingRequests->push($item); } } } @endphp
@forelse($pendingRequests as $r) @php $itemMeta = is_array($r->meta) ? $r->meta : (json_decode($r->meta ?? '{}', true) ?: []); $priceText = trim((string) ($r->price_range ?? '')); $unitAmount = (float) preg_replace('/[^0-9.]/', '', str_replace(',', '', $priceText)); $lineQty = max(1, (int) ($r->quantity ?? 1)); $goodsAmount = ($r->sub_amount !== null && (float) $r->sub_amount > 0) ? (float) $r->sub_amount : round($unitAmount * $lineQty, 2); $overheadPercent = $r->overhead_percentage !== null ? (float) $r->overhead_percentage : null; $feeAmount = 0.0; if ($r->overhead_amount !== null && (float) $r->overhead_amount > 0) { $feeAmount = round((float) $r->overhead_amount, 2); } elseif ($goodsAmount > 0 && $overheadPercent !== null) { $feeAmount = round($goodsAmount * $overheadPercent / 100, 2); } $finalAmount = $r->final_amount !== null ? (float) $r->final_amount : round($goodsAmount + $feeAmount, 2); $unitLabel = $priceText !== '' ? $priceText : ('₹' . number_format($unitAmount, 2)); $iconUrl = $r->store_icon ? asset($r->store_icon) : asset('images/assisted-stores/other.svg'); @endphp
@empty @endforelse
@once @include('wuser.partials.delivery-badge-styles') @endonce
Purchase History
@forelse(($historyPayments ?? collect()) as $payment) @php $lines = $payment->items->map(function ($row) { return $row->assistedPurchaseRequest; })->filter()->values(); $primaryRequest = $lines->firstWhere('id', $payment->assisted_purchase_request_id) ?: $lines->first(); $pathway = strtolower((string) ($payment->pathway ?: '')); $payStatus = strtolower((string) $payment->payment_status); $isPaid = in_array($payStatus, ['success', 'completed'], true); $isFailed = !$isPaid && $pathway === 'a' && in_array($payStatus, ['failed', 'cancelled', 'canceled'], true); $bankRecorded = $pathway === 'c' && $payment->bank_transactionID; $trackingStatus = optional($payment->tracking)->status ?: $payment->status; if ($isFailed) { $statusLabel = 'Failed'; $statusClass = 'is-fail'; } elseif ($isPaid || $bankRecorded) { $statusLabel = $bankRecorded && !$isPaid ? 'Recorded' : 'Completed'; $statusClass = 'is-done'; } else { $statusLabel = 'Pending'; $statusClass = 'is-pending'; } if ($trackingStatus && !$isFailed) { $statusLabel = $trackingStatus; $statusClass = $trackingStatus === 'Customer Paid' ? 'is-done' : 'is-pending'; } $warehouseMarked = $pathway === 'c' && $payment->trackingHistory->contains(function ($row) { return $row->status === 'Customer Paid' && $row->wuser_id; }); if ($pathway === 'c' && $statusLabel === 'Customer Paid' && !$warehouseMarked) { $statusLabel = 'Transaction Successful'; } $storeIcons = $lines->map(function ($line) { $path = trim((string) $line->store_icon); if ($path === '') { $path = \App\Support\AssistedStoreIcon::match($line->url)['path']; } return [ 'store' => trim((string) $line->store) ?: 'Store', 'icon' => asset($path), ]; })->unique('store')->values(); $pathwayNames = ['a' => 'Card Gateway', 'b' => 'Maldives Post Link', 'c' => 'Cash / Bank Transfer']; $shortNames = ['a' => 'Card Gateway', 'b' => 'Maldives Post', 'c' => 'Cash / Bank']; $methodLabel = isset($pathwayNames[$pathway]) ? 'Payment method - Pathway '.strtoupper($pathway).': '.$pathwayNames[$pathway] : ''; $suiteNumber = $payment->suite_number ?: optional($primaryRequest)->suite_number; $suiteAddress = $payment->virtualAddress; if (!$suiteAddress && $suiteNumber && isset($deliverySuites)) { $suiteAddress = $deliverySuites->firstWhere('suite_number', $suiteNumber); } $suiteBadges = $suiteAddress ? $suiteAddress->deliveryBadges() : null; $needsCardPayment = $pathway === 'a' && !$isPaid; $purchaseCount = max($lines->count(), 1); $usdToInr = !empty($currencyRates['USD_INR']) ? (float) $currencyRates['USD_INR'] : 0; $currencyCode = strtoupper((string) ($payment->currency ?: 'INR')); $currencyMark = ['INR' => '₹', 'USD' => '$', 'MVR' => 'Rf'][$currencyCode] ?? $currencyCode; $money = $payment->selectedMoney(); $payableAmount = $money['total']; $payableUsd = ($payableAmount !== null && $currencyCode === 'INR' && $usdToInr > 0) ? $payableAmount / $usdToInr : null; $stores = $lines->pluck('store')->map(function ($store) { return trim((string) $store); })->filter()->unique()->values(); if ($stores->isEmpty() && $primaryRequest && trim((string) $primaryRequest->store) !== '') { $stores = collect([trim((string) $primaryRequest->store)]); } @endphp
Suite {{ $suiteNumber ?: 'N/A' }} @if($suiteBadges) @include('wuser.partials.delivery-badges', ['badges' => $suiteBadges, 'popId' => 'ap-dl-pay-'.$payment->id, 'suiteLine' => $suiteNumber]) @endif @if($statusLabel) {{ $statusLabel }} @endif @if($methodLabel !== '') {{ $methodLabel }} @endif
@if($storeIcons->isNotEmpty()) @foreach($storeIcons as $storeIcon) {{ $storeIcon['store'] }} @endforeach @endif {{ $purchaseCount }} {{ $purchaseCount === 1 ? 'purchase' : 'purchases' }} {{ $payableAmount !== null ? $currencyMark.number_format($payableAmount, 2) : '—' }}
@forelse($lines as $line)
{{ $loop->iteration }} {{ $line->title }} @if($line->url) @endif
@empty
1 {{ optional($primaryRequest)->title ?: 'Purchase' }}
@endforelse
@empty @endforelse
@include('kuser.partials.surface-styles') @endsection @push('scripts') @endpush