Conversation
Emit a PaymentIncrementalAuthorization audit event from the incremental authorization update tracker, after the authorization record is created and authorization_count is updated. The event carries authorization_id, additional_amount, total_amount and reason, plus the payment intent and attempt, matching the existing capture and cancel audit events. Closes juspay#4676 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Changed Files
|
Add unit tests for the identifier and the serialized payload of AuditEventType::PaymentIncrementalAuthorization. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Type of Change
Description
Adds an audit event for the incremental authorization operation (
POST /payments/{payment_id}/incremental_authorization). Most other payment operations already emit one (create, confirm, update, capture, cancel, approve, reject, status, complete authorize, recurrence).crates/router/src/events/audit_events.rs: new variantwith identifier
payment_incremental_authorization.crates/router/src/core/payments/operations/payments_incremental_authorization.rs:update_trackersnow usesreq_stateand emits the event withpayment_data.to_event()(payment intent and attempt). It fires after theauthorizationrecord is inserted andauthorization_countis updated, soauthorization_idis always set. Capture (feat(events): Add payment cancel events #4166) and cancel emit at the same point.The existing
matchthat writesauthorization_idback intoincremental_authorization_detailsis now aletbinding, so the event andpayment_datause the same value. The error path for missing details is unchanged.Emitted payload (synthetic values):
{ "event_type": "PaymentIncrementalAuthorization", "authorization_id": "auth_XXXXXXXXXXXXXXXXXXXX_1", "additional_amount": 500, "total_amount": 1500, "reason": "customer added items", "created_at": "2026-09-17T12:00:00.000Z" }Not in this PR: the issue also mentions error codes and rejection metadata. Those only exist after the connector responds, in
PostUpdateTracker(payment_response.rs), and that has noReqStateor event context. The same is true of the capture and cancel audit events, which also record the request, not the connector outcome. Glad to follow up if you'd like the outcome recorded too.Additional Changes
Motivation and Context
Closes #4676. The issue was created from #4525 and asks for an audit event for this operation, similar to
PaymentCancel(#4166).How did you test it?
cargo clippy -p router --all-targets --features releasecompletes with no warnings. The only warnings arevergenbuild-script notices about git metadata in a worktree.rustfmt +nightly --checkpasses on both files.#[cfg(feature = "v1")]. The new variant only uses typesaudit_events.rsalready imports, so the v2 build is unaffected.audit_events.rs, covering the new event's identifier and its serialized payload:(
cargo test -p router --lib --features release audit_events)update_trackersneeds a fullSessionState, so it is covered by the type checker and review only.Checklist
cargo +nightly fmt --allcargo clippy🤖 Generated with Claude Code