diff --git a/src/Id/Webhooks/EventType.php b/src/Id/Webhooks/EventType.php index 9a1de68..a1c31a8 100644 --- a/src/Id/Webhooks/EventType.php +++ b/src/Id/Webhooks/EventType.php @@ -61,6 +61,21 @@ final class EventType /** A checkout session was not confirmed within 24 hours; its drafts were cancelled. */ public const CHECKOUT_EXPIRED = 'checkout.expired'; + /** + * A user's open monthly bill reached their billing limit: start no new paid service for them. + * `data.object` is the billing limit as the app reads it (with `version`), `data.reason` + * `booking` or `limit_changed`. Opt-in: only endpoints that select this event get it (not + * through `*`), and only apps that may read the limit of a user connected to them. + */ + public const BILLING_LIMIT_REACHED = 'billing_limit.reached'; + + /** + * A user whose billing limit was reached has room again. `data.object` is the billing limit + * (with `version`), `data.reason` `limit_changed`, `limit_removed`, `voided`, `period_reset` + * or `order_changed`. Opt-in like BILLING_LIMIT_REACHED. + */ + public const BILLING_LIMIT_AVAILABLE = 'billing_limit.available'; + public const TEST = 'webhook.test'; /** diff --git a/tests/Id/WebhookTest.php b/tests/Id/WebhookTest.php index 5061bb3..2c8b984 100644 --- a/tests/Id/WebhookTest.php +++ b/tests/Id/WebhookTest.php @@ -76,6 +76,14 @@ class WebhookTest extends TestCase $this->assertContains(EventType::ORDER_REFUNDED, EventType::all()); } + public function test_billing_limit_events_have_their_own_types(): void + { + $this->assertSame('billing_limit.reached', EventType::BILLING_LIMIT_REACHED); + $this->assertSame('billing_limit.available', EventType::BILLING_LIMIT_AVAILABLE); + $this->assertContains(EventType::BILLING_LIMIT_REACHED, EventType::all()); + $this->assertContains(EventType::BILLING_LIMIT_AVAILABLE, EventType::all()); + } + public function test_a_change_carries_the_previous_attributes(): void { $this->payload = json_encode(['id' => '01JEVT', 'type' => EventType::SUBSCRIPTION_UPDATED, 'created' => time(), 'data' => [