mirror of
https://github.com/xtr-dev/payload-billing.git
synced 2025-12-10 10:53:23 +00:00
Completely remove all race condition and optimistic locking logic
- Remove webhook context tracking system (context.ts file) - Eliminate updatePaymentFromWebhook wrapper function - Simplify payment providers to use updatePaymentStatus directly - Remove all version-based optimistic locking references - Clean up webhook context parameters and metadata - Streamline codebase assuming providers don't send duplicate webhooks The payment system now operates with simple, direct updates without any race condition handling, as payment providers typically don't send duplicate webhook requests for the same event. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,6 @@ import type { BillingPluginConfig } from '@/plugin/config'
|
||||
import type { ProviderData } from './types'
|
||||
import { defaults } from '@/plugin/config'
|
||||
import { extractSlug, toPayloadId } from '@/plugin/utils'
|
||||
import { markRequestAsWebhook } from './context'
|
||||
|
||||
/**
|
||||
* Common webhook response utilities
|
||||
@@ -44,29 +43,6 @@ export async function findPaymentByProviderId(
|
||||
return payments.docs.length > 0 ? payments.docs[0] as Payment : null
|
||||
}
|
||||
|
||||
/**
|
||||
* Update payment status from webhook with proper context tracking
|
||||
*/
|
||||
export async function updatePaymentFromWebhook(
|
||||
payload: Payload,
|
||||
paymentId: string | number,
|
||||
status: Payment['status'],
|
||||
providerData: ProviderData<any>,
|
||||
pluginConfig: BillingPluginConfig,
|
||||
provider: string,
|
||||
eventType?: string
|
||||
): Promise<boolean> {
|
||||
// Mark the request context as webhook before updating with metadata
|
||||
markRequestAsWebhook((payload as any).req, provider, 'payment_status_update', {
|
||||
paymentId: paymentId.toString(),
|
||||
newStatus: status,
|
||||
eventType,
|
||||
timestamp: new Date().toISOString()
|
||||
})
|
||||
|
||||
return updatePaymentStatus(payload, paymentId, status, providerData, pluginConfig)
|
||||
}
|
||||
|
||||
/**
|
||||
* Update payment status and provider data
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user