@extends('admin.layouts.app') @section('title', $tx->receipt) @section('content') @php use Modules\Gateways\Mpesa\Services\Money; $me = auth('admin')->user(); $canAllocate = $me?->hasPermission('allocate_mpesa_payments'); $canReverse = $me?->hasPermission('request_mpesa_reversals'); $canApprove = $me?->hasPermission('approve_mpesa_reversals'); @endphp @include('mpesa::admin._nav', ['title' => __('mpesa::mpesa.admin.payment').' '.$tx->receipt])
{{ __('mpesa::mpesa.admin.details') }}
@if($tx->paymentRequest) @endif
{{ __('mpesa::mpesa.admin.receipt') }}{{ $tx->receipt }}
{{ __('mpesa::mpesa.admin.amount_kes') }}{{ Money::format(Money::minor($tx->amount)) }}
{{ __('mpesa::mpesa.admin.paid_at') }}{{ $tx->transacted_at?->format('Y-m-d H:i:s') ?? '—' }} UTC
{{ __('mpesa::mpesa.admin.environment') }} / {{ __('mpesa::mpesa.admin.shortcode') }}{{ $tx->environment }} / {{ $tx->shortcode }}
{{ __('mpesa::mpesa.admin.source') }}{{ $tx->source }} {{ $tx->transaction_type ? '('.$tx->transaction_type.')' : '' }}
{{ __('mpesa::mpesa.admin.reference') }}{{ $tx->bill_reference ?: '—' }}
{{ __('mpesa::mpesa.admin.payer') }}{{ $tx->payer_name ?: '—' }} {{ $tx->msisdn_masked }}
{{ __('common.table.client') }}@if($tx->client){{ $tx->client->full_name }}@else — @endif
{{ __('mpesa::mpesa.admin.status') }}@include('mpesa::admin._badge', ['value' => $tx->status, 'group' => 'tx_status']) {{ $tx->verified_by ? __('mpesa::mpesa.admin.verified_by', ['by' => $tx->verified_by, 'at' => $tx->verified_at?->format('Y-m-d H:i')]) : '' }}
{{ __('mpesa::mpesa.admin.allocation') }}@include('mpesa::admin._badge', ['value' => $tx->allocation_status, 'group' => 'allocation']) @if($tx->match_rule) {{ __('mpesa::mpesa.admin.rule', ['rule' => $tx->match_rule]) }}@endif @if($tx->match_note)
{{ $tx->match_note }}
@endif @if($tx->allocation_error)
{{ \Illuminate\Support\Str::limit($tx->allocation_error, 300) }}
@endif
{{ __('mpesa::mpesa.admin.reversal') }}@include('mpesa::admin._badge', ['value' => $tx->reversal_status, 'group' => 'reversal_status'])@if(Money::minor($tx->reversed_amount) > 0) {{ Money::format(Money::minor($tx->reversed_amount)) }}@endif
{{ __('mpesa::mpesa.admin.request') }}#{{ $tx->paymentRequest->id }} ({{ $tx->paymentRequest->type }}, {{ $tx->paymentRequest->checkout_request_id ?: $tx->paymentRequest->claimed_receipt }})
{{ __('mpesa::mpesa.admin.allocations') }}
@forelse($tx->allocations as $a) @empty @endforelse
{{ __('mpesa::mpesa.admin.invoice') }}{{ __('mpesa::mpesa.admin.booked') }}{{ __('mpesa::mpesa.admin.to_invoice') }}{{ __('mpesa::mpesa.admin.to_credit') }}{{ __('mpesa::mpesa.admin.status') }}
#{{ $a->invoice?->invoice_num ?: $a->invoice_id }}
{{ $a->rule }}{{ $a->admin ? ' · '.$a->admin->username : '' }} · {{ $a->ledger_reference }}
{{ $a->source_currency }} {{ $a->amount_source }} {{ $a->invoice_portion }} {{ $a->credit_portion }} {{ $a->status }}
{{ __('mpesa::mpesa.admin.not_allocated') }}
@if($canAllocate && $tx->isConfirmed() && ! $tx->isAllocated() && $tx->allocation_status !== 'allocating' && ! in_array($tx->reversal_status, ['pending', 'reversed'], true))
@csrf {{ __('mpesa::mpesa.admin.allocate_title') }}
@foreach($candidates as $inv)@endforeach
@endif @if($canAllocate && $tx->isAllocated() && $tx->reversal_status === 'none')
{{ __('mpesa::mpesa.admin.unallocate_title') }}
@csrf

{{ __('mpesa::mpesa.admin.unallocate_help') }}

@endif
@if($canAllocate && $tx->isConfirmed() && in_array($tx->allocation_status, ['failed', 'allocating', 'pending'], true))
@csrf
@endif @if($canAllocate && $tx->status !== 'confirmed')
@csrf
@endif @if($canReverse && ! $reversalBlocked) {{ __('mpesa::mpesa.reversal.request_button') }} @elseif($canReverse && $tx->reversal_status !== 'reversed') {{ __('mpesa::mpesa.reversal.unavailable') }}: {{ $reversalBlocked }} @endif
@if($tx->reversals->isNotEmpty())
{{ __('mpesa::mpesa.reversal.history') }}
@foreach($tx->reversals as $r) @endforeach
#{{ __('mpesa::mpesa.admin.amount_kes') }}{{ __('mpesa::mpesa.reversal.reason') }}{{ __('mpesa::mpesa.reversal.requested_by') }}{{ __('mpesa::mpesa.reversal.approved_by') }}{{ __('mpesa::mpesa.admin.status') }}{{ __('mpesa::mpesa.reversal.result') }}
{{ $r->id }}
{{ $r->created_at->format('Y-m-d H:i') }}
{{ Money::format(Money::minor($r->amount)) }} {{ $r->reason }} {{ $r->requester?->username }} {{ $r->approver?->username ?? '—' }} @include('mpesa::admin._badge', ['value' => $r->status, 'group' => 'reversal']) {{ $r->result_code ? '['.$r->result_code.'] ' : '' }}{{ $r->result_desc }}@if($r->reversal_receipt)
{{ $r->reversal_receipt }}
@endif @if(! empty($r->adjustments['credit_shortfall']) && $r->adjustments['credit_shortfall'] !== '0.00')
{{ __('mpesa::mpesa.reversal.shortfall', ['amount' => $r->adjustments['credit_shortfall']]) }}
@endif
@if($r->status === 'awaiting_approval') @if($canApprove && (int) $r->requested_by !== (int) $me->id)
@csrf
@endif
@csrf
@endif @if(in_array($r->status, ['unknown', 'pending', 'submitting'], true) && $canApprove)
{{ __('mpesa::mpesa.reversal.record_outcome') }}
@csrf
@endif
@endif
{{ __('mpesa::mpesa.admin.timeline') }}
@foreach($timeline as $e) @endforeach @foreach($callbacks as $cb) @endforeach
{{ $e->created_at?->format('Y-m-d H:i:s') }} {{ $e->type }} {{ $e->message }}@if($e->admin) — {{ $e->admin->username }}@endif
{{ $cb->created_at?->format('Y-m-d H:i:s') }} callback {{ $cb->kind }} — {{ $cb->status }} ({{ $cb->attempts }}x){{ $cb->error ? ': '.\Illuminate\Support\Str::limit($cb->error, 150) : '' }}
@csrf
@if($canAllocate)
@csrf
@endif
@endsection