$fixture['userAbo'], 'isAdmin' => false, 'only_show_products' => true, ])->render(); expect($html) ->toContain('Zahlung fehlgeschlagen') ->toContain('923') ->toContain('Keine Deckung'); }); it('blockiert erneute Zahlungsversuche für nicht angehaltene Abos vor dem Payment-Aufruf', function () { $service = new AboRetryPaymentService; $userAbo = new UserAbo([ 'status' => 2, 'active' => true, ]); $result = $service->retry($userAbo); expect($result['success'])->toBeFalse(); expect($result['message'])->toBe(__('abo.retry_only_hold')); }); it('speichert PAYONE-Fehler aus dem automatischen Abo-Lauf als PaymentTransaction', function () { $fixture = createAdminAboRetryFixture(); $shoppingPayment = $fixture['userAboOrder']->shopping_order->shopping_payments()->firstOrFail(); $userMakeOrder = new UserMakeOrder($fixture['userAbo']); $payProperty = new ReflectionProperty($userMakeOrder, 'pay'); $payProperty->setAccessible(true); $payProperty->setValue($userMakeOrder, new class($shoppingPayment) { public function __construct(private ShoppingPayment $shoppingPayment) {} public function getShoppingPayment(): ShoppingPayment { return $this->shoppingPayment; } }); $recordMethod = new ReflectionMethod($userMakeOrder, 'recordPaymentTransaction'); $recordMethod->setAccessible(true); $recordMethod->invoke($userMakeOrder, [ 'status' => 'ERROR', 'errorcode' => 130, 'errormessage' => 'Limit überschritten', 'customermessage' => 'Die Zahlung wurde abgelehnt.', ]); $paymentTransaction = $shoppingPayment->payment_transactions()->latest('id')->firstOrFail(); expect($paymentTransaction->status)->toBe('ERROR'); expect($paymentTransaction->errorcode)->toBe(130); expect($paymentTransaction->errormessage)->toBe('Limit überschritten'); }); it('setzt die Mindestlaufzeit-Sperre fuer Admin-Bearbeitung ausser Kraft', function () { $fixture = createAdminAboRetryFixture(); expect(AboHelper::isAddOnlyMode($fixture['userAbo'], 'admin'))->toBeFalse(); }); /** * @return array{userAbo: UserAbo, userAboOrder: UserAboOrder} */ function createAdminAboRetryFixture(): array { $country = Country::create([ 'code' => 'DE', 'phone' => '49', 'en' => 'Germany', 'de' => 'Deutschland', 'es' => 'Alemania', 'fr' => 'Allemagne', 'it' => 'Germania', 'ru' => 'Deutschland', ]); $shipping = Shipping::create([ 'name' => 'Standard', 'active' => true, ]); $shippingCountry = ShippingCountry::create([ 'shipping_id' => $shipping->id, 'country_id' => $country->id, ]); $user = User::forceCreate([ 'email' => 'admin-abo-retry-'.uniqid('', true).'@example.com', 'password' => bcrypt('secret'), 'lang' => 'de', ]); $userShop = UserShop::create([ 'user_id' => $user->id, 'name' => 'TS'.substr(uniqid('', true), 0, 8), 'slug' => 'ts-'.uniqid(), 'active' => true, ]); $shoppingUser = ShoppingUser::create([ 'auth_user_id' => $user->id, 'member_id' => $user->id, 'billing_country_id' => $country->id, 'shipping_country_id' => $country->id, 'billing_email' => $user->email, 'shipping_email' => $user->email, 'shipping_firstname' => 'Max', 'shipping_lastname' => 'Muster', 'is_for' => 'me', 'is_from' => 'user_order', ]); $userAbo = UserAbo::create([ 'user_id' => $user->id, 'member_id' => $user->id, 'shopping_user_id' => $shoppingUser->id, 'is_for' => 'me', 'email' => $user->email, 'payone_userid' => 123456, 'clearingtype' => 'wlt', 'wallettype' => 'PPE', 'active' => true, 'status' => 3, 'abo_interval' => 5, 'next_date' => now()->toDateString(), ]); $shoppingOrder = ShoppingOrder::create([ 'shopping_user_id' => $shoppingUser->id, 'auth_user_id' => $user->id, 'member_id' => $user->id, 'country_id' => $shippingCountry->id, 'user_shop_id' => $userShop->id, 'payment_for' => 3, 'total' => 100, 'subtotal' => 90, 'total_shipping' => 100, 'paid' => false, 'is_abo' => true, 'txaction' => 'failed', 'mode' => 'test', ]); $shoppingPayment = ShoppingPayment::create([ 'shopping_order_id' => $shoppingOrder->id, 'clearingtype' => 'wlt', 'wallettype' => 'PPE', 'reference' => 'RF123456', 'amount' => 10000, 'currency' => 'EUR', 'mode' => 'test', 'is_abo' => true, 'abo_interval' => 5, ]); PaymentTransaction::create([ 'shopping_payment_id' => $shoppingPayment->id, 'request' => 'debit', 'txid' => 1, 'userid' => 123456, 'status' => 'ERROR', 'txaction' => 'failed', 'errorcode' => 923, 'errormessage' => 'Keine Deckung', 'mode' => 'test', ]); $userAboOrder = UserAboOrder::create([ 'user_abo_id' => $userAbo->id, 'shopping_order_id' => $shoppingOrder->id, 'status' => 3, 'paid' => false, ]); return [ 'userAbo' => $userAbo, 'userAboOrder' => $userAboOrder, ]; }