Skip to main content

Laravel Cashier Billing Implementation

Implement subscription billing with Laravel Cashier including plans, trials, metered billing, invoices, payment methods, and webhook handling.

Füllen Sie die Platzhalter aus

Edit the values, then copy your finished prompt.

Ihr Prompt
prompt.txt

                                

What this prompt does

This prompt makes the AI implement a complete subscription-billing system with Laravel Cashier on [payment_provider], for a [app_description] with [plan_count] plans serving [customer_count] customers on Laravel [laravel_version]. It adds the Billable trait to [billable_model], configures credentials, sets up the webhook at [webhook_route], and builds the subscription flow with [checkout_method] and a [trial_duration]-day trial. Billing is unforgiving, so the prompt front-loads the pieces that quietly lose revenue.

The structure works because it covers the full billing surface. Plan management uses swap() with [proration_behavior], grace periods, and add-ons for [addon_features]; metered billing reports [metered_features] at [usage_reporting_frequency] with caps; webhook handling for [webhook_events] is idempotent and signature-validated, including the [dunning_sequence] on failed payments; a customer billing dashboard manages payment methods and invoices; and admin tooling surfaces MRR, churn, and the failed-payment queue. The [trial_without_payment] setting decides whether you collect a card up front or at trial end, and the [cap_behavior] controls what happens when metered usage exceeds the plan allowance. Because billing is unforgiving, the prompt insists on reconciling local subscription state against [payment_provider] rather than trusting the database alone, and styles the customer-facing pages with [ui_framework] so the billing dashboard matches the rest of your product.

When to use it

  • You are building SaaS subscription billing and cannot afford to get it wrong
  • You need trials, upgrades, downgrades with proration, and add-on subscriptions
  • You have usage-based metered billing on top of a flat plan fee
  • You need idempotent, signature-validated webhook handling
  • You want a dunning sequence that retries and escalates failed payments
  • You need admin billing views for MRR, churn, and failed payments

Example output

The AI returns Cashier setup on [billable_model], products and prices matching [plan_details], a SubscriptionController driving [checkout_method] and a [trial_duration]-day trial, upgrade/downgrade logic with [proration_behavior], metered billing reporting [metered_features] at [usage_reporting_frequency], a WebhookController handling [webhook_events] with idempotency and signature validation plus the [dunning_sequence], a customer billing dashboard styled with [ui_framework], and admin tooling for MRR, churn analytics, and the failed-payment queue.

Pro tips

  • Make webhook handling idempotent — skip already-processed events so a duplicate delivery never double-charges or double-cancels
  • Always validate the webhook signature before trusting the payload; unsigned events are an attack surface
  • Implement the full [dunning_sequence] (retry, warn, final notice, cancel); silent payment failures are pure lost revenue
  • Reconcile local subscription state against [payment_provider] rather than trusting your database alone
  • Set [proration_behavior] intentionally per direction — always_invoice on upgrades, prorations on downgrades, behave differently
  • Use the real [billable_model] (often Team, not User) so billing maps to the organization that actually pays
  • Decide [trial_without_payment] deliberately; collecting a card at trial end lifts signups but raises involuntary churn at conversion
  • Build the admin failed-payment queue early so you can intervene on recoverable accounts before the [dunning_sequence] cancels them

Frequently Asked Questions

Should billing be attached to the User or the Team model?
It depends on `[billable_model]`; the default uses Team because billing is usually per organization, not per individual user. Putting the Billable trait on the wrong model means subscriptions do not map to whoever actually pays the invoice.
How does the prompt prevent duplicate webhook processing?
The WebhookController implements idempotency by skipping events it has already processed, and validates the signature before acting. This matters because providers can deliver the same webhook more than once, and double-processing could double-charge or wrongly cancel a subscription.
What happens when a payment fails?
The prompt handles `invoice.payment_failed` with a `[dunning_sequence]` that retries, sends escalating warnings, and finally cancels the subscription after the configured window. A proper dunning flow is where many setups quietly lose recoverable revenue.
Does it support usage-based metered billing?
Yes. It reports `[metered_features]` usage with reportUsage() at `[usage_reporting_frequency]`, shows current usage and projected cost, and applies caps via `[cap_behavior]` when limits are exceeded. Usage data is aggregated from `[usage_source]`.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

Mehr in Laravel & PHP Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support