@open-mercato/gateway-stripe 0.6.6-develop.6465.1.019f0fb26f → 0.6.6-develop.6472.1.1673e7e66b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/gateway_stripe/setup.js +3 -2
- package/dist/modules/gateway_stripe/setup.js.map +2 -2
- package/dist/modules/gateway_stripe/workers/webhook-processor.js +5 -2
- package/dist/modules/gateway_stripe/workers/webhook-processor.js.map +2 -2
- package/package.json +6 -6
- package/src/modules/gateway_stripe/setup.ts +4 -2
- package/src/modules/gateway_stripe/workers/webhook-processor.ts +5 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { createLogger } from "@open-mercato/shared/lib/logger";
|
|
1
2
|
import { createCredentialsService } from "@open-mercato/core/modules/integrations/lib/credentials-service";
|
|
2
3
|
import { createIntegrationLogService } from "@open-mercato/core/modules/integrations/lib/log-service";
|
|
3
4
|
import { createIntegrationStateService } from "@open-mercato/core/modules/integrations/lib/state-service";
|
|
4
5
|
import { applyStripeEnvPreset } from "./lib/preset.js";
|
|
6
|
+
const logger = createLogger("gateway_stripe");
|
|
5
7
|
const setup = {
|
|
6
8
|
defaultRoleFeatures: {
|
|
7
9
|
superadmin: ["gateway_stripe.view", "gateway_stripe.configure"],
|
|
@@ -16,8 +18,7 @@ const setup = {
|
|
|
16
18
|
scope: { tenantId, organizationId }
|
|
17
19
|
});
|
|
18
20
|
} catch (error) {
|
|
19
|
-
|
|
20
|
-
console.warn(`[gateway_stripe] Failed to apply env preset during tenant setup: ${message}`);
|
|
21
|
+
logger.warn("Failed to apply env preset during tenant setup", { err: error });
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/modules/gateway_stripe/setup.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'\nimport { createCredentialsService } from '@open-mercato/core/modules/integrations/lib/credentials-service'\nimport { createIntegrationLogService } from '@open-mercato/core/modules/integrations/lib/log-service'\nimport { createIntegrationStateService } from '@open-mercato/core/modules/integrations/lib/state-service'\nimport { applyStripeEnvPreset } from './lib/preset'\n\nexport const setup: ModuleSetupConfig = {\n defaultRoleFeatures: {\n superadmin: ['gateway_stripe.view', 'gateway_stripe.configure'],\n admin: ['gateway_stripe.view', 'gateway_stripe.configure'],\n },\n\n async onTenantCreated({ em, organizationId, tenantId }) {\n try {\n await applyStripeEnvPreset({\n credentialsService: createCredentialsService(em),\n integrationStateService: createIntegrationStateService(em),\n integrationLogService: createIntegrationLogService(em),\n scope: { tenantId, organizationId },\n })\n } catch (error) {\n
|
|
5
|
-
"mappings": "AACA,SAAS,gCAAgC;AACzC,SAAS,mCAAmC;AAC5C,SAAS,qCAAqC;AAC9C,SAAS,4BAA4B;
|
|
4
|
+
"sourcesContent": ["import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\nimport { createCredentialsService } from '@open-mercato/core/modules/integrations/lib/credentials-service'\nimport { createIntegrationLogService } from '@open-mercato/core/modules/integrations/lib/log-service'\nimport { createIntegrationStateService } from '@open-mercato/core/modules/integrations/lib/state-service'\nimport { applyStripeEnvPreset } from './lib/preset'\n\nconst logger = createLogger('gateway_stripe')\n\nexport const setup: ModuleSetupConfig = {\n defaultRoleFeatures: {\n superadmin: ['gateway_stripe.view', 'gateway_stripe.configure'],\n admin: ['gateway_stripe.view', 'gateway_stripe.configure'],\n },\n\n async onTenantCreated({ em, organizationId, tenantId }) {\n try {\n await applyStripeEnvPreset({\n credentialsService: createCredentialsService(em),\n integrationStateService: createIntegrationStateService(em),\n integrationLogService: createIntegrationLogService(em),\n scope: { tenantId, organizationId },\n })\n } catch (error) {\n logger.warn('Failed to apply env preset during tenant setup', { err: error })\n }\n },\n}\n\nexport default setup\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,oBAAoB;AAC7B,SAAS,gCAAgC;AACzC,SAAS,mCAAmC;AAC5C,SAAS,qCAAqC;AAC9C,SAAS,4BAA4B;AAErC,MAAM,SAAS,aAAa,gBAAgB;AAErC,MAAM,QAA2B;AAAA,EACtC,qBAAqB;AAAA,IACnB,YAAY,CAAC,uBAAuB,0BAA0B;AAAA,IAC9D,OAAO,CAAC,uBAAuB,0BAA0B;AAAA,EAC3D;AAAA,EAEA,MAAM,gBAAgB,EAAE,IAAI,gBAAgB,SAAS,GAAG;AACtD,QAAI;AACF,YAAM,qBAAqB;AAAA,QACzB,oBAAoB,yBAAyB,EAAE;AAAA,QAC/C,yBAAyB,8BAA8B,EAAE;AAAA,QACzD,uBAAuB,4BAA4B,EAAE;AAAA,QACrD,OAAO,EAAE,UAAU,eAAe;AAAA,MACpC,CAAC;AAAA,IACH,SAAS,OAAO;AACd,aAAO,KAAK,kDAAkD,EAAE,KAAK,MAAM,CAAC;AAAA,IAC9E;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { claimWebhookProcessing, releaseWebhookClaim } from "@open-mercato/core/modules/payment_gateways/lib/webhook-utils";
|
|
2
2
|
import { mapWebhookEventToStatus, mapStripeStatus } from "../lib/status-map.js";
|
|
3
|
+
import { createLogger } from "@open-mercato/shared/lib/logger";
|
|
4
|
+
const logger = createLogger("gateway_stripe").child({ component: "webhook-processor" });
|
|
3
5
|
const metadata = {
|
|
4
6
|
queue: "stripe-webhook",
|
|
5
7
|
id: "gateway-stripe:webhook-processor",
|
|
@@ -77,9 +79,10 @@ async function handle(job, ctx) {
|
|
|
77
79
|
}
|
|
78
80
|
}, scope);
|
|
79
81
|
} else {
|
|
80
|
-
|
|
82
|
+
logger.error("Stripe webhook processing failed", {
|
|
81
83
|
eventType: event.eventType,
|
|
82
|
-
transactionId: job.payload.transactionId ?? null
|
|
84
|
+
transactionId: job.payload.transactionId ?? null,
|
|
85
|
+
err: error
|
|
83
86
|
});
|
|
84
87
|
}
|
|
85
88
|
throw error;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/gateway_stripe/workers/webhook-processor.ts"],
|
|
4
|
-
"sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport type { JobContext, QueuedJob, WorkerMeta } from '@open-mercato/queue'\nimport type { WebhookEvent } from '@open-mercato/shared/modules/payment_gateways/types'\nimport type { IntegrationLogService } from '@open-mercato/core/modules/integrations/lib/log-service'\nimport type { PaymentGatewayService } from '@open-mercato/core/modules/payment_gateways/lib/gateway-service'\nimport { claimWebhookProcessing, releaseWebhookClaim } from '@open-mercato/core/modules/payment_gateways/lib/webhook-utils'\nimport { mapWebhookEventToStatus, mapStripeStatus } from '../lib/status-map'\n\ntype WebhookJobPayload = {\n providerKey: string\n event: WebhookEvent\n transactionId?: string | null\n scope?: {\n organizationId: string\n tenantId: string\n } | null\n}\n\ntype HandlerContext = JobContext & {\n resolve: <T = unknown>(name: string) => T\n}\n\nexport const metadata: WorkerMeta = {\n queue: 'stripe-webhook',\n id: 'gateway-stripe:webhook-processor',\n concurrency: 5,\n}\n\nfunction readSessionIdFromEvent(event: WebhookEvent): string | null {\n const id = event.data.id\n if (typeof id === 'string' && id.trim().length > 0) return id.trim()\n const paymentIntent = event.data.payment_intent\n if (typeof paymentIntent === 'string' && paymentIntent.trim().length > 0) return paymentIntent.trim()\n return null\n}\n\nfunction readScopeFromEvent(event: WebhookEvent): { organizationId: string; tenantId: string } | null {\n const metadata = event.data.metadata\n if (!metadata || typeof metadata !== 'object') return null\n\n const metadataRecord = metadata as Record<string, unknown>\n const organizationId = typeof metadataRecord.organizationId === 'string'\n ? metadataRecord.organizationId.trim()\n : ''\n const tenantId = typeof metadataRecord.tenantId === 'string'\n ? metadataRecord.tenantId.trim()\n : ''\n\n if (!organizationId || !tenantId) return null\n return { organizationId, tenantId }\n}\n\nexport default async function handle(job: QueuedJob<WebhookJobPayload>, ctx: HandlerContext): Promise<void> {\n const em = ctx.resolve<EntityManager>('em')\n const paymentGatewayService = ctx.resolve<PaymentGatewayService>('paymentGatewayService')\n const integrationLogService = ctx.resolve<IntegrationLogService>('integrationLogService')\n const event = job.payload.event\n const scope = job.payload.scope ?? readScopeFromEvent(event)\n\n try {\n let transaction = job.payload.transactionId && scope\n ? await paymentGatewayService.findTransaction(job.payload.transactionId, scope)\n : null\n if (!transaction) {\n const sessionId = readSessionIdFromEvent(event)\n if (!sessionId || !scope) return\n transaction = await paymentGatewayService.findTransactionBySessionId(sessionId, scope, 'stripe')\n }\n if (!transaction) return\n\n const transactionScope = { organizationId: transaction.organizationId, tenantId: transaction.tenantId }\n const log = integrationLogService.scoped('gateway_stripe', transactionScope)\n const claimed = await claimWebhookProcessing(em, event.idempotencyKey, 'stripe', transactionScope, event.eventType)\n if (!claimed) {\n await log.info('Duplicate Stripe webhook skipped', {\n eventType: event.eventType,\n idempotencyKey: event.idempotencyKey,\n transactionId: transaction.id,\n })\n return\n }\n\n const eventStatus = mapWebhookEventToStatus(event.eventType)\n const providerStatus = typeof event.data.status === 'string' ? event.data.status : ''\n const unifiedStatus = eventStatus ?? mapStripeStatus(providerStatus)\n\n if (unifiedStatus !== 'unknown') {\n await paymentGatewayService.syncTransactionStatus(transaction.id, {\n unifiedStatus,\n providerStatus: event.eventType,\n providerData: event.data,\n }, transactionScope)\n }\n\n await log.info('Stripe webhook processed', {\n eventType: event.eventType,\n transactionId: transaction.id,\n unifiedStatus,\n })\n } catch (error: unknown) {\n const message = error instanceof Error ? error.message : 'Stripe webhook processing failed'\n if (scope) {\n await releaseWebhookClaim(em, event.idempotencyKey, 'stripe', scope)\n await integrationLogService.write({\n integrationId: 'gateway_stripe',\n level: 'error',\n message: 'Stripe webhook processing failed',\n code: 'stripe_webhook_processing_failed',\n payload: {\n error: message,\n eventType: event.eventType,\n transactionId: job.payload.transactionId ?? null,\n },\n }, scope)\n } else {\n
|
|
5
|
-
"mappings": "AAKA,SAAS,wBAAwB,2BAA2B;AAC5D,SAAS,yBAAyB,uBAAuB;
|
|
4
|
+
"sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport type { JobContext, QueuedJob, WorkerMeta } from '@open-mercato/queue'\nimport type { WebhookEvent } from '@open-mercato/shared/modules/payment_gateways/types'\nimport type { IntegrationLogService } from '@open-mercato/core/modules/integrations/lib/log-service'\nimport type { PaymentGatewayService } from '@open-mercato/core/modules/payment_gateways/lib/gateway-service'\nimport { claimWebhookProcessing, releaseWebhookClaim } from '@open-mercato/core/modules/payment_gateways/lib/webhook-utils'\nimport { mapWebhookEventToStatus, mapStripeStatus } from '../lib/status-map'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nconst logger = createLogger('gateway_stripe').child({ component: 'webhook-processor' })\n\ntype WebhookJobPayload = {\n providerKey: string\n event: WebhookEvent\n transactionId?: string | null\n scope?: {\n organizationId: string\n tenantId: string\n } | null\n}\n\ntype HandlerContext = JobContext & {\n resolve: <T = unknown>(name: string) => T\n}\n\nexport const metadata: WorkerMeta = {\n queue: 'stripe-webhook',\n id: 'gateway-stripe:webhook-processor',\n concurrency: 5,\n}\n\nfunction readSessionIdFromEvent(event: WebhookEvent): string | null {\n const id = event.data.id\n if (typeof id === 'string' && id.trim().length > 0) return id.trim()\n const paymentIntent = event.data.payment_intent\n if (typeof paymentIntent === 'string' && paymentIntent.trim().length > 0) return paymentIntent.trim()\n return null\n}\n\nfunction readScopeFromEvent(event: WebhookEvent): { organizationId: string; tenantId: string } | null {\n const metadata = event.data.metadata\n if (!metadata || typeof metadata !== 'object') return null\n\n const metadataRecord = metadata as Record<string, unknown>\n const organizationId = typeof metadataRecord.organizationId === 'string'\n ? metadataRecord.organizationId.trim()\n : ''\n const tenantId = typeof metadataRecord.tenantId === 'string'\n ? metadataRecord.tenantId.trim()\n : ''\n\n if (!organizationId || !tenantId) return null\n return { organizationId, tenantId }\n}\n\nexport default async function handle(job: QueuedJob<WebhookJobPayload>, ctx: HandlerContext): Promise<void> {\n const em = ctx.resolve<EntityManager>('em')\n const paymentGatewayService = ctx.resolve<PaymentGatewayService>('paymentGatewayService')\n const integrationLogService = ctx.resolve<IntegrationLogService>('integrationLogService')\n const event = job.payload.event\n const scope = job.payload.scope ?? readScopeFromEvent(event)\n\n try {\n let transaction = job.payload.transactionId && scope\n ? await paymentGatewayService.findTransaction(job.payload.transactionId, scope)\n : null\n if (!transaction) {\n const sessionId = readSessionIdFromEvent(event)\n if (!sessionId || !scope) return\n transaction = await paymentGatewayService.findTransactionBySessionId(sessionId, scope, 'stripe')\n }\n if (!transaction) return\n\n const transactionScope = { organizationId: transaction.organizationId, tenantId: transaction.tenantId }\n const log = integrationLogService.scoped('gateway_stripe', transactionScope)\n const claimed = await claimWebhookProcessing(em, event.idempotencyKey, 'stripe', transactionScope, event.eventType)\n if (!claimed) {\n await log.info('Duplicate Stripe webhook skipped', {\n eventType: event.eventType,\n idempotencyKey: event.idempotencyKey,\n transactionId: transaction.id,\n })\n return\n }\n\n const eventStatus = mapWebhookEventToStatus(event.eventType)\n const providerStatus = typeof event.data.status === 'string' ? event.data.status : ''\n const unifiedStatus = eventStatus ?? mapStripeStatus(providerStatus)\n\n if (unifiedStatus !== 'unknown') {\n await paymentGatewayService.syncTransactionStatus(transaction.id, {\n unifiedStatus,\n providerStatus: event.eventType,\n providerData: event.data,\n }, transactionScope)\n }\n\n await log.info('Stripe webhook processed', {\n eventType: event.eventType,\n transactionId: transaction.id,\n unifiedStatus,\n })\n } catch (error: unknown) {\n const message = error instanceof Error ? error.message : 'Stripe webhook processing failed'\n if (scope) {\n await releaseWebhookClaim(em, event.idempotencyKey, 'stripe', scope)\n await integrationLogService.write({\n integrationId: 'gateway_stripe',\n level: 'error',\n message: 'Stripe webhook processing failed',\n code: 'stripe_webhook_processing_failed',\n payload: {\n error: message,\n eventType: event.eventType,\n transactionId: job.payload.transactionId ?? null,\n },\n }, scope)\n } else {\n logger.error('Stripe webhook processing failed', {\n eventType: event.eventType,\n transactionId: job.payload.transactionId ?? null,\n err: error,\n })\n }\n throw error\n }\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": ["metadata"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/gateway-stripe",
|
|
3
|
-
"version": "0.6.6-develop.
|
|
3
|
+
"version": "0.6.6-develop.6472.1.1673e7e66b",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -62,21 +62,21 @@
|
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@open-mercato/core": "0.6.6-develop.
|
|
66
|
-
"@open-mercato/queue": "0.6.6-develop.
|
|
67
|
-
"@open-mercato/ui": "0.6.6-develop.
|
|
65
|
+
"@open-mercato/core": "0.6.6-develop.6472.1.1673e7e66b",
|
|
66
|
+
"@open-mercato/queue": "0.6.6-develop.6472.1.1673e7e66b",
|
|
67
|
+
"@open-mercato/ui": "0.6.6-develop.6472.1.1673e7e66b",
|
|
68
68
|
"@stripe/react-stripe-js": "^6.6.0",
|
|
69
69
|
"@stripe/stripe-js": "^9.8.0",
|
|
70
70
|
"stripe": "^22.3.0"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"@mikro-orm/postgresql": "^7.0.14",
|
|
74
|
-
"@open-mercato/shared": "0.6.6-develop.
|
|
74
|
+
"@open-mercato/shared": "0.6.6-develop.6472.1.1673e7e66b",
|
|
75
75
|
"react": "^19.0.0",
|
|
76
76
|
"react-dom": "^19.0.0"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"@open-mercato/shared": "0.6.6-develop.
|
|
79
|
+
"@open-mercato/shared": "0.6.6-develop.6472.1.1673e7e66b",
|
|
80
80
|
"@types/jest": "^30.0.0",
|
|
81
81
|
"@types/react": "^19.2.17",
|
|
82
82
|
"@types/react-dom": "^19.2.3",
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'
|
|
2
|
+
import { createLogger } from '@open-mercato/shared/lib/logger'
|
|
2
3
|
import { createCredentialsService } from '@open-mercato/core/modules/integrations/lib/credentials-service'
|
|
3
4
|
import { createIntegrationLogService } from '@open-mercato/core/modules/integrations/lib/log-service'
|
|
4
5
|
import { createIntegrationStateService } from '@open-mercato/core/modules/integrations/lib/state-service'
|
|
5
6
|
import { applyStripeEnvPreset } from './lib/preset'
|
|
6
7
|
|
|
8
|
+
const logger = createLogger('gateway_stripe')
|
|
9
|
+
|
|
7
10
|
export const setup: ModuleSetupConfig = {
|
|
8
11
|
defaultRoleFeatures: {
|
|
9
12
|
superadmin: ['gateway_stripe.view', 'gateway_stripe.configure'],
|
|
@@ -19,8 +22,7 @@ export const setup: ModuleSetupConfig = {
|
|
|
19
22
|
scope: { tenantId, organizationId },
|
|
20
23
|
})
|
|
21
24
|
} catch (error) {
|
|
22
|
-
|
|
23
|
-
console.warn(`[gateway_stripe] Failed to apply env preset during tenant setup: ${message}`)
|
|
25
|
+
logger.warn('Failed to apply env preset during tenant setup', { err: error })
|
|
24
26
|
}
|
|
25
27
|
},
|
|
26
28
|
}
|
|
@@ -5,6 +5,9 @@ import type { IntegrationLogService } from '@open-mercato/core/modules/integrati
|
|
|
5
5
|
import type { PaymentGatewayService } from '@open-mercato/core/modules/payment_gateways/lib/gateway-service'
|
|
6
6
|
import { claimWebhookProcessing, releaseWebhookClaim } from '@open-mercato/core/modules/payment_gateways/lib/webhook-utils'
|
|
7
7
|
import { mapWebhookEventToStatus, mapStripeStatus } from '../lib/status-map'
|
|
8
|
+
import { createLogger } from '@open-mercato/shared/lib/logger'
|
|
9
|
+
|
|
10
|
+
const logger = createLogger('gateway_stripe').child({ component: 'webhook-processor' })
|
|
8
11
|
|
|
9
12
|
type WebhookJobPayload = {
|
|
10
13
|
providerKey: string
|
|
@@ -113,9 +116,10 @@ export default async function handle(job: QueuedJob<WebhookJobPayload>, ctx: Han
|
|
|
113
116
|
},
|
|
114
117
|
}, scope)
|
|
115
118
|
} else {
|
|
116
|
-
|
|
119
|
+
logger.error('Stripe webhook processing failed', {
|
|
117
120
|
eventType: event.eventType,
|
|
118
121
|
transactionId: job.payload.transactionId ?? null,
|
|
122
|
+
err: error,
|
|
119
123
|
})
|
|
120
124
|
}
|
|
121
125
|
throw error
|