Repository navigation
Carry orderId (credit order) on the refund webhook events - #69
Merged
Merged
Conversation
RefundCompleted/RefundFailed/RefundCanceled dropped the refund's orderId - the credit order Vatly creates from a refund, whose customerInvoice is the credit note - even though it is already present in the signed refund payload the factory hydrates from. A consumer stamping the credit note therefore had to re-fetch the refund with GetRefund just to recover that id, a redundant round-trip. Expose orderId (?string, null until a credit order materializes) so the credit note is one GetOrder away. Also corrects the stale 'enriches via GetRefund before dispatching' docblock: the factory hydrates these events from the fat, signed webhook payload with no network round-trip.
The list samples for checkouts, customers, subscriptions, refunds and chargebacks called a list() method that does not exist. The refund samples called refunds->create(), and the checkout samples called getCheckoutUrl(). Replace them with working calls, and align the affected reference tables with the resources and the published API spec.
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.
Summary
Carries
orderId, the credit order Vatly creates from a refund (whosecustomerInvoiceis the credit note), on the three refund webhook DTOs:RefundCompleted,RefundFailed, andRefundCanceled.Why
The refund webhook payload is fat and signed (byte-identical to
GET /v1/refunds/{id}), andWebhookEventFactoryalready hydrates the fullRefundresource from it with zero network round-trip. ButfromApiRefund()copied only a subset and droppedorderId. A consumer that needs the credit note (thecustomerInvoiceof the credit order) therefore had to callGetRefund($refundId)again purely to recover the credit-order id, re-fetching data that was in hand a moment earlier, before the single legitimateGetOrder.This surfaced in the FluentCart Merchant-of-Record gateway's credit-note reaction, which does
GetRefundthenGetOrderon everyrefund.completed. ExposingorderIdlets that collapse to a singleGetOrder.Changes
RefundCompleted,RefundFailed,RefundCanceled: newpublic ?string $orderId = nullconstructor-promoted property, mapped from$refund->orderIdinfromApiRefund(). Added last with anulldefault, so the change is backward-compatible for both positional and named construction.GetRefundbefore dispatching") to describe what the factory actually does: hydrate from the fat, signed payload with no round-trip.CHANGELOG.md: entry under Unreleased.tests/Webhooks/Events/RefundEventsTest.php: assertorderIdmaps through, and defaults tonullwhen the refund has no credit order yet.Testing
composer test: 284 tests green.composer phpstan(with--memory-limit=1G): no errors.Notes
orderIdis typically populated forrefund.completed(a credit order exists) andnullforrefund.failedandrefund.canceled. It is carried on all three for a uniform DTO shape.