Skip to content

Billing facade

Fomvasss\Billing\Facades\Billing, alias Billing. Resolves the Fomvasss\Billing\BillingManager singleton — app(BillingManager::class) is the same object.

MethodReturnsDescription
charge(Payment $payment, ChargeOptions $options = new ChargeOptions())PaymentResultOpens a checkout and writes external_id, payment_url, payment_url_expires_at, initiation, raw_response back; resets a non-paid row to pending. See Payments
startSubscription(Payment $payment, ChargeOptions $options = new ChargeOptions())PaymentResultSame, for the first payment of a provider-managed subscription. $payment->payable must be the Subscription. See Provider-managed subscriptions
chargeWithMethod(Payment $payment, PaymentMethod $method, ChargeOptions $options = new ChargeOptions())PaymentResultOff-session charge with a saved card; the method must belong to the payment’s gateway and billable. See Saved cards
refund(Payment $payment, ?Money $amount = null)Payment (the refund row)Full remainder by default. See Refunds
resolveChargeAmount(Price $price, string $gateway)ResolvedAmountPer-unit money for a price on a gateway. See Currency resolution
MethodReturnsDescription
extend(string $name, string $class)BillingManagerRegister a driver class under a name. fake outside local/testing throws
registerWebhook(string $name, string $validator, ?string $responder = null)BillingManagerRegister the signature validator (and optional responder) for a name
driver(string $name, ?string $tenantId = null)PaymentGatewayContractA fresh driver with resolved credentials. Unknown name → BillingException
gateways()arrayMetadata of every registered gateway, see Gateways overview
gateway(string $name)?arrayOne entry of gateways()
supportedCurrencies(string $gateway)arrayConfig override or the driver’s list
gatewaysImplementing(string $contract)list<string>Names whose driver implements a contract
health(string $gateway, ?string $tenantId = null)GatewayHealthLive probe; NotSupportedException without ChecksGatewayHealth
signatureValidatorFor(string $name), responderFor(string $name)stringRegistered class names (used by the webhook controller)
MethodReturnsDescription
issueInvoice(Payment $payment, ?BillingDetails $buyer = null, array $extra = [], ?DateTimeInterface $dueAt = null, ?string $locale = null, ?BillingDetails $seller = null)InvoiceIdempotent per payment
issueReceipt(Payment $payment, ?BillingDetails $buyer = null, array $extra = [], ?string $locale = null, ?BillingDetails $seller = null)InvoicePaid charges only; settles the payment’s invoice
voidInvoice(Invoice $invoice)InvoiceThrows on a paid one
invoiceDocument(Invoice $invoice)InvoiceDocumentThe formatted snapshot
renderInvoice(Invoice $invoice)stringHTML in the document’s locale
invoicePdf(Invoice $invoice)stringPDF bytes (stored copy if storage.disk)
invoicePdfUrl(Invoice $invoice, ?int $ttlMinutes = null)stringTemporary signed URL; throws when pdf_route is off

See Invoices and receipts.

ExceptionWhen
Fomvasss\Billing\Exceptions\BillingExceptionConfiguration and business errors: unknown gateway, missing return URL or credential, unsupported currency, basket not matching the amount, refund guards, a gateway refusing a refund or a subscription change, wrong card for the payment
Fomvasss\Billing\Exceptions\NotSupportedExceptionThe driver lacks the capability (refunds, tokenization, provider subscriptions, health), or the provider can’t do the operation (Stripe pause)
Illuminate\Http\Client\RequestExceptionA gateway HTTP error the driver didn’t translate

Both package exceptions extend RuntimeException.