Enhance webhook detection with explicit context tracking and database optimization

- Add database index on version field for optimistic locking performance
- Implement explicit webhook context tracking with symbols to avoid conflicts
- Replace fragile webhook detection logic with robust context-based approach
- Add request metadata support for enhanced debugging and audit trails
- Simplify version management in payment collection hooks
- Fix TypeScript compilation errors and improve type safety

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-17 20:07:02 +02:00
parent a5b6bb9bfd
commit 876501d94f
5 changed files with 111 additions and 40 deletions

View File

@@ -6,7 +6,7 @@ import type { createMollieClient, MollieClient } from '@mollie/api-client'
import {
webhookResponses,
findPaymentByProviderId,
updatePaymentStatus,
updatePaymentFromWebhook,
updateInvoiceOnPaymentSuccess,
handleWebhookError,
validateProductionUrl
@@ -83,13 +83,15 @@ export const mollieProvider = (mollieConfig: MollieProviderConfig & {
// Map Mollie status to our status using proper type-safe mapping
const status = mapMollieStatusToPaymentStatus(molliePayment.status)
// Update the payment status and provider data
const updateSuccess = await updatePaymentStatus(
// Update the payment status and provider data with webhook context
const updateSuccess = await updatePaymentFromWebhook(
payload,
payment.id,
status,
molliePayment.toPlainObject(),
pluginConfig
pluginConfig,
'mollie',
`payment.${molliePayment.status}`
)
// If payment is successful and update succeeded, update the invoice