@plumbus/payments-stripe 0.2.0
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/CHANGELOG.md +21 -0
- package/README.md +60 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/catalog.d.ts +14 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +286 -0
- package/dist/catalog.js.map +1 -0
- package/dist/charges.d.ts +64 -0
- package/dist/charges.d.ts.map +1 -0
- package/dist/charges.js +339 -0
- package/dist/charges.js.map +1 -0
- package/dist/config-rules.d.ts +7 -0
- package/dist/config-rules.d.ts.map +1 -0
- package/dist/config-rules.js +87 -0
- package/dist/config-rules.js.map +1 -0
- package/dist/diagnose.d.ts +17 -0
- package/dist/diagnose.d.ts.map +1 -0
- package/dist/diagnose.js +237 -0
- package/dist/diagnose.js.map +1 -0
- package/dist/errors.d.ts +4 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +45 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.d.ts +38 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +167 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/mapping.d.ts +328 -0
- package/dist/mapping.d.ts.map +1 -0
- package/dist/mapping.js +437 -0
- package/dist/mapping.js.map +1 -0
- package/dist/provider.d.ts +33 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +634 -0
- package/dist/provider.js.map +1 -0
- package/dist/resolve.d.ts +10 -0
- package/dist/resolve.d.ts.map +1 -0
- package/dist/resolve.js +171 -0
- package/dist/resolve.js.map +1 -0
- package/dist/secrets.d.ts +7 -0
- package/dist/secrets.d.ts.map +1 -0
- package/dist/secrets.js +33 -0
- package/dist/secrets.js.map +1 -0
- package/dist/testing/index.d.ts +54 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +119 -0
- package/dist/testing/index.js.map +1 -0
- package/instructions/README.md +14 -0
- package/instructions/configure-stripe.md +69 -0
- package/instructions/framework.md +62 -0
- package/instructions/testing.md +41 -0
- package/instructions/webhooks.md +44 -0
- package/package.json +66 -0
package/dist/diagnose.js
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
// ── Environment checks and webhook setup ──
|
|
2
|
+
// `plumbus payments doctor --live` and `plumbus payments webhooks setup`.
|
|
3
|
+
import Stripe from 'stripe';
|
|
4
|
+
import { reconcileCatalog } from './catalog.js';
|
|
5
|
+
import { STRIPE_SNAPSHOT_EVENTS, STRIPE_SNAPSHOT_SOURCES, STRIPE_THIN_EVENTS } from './events.js';
|
|
6
|
+
import { keyMode } from './secrets.js';
|
|
7
|
+
export const STRIPE_API_VERSION = Stripe.API_VERSION;
|
|
8
|
+
export const STRIPE_DESTINATION_NAMES = {
|
|
9
|
+
snapshot: 'plumbus-payments-sellers',
|
|
10
|
+
thin: 'plumbus-payments-accounts',
|
|
11
|
+
};
|
|
12
|
+
const PLANS = [
|
|
13
|
+
{
|
|
14
|
+
name: STRIPE_DESTINATION_NAMES.snapshot,
|
|
15
|
+
format: 'snapshot',
|
|
16
|
+
events: STRIPE_SNAPSHOT_EVENTS,
|
|
17
|
+
sources: STRIPE_SNAPSHOT_SOURCES,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: STRIPE_DESTINATION_NAMES.thin,
|
|
21
|
+
format: 'thin',
|
|
22
|
+
events: STRIPE_THIN_EVENTS,
|
|
23
|
+
sources: ['@self'],
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
const hasSources = (destination, sources) => sources.every((source) => destination.events_from?.includes(source));
|
|
27
|
+
/** The destination doctor and setup look at: at the URL, with every source, when there is one. */
|
|
28
|
+
function pick(named, plan, url) {
|
|
29
|
+
const atUrl = url ? named.filter((d) => d.webhook_endpoint?.url === url) : named;
|
|
30
|
+
const pool = atUrl.length > 0 ? atUrl : named;
|
|
31
|
+
return pool.find((d) => hasSources(d, plan.sources)) ?? pool[0];
|
|
32
|
+
}
|
|
33
|
+
export async function diagnoseStripe(input) {
|
|
34
|
+
const findings = [];
|
|
35
|
+
let key;
|
|
36
|
+
try {
|
|
37
|
+
key = await input.secretKey();
|
|
38
|
+
const mode = keyMode(key);
|
|
39
|
+
const production = process.env.NODE_ENV === 'production';
|
|
40
|
+
if (production && mode === 'test') {
|
|
41
|
+
findings.push({
|
|
42
|
+
level: 'error',
|
|
43
|
+
code: 'stripe_test_key_in_production',
|
|
44
|
+
message: 'NODE_ENV is production but the Stripe key is a test key',
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (!production && mode === 'live') {
|
|
48
|
+
findings.push({
|
|
49
|
+
level: 'warning',
|
|
50
|
+
code: 'stripe_live_key_outside_production',
|
|
51
|
+
message: 'A live Stripe key is configured outside production',
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (key.startsWith('sk_')) {
|
|
55
|
+
findings.push({
|
|
56
|
+
level: 'info',
|
|
57
|
+
code: 'stripe_use_restricted_key',
|
|
58
|
+
message: 'Consider a restricted key (rk_…) with only the permissions listed in docs/payments/stripe.md',
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
findings.push({ level: 'error', code: 'stripe_key_invalid', message: messageOf(err) });
|
|
64
|
+
return findings;
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
const secrets = await input.webhookSecrets();
|
|
68
|
+
if (secrets.length < 2) {
|
|
69
|
+
findings.push({
|
|
70
|
+
level: 'warning',
|
|
71
|
+
code: 'stripe_webhook_secrets_incomplete',
|
|
72
|
+
message: `Two event destinations sign with separate secrets; ${secrets.length} configured`,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
findings.push({
|
|
78
|
+
level: 'error',
|
|
79
|
+
code: 'stripe_webhook_secrets_missing',
|
|
80
|
+
message: messageOf(err),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const stripe = await input.client();
|
|
84
|
+
try {
|
|
85
|
+
await stripe.v2.core.accounts.list({ limit: 1 });
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
findings.push({
|
|
89
|
+
level: 'error',
|
|
90
|
+
code: 'stripe_accounts_v2_unavailable',
|
|
91
|
+
message: `Accounts v2 is not usable with this key: ${messageOf(err)}. Finish Connect onboarding (platform profile) and use a key with Connect access.`,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
const destinations = (await stripe.v2.core.eventDestinations.list({ include: ['webhook_endpoint.url'], limit: 20 })).data;
|
|
96
|
+
for (const plan of PLANS) {
|
|
97
|
+
const { format, name } = plan;
|
|
98
|
+
const named = destinations.filter((d) => d.event_payload === format && d.name === name);
|
|
99
|
+
const found = pick(named, plan, input.webhookUrl);
|
|
100
|
+
if (found && named.length > 1) {
|
|
101
|
+
findings.push({
|
|
102
|
+
level: 'warning',
|
|
103
|
+
code: `stripe_${format}_destination_duplicate`,
|
|
104
|
+
message: `${named.length} event destinations are named "${name}"; Stripe sends events to each. Keep ${found.id} and delete ${named
|
|
105
|
+
.filter((d) => d !== found)
|
|
106
|
+
.map((d) => `${d.id} (${d.webhook_endpoint?.url ?? 'no url'})`)
|
|
107
|
+
.join(', ')}`,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
if (!found) {
|
|
111
|
+
findings.push({
|
|
112
|
+
level: 'error',
|
|
113
|
+
code: `stripe_${format}_destination_missing`,
|
|
114
|
+
message: `No ${format} event destination "${name}"; run plumbus payments webhooks setup --url <your webhook URL>`,
|
|
115
|
+
});
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (found.status !== 'enabled') {
|
|
119
|
+
findings.push({
|
|
120
|
+
level: 'error',
|
|
121
|
+
code: `stripe_${format}_destination_disabled`,
|
|
122
|
+
message: `Event destination "${name}" is disabled`,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
if (input.webhookUrl && found.webhook_endpoint?.url !== input.webhookUrl) {
|
|
126
|
+
findings.push({
|
|
127
|
+
level: 'error',
|
|
128
|
+
code: `stripe_${format}_destination_url`,
|
|
129
|
+
message: `Event destination "${name}" points at ${found.webhook_endpoint?.url ?? '(none)'}, not ${input.webhookUrl}`,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
if (!hasSources(found, plan.sources)) {
|
|
133
|
+
findings.push({
|
|
134
|
+
level: 'error',
|
|
135
|
+
code: `stripe_${format}_destination_sources`,
|
|
136
|
+
message: `Event destination "${name}" takes events from ${(found.events_from ?? []).join(', ') || '(nothing)'}, not ${plan.sources.join(' and ')}; run plumbus payments webhooks setup again (Stripe cannot change the sources of a destination, so it makes a new one)`,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
const missing = plan.events.filter((type) => !found.enabled_events.includes(type));
|
|
140
|
+
if (missing.length > 0) {
|
|
141
|
+
findings.push({
|
|
142
|
+
level: 'error',
|
|
143
|
+
code: `stripe_${format}_destination_events`,
|
|
144
|
+
message: `Event destination "${name}" is missing: ${missing.join(', ')}; run plumbus payments webhooks setup again`,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
if (format === 'snapshot' &&
|
|
148
|
+
found.snapshot_api_version &&
|
|
149
|
+
found.snapshot_api_version !== STRIPE_API_VERSION) {
|
|
150
|
+
findings.push({
|
|
151
|
+
level: 'error',
|
|
152
|
+
code: 'stripe_snapshot_version_mismatch',
|
|
153
|
+
message: `Event destination "${name}" renders events as ${found.snapshot_api_version}; this package expects ${STRIPE_API_VERSION}`,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
catch (err) {
|
|
159
|
+
findings.push({
|
|
160
|
+
level: 'error',
|
|
161
|
+
code: 'stripe_destinations_unreadable',
|
|
162
|
+
message: `Could not list event destinations: ${messageOf(err)}`,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
if (input.catalog) {
|
|
166
|
+
try {
|
|
167
|
+
const { changes } = await reconcileCatalog(stripe, input.catalog, false);
|
|
168
|
+
if (changes.length > 0) {
|
|
169
|
+
findings.push({
|
|
170
|
+
level: 'error',
|
|
171
|
+
code: 'stripe_catalog_out_of_date',
|
|
172
|
+
message: `The billing catalog at Stripe differs from billing in the config; run plumbus payments catalog sync. Differences: ${changes.join('; ')}`,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
catch (err) {
|
|
177
|
+
findings.push({
|
|
178
|
+
level: 'error',
|
|
179
|
+
code: 'stripe_catalog_unreadable',
|
|
180
|
+
message: `Could not read the billing catalog: ${messageOf(err)}`,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return findings;
|
|
185
|
+
}
|
|
186
|
+
export async function setupStripeDestinations(stripe, url) {
|
|
187
|
+
const existing = (await stripe.v2.core.eventDestinations.list({ include: ['webhook_endpoint.url'], limit: 20 })).data;
|
|
188
|
+
const result = { destinations: [] };
|
|
189
|
+
for (const plan of PLANS) {
|
|
190
|
+
const found = existing.find((d) => d.name === plan.name &&
|
|
191
|
+
d.event_payload === plan.format &&
|
|
192
|
+
d.webhook_endpoint?.url === url &&
|
|
193
|
+
hasSources(d, plan.sources));
|
|
194
|
+
if (found) {
|
|
195
|
+
// Newer releases act on more events: add them to the destination in place.
|
|
196
|
+
const missing = plan.events.filter((type) => !found.enabled_events.includes(type));
|
|
197
|
+
if (missing.length > 0) {
|
|
198
|
+
await stripe.v2.core.eventDestinations.update(found.id, {
|
|
199
|
+
enabled_events: [...new Set([...found.enabled_events, ...plan.events])],
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
result.destinations.push({
|
|
203
|
+
id: found.id,
|
|
204
|
+
name: plan.name,
|
|
205
|
+
format: plan.format,
|
|
206
|
+
url,
|
|
207
|
+
secret: null,
|
|
208
|
+
created: false,
|
|
209
|
+
});
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
const created = await stripe.v2.core.eventDestinations.create({
|
|
213
|
+
name: plan.name,
|
|
214
|
+
description: 'Created by @plumbus/payments-stripe',
|
|
215
|
+
type: 'webhook_endpoint',
|
|
216
|
+
event_payload: plan.format,
|
|
217
|
+
events_from: [...plan.sources],
|
|
218
|
+
enabled_events: [...plan.events],
|
|
219
|
+
...(plan.format === 'snapshot' ? { snapshot_api_version: STRIPE_API_VERSION } : {}),
|
|
220
|
+
webhook_endpoint: { url },
|
|
221
|
+
include: ['webhook_endpoint.signing_secret', 'webhook_endpoint.url'],
|
|
222
|
+
});
|
|
223
|
+
result.destinations.push({
|
|
224
|
+
id: created.id,
|
|
225
|
+
name: plan.name,
|
|
226
|
+
format: plan.format,
|
|
227
|
+
url,
|
|
228
|
+
secret: created.webhook_endpoint?.signing_secret ?? null,
|
|
229
|
+
created: true,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
return result;
|
|
233
|
+
}
|
|
234
|
+
export function messageOf(err) {
|
|
235
|
+
return err instanceof Error ? err.message : String(err);
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=diagnose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnose.js","sourceRoot":"","sources":["../src/diagnose.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,0EAA0E;AAG1E,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAClG,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,WAAW,CAAC;AAErD,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACt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a,EAAE,IAAI,CAAC,MAAM;YAC1B,WAAW,EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC;YAC9B,cAAc,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;YAChC,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACnF,gBAAgB,EAAE,EAAE,GAAG,EAAE;YACzB,OAAO,EAAE,CAAC,iCAAiC,EAAE,sBAAsB,CAAC;SACrE,CAAC,CAAC;QACH,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC;YACvB,EAAE,EAAE,OAAO,CAAC,EAAE;YACd,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,GAAG;YACH,MAAM,EAAE,OAAO,CAAC,gBAAgB,EAAE,cAAc,IAAI,IAAI;YACxD,OAAO,EAAE,IAAI;SACd,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,GAAY;IACpC,OAAO,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC1D,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function translateStripeError(err: unknown): unknown;
|
|
2
|
+
/** Wrap an async provider method so Stripe errors come out as PlumbusErrors. */
|
|
3
|
+
export declare function withStripeErrors<A extends unknown[], R>(fn: (...args: A) => Promise<R>): (...args: A) => Promise<R>;
|
|
4
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAQA,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CA6B1D;AAED,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,EACrD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GAC7B,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAQ5B"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// ── Stripe errors → Plumbus errors ──
|
|
2
|
+
// Capabilities surface provider failures to sellers, so Stripe's message and
|
|
3
|
+
// codes are kept (e.g. "Amount must be at least $0.50 usd") while the error
|
|
4
|
+
// becomes a structured PlumbusError the HTTP layer maps to a status.
|
|
5
|
+
import { ErrorCode, PlumbusError } from '@plumbus/core';
|
|
6
|
+
import Stripe from 'stripe';
|
|
7
|
+
export function translateStripeError(err) {
|
|
8
|
+
if (!(err instanceof Stripe.errors.StripeError))
|
|
9
|
+
return err;
|
|
10
|
+
const metadata = {
|
|
11
|
+
reason: 'stripe_error',
|
|
12
|
+
stripeType: err.type,
|
|
13
|
+
...(err.code ? { stripeCode: err.code } : {}),
|
|
14
|
+
...(err.param ? { param: err.param } : {}),
|
|
15
|
+
...(err.requestId ? { requestId: err.requestId } : {}),
|
|
16
|
+
...(err.statusCode ? { statusCode: err.statusCode } : {}),
|
|
17
|
+
};
|
|
18
|
+
switch (err.type) {
|
|
19
|
+
case 'StripeInvalidRequestError':
|
|
20
|
+
case 'StripeCardError':
|
|
21
|
+
return new PlumbusError(ErrorCode.Validation, err.message, metadata);
|
|
22
|
+
case 'StripeIdempotencyError':
|
|
23
|
+
return new PlumbusError(ErrorCode.Conflict, err.message, metadata);
|
|
24
|
+
case 'StripeAuthenticationError':
|
|
25
|
+
case 'StripePermissionError':
|
|
26
|
+
return new PlumbusError(ErrorCode.Internal, `Stripe rejected the platform credentials: ${err.message}`, metadata);
|
|
27
|
+
default:
|
|
28
|
+
return new PlumbusError(ErrorCode.Internal, `Stripe request failed: ${err.message}`, {
|
|
29
|
+
...metadata,
|
|
30
|
+
retryable: true,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** Wrap an async provider method so Stripe errors come out as PlumbusErrors. */
|
|
35
|
+
export function withStripeErrors(fn) {
|
|
36
|
+
return async (...args) => {
|
|
37
|
+
try {
|
|
38
|
+
return await fn(...args);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
throw translateStripeError(err);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,6EAA6E;AAC7E,4EAA4E;AAC5E,qEAAqE;AAErE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,UAAU,oBAAoB,CAAC,GAAY;IAC/C,IAAI,CAAC,CAAC,GAAG,YAAY,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC;QAAE,OAAO,GAAG,CAAC;IAC5D,MAAM,QAAQ,GAAG;QACf,MAAM,EAAE,cAAc;QACtB,UAAU,EAAE,GAAG,CAAC,IAAI;QACpB,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7C,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1C,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,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viderEvent } from '@plumbus/payments';
|
|
2
|
+
/** Snapshot (v1) event types the adapter acts on, from the platform and from sellers' accounts. */
|
|
3
|
+
export declare const STRIPE_SNAPSHOT_EVENTS: readonly ["checkout.session.completed", "checkout.session.async_payment_succeeded", "checkout.session.async_payment_failed", "checkout.session.expired", "payment_intent.succeeded", "payment_intent.amount_capturable_updated", "payment_intent.payment_failed", "payment_intent.processing", "payment_intent.requires_action", "payment_intent.canceled", "charge.refunded", "charge.refund.updated", "refund.created", "refund.updated", "refund.failed", "charge.dispute.created", "charge.dispute.updated", "charge.dispute.closed", "charge.dispute.funds_withdrawn", "charge.dispute.funds_reinstated", "payment_method.attached", "payment_method.updated", "payment_method.detached", "customer.subscription.created", "customer.subscription.updated", "customer.subscription.deleted", "customer.subscription.paused", "customer.subscription.resumed", "invoice.finalized", "invoice.paid", "invoice.payment_failed", "invoice.voided", "invoice.marked_uncollectible", "transfer.created", "transfer.updated", "transfer.reversed", "payout.created", "payout.updated", "payout.paid", "payout.failed", "payout.canceled", "entitlements.active_entitlement_summary.updated"];
|
|
4
|
+
/** Thin (v2) event types about sellers' v2 Accounts. */
|
|
5
|
+
export declare const STRIPE_THIN_EVENTS: readonly ["v2.core.account.created", "v2.core.account.updated", "v2.core.account.closed", "v2.core.account[requirements].updated", "v2.core.account[configuration.merchant].updated", "v2.core.account[configuration.merchant].capability_status_updated", "v2.core.account[configuration.recipient].updated", "v2.core.account[configuration.recipient].capability_status_updated", "v2.core.account[defaults].updated", "v2.core.account[identity].updated"];
|
|
6
|
+
/** Where the snapshot destination takes events from: the platform itself and every seller. */
|
|
7
|
+
export declare const STRIPE_SNAPSHOT_SOURCES: readonly ["@self", "@accounts"];
|
|
8
|
+
export declare function isRelevantStripeEvent(type: string): boolean;
|
|
9
|
+
type Ref = string | {
|
|
10
|
+
id?: string;
|
|
11
|
+
} | null | undefined;
|
|
12
|
+
interface SnapshotObject {
|
|
13
|
+
id?: string;
|
|
14
|
+
object?: string;
|
|
15
|
+
metadata?: Record<string, string> | null;
|
|
16
|
+
customer?: Ref;
|
|
17
|
+
payment_intent?: Ref;
|
|
18
|
+
subscription?: Ref;
|
|
19
|
+
parent?: {
|
|
20
|
+
subscription_details?: {
|
|
21
|
+
subscription?: Ref;
|
|
22
|
+
} | null;
|
|
23
|
+
} | null;
|
|
24
|
+
}
|
|
25
|
+
/** Hints for finding the tenant of a platform-account event, read from the object itself. */
|
|
26
|
+
export declare function routingOf(object: SnapshotObject | undefined): ProviderEventRouting;
|
|
27
|
+
/**
|
|
28
|
+
* Verify `Stripe-Signature` against any of the configured secrets (one per
|
|
29
|
+
* destination, plus old secrets during a rotation), then normalize the body.
|
|
30
|
+
*/
|
|
31
|
+
export declare function verifyStripeWebhook(input: {
|
|
32
|
+
rawBody: Buffer;
|
|
33
|
+
headers: Record<string, string | string[] | undefined>;
|
|
34
|
+
secrets: readonly string[];
|
|
35
|
+
toleranceSeconds: number;
|
|
36
|
+
}): VerifiedProviderEvent;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAGrF,mGAAmG;AACnG,eAAO,MAAM,sBAAsB,4nCA2CzB,CAAC;AAEX,wDAAwD;AACxD,eAAO,MAAM,kBAAkB,gcAWrB,CAAC;AAEX,8FAA8F;AAC9F,eAAO,MAAM,uBAAuB,iCAAkC,CAAC;AAIvE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED,KAAK,GAAG,GAAG,MAAM,GAAG;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,CAAC;AAEvD,UAAU,cAAc;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IACzC,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,cAAc,CAAC,EAAE,GAAG,CAAC;IACrB,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,MAAM,CAAC,EAAE;QAAE,oBAAoB,CAAC,EAAE;YAAE,YAAY,CAAC,EAAE,GAAG,CAAA;SAAE,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;CAC1E;AAgCD,6FAA6F;AAC7F,wBAAgB,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,GAAG,oBAAoB,CAYlF;AAaD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;IACvD,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;CAC1B,GAAG,qBAAqB,CAyDxB"}
|
package/dist/events.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// ── Stripe webhook events ──
|
|
2
|
+
// Two destinations feed one route:
|
|
3
|
+
// • snapshot events from the platform account (`@self`) and from sellers'
|
|
4
|
+
// accounts (`@accounts`): checkout, payments, refunds, disputes, saved
|
|
5
|
+
// methods, subscriptions, invoices, transfers, payouts, entitlements
|
|
6
|
+
// • thin v2 events about the sellers' v2 Accounts (`@self`): onboarding progress
|
|
7
|
+
// Both use the same `Stripe-Signature` scheme, so the route verifies first and
|
|
8
|
+
// only then looks at the body to tell the formats apart.
|
|
9
|
+
import { ErrorCode, PlumbusError } from '@plumbus/core';
|
|
10
|
+
import Stripe from 'stripe';
|
|
11
|
+
/** Snapshot (v1) event types the adapter acts on, from the platform and from sellers' accounts. */
|
|
12
|
+
export const STRIPE_SNAPSHOT_EVENTS = [
|
|
13
|
+
'checkout.session.completed',
|
|
14
|
+
'checkout.session.async_payment_succeeded',
|
|
15
|
+
'checkout.session.async_payment_failed',
|
|
16
|
+
'checkout.session.expired',
|
|
17
|
+
'payment_intent.succeeded',
|
|
18
|
+
'payment_intent.amount_capturable_updated',
|
|
19
|
+
'payment_intent.payment_failed',
|
|
20
|
+
'payment_intent.processing',
|
|
21
|
+
'payment_intent.requires_action',
|
|
22
|
+
'payment_intent.canceled',
|
|
23
|
+
'charge.refunded',
|
|
24
|
+
'charge.refund.updated',
|
|
25
|
+
'refund.created',
|
|
26
|
+
'refund.updated',
|
|
27
|
+
'refund.failed',
|
|
28
|
+
'charge.dispute.created',
|
|
29
|
+
'charge.dispute.updated',
|
|
30
|
+
'charge.dispute.closed',
|
|
31
|
+
'charge.dispute.funds_withdrawn',
|
|
32
|
+
'charge.dispute.funds_reinstated',
|
|
33
|
+
'payment_method.attached',
|
|
34
|
+
'payment_method.updated',
|
|
35
|
+
'payment_method.detached',
|
|
36
|
+
'customer.subscription.created',
|
|
37
|
+
'customer.subscription.updated',
|
|
38
|
+
'customer.subscription.deleted',
|
|
39
|
+
'customer.subscription.paused',
|
|
40
|
+
'customer.subscription.resumed',
|
|
41
|
+
'invoice.finalized',
|
|
42
|
+
'invoice.paid',
|
|
43
|
+
'invoice.payment_failed',
|
|
44
|
+
'invoice.voided',
|
|
45
|
+
'invoice.marked_uncollectible',
|
|
46
|
+
'transfer.created',
|
|
47
|
+
'transfer.updated',
|
|
48
|
+
'transfer.reversed',
|
|
49
|
+
'payout.created',
|
|
50
|
+
'payout.updated',
|
|
51
|
+
'payout.paid',
|
|
52
|
+
'payout.failed',
|
|
53
|
+
'payout.canceled',
|
|
54
|
+
'entitlements.active_entitlement_summary.updated',
|
|
55
|
+
];
|
|
56
|
+
/** Thin (v2) event types about sellers' v2 Accounts. */
|
|
57
|
+
export const STRIPE_THIN_EVENTS = [
|
|
58
|
+
'v2.core.account.created',
|
|
59
|
+
'v2.core.account.updated',
|
|
60
|
+
'v2.core.account.closed',
|
|
61
|
+
'v2.core.account[requirements].updated',
|
|
62
|
+
'v2.core.account[configuration.merchant].updated',
|
|
63
|
+
'v2.core.account[configuration.merchant].capability_status_updated',
|
|
64
|
+
'v2.core.account[configuration.recipient].updated',
|
|
65
|
+
'v2.core.account[configuration.recipient].capability_status_updated',
|
|
66
|
+
'v2.core.account[defaults].updated',
|
|
67
|
+
'v2.core.account[identity].updated',
|
|
68
|
+
];
|
|
69
|
+
/** Where the snapshot destination takes events from: the platform itself and every seller. */
|
|
70
|
+
export const STRIPE_SNAPSHOT_SOURCES = ['@self', '@accounts'];
|
|
71
|
+
const RELEVANT = new Set([...STRIPE_SNAPSHOT_EVENTS, ...STRIPE_THIN_EVENTS]);
|
|
72
|
+
export function isRelevantStripeEvent(type) {
|
|
73
|
+
return RELEVANT.has(type);
|
|
74
|
+
}
|
|
75
|
+
const refId = (value) => value == null ? null : typeof value === 'string' ? value : (value.id ?? null);
|
|
76
|
+
const NO_ROUTING = {
|
|
77
|
+
tenantId: null,
|
|
78
|
+
customerId: null,
|
|
79
|
+
paymentId: null,
|
|
80
|
+
subscriptionId: null,
|
|
81
|
+
};
|
|
82
|
+
/** Hints for finding the tenant of a platform-account event, read from the object itself. */
|
|
83
|
+
export function routingOf(object) {
|
|
84
|
+
if (!object)
|
|
85
|
+
return NO_ROUTING;
|
|
86
|
+
const kind = object.object;
|
|
87
|
+
return {
|
|
88
|
+
tenantId: object.metadata?.plumbus_tenant_id ?? null,
|
|
89
|
+
customerId: kind === 'customer' ? (object.id ?? null) : refId(object.customer),
|
|
90
|
+
paymentId: kind === 'payment_intent' ? (object.id ?? null) : refId(object.payment_intent),
|
|
91
|
+
subscriptionId: kind === 'subscription'
|
|
92
|
+
? (object.id ?? null)
|
|
93
|
+
: (refId(object.subscription) ?? refId(object.parent?.subscription_details?.subscription)),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/** The object an event is about; entitlement summaries have no id of their own, only a customer. */
|
|
97
|
+
function objectIdOf(object) {
|
|
98
|
+
if (!object)
|
|
99
|
+
return null;
|
|
100
|
+
if (object.object === 'entitlements.active_entitlement_summary')
|
|
101
|
+
return refId(object.customer);
|
|
102
|
+
return object.id ?? null;
|
|
103
|
+
}
|
|
104
|
+
function headerValue(value) {
|
|
105
|
+
return Array.isArray(value) ? value[0] : value;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Verify `Stripe-Signature` against any of the configured secrets (one per
|
|
109
|
+
* destination, plus old secrets during a rotation), then normalize the body.
|
|
110
|
+
*/
|
|
111
|
+
export function verifyStripeWebhook(input) {
|
|
112
|
+
const header = headerValue(input.headers['stripe-signature']);
|
|
113
|
+
if (!header) {
|
|
114
|
+
throw new PlumbusError(ErrorCode.Unauthorized, 'Missing Stripe-Signature header', {
|
|
115
|
+
reason: 'stripe_signature_missing',
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
const signature = Stripe.webhooks.signature;
|
|
119
|
+
const verified = input.secrets.some((secret) => {
|
|
120
|
+
try {
|
|
121
|
+
return (signature?.verifyHeader(input.rawBody, header, secret, input.toleranceSeconds) === true);
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
if (!verified) {
|
|
128
|
+
throw new PlumbusError(ErrorCode.Unauthorized, 'Stripe signature did not verify', {
|
|
129
|
+
reason: 'stripe_signature_invalid',
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
const body = JSON.parse(input.rawBody.toString('utf8'));
|
|
133
|
+
if (body.object === 'event') {
|
|
134
|
+
return {
|
|
135
|
+
eventId: body.id,
|
|
136
|
+
type: body.type,
|
|
137
|
+
format: 'snapshot',
|
|
138
|
+
livemode: body.livemode,
|
|
139
|
+
occurredAt: new Date(body.created * 1000),
|
|
140
|
+
accountId: body.account ?? null,
|
|
141
|
+
objectId: objectIdOf(body.data?.object),
|
|
142
|
+
objectType: body.data?.object?.object ?? null,
|
|
143
|
+
routing: routingOf(body.data?.object),
|
|
144
|
+
payload: body,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
if (body.object === 'v2.core.event') {
|
|
148
|
+
const related = body.related_object ?? null;
|
|
149
|
+
const isAccount = related?.type === 'v2.core.account';
|
|
150
|
+
return {
|
|
151
|
+
eventId: body.id,
|
|
152
|
+
type: body.type,
|
|
153
|
+
format: 'thin',
|
|
154
|
+
livemode: body.livemode,
|
|
155
|
+
occurredAt: new Date(body.created),
|
|
156
|
+
accountId: isAccount ? (related?.id ?? null) : (body.context ?? null),
|
|
157
|
+
objectId: related?.id ?? null,
|
|
158
|
+
objectType: related?.type ?? null,
|
|
159
|
+
routing: NO_ROUTING,
|
|
160
|
+
payload: body,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
throw new PlumbusError(ErrorCode.Validation, 'Unrecognized Stripe webhook body', {
|
|
164
|
+
reason: 'stripe_webhook_unrecognized',
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,mCAAmC;AACnC,2EAA2E;AAC3E,0EAA0E;AAC1E,wEAAwE;AACxE,kFAAkF;AAClF,+EAA+E;AAC/E,yDAAyD;AAEzD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,mGAAmG;AACnG,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,4BAA4B;IAC5B,0CAA0C;IAC1C,uCAAuC;IACvC,0BAA0B;IAC1B,0BAA0B;IAC1B,0CAA0C;IAC1C,+BAA+B;IAC/B,2BAA2B;IAC3B,gCAAgC;IAChC,yBAAyB;IACzB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@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { STRIPE_API_VERSION, STRIPE_DESTINATION_NAMES, stripeProvider, type StripePaymentProvider, type StripeProviderOptions, } from './provider.js';
|
|
2
|
+
export { isRelevantStripeEvent, routingOf, STRIPE_SNAPSHOT_EVENTS, STRIPE_SNAPSHOT_SOURCES, STRIPE_THIN_EVENTS, verifyStripeWebhook, } from './events.js';
|
|
3
|
+
export { stripeDefaultResponsibilities, validateStripeConfig } from './config-rules.js';
|
|
4
|
+
export { mapAccount, mapDispute, mapIntent, mapInvoice, mapInvoiceCharge, mapPaymentMethod, mapPayout, mapPayoutSchedule, mapRefund, mapSession, mapSubscription, mapTransfer, toDisputeStatus, } from './mapping.js';
|
|
5
|
+
export { catalogProductId, featureLookupKey } from './catalog.js';
|
|
6
|
+
export { keyMode, type SecretSource } from './secrets.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,cAAc,EACd,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,GAC3B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,qBAAqB,EACrB,SAAS,EACT,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,EACL,UAAU,EACV,UAAU,EACV,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,EACT,iBAAiB,EACjB,SAAS,EACT,UAAU,EACV,eAAe,EACf,WAAW,EACX,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// ── @plumbus/payments-stripe ──
|
|
2
|
+
// Stripe Connect provider for @plumbus/payments on Stripe's newest APIs
|
|
3
|
+
// (Accounts v2 sellers, Checkout, Billing, snapshot + thin webhooks).
|
|
4
|
+
export { STRIPE_API_VERSION, STRIPE_DESTINATION_NAMES, stripeProvider, } from './provider.js';
|
|
5
|
+
export { isRelevantStripeEvent, routingOf, STRIPE_SNAPSHOT_EVENTS, STRIPE_SNAPSHOT_SOURCES, STRIPE_THIN_EVENTS, verifyStripeWebhook, } from './events.js';
|
|
6
|
+
export { stripeDefaultResponsibilities, validateStripeConfig } from './config-rules.js';
|
|
7
|
+
export { mapAccount, mapDispute, mapIntent, mapInvoice, mapInvoiceCharge, mapPaymentMethod, mapPayout, mapPayoutSchedule, mapRefund, mapSession, mapSubscription, mapTransfer, toDisputeStatus, } from './mapping.js';
|
|
8
|
+
export { catalogProductId, featureLookupKey } from './catalog.js';
|
|
9
|
+
export { keyMode } from './secrets.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,wEAAwE;AACxE,sEAAsE;AAEtE,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,cAAc,GAGf,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,qBAAqB,EACrB,SAAS,EACT,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,EACL,UAAU,EACV,UAAU,EACV,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,EACT,iBAAiB,EACjB,SAAS,EACT,UAAU,EACV,eAAe,EACf,WAAW,EACX,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,OAAO,EAAqB,MAAM,cAAc,CAAC"}
|