fix(payments-syncs): Support payments sync on async resolution paths - #5982
Open
osmarluz wants to merge 2 commits into
Open
fix(payments-syncs): Support payments sync on async resolution paths#5982osmarluz wants to merge 2 commits into
osmarluz wants to merge 2 commits into
Conversation
osmarluz
commented
Jul 21, 2026
| return result if payload.integration_payment | ||
|
|
||
| throttle!(:netsuite, :xero) | ||
| LockService.call(payment:, timeout_seconds: 0, transaction: false) do |
Contributor
Author
There was a problem hiding this comment.
timeout_seconds is 0 here because we don't care about waiting and retrying (if the lock is taken, another process is already syncing this same payment, so this caller can safely bail and let the holder finish)
ancorcruz
approved these changes
Aug 13, 2026
| deliver_webhook if payable_payment_status.to_sym == :succeeded | ||
| if payable_payment_status.to_sym == :succeeded | ||
| deliver_webhook | ||
| Integrations::Aggregator::Payments::CreateJob.perform_later(payment:) if payment.should_sync_payment? |
Contributor
There was a problem hiding this comment.
have you consider if this work for payment gated subscriptions? should_sync_payment? checks if invoice is finalized, won't it be 'open' for payment gated subs?
| deliver_webhook if payable_payment_status.to_sym == :succeeded | ||
| if payable_payment_status.to_sym == :succeeded | ||
| deliver_webhook | ||
| Integrations::Aggregator::Payments::CreateJob.perform_later(payment:) if payment.should_sync_payment? |
| deliver_webhook if payable_payment_status.to_sym == :succeeded | ||
| if payable_payment_status.to_sym == :succeeded | ||
| deliver_webhook | ||
| Integrations::Aggregator::Payments::CreateJob.perform_later(payment:) if payment.should_sync_payment? |
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.
Context
Payments that reach
succeededthrough a provider webhook (3DS/SCA flows, async off-session confirmations, recovery of a payment missing in the database) were never synced to accounting providers: the sync job was only enqueued from the synchronous charge path and manual payments. The invoice would show up in NetSuite/Xero with no payment applied against it.Description
Enqueue
Integrations::Aggregator::Payments::CreateJobwhen a payment reachessucceededin the Stripe, Adyen and GoCardless webhook settlement paths, reusing theshould_sync_payment?guard from the synchronous path.Duplicated provider webhooks can enqueue concurrent syncs for the same payment, so the sync in
Integrations::Aggregator::Payments::CreateServiceis now serialized with a payment-scoped advisory lock (newLockService): the already-synced check runs under the lock, so the payment cannot be created twice in the accounting provider. A job that fails to acquire the lock is a duplicate and is discarded as a no-op — the lock holder and its retries own the sync.