Fix issues with recording contact on payments.
This commit is contained in:
parent
9cf128a887
commit
9e8e046985
|
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Enums\PaymentMethod;
|
use App\Enums\PaymentMethod;
|
||||||
use App\Enums\PaymentStatus;
|
use App\Enums\PaymentStatus;
|
||||||
|
use App\Models\Contact;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
@ -86,8 +87,12 @@ class StripeController extends Controller
|
||||||
|
|
||||||
$feeAmount = $paymentIntent->latest_charge?->balance_transaction?->fee ?? 0;
|
$feeAmount = $paymentIntent->latest_charge?->balance_transaction?->fee ?? 0;
|
||||||
|
|
||||||
|
$email = $session->customer_details?->email;
|
||||||
|
$contact = $email ? Contact::where('email', $email)->first() : null;
|
||||||
|
|
||||||
Payment::create([
|
Payment::create([
|
||||||
'invoice_id' => $invoice->id,
|
'invoice_id' => $invoice->id,
|
||||||
|
'contact_id' => $contact?->id,
|
||||||
'payment_date' => now(),
|
'payment_date' => now(),
|
||||||
'status' => PaymentStatus::COMPLETED,
|
'status' => PaymentStatus::COMPLETED,
|
||||||
'payment_method' => PaymentMethod::CARD,
|
'payment_method' => PaymentMethod::CARD,
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ new class extends Component {
|
||||||
<flux:table.row>
|
<flux:table.row>
|
||||||
<flux:table.cell>{{ $payment->payment_date->local()->format('m/d/Y') }}</flux:table.cell>
|
<flux:table.cell>{{ $payment->payment_date->local()->format('m/d/Y') }}</flux:table.cell>
|
||||||
<flux:table.cell>{{ $payment->invoice->invoice_number }}</flux:table.cell>
|
<flux:table.cell>{{ $payment->invoice->invoice_number }}</flux:table.cell>
|
||||||
<flux:table.cell>{{ $payment->contact->full_name }}</flux:table.cell>
|
<flux:table.cell>{{ $payment->contact?->full_name }}</flux:table.cell>
|
||||||
<flux:table.cell>{{ $payment->status->label() }}</flux:table.cell>
|
<flux:table.cell>{{ $payment->status->label() }}</flux:table.cell>
|
||||||
<flux:table.cell>{{ $payment->payment_method->label() }}<br>{{ $payment->reference }}</flux:table.cell>
|
<flux:table.cell>{{ $payment->payment_method->label() }}<br>{{ $payment->reference }}</flux:table.cell>
|
||||||
<flux:table.cell>{{ formatMoney($payment->fee_amount) }}</flux:table.cell>
|
<flux:table.cell>{{ formatMoney($payment->fee_amount) }}</flux:table.cell>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue