Skip to content

feat: Configure Cashier#10

Open
kofimokome wants to merge 1 commit into
mainfrom
feat/cashier
Open

feat: Configure Cashier#10
kofimokome wants to merge 1 commit into
mainfrom
feat/cashier

Conversation

@kofimokome

@kofimokome kofimokome commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Fixes #7

@sourceant

sourceant Bot commented Jun 26, 2026

Copy link
Copy Markdown

Code Review Summary

This PR configures Laravel Cashier (Stripe) for the Cloud plugin. It introduces billing migrations, a BillingCustomer model, and a checkout endpoint to handle subscriptions.

🚀 Key Improvements

  • Implemented BillingCustomer model utilizing the Billable trait.
  • Added Stripe Webhook endpoint in routes/api.php.
  • Created a checkout method in CloudController with full OpenAPI/Swagger documentation.

💡 Minor Suggestions

  • Consistent naming for price ID keys in config/cloudplans.php.
  • Add null checks for config lookups in the controller.

@sourceant sourceant Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review complete. See the overview comment for a summary.

Comment thread config/cloudplans.php
'us' => [
'name' => 'United States',
'currency' => 'USD',
'monthly_price_id'=>'plan_id', // from stripe

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistency: In other regions you used 'price_id'. It is better to stick to one naming convention for Stripe Price IDs to prevent lookup errors.

Suggested change
'monthly_price_id'=>'plan_id', // from stripe
'monthly_price_id' => 'price_id', // from stripe

'user_id' => $user->id,
]);

$priceIdKey = "{$plan}_price_id";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dynamic Key Lookup: The current code looks for keys like 'monthly_price_id'. However, the configuration keys in config/cloudplans.php are explicitly nested under regions. Ensure you are accessing $regionData correctly.

Suggested change
$priceIdKey = "{$plan}_price_id";
$priceIdKey = "{$plan}_price_id";
$priceId = $regionData[$priceIdKey] ?? null;
if (! $priceId) {
return $this->failure('Price ID not configured for this region', 400);
}

@kofimokome kofimokome requested a review from nfebe June 26, 2026 23:01

@nfebe nfebe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nitpick on the naming of the model

*/
public function up(): void
{
Schema::create('billing_customers', function (Blueprint $table) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is BillingCustomer that name sounds weird. Is it a cashier thingy?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a cloud-owned BillingCustomer model (Cashier Billable, one-to-one with user_id); point cashier.model at it so the core User model stays free of any billing trait or columns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(cloud): Add Stripe subscriptions via Cashier mirror

2 participants