diff --git a/src/Id/Webhooks/EventType.php b/src/Id/Webhooks/EventType.php index 06d5f21..70ee0cb 100644 --- a/src/Id/Webhooks/EventType.php +++ b/src/Id/Webhooks/EventType.php @@ -13,6 +13,12 @@ final class EventType public const ORDER_PAYMENT_FAILED = 'order.payment_failed'; public const ORDER_CANCELLED = 'order.cancelled'; public const ORDER_SHIPPED = 'order.shipped'; + /** + * Money was given back for an order (a refund or a partial cancellation, with a credit note); + * see the order's `refunds` and `refunded_total`. A full refund also cancels the order + * (order.cancelled follows). + */ + public const ORDER_REFUNDED = 'order.refunded'; public const SUBSCRIPTION_CREATED = 'subscription.created'; public const SUBSCRIPTION_ACTIVATED = 'subscription.activated'; diff --git a/tests/Id/WebhookTest.php b/tests/Id/WebhookTest.php index d9e75b0..5061bb3 100644 --- a/tests/Id/WebhookTest.php +++ b/tests/Id/WebhookTest.php @@ -70,6 +70,12 @@ class WebhookTest extends TestCase $this->assertContains(EventType::SUBSCRIPTION_RENEWED, EventType::all()); } + public function test_refunds_have_their_own_event_type(): void + { + $this->assertSame('order.refunded', EventType::ORDER_REFUNDED); + $this->assertContains(EventType::ORDER_REFUNDED, 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' => [