Preventing Data Integrity Issues in ESHOPMAN's Concurrent Payment Processing

Ensuring Robust Customer Data in ESHOPMAN's Headless Payment Workflows

In the dynamic world of headless commerce, ESHOPMAN offers powerful capabilities for managing storefronts and processing payments through its HubSpot integration. However, a recent community discussion highlighted a critical scenario where concurrent payment processing workflows could inadvertently compromise customer data integrity with external payment providers.

The core issue revolves around how ESHOPMAN handles situations where a customer's external payment provider account needs to be 'recovered' or re-linked. When multiple payment collection workflows for the same ESHOPMAN customer are initiated simultaneously, a race condition can occur. This is particularly problematic if the external payment provider initially reports a customer as 'missing' for both requests, but then one workflow successfully recovers and establishes a new link, while the other (delayed) workflow proceeds to delete that newly established link.

The Challenge: Concurrent Account Holder Recovery

Imagine an ESHOPMAN customer linked to an external payment service with account holder ID 'X'. If two payment collections are created for this customer, and the internal

createPaymentSessionsWorkflow
is started for both concurrently, a specific sequence of events can lead to data loss:

  1. Both workflows query the external payment provider for 'X'.
  2. The provider, perhaps due to a temporary glitch or a new setup, reports 'X' as missing for both requests, but with a slight delay for the second response.
  3. The first workflow, upon receiving the 'missing' report, successfully recovers the customer, linking them to a new external ID, say 'Y', and creates its payment session.
  4. Crucially, the second workflow, still processing its delayed 'missing' report, then calls
    replaceAccountHolder
    with the original internal holder ID. It re-reads the (now valid) 'Y', replaces it with a new ID 'Z', and then deletes 'Y'.

The result? The first workflow successfully created a payment session, but the external payment provider customer it was linked to ('Y') has now been deleted by the second workflow. This leaves a valid ESHOPMAN payment session pointing to a non-existent external customer record, leading to potential transaction failures and customer frustration.

The root cause lies in the fact that while ESHOPMAN's cart locking mechanisms serialize operations on individual carts, they do not extend to serializing the broader account-holder recovery process across different payment collections for the same customer.

Proposed Solution: Customer-Scoped Account-Holder Locking

To mitigate this risk and ensure robust data integrity, a proposed fix involves implementing a customer-scoped account-holder lock within ESHOPMAN's payment processing workflows. This lock would be acquired before querying the customer's external payment provider details and retained throughout the session creation and recovery process.

Key aspects of this solution:

  • Serialization: By acquiring a customer-scoped lock, only one workflow can perform account-holder recovery or updates for a given customer at any time.
  • Workflow Integration: The acquire and release steps for this lock would be integrated into child workflows, leveraging the existing workflow transaction as the owner.
  • Scope: This locking mechanism would specifically target operations involving external payment provider customer accounts, leaving customerless payments unaffected.

This approach would utilize ESHOPMAN's existing bounded payment-workflow lease system, ensuring that even during prolonged external provider outages, the system remains stable. Implementing such a fix would significantly enhance the reliability of ESHOPMAN's headless commerce platform, particularly for merchants managing high volumes of concurrent transactions and relying on seamless HubSpot CMS storefront operations.

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools