CluPilotCloud/tests/Feature/Billing
nexxo 3cf16ecd63 Name every property that decides what a price charges
The money gate compared amount, currency and interval and left the rest to a
filter that excluded two fields. A recurring, licensed, monthly price with
transform_quantity divide_by 10, at our exact figure, on our product, carrying
our addon key passed all five conditions. Modules bill BY quantity — a pack is
one item at quantity n — so a customer holding three would have been charged
one. A tiered price was excluded only by accident: Stripe reports unit_amount
null for it and we read that as 0, which fails the amount match unless the
caller's own figure is 0, and PlanPrices::ensure() has no zero guard.

activePricesFor() now also skips a non-empty transform_quantity and any
billing_scheme other than per_unit. Absent keys stay Stripe's defaults, which
is the direction that matters: read the other way round the filter would refuse
every legitimate price and turn recognition into a permanent no-op. The
contract docblock names the four properties instead of claiming to cover all of
them, and says the list is not everything Stripe can put on a price — only
what is known to change what one charges.

And a comment that says a gap is covered is worse than the gap. The sync said a
crash between Stripe creating a product and us storing its id gives back the
same product next run: true for twenty-four hours, false afterwards, and the
exact claim this branch was written to refute. There is no recognition step for
products at all, so an interrupted run leaves an orphan and the next run past
the expiry mints a second one — worse than a duplicate price, because
activePricesFor() then looks at the wrong product and recognition goes blind
for the whole family. Written down as a known gap at both createProduct call
sites, with the trade this branch chose: folding name and metadata into the key
means a renamed family now mints a second product where it used to answer 400,
and a blockade reaches a paying customer while a duplicate product does not.

The sweep no longer reports "created" for what it adopted — the count is taken
before ensure() runs, and telling those two apart is the whole point.

The test named after 2026-07-29 could not reproduce it: the fake's key ledger
was empty, so createPrice() could not have thrown and the test could not tell
"adoption prevented the 400" from "no 400 was possible". Seeded now with the
key today's call sends and a fingerprint over the metadata the pre-9da1358 call
sent. Remove the adopt() call from AddonPrices::ensure() and the test dies with
Stripe's own sentence instead of an assertion.

Also: the plan document still instructed migrate:fresh --env=testing. There is
no .env.testing here, so it targets the live development database; struck
through with the reason, not deleted, and a Korrekturen section records the
five defects the plan's own reviews found in it. Four comments corrected —
"below" that meant above, a counter claimed unable to tie that ties with a
planted price, the unique index's second meaning for remember()'s catch, and
that MariaDB DDL is not transactional so the dedupe commits before the index.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-30 13:50:20 +02:00
..
AddonCancellationTest.php Ask whether they are a consumer, and let one change their mind 2026-07-29 21:06:06 +02:00
AddonEntitlementTest.php Book a downgrade for a date that cannot move, and sell a module once 2026-07-29 17:51:37 +02:00
ApplyPlanChangeTest.php Book a downgrade for a date that cannot move, and sell a module once 2026-07-29 17:51:37 +02:00
ArchivePullAccessTest.php Mint the archive collection key from the console instead of by hand 2026-07-29 10:08:32 +02:00
CustomDomainAccessTest.php Decide who may have their own domain, and decide it in one place 2026-07-29 15:59:04 +02:00
CustomerTypeTest.php Ask whether they are a consumer, and let one change their mind 2026-07-29 21:06:06 +02:00
ExportTargetFormTest.php Keep the SFTP credential on the row it belongs to, encrypted 2026-07-29 02:46:06 +02:00
FinanceSettingsTest.php Decide the VAT rate in one place, before the two disagree 2026-07-29 02:03:29 +02:00
GrantAddonTest.php Let a subscription or add-on be opened for free, with who and why on the row 2026-07-29 12:41:06 +02:00
GrantInvoiceTest.php Skip the invoice for a full gift, keep it out of revenue, hide its price 2026-07-29 12:41:32 +02:00
GrantSubscriptionTest.php Let a subscription or add-on be opened for free, with who and why on the row 2026-07-29 12:41:06 +02:00
InvoiceArchiveTest.php Leave the archive readable by whoever collects from it 2026-07-29 03:48:03 +02:00
InvoiceListTest.php List issued invoices in the console, with no way to change one 2026-07-29 02:21:15 +02:00
InvoiceMailTest.php Send the invoice with the invoice attached 2026-07-29 02:13:41 +02:00
InvoiceMathTest.php Print every line at full price and take the discount off once, in euros 2026-07-29 01:59:56 +02:00
InvoiceNumberTest.php Lay the foundation for self-issued invoices: series, numbers, frozen documents 2026-07-29 00:57:06 +02:00
IssueInvoiceTest.php Issue an invoice from what somebody bought, and freeze it there 2026-07-29 02:09:05 +02:00
PackageCancellationTest.php Stop charging for a service that has ended 2026-07-30 00:52:19 +02:00
PaidOrderFulfilmentTest.php Say the same thing to the customer, the register and the bank 2026-07-30 01:30:24 +02:00
PendingPlanChangeTest.php Say the same thing to the customer, the register and the bank 2026-07-30 01:30:24 +02:00
PlanCatalogueTest.php Paketversionen: Verkauf wieder aufnehmen und saubere Übergabe 2026-07-29 14:58:11 +02:00
PlanChangeTest.php Fix nine defects in the provisioning pipelines 2026-07-30 01:34:55 +02:00
PortalInvoicesTest.php Say the same thing to the customer, the register and the bank 2026-07-30 01:30:24 +02:00
ProofRegisterTest.php Stop charging VAT to the customers who owe us none 2026-07-30 02:15:41 +02:00
RenewalInvoiceTest.php Bill a booked module every month, and put it on the invoice 2026-07-29 20:22:02 +02:00
ReverseChargePriceTest.php Stop charging VAT to the customers who owe us none 2026-07-30 02:15:41 +02:00
SetupFeeTest.php Stop charging VAT to the customers who owe us none 2026-07-30 02:15:41 +02:00
StorageAllowanceTest.php Deliver the storage a customer actually buys 2026-07-29 19:13:10 +02:00
StripeAddonBillingTest.php Stop charging VAT to the customers who owe us none 2026-07-30 02:15:41 +02:00
StripeBillingTest.php Stop charging VAT to the customers who owe us none 2026-07-30 02:15:41 +02:00
StripeIdempotencyKeyTest.php Name every property that decides what a price charges 2026-07-30 13:50:20 +02:00
StripePlanChangeTest.php Invoice every renewal, and tell Stripe when the package changes 2026-07-29 19:35:15 +02:00
StripePriceAdoptionTest.php Name every property that decides what a price charges 2026-07-30 13:50:20 +02:00
VatIdVerificationTest.php Ask the EU register whether a VAT number is real 2026-07-29 22:42:29 +02:00
WithdrawalTest.php Stop charging for a service that has ended 2026-07-30 00:52:19 +02:00