Skip to content

feat(coupons): add lifecycle webhooks - #6306

Open
avanish-garg wants to merge 1 commit into
getlago:mainfrom
avanish-garg:feature/coupon-lifecycle-webhooks
Open

feat(coupons): add lifecycle webhooks#6306
avanish-garg wants to merge 1 commit into
getlago:mainfrom
avanish-garg:feature/coupon-lifecycle-webhooks

Conversation

@avanish-garg

@avanish-garg avanish-garg commented Sep 4, 2026

Copy link
Copy Markdown

Fixes #6307

Problem

Coupon lifecycle (create/update/destroy) never fires webhooks, unlike sibling catalog
resources Plan, BillableMetric, and Feature, which all fire *.created/*.updated/*.deleted
webhooks. The coupon.created/coupon.updated/coupon.deleted event names already existed --
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.

Change

  • Added Webhooks::Coupons::{Created,Updated,Deleted}Service, mirroring the existing
    Webhooks::BillableMetrics::*Service classes exactly.
  • Registered the three new events in SendWebhookJob::WEBHOOK_SERVICES.
  • Wired SendWebhookJob.perform_after_commit calls into Coupons::CreateService,
    Coupons::UpdateService, and Coupons::DestroyService, the same way
    BillableMetrics::CreateService/UpdateService/DestroyService already do (no
    send_webhook: suppression flag needed -- BillableMetric, the closer sibling in
    complexity, doesn't have one either; only Plan does, for its more complex async-destroy
    flow).
  • Added specs for the three new webhook services, webhook-enqueue assertions to the
    existing Coupons::{Create,Update,Destroy}Service specs, and a new context in the
    dispatcher-level send_webhook_job_spec.rb.

Purely additive wiring -- no billing/pricing math touched.

Verified

  • 101 RSpec examples passing (spec/services/coupons/*_service_spec.rb,
    spec/services/webhooks/coupons/*_spec.rb, spec/jobs/send_webhook_job_spec.rb) against
    a real Postgres (getlago/postgres-partman:15.0-alpine, matching CI) + Redis environment.
  • Rubocop clean across all 17 touched/new files.

coupon.created/updated/deleted webhook event names already existed
(added for activity logs), but nothing ever fired them -- sibling
catalog resources Plan/BillableMetric/Feature all fire webhooks on
create/update/destroy, Coupon didn't.

Adds Webhooks::Coupons::{Created,Updated,Deleted}Service mirroring
the existing BillableMetrics webhook services, registers them in
SendWebhookJob::WEBHOOK_SERVICES, and wires the SendWebhookJob calls
into Coupons::{Create,Update,Destroy}Service.
@cla-check-bot

cla-check-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

Welcome, @avanish-garg!

Thanks for your first contribution!

Before we proceed with the review, please sign the Fiduciary License Agreement:

Sign the FLA

Once signed, this PR will be automatically updated.

@cla-check-bot

cla-check-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

Thanks, @avanish-garg! 🎉

Your CLA has been signed and is now on file. We'll proceed with the review shortly.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant