Skip to content

Commit 3e6b059

Browse files
simonhampclaude
andcommitted
Replace hasMaxTierAccess() with hasActiveUltraSubscription() for Ultra-aware platform fee logic
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c3eedba commit 3e6b059

File tree

5 files changed

+25
-48
lines changed

5 files changed

+25
-48
lines changed

app/Jobs/HandleInvoicePaidJob.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ private function createPluginLicense(User $user, Plugin $plugin, int $amount): P
562562

563563
// Create payout record for developer if applicable
564564
if ($plugin->developerAccount && $plugin->developerAccount->canReceivePayouts() && $amount > 0) {
565-
$platformFeePercent = ($user->hasMaxTierAccess() && ! $plugin->isOfficial())
565+
$platformFeePercent = ($user->hasActiveUltraSubscription() && ! $plugin->isOfficial())
566566
? 0
567567
: PluginPayout::PLATFORM_FEE_PERCENT;
568568

@@ -604,7 +604,7 @@ private function createBundlePluginLicense(User $user, Plugin $plugin, PluginBun
604604

605605
// Create proportional payout for developer
606606
if ($plugin->developerAccount && $plugin->developerAccount->canReceivePayouts() && $allocatedAmount > 0) {
607-
$platformFeePercent = ($user->hasMaxTierAccess() && ! $plugin->isOfficial())
607+
$platformFeePercent = ($user->hasActiveUltraSubscription() && ! $plugin->isOfficial())
608608
? 0
609609
: PluginPayout::PLATFORM_FEE_PERCENT;
610610

app/Models/User.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -283,25 +283,6 @@ public function hasUltraAccess(): bool
283283
return ! $subscription->is_comped;
284284
}
285285

286-
public function hasMaxTierAccess(): bool
287-
{
288-
if ($this->hasMaxAccess()) {
289-
return true;
290-
}
291-
292-
$subscription = $this->subscription();
293-
294-
if ($subscription?->active()) {
295-
try {
296-
return Subscription::fromStripePriceId($subscription->stripe_price) === Subscription::Max;
297-
} catch (\RuntimeException) {
298-
return false;
299-
}
300-
}
301-
302-
return false;
303-
}
304-
305286
/**
306287
* Check if user was an Early Access Program customer.
307288
* EAP customers purchased before June 1, 2025.

tests/Feature/MaxSubscriberPayoutTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ class MaxSubscriberPayoutTest extends TestCase
2525

2626
private const PRO_PRICE_ID = 'price_1RoZeVAyFo6rlwXqtnOViUCf';
2727

28+
protected function setUp(): void
29+
{
30+
parent::setUp();
31+
32+
config(['subscriptions.plans.max.stripe_price_id' => self::MAX_PRICE_ID]);
33+
}
34+
2835
private function createStripeInvoice(string $cartId, string $customerId): Invoice
2936
{
3037
$invoice = Invoice::constructFrom([

tests/Feature/PluginSubmissionNotesTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,19 @@ private function fakeGitHubForPlugin(string $repoSlug, array $extraComposerData
3232
], $extraComposerData));
3333

3434
Http::fake([
35-
"{$base}/contents/README.md" => Http::response([
35+
"{$base}/contents/README.md*" => Http::response([
3636
'content' => base64_encode("# {$repoSlug}"),
3737
'encoding' => 'base64',
3838
]),
39-
"{$base}/contents/composer.json" => Http::response([
39+
"{$base}/contents/composer.json*" => Http::response([
4040
'content' => base64_encode($composerJson),
4141
'encoding' => 'base64',
4242
]),
43-
"{$base}/contents/nativephp.json" => Http::response([], 404),
43+
"{$base}/contents/nativephp.json*" => Http::response([], 404),
4444
"{$base}/contents/LICENSE*" => Http::response([], 404),
4545
"{$base}/releases/latest" => Http::response([], 404),
4646
"{$base}/tags*" => Http::response([]),
47+
"{$base}/hooks" => Http::response(['id' => 1]),
4748
"https://raw.githubusercontent.com/{$repoSlug}/*" => Http::response('', 404),
4849
$base => Http::response(['default_branch' => 'main']),
4950
"{$base}/git/trees/main*" => Http::response([
@@ -62,6 +63,7 @@ private function createUserWithGitHub(): User
6263
{
6364
$user = User::factory()->create([
6465
'github_id' => '12345',
66+
'github_token' => encrypt('fake-token'),
6567
]);
6668
DeveloperAccount::factory()->withAcceptedTerms()->create([
6769
'user_id' => $user->id,

tests/Feature/TierBasedPricingTest.php

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ protected function setUp(): void
3535

3636
Feature::define(ShowPlugins::class, true);
3737

38-
// Set config for mini price ID used in tests
38+
// Set config for price IDs used in tests
3939
config(['subscriptions.plans.mini.stripe_price_id' => self::MINI_PRICE_ID]);
40+
config(['subscriptions.plans.max.stripe_price_id' => self::MAX_PRICE_ID]);
4041
}
4142

4243
/**
@@ -184,56 +185,42 @@ public function user_with_subscription_and_eap_license_qualifies_for_both_tiers(
184185
}
185186

186187
// ========================================
187-
// Max Tier Access Tests
188+
// Ultra Subscription Access Tests
188189
// ========================================
189190

190191
#[Test]
191-
public function user_with_max_subscription_has_max_tier_access(): void
192+
public function user_with_max_subscription_has_active_ultra_subscription(): void
192193
{
193194
$user = User::factory()->create();
194195
$this->createSubscription($user, self::MAX_PRICE_ID);
195196

196-
$this->assertTrue($user->hasMaxTierAccess());
197+
$this->assertTrue($user->hasActiveUltraSubscription());
197198
}
198199

199200
#[Test]
200-
public function user_with_pro_subscription_does_not_have_max_tier_access(): void
201+
public function user_with_pro_subscription_does_not_have_active_ultra_subscription(): void
201202
{
202203
$user = User::factory()->create();
203204
$this->createSubscription($user, self::PRO_PRICE_ID);
204205

205-
$this->assertFalse($user->hasMaxTierAccess());
206+
$this->assertFalse($user->hasActiveUltraSubscription());
206207
}
207208

208209
#[Test]
209-
public function user_with_mini_subscription_does_not_have_max_tier_access(): void
210+
public function user_with_mini_subscription_does_not_have_active_ultra_subscription(): void
210211
{
211212
$user = User::factory()->create();
212213
$this->createSubscription($user, self::MINI_PRICE_ID);
213214

214-
$this->assertFalse($user->hasMaxTierAccess());
215+
$this->assertFalse($user->hasActiveUltraSubscription());
215216
}
216217

217218
#[Test]
218-
public function user_without_subscription_does_not_have_max_tier_access(): void
219+
public function user_without_subscription_does_not_have_active_ultra_subscription(): void
219220
{
220221
$user = User::factory()->create();
221222

222-
$this->assertFalse($user->hasMaxTierAccess());
223-
}
224-
225-
#[Test]
226-
public function user_with_max_anystack_license_has_max_tier_access(): void
227-
{
228-
$user = User::factory()->create();
229-
License::factory()
230-
->for($user)
231-
->max()
232-
->active()
233-
->withoutSubscriptionItem()
234-
->create();
235-
236-
$this->assertTrue($user->hasMaxTierAccess());
223+
$this->assertFalse($user->hasActiveUltraSubscription());
237224
}
238225

239226
// ========================================

0 commit comments

Comments
 (0)