Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Billing/License/Plan/Plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ public function __construct(
* Usually, if one plan has a group, all plans should have a group
*/
public ?string $group = null,

// plan will only be available as an annual subscription
public bool $annualOnly = false,
) {
$this->nameReadable = $nameReadable ?? ucfirst($this->name);
}

}
3 changes: 2 additions & 1 deletion src/Billing/License/Plan/PlanAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ protected function plan(
License $license,
?string $nameReadable = null,
?string $group = null,
bool $annualOnly = false,
): void {
assert($this->currentVersionForConfig !== null);
$plan = new Plan(
Expand All @@ -57,6 +58,7 @@ protected function plan(
$license,
$nameReadable,
$group,
$annualOnly,
);

$currentVersionPlans = $this->versions[$this->currentVersionForConfig];
Expand Down Expand Up @@ -106,5 +108,4 @@ public function tryGetPlan(string $name, ?int $version = null): ?Plan
$version ??= $this->getCurrentVersion();
return $this->versions[$version][$name] ?? null;
}

}
25 changes: 24 additions & 1 deletion src/Billing/License/Plan/TalkPlan.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ protected function config(): void
});

$this->version(2, function () {
$this->plan(
'personal',
5,
new TalkLicense(
credits: 2500,
comments: -1,
storage: 5 * 10 ** 9,
sso: false,
noBranding: false,
webhooks: false,
websites: 1,
moderators: 1,
rules: false,
),
nameReadable: "Personal",
annualOnly: true,
);

$this->premiumPlan(100_000, 12);
$this->premiumPlan(500_000, 35);
$this->premiumPlan(1_000_000, 65);
Expand All @@ -59,6 +77,9 @@ private function premiumPlan(int $credits, float $monthlyPrice): void
sso: false,
noBranding: false,
webhooks: false,
websites: 0,
moderators: 0,
rules: true,
);

$nameSuffix = $credits / 1_000_000;
Expand All @@ -84,6 +105,9 @@ private function businessPlan(int $credits, float $monthlyPrice): void
sso: true,
noBranding: true,
webhooks: true,
websites: 0,
moderators: 0,
rules: true,
);

$nameSuffix = $credits / 1_000_000;
Expand All @@ -109,5 +133,4 @@ private function getStorageBytesFromCredits(int $credits): int
$gbBytes = 10 ** 9;
return $creditsMil * 100 * $gbBytes;
}

}
26 changes: 22 additions & 4 deletions src/Billing/License/TalkLicense.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ public function __construct(
public bool $sso,
public bool $noBranding,
public bool $webhooks,
) {
}
public int $websites, // 0 for unlimited
public int $moderators, // 0 for unlimited
public bool $rules,
) {}

public static function properties(): array
{
Expand Down Expand Up @@ -46,6 +48,20 @@ public static function properties(): array
LicenseProperty::bool('webhooks')
->name('Webhooks')
->description('Enable Webhooks to integrate with other services'),

LicenseProperty::int('websites')
->name('Websites')
->description('Number of websites allowed under this license.')
->note('Set to 0 for unlimited'),

LicenseProperty::int('moderators')
->name('Moderators')
->description('Number of moderators allowed under this license.')
->note('Set to 0 for unlimited'),

LicenseProperty::bool('rules')
->name('Rules')
->description('Enable advanced moderation rules to automate your moderation process'),
];
}

Expand All @@ -57,8 +73,10 @@ public static function trial(): static
storage: 100_000_000,
sso: true,
noBranding: false,
webhooks: true
webhooks: true,
websites: 0,
moderators: 0,
rules: true,
);
}

}
Loading