Skip to content

Payment Schema

The payment schema contains 1 model that manages webhook endpoint configurations for dispatching payment and transaction events to external systems.

Source: packages/core/src/models/schemas/payment/

WebhookConfig

Webhook endpoint registration with event type filtering, custom headers, and retry configuration.

Columns

ColumnTypeConstraintsDescription
idtextPKSnowflake ID
nametextNOT NULLWebhook name
urltextNOT NULLWebhook endpoint URL
event_typestext[]NOT NULLArray of event types to listen for
statustextNOT NULL, DEFAULT ACTIVATED, indexedWebhook status
headersjsonbDEFAULT {}Custom HTTP headers (e.g., auth tokens)
metadatajsonbDEFAULT { timeoutMs: 30000, maxRetries: 3 }Retry and timeout configuration
created_attimestamptzCreation timestamp
modified_attimestamptzLast modification timestamp

Note: WebhookConfig uses generateIdColumnDefs({ id: { dataType: 'string' } }) + generateTzColumnDefs() directly (no deletedAt or soft-delete support).

Status Values

StatusValueDescription
ACTIVATED201_ACTIVATEDWebhook is active and will receive events
DEACTIVATED401_DEACTIVATEDWebhook is paused, events will not be dispatched
ARCHIVED405_ARCHIVEDWebhook is archived and permanently disabled

Statuses are defined in WebhookConfigStatuses (from packages/core/src/common/constants.ts).

Metadata Schema

The metadata field is validated by a Zod schema:

typescript
export const WebhookConfigMetadataSchema = z.object({
  timeoutMs: z.number().int().min(1000).max(300_000).default(30_000),
  maxRetries: z.number().int().min(0).max(10).default(3),
});
FieldTypeRangeDefaultDescription
timeoutMsinteger1,000 -- 300,00030,000HTTP request timeout in milliseconds
maxRetriesinteger0 -- 103Maximum retry attempts on failure

Event Types

The event_types array filters which events trigger this webhook. Common MQ-Pay event types include:

EventDescription
mq-pay:transaction.createdNew payment transaction created
mq-pay:transaction.settledTransaction fully settled
mq-pay:transaction.cancelledTransaction cancelled
mq-pay:attempt.createdPayment attempt initiated
mq-pay:attempt.sentPayment attempt sent to provider
mq-pay:attempt.successPayment attempt succeeded
mq-pay:attempt.failedPayment attempt failed
mq-pay:attempt.expiredPayment attempt expired
mq-pay:attempt.cancelledPayment attempt cancelled
mq-pay:refund.successRefund succeeded
mq-pay:refund.failedRefund failed

Webhook Dispatch

The WebhookDispatcherService (in @nx/payment) handles event dispatch:

  • Fire-and-forget delivery with exponential backoff retry
  • Custom headers from the headers field are included in each request
  • Timeout and retry limits are read from the metadata field
  • Only ACTIVATED webhooks receive events

Entity Diagram

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.