14-04-2026

This commit is contained in:
Kevin Adametz 2026-04-14 18:07:45 +02:00
parent f58c709945
commit 0f82fea88a
72 changed files with 7414 additions and 148 deletions

View file

@ -10,6 +10,7 @@ use App\Models\ShoppingPayment;
use App\Models\ShoppingUser;
use App\Repositories\CheckoutRepository;
use App\Services\AboHelper;
use App\Services\CheckoutFunnelTracker;
use App\Services\CustomerPriority;
use App\Services\Payment;
use App\Services\Shop;
@ -98,6 +99,11 @@ class CheckoutController extends Controller
'yard_instance' => $this->instance,
];
CheckoutFunnelTracker::visitedCheckout(
consultantUserId: Util::getUserShop()?->id ?? null,
metadata: ['is_from' => $is_from, 'is_for' => $is_for, 'is_abo' => $is_abo],
);
return view('web.templates.checkout', $data);
}
@ -168,6 +174,14 @@ class CheckoutController extends Controller
Util::setUserHistoryValue(['status' => 2, 'shopping_order_id' => $shopping_order->id]);
CheckoutFunnelTracker::submittedForm(
shoppingUserId: $shopping_user->id,
shoppingOrderId: $shopping_order->id,
consultantUserId: $shopping_user->auth_user_id ?? null,
paymentMethod: Request::get('payment_method'),
amountCents: (int) (Yard::instance($this->instance)->totalWithShipping(2, '.', '') * 100),
);
// Zahlungsmethode verarbeiten
if (Request::get('payment_method')) {
return $this->processPaymentMethod($data, $shopping_user, $shopping_order);
@ -400,6 +414,11 @@ class CheckoutController extends Controller
$ShoppingPayment->status = $status;
$ShoppingPayment->save();
CheckoutFunnelTracker::returnedFromPayment(
shoppingPaymentId: $ShoppingPayment->id,
returnStatus: $status,
);
if ($status === 'success') {
return $this->handleSuccessfulTransaction($ShoppingPayment, $reference);
}
@ -410,7 +429,9 @@ class CheckoutController extends Controller
return $this->showTransactionError(
__('payment.payment_canceled'),
__('payment.payment_canceled_description')
__('payment.payment_canceled_description'),
'cancel',
['checkout_url' => route('checkout.checkout_card')],
);
}
@ -418,9 +439,29 @@ class CheckoutController extends Controller
Util::setUserHistoryValue(['status' => 23]);
Util::setInstanceStatusByPayment($ShoppingPayment, 5); // link_failed
$latestTransaction = $ShoppingPayment->payment_transactions()
->whereNotNull('errorcode')
->orWhere(fn ($q) => $q->whereNotNull('transmitted_data'))
->latest()
->first();
$errorcode = null;
$errorDescription = null;
if ($latestTransaction) {
$errorcode = $latestTransaction->errorcode
?? ($latestTransaction->transmitted_data['errorcode'] ?? null);
$errorDescription = $latestTransaction->error_description;
}
return $this->showTransactionError(
__('payment.payment_error'),
__('payment.payment_error_description')
__('payment.payment_error_description'),
'error',
[
'errorcode' => $errorcode,
'error_description' => $errorDescription,
'checkout_url' => route('checkout.checkout_card'),
],
);
}
@ -434,19 +475,21 @@ class CheckoutController extends Controller
/**
* Zeigt eine Transaktionsfehlerseite an
*
* @param string $title
* @param string $message
* @return \Illuminate\View\View
*/
private function showTransactionError($title, $message)
/**
* @param array<string, mixed> $extra
*/
private function showTransactionError(string $title, string $message, string $type = 'error', array $extra = [])
{
$data = [
$data = array_merge([
'user_shop' => Util::getUserShop(),
'is_checkout' => true,
'yard_instance' => $this->instance,
'error_title' => $title,
'error_message' => $message,
];
'error_type' => $type,
], $extra);
return view('web.templates.checkout-error', $data);
}
@ -494,6 +537,12 @@ class CheckoutController extends Controller
if ($payt->shopping_payment->reference != $reference) {
abort(404);
}
CheckoutFunnelTracker::confirmedPayment(
shoppingPaymentId: $payt->shopping_payment_id,
txaction: $payt->txaction ?? $payt->status ?? 'approved',
);
Yard::instance($this->instance)->destroy();
$this->checkoutRepo->sessionDestroy(true);
Util::setInstanceStatus(3, true); // link_pending