@open-mercato/gateway-stripe 0.10.1-develop.7736.1.88e07906bf → 0.10.1-develop.7748.1.d745ba61aa
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/.turbo/turbo-build.log +1 -1
- package/dist/modules/gateway_stripe/__integration__/TC-STRIPE-001.spec.js +286 -0
- package/dist/modules/gateway_stripe/__integration__/TC-STRIPE-001.spec.js.map +7 -0
- package/dist/modules/gateway_stripe/__integration__/meta.js +9 -0
- package/dist/modules/gateway_stripe/__integration__/meta.js.map +7 -0
- package/dist/modules/gateway_stripe/lib/adapters/v2023-10-16.js +3 -7
- package/dist/modules/gateway_stripe/lib/adapters/v2023-10-16.js.map +2 -2
- package/dist/modules/gateway_stripe/lib/adapters/v2024-12-18.js +3 -7
- package/dist/modules/gateway_stripe/lib/adapters/v2024-12-18.js.map +2 -2
- package/dist/modules/gateway_stripe/lib/adapters/v2025-02-24.acacia.js +3 -7
- package/dist/modules/gateway_stripe/lib/adapters/v2025-02-24.acacia.js.map +2 -2
- package/dist/modules/gateway_stripe/lib/status-map.js +57 -1
- package/dist/modules/gateway_stripe/lib/status-map.js.map +2 -2
- package/dist/modules/gateway_stripe/lib/webhook-handler.js +4 -3
- package/dist/modules/gateway_stripe/lib/webhook-handler.js.map +2 -2
- package/dist/modules/gateway_stripe/workers/webhook-processor.js +2 -4
- package/dist/modules/gateway_stripe/workers/webhook-processor.js.map +2 -2
- package/package.json +6 -6
- package/src/modules/gateway_stripe/__integration__/TC-STRIPE-001.spec.ts +362 -0
- package/src/modules/gateway_stripe/__integration__/meta.ts +5 -0
- package/src/modules/gateway_stripe/__tests__/status-map.test.ts +187 -1
- package/src/modules/gateway_stripe/__tests__/webhook-handler.test.ts +29 -0
- package/src/modules/gateway_stripe/__tests__/webhook-processor-status.test.ts +109 -0
- package/src/modules/gateway_stripe/__tests__/webhook-processor.test.ts +3 -5
- package/src/modules/gateway_stripe/__tests__/webhook-refund-ordering.test.ts +365 -0
- package/src/modules/gateway_stripe/__tests__/webhook-route.stripe-events.test.ts +274 -0
- package/src/modules/gateway_stripe/lib/adapters/v2023-10-16.ts +3 -7
- package/src/modules/gateway_stripe/lib/adapters/v2024-12-18.ts +3 -7
- package/src/modules/gateway_stripe/lib/adapters/v2025-02-24.acacia.ts +3 -7
- package/src/modules/gateway_stripe/lib/status-map.ts +95 -1
- package/src/modules/gateway_stripe/lib/webhook-handler.ts +10 -3
- package/src/modules/gateway_stripe/workers/webhook-processor.ts +2 -4
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
[build:gateway-stripe] found
|
|
1
|
+
[build:gateway-stripe] found 27 entry points
|
|
2
2
|
[build:gateway-stripe] built successfully
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { createHmac, randomUUID } from "node:crypto";
|
|
2
|
+
import { expect, test } from "@playwright/test";
|
|
3
|
+
import { apiRequest, getAuthToken } from "@open-mercato/core/helpers/integration/api";
|
|
4
|
+
import {
|
|
5
|
+
createOrganizationInDb,
|
|
6
|
+
deleteIntegrationCredentialsInDb,
|
|
7
|
+
deleteOrganizationInDb,
|
|
8
|
+
withClient
|
|
9
|
+
} from "@open-mercato/core/helpers/integration/dbFixtures";
|
|
10
|
+
import { getTokenScope } from "@open-mercato/core/helpers/integration/generalFixtures";
|
|
11
|
+
const WEBHOOK_PATH = "/api/payment_gateways/webhook/stripe";
|
|
12
|
+
const LEGACY_API_VERSION = "2025-02-24.acacia";
|
|
13
|
+
const BASIL_API_VERSION = "2025-03-31.basil";
|
|
14
|
+
const stamp = `${Date.now()}_${randomUUID().slice(0, 8)}`;
|
|
15
|
+
const webhookSecret = `whsec_tcstripe001_${stamp}`;
|
|
16
|
+
let eventSequence = 0;
|
|
17
|
+
function nextEventId() {
|
|
18
|
+
eventSequence += 1;
|
|
19
|
+
return `evt_tcstripe001_${stamp}_${eventSequence}`;
|
|
20
|
+
}
|
|
21
|
+
function signedBody(type, object, apiVersion, eventId = nextEventId()) {
|
|
22
|
+
return {
|
|
23
|
+
eventId,
|
|
24
|
+
body: JSON.stringify({
|
|
25
|
+
id: eventId,
|
|
26
|
+
object: "event",
|
|
27
|
+
api_version: apiVersion,
|
|
28
|
+
type,
|
|
29
|
+
created: Math.floor(Date.now() / 1e3),
|
|
30
|
+
livemode: false,
|
|
31
|
+
data: { object }
|
|
32
|
+
})
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function signatureHeader(body, secret) {
|
|
36
|
+
const timestamp = Math.floor(Date.now() / 1e3);
|
|
37
|
+
const signature = createHmac("sha256", secret).update(`${timestamp}.${body}`).digest("hex");
|
|
38
|
+
return `t=${timestamp},v1=${signature}`;
|
|
39
|
+
}
|
|
40
|
+
async function postWebhook(request, body, secret = webhookSecret) {
|
|
41
|
+
const response = await request.post(WEBHOOK_PATH, {
|
|
42
|
+
headers: { "content-type": "application/json", "stripe-signature": signatureHeader(body, secret) },
|
|
43
|
+
data: body
|
|
44
|
+
});
|
|
45
|
+
return response.status();
|
|
46
|
+
}
|
|
47
|
+
async function deliver(request, type, object, apiVersion = LEGACY_API_VERSION) {
|
|
48
|
+
const event = signedBody(type, object, apiVersion);
|
|
49
|
+
return { ...event, status: await postWebhook(request, event.body) };
|
|
50
|
+
}
|
|
51
|
+
function charge(paymentIntentId, overrides) {
|
|
52
|
+
return {
|
|
53
|
+
id: `ch_${paymentIntentId}`,
|
|
54
|
+
object: "charge",
|
|
55
|
+
payment_intent: paymentIntentId,
|
|
56
|
+
amount: 1e3,
|
|
57
|
+
amount_captured: 1e3,
|
|
58
|
+
amount_refunded: 0,
|
|
59
|
+
captured: true,
|
|
60
|
+
refunded: false,
|
|
61
|
+
currency: "usd",
|
|
62
|
+
status: "succeeded",
|
|
63
|
+
...overrides
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
async function seedTransaction(scope, input) {
|
|
67
|
+
return withClient(async (client) => {
|
|
68
|
+
const result = await client.query(
|
|
69
|
+
`insert into gateway_transactions
|
|
70
|
+
(id, payment_id, provider_key, provider_session_id, unified_status, amount, captured_amount, currency_code,
|
|
71
|
+
organization_id, tenant_id, created_at, updated_at)
|
|
72
|
+
values (gen_random_uuid(), gen_random_uuid(), 'stripe', $1, $2, 10, $3, 'USD', $4, $5, now(), now())
|
|
73
|
+
returning id`,
|
|
74
|
+
[input.paymentIntentId, input.status, input.capturedAmount, scope.organizationId, scope.tenantId]
|
|
75
|
+
);
|
|
76
|
+
return result.rows[0].id;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async function readTransaction(id) {
|
|
80
|
+
return withClient(async (client) => {
|
|
81
|
+
const result = await client.query(
|
|
82
|
+
"select unified_status, captured_amount::text as captured_amount, gateway_status, last_webhook_at from gateway_transactions where id = $1",
|
|
83
|
+
[id]
|
|
84
|
+
);
|
|
85
|
+
return result.rows[0];
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
async function statusOf(id) {
|
|
89
|
+
return (await readTransaction(id)).unified_status;
|
|
90
|
+
}
|
|
91
|
+
async function lastWebhookAt(id) {
|
|
92
|
+
return (await readTransaction(id)).last_webhook_at?.getTime() ?? 0;
|
|
93
|
+
}
|
|
94
|
+
async function deliverAndWait(request, transactionId, type, object, apiVersion = LEGACY_API_VERSION) {
|
|
95
|
+
const before = await lastWebhookAt(transactionId);
|
|
96
|
+
expect((await deliver(request, type, object, apiVersion)).status).toBe(202);
|
|
97
|
+
await expect.poll(() => lastWebhookAt(transactionId)).toBeGreaterThan(before);
|
|
98
|
+
}
|
|
99
|
+
async function countClaims(eventId) {
|
|
100
|
+
return withClient(async (client) => {
|
|
101
|
+
const result = await client.query(
|
|
102
|
+
"select count(*)::text as count from gateway_webhook_events where provider_key = 'stripe' and idempotency_key = $1",
|
|
103
|
+
[eventId]
|
|
104
|
+
);
|
|
105
|
+
return Number(result.rows[0].count);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
async function snapshotCredentials(scope) {
|
|
109
|
+
return withClient(async (client) => {
|
|
110
|
+
const result = await client.query(
|
|
111
|
+
`select id, credentials from integration_credentials
|
|
112
|
+
where integration_id = 'gateway_stripe' and organization_id = $1 and tenant_id = $2
|
|
113
|
+
and user_id is null and deleted_at is null
|
|
114
|
+
limit 1`,
|
|
115
|
+
[scope.organizationId, scope.tenantId]
|
|
116
|
+
);
|
|
117
|
+
return result.rows[0] ?? null;
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
async function restoreCredentials(scope, snapshot) {
|
|
121
|
+
await withClient(async (client) => {
|
|
122
|
+
if (snapshot) {
|
|
123
|
+
await client.query("update integration_credentials set credentials = $2::json where id = $1", [
|
|
124
|
+
snapshot.id,
|
|
125
|
+
JSON.stringify(snapshot.credentials)
|
|
126
|
+
]);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
await client.query(
|
|
130
|
+
`delete from integration_credentials
|
|
131
|
+
where integration_id = 'gateway_stripe' and organization_id = $1 and tenant_id = $2 and user_id is null`,
|
|
132
|
+
[scope.organizationId, scope.tenantId]
|
|
133
|
+
);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
test.describe("TC-STRIPE-001: Stripe charge webhooks drive the persisted gateway transaction", () => {
|
|
137
|
+
let scope;
|
|
138
|
+
let credentialsSnapshot = null;
|
|
139
|
+
const transactionIds = [];
|
|
140
|
+
let otherOrganizationId = null;
|
|
141
|
+
test.beforeAll(async ({ request }) => {
|
|
142
|
+
const token = await getAuthToken(request, "admin");
|
|
143
|
+
const tokenScope = getTokenScope(token);
|
|
144
|
+
scope = { organizationId: tokenScope.organizationId, tenantId: tokenScope.tenantId };
|
|
145
|
+
credentialsSnapshot = await snapshotCredentials(scope);
|
|
146
|
+
const response = await apiRequest(request, "PUT", "/api/integrations/gateway_stripe/credentials", {
|
|
147
|
+
token,
|
|
148
|
+
data: {
|
|
149
|
+
credentials: {
|
|
150
|
+
publishableKey: "pk_test_tcstripe001",
|
|
151
|
+
secretKey: "sk_test_tcstripe001",
|
|
152
|
+
webhookSecret
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
expect(response.status(), await response.text()).toBe(200);
|
|
157
|
+
});
|
|
158
|
+
test.afterAll(async () => {
|
|
159
|
+
await withClient(async (client) => {
|
|
160
|
+
if (transactionIds.length > 0) {
|
|
161
|
+
await client.query("delete from gateway_transactions where id = any($1::uuid[])", [transactionIds]);
|
|
162
|
+
}
|
|
163
|
+
await client.query("delete from gateway_webhook_events where provider_key = 'stripe' and idempotency_key like $1", [
|
|
164
|
+
`evt_tcstripe001_${stamp}_%`
|
|
165
|
+
]);
|
|
166
|
+
});
|
|
167
|
+
if (scope) await restoreCredentials(scope, credentialsSnapshot);
|
|
168
|
+
await deleteIntegrationCredentialsInDb(otherOrganizationId);
|
|
169
|
+
await deleteOrganizationInDb(otherOrganizationId);
|
|
170
|
+
});
|
|
171
|
+
async function seed(status, capturedAmount = status === "captured" ? "10" : "0") {
|
|
172
|
+
const paymentIntentId = `pi_tcstripe001_${stamp}_${transactionIds.length + 1}`;
|
|
173
|
+
const id = await seedTransaction(scope, { paymentIntentId, status, capturedAmount });
|
|
174
|
+
transactionIds.push(id);
|
|
175
|
+
return { id, paymentIntentId };
|
|
176
|
+
}
|
|
177
|
+
test("moves a captured payment from partial to full refund, once per event, and keeps it refunded on a stale partial", async ({ request }) => {
|
|
178
|
+
const { id, paymentIntentId } = await seed("captured");
|
|
179
|
+
const firstPartial = await deliver(request, "charge.refunded", charge(paymentIntentId, { amount_refunded: 400 }));
|
|
180
|
+
expect(firstPartial.status).toBe(202);
|
|
181
|
+
await expect.poll(() => statusOf(id)).toBe("partially_refunded");
|
|
182
|
+
expect((await readTransaction(id)).gateway_status).toBe("charge.refunded");
|
|
183
|
+
expect(await postWebhook(request, firstPartial.body)).toBe(202);
|
|
184
|
+
expect(await countClaims(firstPartial.eventId)).toBeGreaterThanOrEqual(1);
|
|
185
|
+
expect(await statusOf(id)).toBe("partially_refunded");
|
|
186
|
+
await deliverAndWait(request, id, "charge.refunded", charge(paymentIntentId, { amount_refunded: 700 }));
|
|
187
|
+
expect(await statusOf(id)).toBe("partially_refunded");
|
|
188
|
+
expect((await deliver(request, "charge.refunded", charge(paymentIntentId, { amount_refunded: 1e3, refunded: true }))).status).toBe(202);
|
|
189
|
+
await expect.poll(() => statusOf(id)).toBe("refunded");
|
|
190
|
+
await deliverAndWait(request, id, "charge.refunded", charge(paymentIntentId, { amount_refunded: 400 }));
|
|
191
|
+
expect(await statusOf(id)).toBe("refunded");
|
|
192
|
+
});
|
|
193
|
+
test("records a refund that overtakes the capture and ignores the late payment_intent.succeeded", async ({ request }) => {
|
|
194
|
+
const { id, paymentIntentId } = await seed("pending");
|
|
195
|
+
expect((await deliver(request, "charge.refunded", charge(paymentIntentId, { amount_refunded: 400 }))).status).toBe(202);
|
|
196
|
+
await expect.poll(() => statusOf(id)).toBe("partially_refunded");
|
|
197
|
+
expect(Number((await readTransaction(id)).captured_amount)).toBe(10);
|
|
198
|
+
await deliverAndWait(request, id, "payment_intent.succeeded", {
|
|
199
|
+
id: paymentIntentId,
|
|
200
|
+
object: "payment_intent",
|
|
201
|
+
status: "succeeded",
|
|
202
|
+
amount: 1e3,
|
|
203
|
+
amount_received: 1e3
|
|
204
|
+
});
|
|
205
|
+
expect(await statusOf(id)).toBe("partially_refunded");
|
|
206
|
+
expect((await deliver(request, "charge.refunded", charge(paymentIntentId, { amount_refunded: 1e3, refunded: true }))).status).toBe(202);
|
|
207
|
+
await expect.poll(() => statusOf(id)).toBe("refunded");
|
|
208
|
+
});
|
|
209
|
+
test("reads a pre-Basil partial capture: the uncaptured remainder is not a refund", async ({ request }) => {
|
|
210
|
+
const { id, paymentIntentId } = await seed("partially_captured", "6");
|
|
211
|
+
const partialCapture = { amount_captured: 600 };
|
|
212
|
+
await deliverAndWait(request, id, "charge.refunded", charge(paymentIntentId, { ...partialCapture, amount_refunded: 400 }), LEGACY_API_VERSION);
|
|
213
|
+
expect(await statusOf(id)).toBe("partially_captured");
|
|
214
|
+
await deliver(request, "charge.refunded", charge(paymentIntentId, { ...partialCapture, amount_refunded: 700 }), LEGACY_API_VERSION);
|
|
215
|
+
await expect.poll(() => statusOf(id)).toBe("partially_refunded");
|
|
216
|
+
await deliver(request, "charge.refunded", charge(paymentIntentId, { ...partialCapture, amount_refunded: 1e3, refunded: true }), LEGACY_API_VERSION);
|
|
217
|
+
await expect.poll(() => statusOf(id)).toBe("refunded");
|
|
218
|
+
expect(Number((await readTransaction(id)).captured_amount)).toBe(6);
|
|
219
|
+
});
|
|
220
|
+
test("reads a Basil partial capture: a refund of 3 out of 6 captured is a partial refund", async ({ request }) => {
|
|
221
|
+
const { id, paymentIntentId } = await seed("partially_captured", "6");
|
|
222
|
+
const partialCapture = { amount_captured: 600 };
|
|
223
|
+
await deliver(request, "charge.refunded", charge(paymentIntentId, { ...partialCapture, amount_refunded: 300 }), BASIL_API_VERSION);
|
|
224
|
+
await expect.poll(() => statusOf(id)).toBe("partially_refunded");
|
|
225
|
+
await deliver(request, "charge.refunded", charge(paymentIntentId, { ...partialCapture, amount_refunded: 600, refunded: true }), BASIL_API_VERSION);
|
|
226
|
+
await expect.poll(() => statusOf(id)).toBe("refunded");
|
|
227
|
+
});
|
|
228
|
+
test("applies concurrent refund and capture deliveries without losing the refund", async ({ request }) => {
|
|
229
|
+
const pairs = [];
|
|
230
|
+
for (let index = 0; index < 15; index += 1) pairs.push(await seed("captured"));
|
|
231
|
+
const refundDeliveries = await Promise.all(pairs.flatMap(({ paymentIntentId }) => [
|
|
232
|
+
deliver(request, "charge.refunded", charge(paymentIntentId, { amount_refunded: 400 })),
|
|
233
|
+
deliver(request, "charge.refunded", charge(paymentIntentId, { amount_refunded: 1e3, refunded: true }))
|
|
234
|
+
]));
|
|
235
|
+
expect(refundDeliveries.map((delivery) => delivery.status)).toEqual(refundDeliveries.map(() => 202));
|
|
236
|
+
for (const { id } of pairs) {
|
|
237
|
+
await expect.poll(() => statusOf(id)).toBe("refunded");
|
|
238
|
+
}
|
|
239
|
+
const pending = [await seed("pending"), await seed("pending"), await seed("pending")];
|
|
240
|
+
const captureRaceDeliveries = await Promise.all(pending.flatMap(({ paymentIntentId }) => [
|
|
241
|
+
deliver(request, "charge.refunded", charge(paymentIntentId, { amount_refunded: 400 })),
|
|
242
|
+
deliver(request, "payment_intent.succeeded", {
|
|
243
|
+
id: paymentIntentId,
|
|
244
|
+
object: "payment_intent",
|
|
245
|
+
status: "succeeded",
|
|
246
|
+
amount: 1e3,
|
|
247
|
+
amount_received: 1e3
|
|
248
|
+
})
|
|
249
|
+
]));
|
|
250
|
+
expect(captureRaceDeliveries.map((delivery) => delivery.status)).toEqual(captureRaceDeliveries.map(() => 202));
|
|
251
|
+
for (const { id } of pending) {
|
|
252
|
+
await expect.poll(() => statusOf(id)).toBe("partially_refunded");
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
test("changes only the transaction of the organization whose secret signed the event", async ({ request }) => {
|
|
256
|
+
const { id, paymentIntentId } = await seed("captured");
|
|
257
|
+
otherOrganizationId = await createOrganizationInDb({ name: `TC-STRIPE-001 other ${stamp}`, tenantId: scope.tenantId });
|
|
258
|
+
const superadminToken = await getAuthToken(request, "superadmin");
|
|
259
|
+
const otherSecret = `whsec_tcstripe001_other_${stamp}`;
|
|
260
|
+
const saved = await apiRequest(request, "PUT", "/api/integrations/gateway_stripe/credentials", {
|
|
261
|
+
token: superadminToken,
|
|
262
|
+
headers: {
|
|
263
|
+
Cookie: `om_selected_tenant=${encodeURIComponent(scope.tenantId)}; om_selected_org=${encodeURIComponent(otherOrganizationId)}`
|
|
264
|
+
},
|
|
265
|
+
data: { credentials: { publishableKey: "pk_test_tcstripe001_other", secretKey: "sk_test_tcstripe001_other", webhookSecret: otherSecret } }
|
|
266
|
+
});
|
|
267
|
+
expect(saved.status(), await saved.text()).toBe(200);
|
|
268
|
+
const otherId = await seedTransaction(
|
|
269
|
+
{ organizationId: otherOrganizationId, tenantId: scope.tenantId },
|
|
270
|
+
{ paymentIntentId, status: "captured", capturedAmount: "10" }
|
|
271
|
+
);
|
|
272
|
+
transactionIds.push(otherId);
|
|
273
|
+
const forged = signedBody("charge.refunded", charge(paymentIntentId, { amount_refunded: 1e3, refunded: true }), LEGACY_API_VERSION);
|
|
274
|
+
expect(await postWebhook(request, forged.body, `whsec_forged_${stamp}`)).toBe(401);
|
|
275
|
+
expect(await statusOf(id)).toBe("captured");
|
|
276
|
+
expect(await statusOf(otherId)).toBe("captured");
|
|
277
|
+
const signedByOther = signedBody("charge.refunded", charge(paymentIntentId, { amount_refunded: 400 }), LEGACY_API_VERSION);
|
|
278
|
+
expect(await postWebhook(request, signedByOther.body, otherSecret)).toBe(202);
|
|
279
|
+
await expect.poll(() => statusOf(otherId)).toBe("partially_refunded");
|
|
280
|
+
expect(await statusOf(id)).toBe("captured");
|
|
281
|
+
expect((await deliver(request, "charge.refunded", charge(paymentIntentId, { amount_refunded: 1e3, refunded: true }))).status).toBe(202);
|
|
282
|
+
await expect.poll(() => statusOf(id)).toBe("refunded");
|
|
283
|
+
expect(await statusOf(otherId)).toBe("partially_refunded");
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
//# sourceMappingURL=TC-STRIPE-001.spec.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/gateway_stripe/__integration__/TC-STRIPE-001.spec.ts"],
|
|
4
|
+
"sourcesContent": ["import { createHmac, randomUUID } from 'node:crypto'\nimport { expect, test, type APIRequestContext } from '@playwright/test'\nimport { apiRequest, getAuthToken } from '@open-mercato/core/helpers/integration/api'\nimport {\n createOrganizationInDb,\n deleteIntegrationCredentialsInDb,\n deleteOrganizationInDb,\n withClient,\n} from '@open-mercato/core/helpers/integration/dbFixtures'\nimport { getTokenScope } from '@open-mercato/core/helpers/integration/generalFixtures'\n\n/**\n * TC-STRIPE-001: Stripe charge webhooks drive the persisted gateway transaction\n *\n * Signed Stripe events are POSTed to the real `/api/payment_gateways/webhook/stripe` route, which\n * verifies the signature with the organization's saved credentials, locates the transaction by the\n * PaymentIntent the Charge references, and syncs it through the payment service and state machine.\n * Assertions read `gateway_transactions` and `gateway_webhook_events` in Postgres.\n *\n * Transactions are seeded with SQL: creating a real Stripe session needs a Stripe account. No\n * Stripe API is contacted \u2014 webhook verification is local HMAC. Covers partial \u2192 full refunds,\n * duplicate, stale and concurrent delivery, a refund that overtakes the capture, pre-Basil and\n * Basil partial-capture payloads, and two organizations holding a transaction for the same\n * PaymentIntent with their own webhook secrets.\n *\n * Targets the default inline processing, where every processed event advances `last_webhook_at`\n * (status-neutral deliveries are awaited through it). The async Stripe worker records nothing on the\n * transaction for status-neutral events; it and the failure \u2192 redelivery path are covered by\n * `__tests__/webhook-refund-ordering.test.ts` through the real route and payment service.\n *\n * ENVIRONMENT: API + raw `pg` against `DATABASE_URL`; run under a coherent app+DB stack\n * (`yarn test:integration` / `yarn test:integration:ephemeral`).\n */\n\nconst WEBHOOK_PATH = '/api/payment_gateways/webhook/stripe'\nconst LEGACY_API_VERSION = '2025-02-24.acacia'\nconst BASIL_API_VERSION = '2025-03-31.basil'\n\ntype Scope = { organizationId: string; tenantId: string }\n\ntype TransactionRow = {\n unified_status: string\n captured_amount: string\n gateway_status: string | null\n last_webhook_at: Date | null\n}\n\ntype CredentialsSnapshot = { id: string; credentials: unknown } | null\n\nconst stamp = `${Date.now()}_${randomUUID().slice(0, 8)}`\nconst webhookSecret = `whsec_tcstripe001_${stamp}`\nlet eventSequence = 0\n\nfunction nextEventId(): string {\n eventSequence += 1\n return `evt_tcstripe001_${stamp}_${eventSequence}`\n}\n\nfunction signedBody(type: string, object: Record<string, unknown>, apiVersion: string, eventId = nextEventId()): { eventId: string; body: string } {\n return {\n eventId,\n body: JSON.stringify({\n id: eventId,\n object: 'event',\n api_version: apiVersion,\n type,\n created: Math.floor(Date.now() / 1000),\n livemode: false,\n data: { object },\n }),\n }\n}\n\nfunction signatureHeader(body: string, secret: string): string {\n const timestamp = Math.floor(Date.now() / 1000)\n const signature = createHmac('sha256', secret).update(`${timestamp}.${body}`).digest('hex')\n return `t=${timestamp},v1=${signature}`\n}\n\nasync function postWebhook(request: APIRequestContext, body: string, secret = webhookSecret): Promise<number> {\n const response = await request.post(WEBHOOK_PATH, {\n headers: { 'content-type': 'application/json', 'stripe-signature': signatureHeader(body, secret) },\n data: body,\n })\n return response.status()\n}\n\nasync function deliver(\n request: APIRequestContext,\n type: string,\n object: Record<string, unknown>,\n apiVersion = LEGACY_API_VERSION,\n): Promise<{ eventId: string; body: string; status: number }> {\n const event = signedBody(type, object, apiVersion)\n return { ...event, status: await postWebhook(request, event.body) }\n}\n\nfunction charge(paymentIntentId: string, overrides: Record<string, unknown>): Record<string, unknown> {\n return {\n id: `ch_${paymentIntentId}`,\n object: 'charge',\n payment_intent: paymentIntentId,\n amount: 1000,\n amount_captured: 1000,\n amount_refunded: 0,\n captured: true,\n refunded: false,\n currency: 'usd',\n status: 'succeeded',\n ...overrides,\n }\n}\n\nasync function seedTransaction(scope: Scope, input: { paymentIntentId: string; status: string; capturedAmount: string }): Promise<string> {\n return withClient(async (client) => {\n const result = await client.query<{ id: string }>(\n `insert into gateway_transactions\n (id, payment_id, provider_key, provider_session_id, unified_status, amount, captured_amount, currency_code,\n organization_id, tenant_id, created_at, updated_at)\n values (gen_random_uuid(), gen_random_uuid(), 'stripe', $1, $2, 10, $3, 'USD', $4, $5, now(), now())\n returning id`,\n [input.paymentIntentId, input.status, input.capturedAmount, scope.organizationId, scope.tenantId],\n )\n return result.rows[0].id\n })\n}\n\nasync function readTransaction(id: string): Promise<TransactionRow> {\n return withClient(async (client) => {\n const result = await client.query<TransactionRow>(\n 'select unified_status, captured_amount::text as captured_amount, gateway_status, last_webhook_at from gateway_transactions where id = $1',\n [id],\n )\n return result.rows[0]\n })\n}\n\nasync function statusOf(id: string): Promise<string> {\n return (await readTransaction(id)).unified_status\n}\n\nasync function lastWebhookAt(id: string): Promise<number> {\n return (await readTransaction(id)).last_webhook_at?.getTime() ?? 0\n}\n\nasync function deliverAndWait(\n request: APIRequestContext,\n transactionId: string,\n type: string,\n object: Record<string, unknown>,\n apiVersion = LEGACY_API_VERSION,\n): Promise<void> {\n const before = await lastWebhookAt(transactionId)\n expect((await deliver(request, type, object, apiVersion)).status).toBe(202)\n await expect.poll(() => lastWebhookAt(transactionId)).toBeGreaterThan(before)\n}\n\nasync function countClaims(eventId: string): Promise<number> {\n return withClient(async (client) => {\n const result = await client.query<{ count: string }>(\n \"select count(*)::text as count from gateway_webhook_events where provider_key = 'stripe' and idempotency_key = $1\",\n [eventId],\n )\n return Number(result.rows[0].count)\n })\n}\n\nasync function snapshotCredentials(scope: Scope): Promise<CredentialsSnapshot> {\n return withClient(async (client) => {\n const result = await client.query<{ id: string; credentials: unknown }>(\n `select id, credentials from integration_credentials\n where integration_id = 'gateway_stripe' and organization_id = $1 and tenant_id = $2\n and user_id is null and deleted_at is null\n limit 1`,\n [scope.organizationId, scope.tenantId],\n )\n return result.rows[0] ?? null\n })\n}\n\nasync function restoreCredentials(scope: Scope, snapshot: CredentialsSnapshot): Promise<void> {\n await withClient(async (client) => {\n if (snapshot) {\n await client.query('update integration_credentials set credentials = $2::json where id = $1', [\n snapshot.id,\n JSON.stringify(snapshot.credentials),\n ])\n return\n }\n await client.query(\n `delete from integration_credentials\n where integration_id = 'gateway_stripe' and organization_id = $1 and tenant_id = $2 and user_id is null`,\n [scope.organizationId, scope.tenantId],\n )\n })\n}\n\ntest.describe('TC-STRIPE-001: Stripe charge webhooks drive the persisted gateway transaction', () => {\n let scope: Scope\n let credentialsSnapshot: CredentialsSnapshot = null\n const transactionIds: string[] = []\n let otherOrganizationId: string | null = null\n\n test.beforeAll(async ({ request }) => {\n const token = await getAuthToken(request, 'admin')\n const tokenScope = getTokenScope(token)\n scope = { organizationId: tokenScope.organizationId, tenantId: tokenScope.tenantId }\n credentialsSnapshot = await snapshotCredentials(scope)\n const response = await apiRequest(request, 'PUT', '/api/integrations/gateway_stripe/credentials', {\n token,\n data: {\n credentials: {\n publishableKey: 'pk_test_tcstripe001',\n secretKey: 'sk_test_tcstripe001',\n webhookSecret,\n },\n },\n })\n expect(response.status(), await response.text()).toBe(200)\n })\n\n test.afterAll(async () => {\n await withClient(async (client) => {\n if (transactionIds.length > 0) {\n await client.query('delete from gateway_transactions where id = any($1::uuid[])', [transactionIds])\n }\n await client.query(\"delete from gateway_webhook_events where provider_key = 'stripe' and idempotency_key like $1\", [\n `evt_tcstripe001_${stamp}_%`,\n ])\n })\n if (scope) await restoreCredentials(scope, credentialsSnapshot)\n await deleteIntegrationCredentialsInDb(otherOrganizationId)\n await deleteOrganizationInDb(otherOrganizationId)\n })\n\n async function seed(status: string, capturedAmount = status === 'captured' ? '10' : '0'): Promise<{ id: string; paymentIntentId: string }> {\n const paymentIntentId = `pi_tcstripe001_${stamp}_${transactionIds.length + 1}`\n const id = await seedTransaction(scope, { paymentIntentId, status, capturedAmount })\n transactionIds.push(id)\n return { id, paymentIntentId }\n }\n\n test('moves a captured payment from partial to full refund, once per event, and keeps it refunded on a stale partial', async ({ request }) => {\n const { id, paymentIntentId } = await seed('captured')\n\n const firstPartial = await deliver(request, 'charge.refunded', charge(paymentIntentId, { amount_refunded: 400 }))\n expect(firstPartial.status).toBe(202)\n await expect.poll(() => statusOf(id)).toBe('partially_refunded')\n expect((await readTransaction(id)).gateway_status).toBe('charge.refunded')\n\n expect(await postWebhook(request, firstPartial.body)).toBe(202)\n expect(await countClaims(firstPartial.eventId)).toBeGreaterThanOrEqual(1)\n expect(await statusOf(id)).toBe('partially_refunded')\n\n await deliverAndWait(request, id, 'charge.refunded', charge(paymentIntentId, { amount_refunded: 700 }))\n expect(await statusOf(id)).toBe('partially_refunded')\n expect((await deliver(request, 'charge.refunded', charge(paymentIntentId, { amount_refunded: 1000, refunded: true }))).status).toBe(202)\n await expect.poll(() => statusOf(id)).toBe('refunded')\n\n await deliverAndWait(request, id, 'charge.refunded', charge(paymentIntentId, { amount_refunded: 400 }))\n expect(await statusOf(id)).toBe('refunded')\n })\n\n test('records a refund that overtakes the capture and ignores the late payment_intent.succeeded', async ({ request }) => {\n const { id, paymentIntentId } = await seed('pending')\n\n expect((await deliver(request, 'charge.refunded', charge(paymentIntentId, { amount_refunded: 400 }))).status).toBe(202)\n await expect.poll(() => statusOf(id)).toBe('partially_refunded')\n expect(Number((await readTransaction(id)).captured_amount)).toBe(10)\n\n await deliverAndWait(request, id, 'payment_intent.succeeded', {\n id: paymentIntentId, object: 'payment_intent', status: 'succeeded', amount: 1000, amount_received: 1000,\n })\n expect(await statusOf(id)).toBe('partially_refunded')\n\n expect((await deliver(request, 'charge.refunded', charge(paymentIntentId, { amount_refunded: 1000, refunded: true }))).status).toBe(202)\n await expect.poll(() => statusOf(id)).toBe('refunded')\n })\n\n test('reads a pre-Basil partial capture: the uncaptured remainder is not a refund', async ({ request }) => {\n const { id, paymentIntentId } = await seed('partially_captured', '6')\n const partialCapture = { amount_captured: 600 }\n\n await deliverAndWait(request, id, 'charge.refunded', charge(paymentIntentId, { ...partialCapture, amount_refunded: 400 }), LEGACY_API_VERSION)\n expect(await statusOf(id)).toBe('partially_captured')\n\n await deliver(request, 'charge.refunded', charge(paymentIntentId, { ...partialCapture, amount_refunded: 700 }), LEGACY_API_VERSION)\n await expect.poll(() => statusOf(id)).toBe('partially_refunded')\n await deliver(request, 'charge.refunded', charge(paymentIntentId, { ...partialCapture, amount_refunded: 1000, refunded: true }), LEGACY_API_VERSION)\n await expect.poll(() => statusOf(id)).toBe('refunded')\n expect(Number((await readTransaction(id)).captured_amount)).toBe(6)\n })\n\n test('reads a Basil partial capture: a refund of 3 out of 6 captured is a partial refund', async ({ request }) => {\n const { id, paymentIntentId } = await seed('partially_captured', '6')\n const partialCapture = { amount_captured: 600 }\n\n await deliver(request, 'charge.refunded', charge(paymentIntentId, { ...partialCapture, amount_refunded: 300 }), BASIL_API_VERSION)\n await expect.poll(() => statusOf(id)).toBe('partially_refunded')\n await deliver(request, 'charge.refunded', charge(paymentIntentId, { ...partialCapture, amount_refunded: 600, refunded: true }), BASIL_API_VERSION)\n await expect.poll(() => statusOf(id)).toBe('refunded')\n })\n\n test('applies concurrent refund and capture deliveries without losing the refund', async ({ request }) => {\n const pairs: Array<{ id: string; paymentIntentId: string }> = []\n for (let index = 0; index < 15; index += 1) pairs.push(await seed('captured'))\n const refundDeliveries = await Promise.all(pairs.flatMap(({ paymentIntentId }) => [\n deliver(request, 'charge.refunded', charge(paymentIntentId, { amount_refunded: 400 })),\n deliver(request, 'charge.refunded', charge(paymentIntentId, { amount_refunded: 1000, refunded: true })),\n ]))\n expect(refundDeliveries.map((delivery) => delivery.status)).toEqual(refundDeliveries.map(() => 202))\n for (const { id } of pairs) {\n await expect.poll(() => statusOf(id)).toBe('refunded')\n }\n\n const pending = [await seed('pending'), await seed('pending'), await seed('pending')]\n const captureRaceDeliveries = await Promise.all(pending.flatMap(({ paymentIntentId }) => [\n deliver(request, 'charge.refunded', charge(paymentIntentId, { amount_refunded: 400 })),\n deliver(request, 'payment_intent.succeeded', {\n id: paymentIntentId, object: 'payment_intent', status: 'succeeded', amount: 1000, amount_received: 1000,\n }),\n ]))\n expect(captureRaceDeliveries.map((delivery) => delivery.status)).toEqual(captureRaceDeliveries.map(() => 202))\n for (const { id } of pending) {\n await expect.poll(() => statusOf(id)).toBe('partially_refunded')\n }\n })\n\n test('changes only the transaction of the organization whose secret signed the event', async ({ request }) => {\n const { id, paymentIntentId } = await seed('captured')\n otherOrganizationId = await createOrganizationInDb({ name: `TC-STRIPE-001 other ${stamp}`, tenantId: scope.tenantId })\n const superadminToken = await getAuthToken(request, 'superadmin')\n const otherSecret = `whsec_tcstripe001_other_${stamp}`\n const saved = await apiRequest(request, 'PUT', '/api/integrations/gateway_stripe/credentials', {\n token: superadminToken,\n headers: {\n Cookie: `om_selected_tenant=${encodeURIComponent(scope.tenantId)}; om_selected_org=${encodeURIComponent(otherOrganizationId)}`,\n },\n data: { credentials: { publishableKey: 'pk_test_tcstripe001_other', secretKey: 'sk_test_tcstripe001_other', webhookSecret: otherSecret } },\n })\n expect(saved.status(), await saved.text()).toBe(200)\n const otherId = await seedTransaction(\n { organizationId: otherOrganizationId, tenantId: scope.tenantId },\n { paymentIntentId, status: 'captured', capturedAmount: '10' },\n )\n transactionIds.push(otherId)\n\n const forged = signedBody('charge.refunded', charge(paymentIntentId, { amount_refunded: 1000, refunded: true }), LEGACY_API_VERSION)\n expect(await postWebhook(request, forged.body, `whsec_forged_${stamp}`)).toBe(401)\n expect(await statusOf(id)).toBe('captured')\n expect(await statusOf(otherId)).toBe('captured')\n\n const signedByOther = signedBody('charge.refunded', charge(paymentIntentId, { amount_refunded: 400 }), LEGACY_API_VERSION)\n expect(await postWebhook(request, signedByOther.body, otherSecret)).toBe(202)\n await expect.poll(() => statusOf(otherId)).toBe('partially_refunded')\n expect(await statusOf(id)).toBe('captured')\n\n expect((await deliver(request, 'charge.refunded', charge(paymentIntentId, { amount_refunded: 1000, refunded: true }))).status).toBe(202)\n await expect.poll(() => statusOf(id)).toBe('refunded')\n expect(await statusOf(otherId)).toBe('partially_refunded')\n })\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,YAAY,kBAAkB;AACvC,SAAS,QAAQ,YAAoC;AACrD,SAAS,YAAY,oBAAoB;AACzC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB;AAyB9B,MAAM,eAAe;AACrB,MAAM,qBAAqB;AAC3B,MAAM,oBAAoB;AAa1B,MAAM,QAAQ,GAAG,KAAK,IAAI,CAAC,IAAI,WAAW,EAAE,MAAM,GAAG,CAAC,CAAC;AACvD,MAAM,gBAAgB,qBAAqB,KAAK;AAChD,IAAI,gBAAgB;AAEpB,SAAS,cAAsB;AAC7B,mBAAiB;AACjB,SAAO,mBAAmB,KAAK,IAAI,aAAa;AAClD;AAEA,SAAS,WAAW,MA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,WAAO,MAAM,SAAS,EAAE,CAAC,EAAE,KAAK,UAAU;AAE1C,YAAQ,MAAM,QAAQ,SAAS,mBAAmB,OAAO,iBAAiB,EAAE,iBAAiB,KAAM,UAAU,KAAK,CAAC,CAAC,GAAG,MAAM,EAAE,KAAK,GAAG;AACvI,UAAM,OAAO,KAAK,MAAM,SAAS,EAAE,CAAC,EAAE,KAAK,UAAU;AACrD,WAAO,MAAM,SAAS,OAAO,CAAC,EAAE,KAAK,oBAAoB;AAAA,EAC3D,CAAC;AACH,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/gateway_stripe/__integration__/meta.ts"],
|
|
4
|
+
"sourcesContent": ["export const integrationMeta = {\n dependsOnModules: ['payment_gateways', 'gateway_stripe'],\n}\n\nexport default integrationMeta\n"],
|
|
5
|
+
"mappings": "AAAO,MAAM,kBAAkB;AAAA,EAC7B,kBAAkB,CAAC,oBAAoB,gBAAgB;AACzD;AAEA,IAAO,eAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolveStripeClient } from "../client.js";
|
|
2
|
-
import { mapRefundReason,
|
|
2
|
+
import { mapRefundReason, mapStripeAdapterStatus, mapStripeStatus } from "../status-map.js";
|
|
3
3
|
import {
|
|
4
4
|
toCents,
|
|
5
5
|
fromCents,
|
|
@@ -103,12 +103,8 @@ const stripeAdapterV20231016 = {
|
|
|
103
103
|
async verifyWebhook(input) {
|
|
104
104
|
return verifyStripeWebhook(input);
|
|
105
105
|
},
|
|
106
|
-
mapStatus(providerStatus, eventType) {
|
|
107
|
-
|
|
108
|
-
const mappedEvent = mapWebhookEventToStatus(eventType);
|
|
109
|
-
if (mappedEvent) return mappedEvent;
|
|
110
|
-
}
|
|
111
|
-
return mapStripeStatus(providerStatus);
|
|
106
|
+
mapStatus(providerStatus, eventType, event) {
|
|
107
|
+
return mapStripeAdapterStatus(providerStatus, eventType, event);
|
|
112
108
|
}
|
|
113
109
|
};
|
|
114
110
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/modules/gateway_stripe/lib/adapters/v2023-10-16.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n GatewayAdapter,\n CreateSessionInput,\n CreateSessionResult,\n CaptureInput,\n CaptureResult,\n RefundInput,\n RefundResult,\n CancelInput,\n CancelResult,\n GetStatusInput,\n GatewayPaymentStatus,\n VerifyWebhookInput,\n WebhookEvent,\n UnifiedPaymentStatus,\n} from '@open-mercato/shared/modules/payment_gateways/types'\nimport { resolveStripeClient } from '../client'\nimport { mapRefundReason,
|
|
5
|
-
"mappings": "AAgBA,SAAS,2BAA2B;AACpC,SAAS,iBAAiB,
|
|
4
|
+
"sourcesContent": ["import type {\n GatewayAdapter,\n CreateSessionInput,\n CreateSessionResult,\n CaptureInput,\n CaptureResult,\n RefundInput,\n RefundResult,\n CancelInput,\n CancelResult,\n GetStatusInput,\n GatewayPaymentStatus,\n VerifyWebhookInput,\n WebhookEvent,\n UnifiedPaymentStatus,\n} from '@open-mercato/shared/modules/payment_gateways/types'\nimport { resolveStripeClient } from '../client'\nimport { mapRefundReason, mapStripeAdapterStatus, mapStripeStatus } from '../status-map'\nimport {\n toCents,\n fromCents,\n buildStripeMetadata,\n normalizeStripePaymentElementSettings,\n resolveStripeRendererKey,\n resolveStripeRefundStatus,\n stripeIdempotencyOptions,\n} from '../shared'\nimport { verifyStripeWebhook } from '../webhook-handler'\n\nexport const stripeAdapterV20231016: GatewayAdapter = {\n providerKey: 'stripe',\n\n async createSession(input: CreateSessionInput): Promise<CreateSessionResult> {\n const stripe = resolveStripeClient(input.credentials, '2023-10-16')\n const rendererKey = resolveStripeRendererKey(input.presentation)\n const rendererSettings = normalizeStripePaymentElementSettings(input.presentation?.rendererSettings)\n\n const paymentIntent = await stripe.paymentIntents.create({\n amount: toCents(input.amount, input.currencyCode),\n currency: input.currencyCode.toLowerCase(),\n capture_method: input.captureMethod ?? 'automatic',\n metadata: buildStripeMetadata({\n paymentId: input.paymentId,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n orderId: input.orderId,\n }),\n payment_method_types: input.paymentTypes ?? ['card'],\n description: input.description,\n }, input.idempotencyKey ? { idempotencyKey: input.idempotencyKey } : undefined)\n\n return {\n sessionId: paymentIntent.id,\n clientSecret: paymentIntent.client_secret ?? undefined,\n status: mapStripeStatus(paymentIntent.status),\n providerData: {\n paymentIntentId: paymentIntent.id,\n publishableKey: typeof input.credentials.publishableKey === 'string'\n ? input.credentials.publishableKey\n : undefined,\n },\n clientSession: paymentIntent.client_secret && typeof input.credentials.publishableKey === 'string'\n ? {\n type: 'embedded',\n rendererKey,\n payload: {\n clientSecret: paymentIntent.client_secret,\n publishableKey: input.credentials.publishableKey,\n },\n settings: rendererSettings,\n }\n : undefined,\n }\n },\n\n async capture(input: CaptureInput): Promise<CaptureResult> {\n const stripe = resolveStripeClient(input.credentials, '2023-10-16')\n const paymentIntent = input.amount\n ? await stripe.paymentIntents.retrieve(input.sessionId)\n : null\n const captured = await stripe.paymentIntents.capture(\n input.sessionId,\n {\n amount_to_capture: input.amount && paymentIntent\n ? toCents(input.amount, paymentIntent.currency)\n : undefined,\n },\n stripeIdempotencyOptions(input.idempotencyKey),\n )\n return {\n status: mapStripeStatus(captured.status),\n capturedAmount: fromCents(captured.amount_received, captured.currency),\n providerData: { chargeId: captured.latest_charge },\n }\n },\n\n async refund(input: RefundInput): Promise<RefundResult> {\n const stripe = resolveStripeClient(input.credentials, '2023-10-16')\n const paymentIntent = input.amount\n ? await stripe.paymentIntents.retrieve(input.sessionId)\n : null\n const refund = await stripe.refunds.create(\n {\n payment_intent: input.sessionId,\n amount: input.amount && paymentIntent\n ? toCents(input.amount, paymentIntent.currency)\n : undefined,\n reason: mapRefundReason(input.reason),\n },\n stripeIdempotencyOptions(input.idempotencyKey),\n )\n return {\n refundId: refund.id,\n status: await resolveStripeRefundStatus(stripe, refund, paymentIntent?.amount_received),\n refundedAmount: fromCents(refund.amount, refund.currency),\n }\n },\n\n async cancel(input: CancelInput): Promise<CancelResult> {\n const stripe = resolveStripeClient(input.credentials, '2023-10-16')\n const cancelled = await stripe.paymentIntents.cancel(\n input.sessionId,\n {},\n stripeIdempotencyOptions(input.idempotencyKey),\n )\n return { status: mapStripeStatus(cancelled.status) }\n },\n\n async getStatus(input: GetStatusInput): Promise<GatewayPaymentStatus> {\n const stripe = resolveStripeClient(input.credentials, '2023-10-16')\n const pi = await stripe.paymentIntents.retrieve(input.sessionId)\n return {\n status: mapStripeStatus(pi.status),\n amount: fromCents(pi.amount, pi.currency),\n amountReceived: fromCents(pi.amount_received, pi.currency),\n currencyCode: pi.currency.toUpperCase(),\n }\n },\n\n async verifyWebhook(input: VerifyWebhookInput): Promise<WebhookEvent> {\n return verifyStripeWebhook(input)\n },\n\n mapStatus(providerStatus: string, eventType?: string, event?: WebhookEvent): UnifiedPaymentStatus {\n return mapStripeAdapterStatus(providerStatus, eventType, event)\n },\n}\n"],
|
|
5
|
+
"mappings": "AAgBA,SAAS,2BAA2B;AACpC,SAAS,iBAAiB,wBAAwB,uBAAuB;AACzE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,2BAA2B;AAE7B,MAAM,yBAAyC;AAAA,EACpD,aAAa;AAAA,EAEb,MAAM,cAAc,OAAyD;AAC3E,UAAM,SAAS,oBAAoB,MAAM,aAAa,YAAY;AAClE,UAAM,cAAc,yBAAyB,MAAM,YAAY;AAC/D,UAAM,mBAAmB,sCAAsC,MAAM,cAAc,gBAAgB;AAEnG,UAAM,gBAAgB,MAAM,OAAO,eAAe,OAAO;AAAA,MACvD,QAAQ,QAAQ,MAAM,QAAQ,MAAM,YAAY;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AAAA,MACzD,cAAc,GAAG,SAAS,YAAY;AAAA,IACxC;AAAA,EACF;AAAA,EAEA,MAAM,cAAc,OAAkD;AACpE,WAAO,oBAAoB,KAAK;AAAA,EAClC;AAAA,EAEA,UAAU,gBAAwB,WAAoB,OAA4C;AAChG,WAAO,uBAAuB,gBAAgB,WAAW,KAAK;AAAA,EAChE;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolveStripeClient } from "../client.js";
|
|
2
|
-
import { mapRefundReason,
|
|
2
|
+
import { mapRefundReason, mapStripeAdapterStatus, mapStripeStatus } from "../status-map.js";
|
|
3
3
|
import {
|
|
4
4
|
toCents,
|
|
5
5
|
fromCents,
|
|
@@ -109,12 +109,8 @@ const stripeAdapterV20241218 = {
|
|
|
109
109
|
async verifyWebhook(input) {
|
|
110
110
|
return verifyStripeWebhook(input);
|
|
111
111
|
},
|
|
112
|
-
mapStatus(providerStatus, eventType) {
|
|
113
|
-
|
|
114
|
-
const mappedEvent = mapWebhookEventToStatus(eventType);
|
|
115
|
-
if (mappedEvent) return mappedEvent;
|
|
116
|
-
}
|
|
117
|
-
return mapStripeStatus(providerStatus);
|
|
112
|
+
mapStatus(providerStatus, eventType, event) {
|
|
113
|
+
return mapStripeAdapterStatus(providerStatus, eventType, event);
|
|
118
114
|
}
|
|
119
115
|
};
|
|
120
116
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/modules/gateway_stripe/lib/adapters/v2024-12-18.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n GatewayAdapter,\n CreateSessionInput,\n CreateSessionResult,\n CaptureInput,\n CaptureResult,\n RefundInput,\n RefundResult,\n CancelInput,\n CancelResult,\n GetStatusInput,\n GatewayPaymentStatus,\n VerifyWebhookInput,\n WebhookEvent,\n UnifiedPaymentStatus,\n} from '@open-mercato/shared/modules/payment_gateways/types'\nimport { resolveStripeClient } from '../client'\nimport { mapRefundReason,
|
|
5
|
-
"mappings": "AAgBA,SAAS,2BAA2B;AACpC,SAAS,iBAAiB,
|
|
4
|
+
"sourcesContent": ["import type {\n GatewayAdapter,\n CreateSessionInput,\n CreateSessionResult,\n CaptureInput,\n CaptureResult,\n RefundInput,\n RefundResult,\n CancelInput,\n CancelResult,\n GetStatusInput,\n GatewayPaymentStatus,\n VerifyWebhookInput,\n WebhookEvent,\n UnifiedPaymentStatus,\n} from '@open-mercato/shared/modules/payment_gateways/types'\nimport { resolveStripeClient } from '../client'\nimport { mapRefundReason, mapStripeAdapterStatus, mapStripeStatus } from '../status-map'\nimport {\n toCents,\n fromCents,\n buildStripeMetadata,\n normalizeStripePaymentElementSettings,\n resolveStripeRendererKey,\n resolveStripeRefundStatus,\n stripeIdempotencyOptions,\n} from '../shared'\nimport { verifyStripeWebhook } from '../webhook-handler'\n\nconst STRIPE_API_VERSION = '2024-12-18'\n\nexport const stripeAdapterV20241218: GatewayAdapter = {\n providerKey: 'stripe',\n\n async createSession(input: CreateSessionInput): Promise<CreateSessionResult> {\n const stripe = resolveStripeClient(input.credentials, STRIPE_API_VERSION)\n const rendererKey = resolveStripeRendererKey(input.presentation)\n const rendererSettings = normalizeStripePaymentElementSettings(input.presentation?.rendererSettings)\n\n const paymentIntent = await stripe.paymentIntents.create({\n amount: toCents(input.amount, input.currencyCode),\n currency: input.currencyCode.toLowerCase(),\n capture_method: input.captureMethod ?? 'automatic',\n metadata: buildStripeMetadata({\n paymentId: input.paymentId,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n orderId: input.orderId,\n }),\n payment_method_types: input.paymentTypes ?? ['card'],\n description: input.description,\n }, input.idempotencyKey ? { idempotencyKey: input.idempotencyKey } : undefined)\n\n return {\n sessionId: paymentIntent.id,\n clientSecret: paymentIntent.client_secret ?? undefined,\n status: mapStripeStatus(paymentIntent.status),\n providerData: {\n paymentIntentId: paymentIntent.id,\n publishableKey: typeof input.credentials.publishableKey === 'string'\n ? input.credentials.publishableKey\n : undefined,\n },\n clientSession: paymentIntent.client_secret && typeof input.credentials.publishableKey === 'string'\n ? {\n type: 'embedded',\n rendererKey,\n payload: {\n clientSecret: paymentIntent.client_secret,\n publishableKey: input.credentials.publishableKey,\n },\n settings: rendererSettings,\n }\n : undefined,\n }\n },\n\n async capture(input: CaptureInput): Promise<CaptureResult> {\n const stripe = resolveStripeClient(input.credentials, STRIPE_API_VERSION)\n const paymentIntent = input.amount\n ? await stripe.paymentIntents.retrieve(input.sessionId)\n : null\n\n const captured = await stripe.paymentIntents.capture(\n input.sessionId,\n {\n amount_to_capture: input.amount && paymentIntent\n ? toCents(input.amount, paymentIntent.currency)\n : undefined,\n },\n stripeIdempotencyOptions(input.idempotencyKey),\n )\n\n const capturedCurrencyCode = captured.currency.toUpperCase()\n\n return {\n status: mapStripeStatus(captured.status),\n capturedAmount: fromCents(captured.amount_received, capturedCurrencyCode),\n providerData: { chargeId: captured.latest_charge },\n }\n },\n\n async refund(input: RefundInput): Promise<RefundResult> {\n const stripe = resolveStripeClient(input.credentials, STRIPE_API_VERSION)\n const paymentIntent = input.amount\n ? await stripe.paymentIntents.retrieve(input.sessionId)\n : null\n\n const refund = await stripe.refunds.create(\n {\n payment_intent: input.sessionId,\n amount: input.amount && paymentIntent\n ? toCents(input.amount, paymentIntent.currency)\n : undefined,\n reason: mapRefundReason(input.reason),\n metadata: input.metadata as Record<string, string> | undefined,\n },\n stripeIdempotencyOptions(input.idempotencyKey),\n )\n\n const refundCurrencyCode = refund.currency.toUpperCase()\n\n return {\n refundId: refund.id,\n status: await resolveStripeRefundStatus(stripe, refund, paymentIntent?.amount_received),\n refundedAmount: fromCents(refund.amount, refundCurrencyCode),\n }\n },\n\n async cancel(input: CancelInput): Promise<CancelResult> {\n const stripe = resolveStripeClient(input.credentials, STRIPE_API_VERSION)\n\n const cancelled = await stripe.paymentIntents.cancel(\n input.sessionId,\n { cancellation_reason: 'requested_by_customer' },\n stripeIdempotencyOptions(input.idempotencyKey),\n )\n\n return {\n status: mapStripeStatus(cancelled.status),\n }\n },\n\n async getStatus(input: GetStatusInput): Promise<GatewayPaymentStatus> {\n const stripe = resolveStripeClient(input.credentials, STRIPE_API_VERSION)\n\n const pi = await stripe.paymentIntents.retrieve(input.sessionId)\n return {\n status: mapStripeStatus(pi.status),\n amount: fromCents(pi.amount, pi.currency),\n amountReceived: fromCents(pi.amount_received, pi.currency),\n currencyCode: pi.currency.toUpperCase(),\n }\n },\n\n async verifyWebhook(input: VerifyWebhookInput): Promise<WebhookEvent> {\n return verifyStripeWebhook(input)\n },\n\n mapStatus(providerStatus: string, eventType?: string, event?: WebhookEvent): UnifiedPaymentStatus {\n return mapStripeAdapterStatus(providerStatus, eventType, event)\n },\n}\n"],
|
|
5
|
+
"mappings": "AAgBA,SAAS,2BAA2B;AACpC,SAAS,iBAAiB,wBAAwB,uBAAuB;AACzE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,2BAA2B;AAEpC,MAAM,qBAAqB;AAEpB,MAAM,yBAAyC;AAAA,EACpD,aAAa;AAAA,EAEb,MAAM,cAAc,OAAyD;AAC3E,UAAM,SAAS,oBAAoB,MAAM,aAAa,kBAAkB;AACxE,UAAM,cAAc,yBAAyB,MAAM,YAAY;AAC/D,UAAM,mBAAmB,sCAAsC,MAAM,cAAc,gBAAgB;AAEnG,UAAM,gBAAgB,MAAM,OAAO,eAAe,OAAO;AAAA,MACvD,QAAQ,QAAQ,MAAM,QAAQ,MAAM,YAAY;AAAA,MAChD,UAAU,MAAM,aAAa,YAAY;AAAA,MACzC,gBAAgB,MAAM,iBAAiB;AAAA,MACvC,UAAU,oBAAoB;AAAA,QAC5B,WAAW,MAAM;AAAA,QACjB,UAAU,MAAM;AAAA,QAChB,gBAAgB,MAAM;AAAA,QACtB,SAAS,MAAM;AAAA,MACjB,CAAC;AAAA,MACD,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kD;AACpE,WAAO,oBAAoB,KAAK;AAAA,EAClC;AAAA,EAEA,UAAU,gBAAwB,WAAoB,OAA4C;AAChG,WAAO,uBAAuB,gBAAgB,WAAW,KAAK;AAAA,EAChE;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolveStripeClient } from "../client.js";
|
|
2
|
-
import { mapRefundReason,
|
|
2
|
+
import { mapRefundReason, mapStripeAdapterStatus, mapStripeStatus } from "../status-map.js";
|
|
3
3
|
import {
|
|
4
4
|
toCents,
|
|
5
5
|
fromCents,
|
|
@@ -107,12 +107,8 @@ const stripeAdapterV20250224Acacia = {
|
|
|
107
107
|
async verifyWebhook(input) {
|
|
108
108
|
return verifyStripeWebhook(input);
|
|
109
109
|
},
|
|
110
|
-
mapStatus(providerStatus, eventType) {
|
|
111
|
-
|
|
112
|
-
const mappedEvent = mapWebhookEventToStatus(eventType);
|
|
113
|
-
if (mappedEvent) return mappedEvent;
|
|
114
|
-
}
|
|
115
|
-
return mapStripeStatus(providerStatus);
|
|
110
|
+
mapStatus(providerStatus, eventType, event) {
|
|
111
|
+
return mapStripeAdapterStatus(providerStatus, eventType, event);
|
|
116
112
|
}
|
|
117
113
|
};
|
|
118
114
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/modules/gateway_stripe/lib/adapters/v2025-02-24.acacia.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n GatewayAdapter,\n CreateSessionInput,\n CreateSessionResult,\n CaptureInput,\n CaptureResult,\n RefundInput,\n RefundResult,\n CancelInput,\n CancelResult,\n GetStatusInput,\n GatewayPaymentStatus,\n VerifyWebhookInput,\n WebhookEvent,\n UnifiedPaymentStatus,\n} from '@open-mercato/shared/modules/payment_gateways/types'\nimport { resolveStripeClient } from '../client'\nimport { mapRefundReason,
|
|
5
|
-
"mappings": "AAgBA,SAAS,2BAA2B;AACpC,SAAS,iBAAiB,
|
|
4
|
+
"sourcesContent": ["import type {\n GatewayAdapter,\n CreateSessionInput,\n CreateSessionResult,\n CaptureInput,\n CaptureResult,\n RefundInput,\n RefundResult,\n CancelInput,\n CancelResult,\n GetStatusInput,\n GatewayPaymentStatus,\n VerifyWebhookInput,\n WebhookEvent,\n UnifiedPaymentStatus,\n} from '@open-mercato/shared/modules/payment_gateways/types'\nimport { resolveStripeClient } from '../client'\nimport { mapRefundReason, mapStripeAdapterStatus, mapStripeStatus } from '../status-map'\nimport {\n toCents,\n fromCents,\n buildStripeMetadata,\n normalizeStripePaymentElementSettings,\n resolveStripeRendererKey,\n resolveStripeRefundStatus,\n stripeIdempotencyOptions,\n} from '../shared'\nimport { verifyStripeWebhook } from '../webhook-handler'\n\nconst STRIPE_API_VERSION = '2025-02-24.acacia'\n\nexport const stripeAdapterV20250224Acacia: GatewayAdapter = {\n providerKey: 'stripe',\n\n async createSession(input: CreateSessionInput): Promise<CreateSessionResult> {\n const stripe = resolveStripeClient(input.credentials, STRIPE_API_VERSION)\n const rendererKey = resolveStripeRendererKey(input.presentation)\n const rendererSettings = normalizeStripePaymentElementSettings(input.presentation?.rendererSettings)\n\n const paymentIntent = await stripe.paymentIntents.create({\n amount: toCents(input.amount, input.currencyCode),\n currency: input.currencyCode.toLowerCase(),\n capture_method: input.captureMethod ?? 'automatic',\n metadata: buildStripeMetadata({\n paymentId: input.paymentId,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n orderId: input.orderId,\n }),\n payment_method_types: input.paymentTypes ?? ['card'],\n description: input.description,\n }, input.idempotencyKey ? { idempotencyKey: input.idempotencyKey } : undefined)\n\n return {\n sessionId: paymentIntent.id,\n clientSecret: paymentIntent.client_secret ?? undefined,\n status: mapStripeStatus(paymentIntent.status),\n providerData: {\n paymentIntentId: paymentIntent.id,\n publishableKey: typeof input.credentials.publishableKey === 'string'\n ? input.credentials.publishableKey\n : undefined,\n },\n clientSession: paymentIntent.client_secret && typeof input.credentials.publishableKey === 'string'\n ? {\n type: 'embedded',\n rendererKey,\n payload: {\n clientSecret: paymentIntent.client_secret,\n publishableKey: input.credentials.publishableKey,\n },\n settings: rendererSettings,\n }\n : undefined,\n }\n },\n\n async capture(input: CaptureInput): Promise<CaptureResult> {\n const stripe = resolveStripeClient(input.credentials, STRIPE_API_VERSION)\n const paymentIntent = input.amount\n ? await stripe.paymentIntents.retrieve(input.sessionId)\n : null\n\n const captured = await stripe.paymentIntents.capture(\n input.sessionId,\n {\n amount_to_capture: input.amount && paymentIntent\n ? toCents(input.amount, paymentIntent.currency)\n : undefined,\n },\n stripeIdempotencyOptions(input.idempotencyKey),\n )\n\n return {\n status: mapStripeStatus(captured.status),\n capturedAmount: fromCents(captured.amount_received, captured.currency),\n providerData: { chargeId: captured.latest_charge },\n }\n },\n\n async refund(input: RefundInput): Promise<RefundResult> {\n const stripe = resolveStripeClient(input.credentials, STRIPE_API_VERSION)\n const paymentIntent = input.amount\n ? await stripe.paymentIntents.retrieve(input.sessionId)\n : null\n\n const refund = await stripe.refunds.create(\n {\n payment_intent: input.sessionId,\n amount: input.amount && paymentIntent\n ? toCents(input.amount, paymentIntent.currency)\n : undefined,\n reason: mapRefundReason(input.reason),\n metadata: input.metadata as Record<string, string> | undefined,\n },\n stripeIdempotencyOptions(input.idempotencyKey),\n )\n\n return {\n refundId: refund.id,\n status: await resolveStripeRefundStatus(stripe, refund, paymentIntent?.amount_received),\n refundedAmount: fromCents(refund.amount, refund.currency),\n }\n },\n\n async cancel(input: CancelInput): Promise<CancelResult> {\n const stripe = resolveStripeClient(input.credentials, STRIPE_API_VERSION)\n\n const cancelled = await stripe.paymentIntents.cancel(\n input.sessionId,\n { cancellation_reason: 'requested_by_customer' },\n stripeIdempotencyOptions(input.idempotencyKey),\n )\n\n return {\n status: mapStripeStatus(cancelled.status),\n }\n },\n\n async getStatus(input: GetStatusInput): Promise<GatewayPaymentStatus> {\n const stripe = resolveStripeClient(input.credentials, STRIPE_API_VERSION)\n\n const pi = await stripe.paymentIntents.retrieve(input.sessionId)\n return {\n status: mapStripeStatus(pi.status),\n amount: fromCents(pi.amount, pi.currency),\n amountReceived: fromCents(pi.amount_received, pi.currency),\n currencyCode: pi.currency.toUpperCase(),\n }\n },\n\n async verifyWebhook(input: VerifyWebhookInput): Promise<WebhookEvent> {\n return verifyStripeWebhook(input)\n },\n\n mapStatus(providerStatus: string, eventType?: string, event?: WebhookEvent): UnifiedPaymentStatus {\n return mapStripeAdapterStatus(providerStatus, eventType, event)\n },\n}\n"],
|
|
5
|
+
"mappings": "AAgBA,SAAS,2BAA2B;AACpC,SAAS,iBAAiB,wBAAwB,uBAAuB;AACzE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,2BAA2B;AAEpC,MAAM,qBAAqB;AAEpB,MAAM,+BAA+C;AAAA,EAC1D,aAAa;AAAA,EAEb,MAAM,cAAc,OAAyD;AAC3E,UAAM,SAAS,oBAAoB,MAAM,aAAa,kBAAkB;AACxE,UAAM,cAAc,yBAAyB,MAAM,YAAY;AAC/D,UAAM,mBAAmB,sCAAsC,MAAM,cAAc,gBAAgB;AAEnG,UAAM,gBAAgB,MAAM,OAAO,eAAe,OAAO;AAAA,MACvD,QAAQ,QAAQ,MAAM,QAAQ,MAAM,YAAY;AAAA,MAChD,UAAU,MAAM,aAAa,YAAY;AAAA,MACzC,gBAAgB,MAAM,iBAAiB;AAAA,MACvC,UAAU,oBAAoB;AAAA,QAC5B,WAAW,MAAM;AAAA,QACjB,UAAU,MAAM;AAAA,QAChB,gBAAgB,MAAM;AAAA,QACtB,SAAS,MAAM;AAAA,MACjB,CAAC;AAAA,MACD,sBAAsB,MAAM,gBAAgB,CAAC,MAAM;AAAA,MACnD,aAAa,MAAM;AAAA,IACrB,GAAG,MAAM,iBAAiB,EAAE,gBAAgB,MAAM,eAAe,IAAI,MAAS;AAE9E,WAAO;AAA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