From 57cf7cdbcf6a5c09be042127c3b4f47930dbb47c Mon Sep 17 00:00:00 2001 From: Nadil Karunarathna Date: Thu, 10 Sep 2026 23:29:54 +0530 Subject: [PATCH 1/6] license --- src/Billing/License/RelayLicense.php | 37 ++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/Billing/License/RelayLicense.php b/src/Billing/License/RelayLicense.php index 944fe1e..67dda31 100644 --- a/src/Billing/License/RelayLicense.php +++ b/src/Billing/License/RelayLicense.php @@ -2,12 +2,45 @@ namespace Hyvor\Internal\Billing\License; +use Hyvor\Internal\Billing\License\Property\LicenseProperty; + final class RelayLicense extends License { + public function __construct( + public int $emails, + public int $projects, + public int $domains, + public bool $dedicatedIps, + ) {} - public static function trial(): static + public static function properties(): array { - return new self(); + return [ + LicenseProperty::int('emails') + ->name('Emails') + ->description('The number of emails allowed to be sent per month'), + + LicenseProperty::int('projects') + ->name('Projects') + ->description('The number of projects allowed to create'), + + LicenseProperty::int('domains') + ->name('Domains') + ->description('The number of domains allowed to send emails from'), + + LicenseProperty::bool('dedicatedIps') + ->name('Dedicated IPs') + ->description('Whether user is allowed to purchase dedicated IPs'), + ]; } + public static function trial(): static + { + return new self( + emails: 50, + projects: 1, + domains: 1, + dedicatedIps: false, + ); + } } From a4f8090f15550041d48d50b4de2a798abf5fca97 Mon Sep 17 00:00:00 2001 From: Nadil Karunarathna Date: Thu, 10 Sep 2026 23:30:02 +0530 Subject: [PATCH 2/6] plan --- src/Billing/License/Plan/RelayPlan.php | 33 +++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/Billing/License/Plan/RelayPlan.php b/src/Billing/License/Plan/RelayPlan.php index f274086..829f8f4 100644 --- a/src/Billing/License/Plan/RelayPlan.php +++ b/src/Billing/License/Plan/RelayPlan.php @@ -2,14 +2,41 @@ namespace Hyvor\Internal\Billing\License\Plan; +use Hyvor\Internal\Billing\License\RelayLicense; + +/** + * @extends PlanAbstract + */ class RelayPlan extends PlanAbstract { - /** - * @codeCoverageIgnore - */ protected function config(): void { $this->version(1, function () { + $this->plan( + 'starter', + 30, + new RelayLicense( + emails:200_000, + projects: 3, + domains: 10, + dedicatedIps: false + ), + nameReadable: 'Starter', + monthlyOnly: true + ); + + $this->plan( + 'pro', + 80, + new RelayLicense( + emails: 800_000, + projects: 20, + domains: 1_000, + dedicatedIps: true + ), + nameReadable: 'Pro', + monthlyOnly: true + ); }); } } \ No newline at end of file From 137ec1a8a21794787bdc63149817e939d87575c2 Mon Sep 17 00:00:00 2001 From: Nadil Karunarathna Date: Mon, 14 Sep 2026 14:00:35 +0530 Subject: [PATCH 3/6] org - has_payment_method --- src/Auth/Dto/Organization.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Auth/Dto/Organization.php b/src/Auth/Dto/Organization.php index e22e450..d71dc9c 100644 --- a/src/Auth/Dto/Organization.php +++ b/src/Auth/Dto/Organization.php @@ -15,6 +15,7 @@ * created_user?: AuthUserArray|AuthUser, * billing_email?: string, * billing_address?: BillingAddress|null, + * has_payment_method?: bool, * } * * @phpstan-type OrganizationArrayPartial array{ @@ -24,6 +25,7 @@ * created_user?: AuthUserArray, * billing_email?: string, * billing_address?: BillingAddress|null, + * has_payment_method?: bool, * } * * @phpstan-type BillingAddress array{ @@ -44,6 +46,8 @@ final class Organization { */ private ?array $billing_address = null; + private bool $has_payment_method = false; + public function __construct( private int $id, private string $name, @@ -102,6 +106,16 @@ public function setBillingAddress(?array $billing_address): void $this->billing_address = $billing_address; } + public function hasPaymentMethod(): bool + { + return $this->has_payment_method; + } + + public function setHasPaymentMethod(bool $has_payment_method): void + { + $this->has_payment_method = $has_payment_method; + } + /** * @param OrganizationArray $data */ @@ -129,6 +143,10 @@ public static function fromArray(array $data): self $org->setBillingAddress($data['billing_address']); } + if (isset($data['has_payment_method'])) { + $org->setHasPaymentMethod($data['has_payment_method']); + } + return $org; } } From 51909eb05d0ecb77a0f076ba5dd6c55563d29f34 Mon Sep 17 00:00:00 2001 From: Nadil Karunarathna Date: Mon, 14 Sep 2026 14:00:52 +0530 Subject: [PATCH 4/6] create-subscription-event --- .../ToCore/Billing/CreateSubscription.php | 46 +++++++++++++++++++ .../Billing/CreateSubscriptionResponse.php | 30 ++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 bundle/src/Comms/Event/ToCore/Billing/CreateSubscription.php create mode 100644 bundle/src/Comms/Event/ToCore/Billing/CreateSubscriptionResponse.php diff --git a/bundle/src/Comms/Event/ToCore/Billing/CreateSubscription.php b/bundle/src/Comms/Event/ToCore/Billing/CreateSubscription.php new file mode 100644 index 0000000..3e182a1 --- /dev/null +++ b/bundle/src/Comms/Event/ToCore/Billing/CreateSubscription.php @@ -0,0 +1,46 @@ + + */ +class CreateSubscription extends AbstractEvent +{ + + public function __construct( + private int $organizationId, + private Component $component, + private string $plan, + ) { + } + + public function getOrganizationId(): int + { + return $this->organizationId; + } + + public function getComponent(): Component + { + return $this->component; + } + + public function getPlan(): string + { + return $this->plan; + } + + public function from(): array + { + return []; + } + + public function to(): array + { + return [Component::CORE]; + } + +} diff --git a/bundle/src/Comms/Event/ToCore/Billing/CreateSubscriptionResponse.php b/bundle/src/Comms/Event/ToCore/Billing/CreateSubscriptionResponse.php new file mode 100644 index 0000000..268a161 --- /dev/null +++ b/bundle/src/Comms/Event/ToCore/Billing/CreateSubscriptionResponse.php @@ -0,0 +1,30 @@ +success; + } + + public function getSubscriptionId(): ?int + { + return $this->subscriptionId; + } + + public function getErrorMessage(): ?string + { + return $this->errorMessage; + } + +} From 3098447c6dc0b1ae058d77d2f5f6e6dd324ae132 Mon Sep 17 00:00:00 2001 From: Nadil Karunarathna Date: Mon, 14 Sep 2026 14:01:00 +0530 Subject: [PATCH 5/6] changelog update --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d72101..1c78f29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## Unreleased + +- `Hyvor\Internal\Auth\Dto\Organization` gained `has_payment_method` (bool), populated by + `ToCore\Organization\GetOrganizations` when `includeBillingInfo` is true +- New Comms event: ToCore\Billing\CreateSubscription + ## 4.0.0 - 2026-02-01 - Organization support From 63a05f925d6411feac2d44e52b33e0d03d9d65ae Mon Sep 17 00:00:00 2001 From: Nadil Karunarathna Date: Thu, 17 Sep 2026 23:36:28 +0530 Subject: [PATCH 6/6] use setError of AbstractEvent --- .../Billing/CreateSubscriptionResponse.php | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/bundle/src/Comms/Event/ToCore/Billing/CreateSubscriptionResponse.php b/bundle/src/Comms/Event/ToCore/Billing/CreateSubscriptionResponse.php index 268a161..15c67c2 100644 --- a/bundle/src/Comms/Event/ToCore/Billing/CreateSubscriptionResponse.php +++ b/bundle/src/Comms/Event/ToCore/Billing/CreateSubscriptionResponse.php @@ -6,25 +6,12 @@ { public function __construct( - private bool $success, - private ?int $subscriptionId, - private ?string $errorMessage, + private int $subscriptionId, ) { } - public function isSuccess(): bool - { - return $this->success; - } - - public function getSubscriptionId(): ?int + public function getSubscriptionId(): int { return $this->subscriptionId; } - - public function getErrorMessage(): ?string - { - return $this->errorMessage; - } - }