Skip to content

Handle CHARGE_REFUNDED and REFUND_CREATED events for Non-SaaS Stripe Integration on Refunds 🤖 #1156

Open
mrjbj wants to merge 2 commits intoHiEventsDev:developfrom
mrjbj:fix/stripe-charge-refunded
Open

Handle CHARGE_REFUNDED and REFUND_CREATED events for Non-SaaS Stripe Integration on Refunds 🤖 #1156
mrjbj wants to merge 2 commits intoHiEventsDev:developfrom
mrjbj:fix/stripe-charge-refunded

Conversation

@mrjbj
Copy link
Copy Markdown

@mrjbj mrjbj commented Apr 10, 2026

What changes I've made

  • Added Event::CHARGE_REFUNDED and Event::REFUND_CREATED to the $validEvents list in IncomingWebhookHandler
  • Added handleChargeRefunded() method that extracts refund objects from the charge and passes each to the existing ChargeRefundUpdatedHandler
  • Routed refund.created events to ChargeRefundUpdatedHandler (same as refund.updated)
  • Added Stripe webhook events reference doc (backend/docs/stripe-webhook-events.md)

Why I've made these changes

When refunds are initiated from the Stripe dashboard (rather than from within Hi.Events) or when stripe integration is based upon non SaaS rather than SaaS mode, Stripe sends charge.refunded and refund.created events. The existing code receives these events but has no handlers for them, so they are silently dropped. This causes orders to remain stuck in REFUND_PENDING status with total_refunded = 0.00, even though Stripe has completed the refund.

Additionally, for fast-processing refunds, refund.created may arrive with status: succeeded and be the only timely signal before refund.updated.

How I've tested these changes

  • Created paid orders using Stripe test mode (card 4242 4242 4242 4242)
  • Verified payment_intent.succeeded webhook completes the order
  • Cancelled and refunded orders from Hi.Events admin — confirmed refund.updated updates status to REFUNDED
  • Refunded from Stripe dashboard directly — confirmed charge.refunded event is now handled and order status updates correctly
  • Used stripe events resend to replay previously missed refund events — confirmed stuck REFUND_PENDING orders recovered to REFUNDED with correct total_refunded amounts
  • Verified duplicate refund processing is prevented by existing refund_id check in ChargeRefundUpdatedHandler

Checklist

  • I have read the contributing guidelines.
  • My code follows the coding standards of the project.
  • I have tested my changes, and they work as expected.
  • I understand that this PR will be closed if I do not follow the [contributor guidelines (https://github.com/HiEventsDev/hi.events/blob/develop/CONTRIBUTING.md) and if this PR template is left unedited.

mrjbj added 2 commits April 9, 2026 14:03
Add handling for charge.refunded events to detect refunds
initiated outside Hi.Events and pass them to the existing
refundEventHandlerService.
@mrjbj mrjbj changed the title Handle CHARGE_REFUNDED and REFUND_CREATED events for Non-SaaS Stripe Integration on Refunds Handle CHARGE_REFUNDED and REFUND_CREATED events for Non-SaaS Stripe Integration on Refunds 🤖 Apr 13, 2026
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.

1 participant