@extends('admin.layouts.app')

@section('content')
    <section class="section">
        <div class="section-header">
            <h1>{{ $pageTitle }}</h1>
            <div class="section-header-breadcrumb">
                <div class="breadcrumb-item active"><a href="/admin">{{ trans('admin/main.dashboard') }}</a></div>
                <div class="breadcrumb-item"><a href="/admin/financial/payment-transactions">{{ trans('admin/main.payment_transactions_title') }}</a></div>
                <div class="breadcrumb-item">#{{ $log->id }}</div>
            </div>
        </div>

        <div class="section-body">
            <div class="card">
                <div class="card-body">
                    <dl class="row">
                        <dt class="col-sm-3">{{ trans('admin/main.date') }}</dt>
                        <dd class="col-sm-9">{{ dateTimeFormat($log->created_at, 'j M Y H:i:s') }}</dd>

                        <dt class="col-sm-3">{{ trans('admin/main.order_id') }}</dt>
                        <dd class="col-sm-9">{{ $log->order_id ?? '-' }}</dd>

                        <dt class="col-sm-3">{{ trans('admin/main.user') }}</dt>
                        <dd class="col-sm-9">
                            @if($log->user)
                                {{ $log->user->full_name }} ({{ $log->user->email }})
                            @else
                                -
                            @endif
                        </dd>

                        <dt class="col-sm-3">Gateway</dt>
                        <dd class="col-sm-9">{{ $log->gateway }}</dd>

                        <dt class="col-sm-3">{{ trans('admin/main.event') }}</dt>
                        <dd class="col-sm-9">{{ $log->event }}</dd>

                        <dt class="col-sm-3">{{ trans('admin/main.status') }}</dt>
                        <dd class="col-sm-9">{{ $log->status }}</dd>

                        <dt class="col-sm-3">{{ trans('admin/main.amount') }}</dt>
                        <dd class="col-sm-9">{{ $log->amount }} {{ $log->currency }}</dd>

                        <dt class="col-sm-3">HTTP</dt>
                        <dd class="col-sm-9">{{ $log->http_status ?? '-' }}</dd>

                        <dt class="col-sm-3">{{ trans('admin/main.failure_reason') }}</dt>
                        <dd class="col-sm-9 text-danger">{{ $log->failure_reason ?? '-' }}</dd>
                    </dl>

                    @if($log->order && !empty($log->order->payment_failure_reason))
                        <div class="alert alert-danger">
                            <strong>{{ trans('admin/main.order_failure_reason') }}:</strong>
                            {{ $log->order->payment_failure_reason }}
                        </div>
                    @endif

                    <h5 class="mt-4">{{ trans('admin/main.request_payload') }}</h5>
                    <pre class="bg-light p-3 rounded" style="max-height:300px;overflow:auto">{{ $log->request_payload }}</pre>

                    <h5 class="mt-4">{{ trans('admin/main.response_body') }}</h5>
                    <pre class="bg-light p-3 rounded" style="max-height:300px;overflow:auto">{{ $log->response_body }}</pre>

                    <a href="/admin/financial/payment-transactions" class="btn btn-secondary mt-3">{{ trans('admin/main.back') }}</a>
                </div>
            </div>
        </div>
    </section>
@endsection
