Handle CHARGE_REFUNDED and REFUND_CREATED events for Non-SaaS Stripe Integration on Refunds 🤖 #1156
Open
mrjbj wants to merge 2 commits intoHiEventsDev:developfrom
Open
Handle CHARGE_REFUNDED and REFUND_CREATED events for Non-SaaS Stripe Integration on Refunds 🤖 #1156mrjbj wants to merge 2 commits intoHiEventsDev:developfrom
mrjbj wants to merge 2 commits intoHiEventsDev:developfrom
Conversation
Add handling for charge.refunded events to detect refunds initiated outside Hi.Events and pass them to the existing refundEventHandlerService.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes I've made
Event::CHARGE_REFUNDEDandEvent::REFUND_CREATEDto the$validEventslist inIncomingWebhookHandlerhandleChargeRefunded()method that extracts refund objects from the charge and passes each to the existingChargeRefundUpdatedHandlerrefund.createdevents toChargeRefundUpdatedHandler(same asrefund.updated)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.refundedandrefund.createdevents. The existing code receives these events but has no handlers for them, so they are silently dropped. This causes orders to remain stuck inREFUND_PENDINGstatus withtotal_refunded = 0.00, even though Stripe has completed the refund.Additionally, for fast-processing refunds,
refund.createdmay arrive withstatus: succeededand be the only timely signal beforerefund.updated.How I've tested these changes
4242 4242 4242 4242)payment_intent.succeededwebhook completes the orderrefund.updatedupdates status toREFUNDEDcharge.refundedevent is now handled and order status updates correctlystripe events resendto replay previously missed refund events — confirmed stuckREFUND_PENDINGorders recovered toREFUNDEDwith correcttotal_refundedamountsrefund_idcheck inChargeRefundUpdatedHandlerChecklist