Skip to content

Models

All in Fomvasss\Billing\Models (the webhook call in Fomvasss\Billing\Webhooks), UUID v7 keys (HasUuids), $guarded = ['id']. Columns — Database tables.

Table billing_payments, soft deletes. paid_at is stamped when status becomes paid and cleared when it leaves; tenant_id is derived from the billable on create when empty.

MemberReturnsDescription
payable(), billable()MorphTo
parentPayment()BelongsToThe charge a refund row belongs to
refunds()HasManyChild refund rows
isPaid(), isPending(), isFailed()boolStatus checks
isRefund()booltype is refund
isManual(), isAutomatic()boolinitiation; both false when null
transitionTo(PaymentStatus $status, array $attributes = [])boolStatus update that refuses to leave paid (logs, returns false)
money()Moneyamount + currency
refundedAmount() / refundedMoney()int / MoneySum of paid refund rows, trashed included
refundableRemainder() / refundableRemainderMoney()int / Moneyamount minus paid and pending refunds
netAmount() / netMoney()?int / ?Moneyamount - fee; null while fee is unknown
feeMoney()?Money
hasActivePaymentUrl()boolpayment_url set and not expired (no expiry = alive)
Payment::recordRefundOf(Payment $charge, Money $money, ?string $externalId = null, array $raw = [], PaymentStatus $status = Paid)PaymentBuilds a refund row (used by the package)
Payment::findByNumber(string $number)?PaymentBy number
scopes paid(), pending(), forBillable(Model $billable)

Table billing_subscriptions. On create: trial_ends_at from the price’s trial_days for a trialing row without one; quota_period_ends_at for a price with its own quota cycle; tenant_id from the billable.

MemberReturnsDescription
billable(), price()relations
isActive()boolEntitled right now, see Access
onTrial()booltrialing and trial_ends_at null or future
onGracePeriod()boolgrace_ends_at in the future
isCanceled()bool
isCancelling()boolcancels_at in the future, not yet canceled
hasGraceAccess()boolprice.grace_access ?? config
isProviderManaged()boolexternal_id not null
nextPeriodEnd()?CarbonWhere a successful renewal moves the period; null for a price without interval
nextQuotaPeriodEnd(?Carbon $base = null)?CarbonNext quota boundary for an own-cycle price
retryIntervals(), periodEndingNotices()listEffective lists (price override or config)
reportUsage(float $quantity, ?string $idempotencyKey = null)voidAdds usage, fires UsageLimitReached on crossing the quota
remainingUsage()?floatNull without included_units
resetUsageQuota()boolUsed by billing:reset-usage-quotas
pause(?DateTimeInterface $until = null), resume()voidLocal, or forwarded for provider-managed
cancel(bool $atPeriodEnd = true)voidLocal, or forwarded
swapPlan(Price $newPrice)voidLocal, or forwarded
markCanceled(array $attributes = [])voidThe one way into canceled; fires SubscriptionCancelled
recordRenewalSuccess(?string $gateway = null)boolAdvances the period; false (logged) for canceled/ended/paused
recordRenewalFailure()voidOne dunning step
applyProviderSnapshot(SubscriptionSnapshot $snapshot)boolWrites provider state, fires events from the diff; false for a stale snapshot
scopes active(), forBillable(Model $billable)active() mirrors isActive() in SQL

Table billing_plans: code, name, meta (array). prices() — HasMany.

Table billing_prices. Casts: interval/quota_interval → Interval, pricing_type → PricingType, notice/retry lists → arrays, included_units → float.

MemberReturnsDescription
plan(), subscriptions()relations
money()Money
hasOwnQuotaCycle()boolquota_interval and included_units both set
chargeMultiplier(Subscription $subscription)int|float1 / qty / current_usage by pricing type

Table billing_payment_methods: gateway, type (card), brand, last4, expires_at, is_default, external_customer_id, external_id (the token), billable morph, tenant_id. billable() — MorphTo.

Table billing_invoices. Issue through the facade, not create().

MemberReturnsDescription
payment(), billable()relations
invoice()BelongsToThe invoice a receipt settles
receipts()HasManyReceipts of an invoice
isInvoice(), isReceipt(), isPaid(), isVoid()bool
money()Moneytotal + currency
sellerDetails(), buyerDetails()BillingDetailsFrom the snapshot
scope forBillable(Model $billable)

Fomvasss\Billing\Webhooks\BillingWebhookCall, table billing_webhook_calls, MassPrunable (older than webhook.prune_after_days). storeWebhook(string $gateway, Request $request) stores a call with credential headers redacted; saveException(Throwable $e).

Fomvasss\Billing\Concerns\Billable — tenantId() (null), payments(), subscriptions(), paymentMethods(), defaultPaymentMethod() (MorphOne, is_default), defaultPaymentMethodFor(string $gateway), activeSubscription(?string $planCode = null) (latest active), hasActiveSubscription(?string $planCode = null).