Skip to content

[FEAT]: Coupon lifecycle (create/update/destroy) never fires webhooks #6307

Description

@avanish-garg

Problem:
Coupon lifecycle (create/update/destroy) never fires webhooks, unlike sibling catalog
resources Plan, BillableMetric, and Feature, which all fire .created/.updated/.deleted
webhooks. External integrations have no way to be notified when a coupon is created,
updated, or deleted.
The coupon.created/coupon.updated/coupon.deleted event names already exist in the
codebase -- they were added for activity logs (app/services/coupons/{create,update,destroy}_service.rb's
activity_loggable calls) -- but the webhook half of that parity was never done. There are
zero coupon.
entries in SendWebhookJob::WEBHOOK_SERVICES.

Solution:
Add Webhooks::Coupons::{Created,Updated,Deleted}Service, mirroring the existing
Webhooks::BillableMetrics::*Service classes, register them in
SendWebhookJob::WEBHOOK_SERVICES, and fire them from Coupons::{Create,Update,Destroy}Service
the same way Plans/BillableMetrics services already do.

Alternatives:
N/A -- this mirrors an existing, already-proven pattern used by three other catalog
resources; no new architecture needed.

Additional context:
Opened a PR with the implementation, verified against a real Postgres+Redis test
environment (101 RSpec examples passing, rubocop clean): #6306

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions