feat: Configure AI usage counter#11
Conversation
# Conflicts: # src/CloudServiceProvider.php
Code Review SummaryThis PR introduces AI usage tracking and Stripe-based billing using Laravel Cashier. It includes migrations for usage counters and billing entities, a service for entitlement management, and a checkout controller. 🚀 Key Improvements
💡 Minor Suggestions
🚨 Critical Issues
|
| 'us' => [ | ||
| 'name' => 'United States', | ||
| 'currency' => 'USD', | ||
| 'monthly_price_id'=>'plan_id', // from stripe |
There was a problem hiding this comment.
The keys 'monthly_price_id' and 'yearly_price_id' should be consistent across all regions and should preferably use ENV variables instead of hardcoded 'plan_id' or 'price_id' placeholders to ensure security and flexibility across environments.
| 'monthly_price_id'=>'plan_id', // from stripe | |
| 'monthly_price_id' => env('STRIPE_MONTHLY_PRICE_ID_US'), | |
| 'monthly_price' => (float) env('CLOUD_PLAN_MONTHLY_PRICE_US', 5.00), | |
| 'yearly_price' => (float) env('CLOUD_PLAN_YEARLY_PRICE_US', 50.00), | |
| 'yearly_price_id' => env('STRIPE_YEARLY_PRICE_ID_US'), |
| /** | ||
| * Find the chat message ID from the backtrace to key the idempotent increment. | ||
| */ | ||
| private function getCurrentChatMessageId(): ?int |
There was a problem hiding this comment.
Using debug_backtrace to implement idempotency is highly discouraged. It is slow and relies on internal call structures that may change. Pass the message ID or an idempotency token explicitly to the consume method instead.
| private function getCurrentChatMessageId(): ?int | |
| // Recommended: Pass the unique identifier directly to the consume method. | |
| // If that is not possible, ensure ProcessChatMessageJob is always present in the stack. |
Fixes #7