@happyvertical/payments 0.106.1 → 0.107.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/AGENT.md +13 -0
- package/README.md +80 -0
- package/dist/adapters/stripe.d.ts +21 -2
- package/dist/adapters/stripe.d.ts.map +1 -1
- package/dist/adapters/stripe.js +133 -1
- package/dist/adapters/stripe.js.map +1 -1
- package/dist/types.d.ts +35 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/AGENT.md
CHANGED
|
@@ -30,3 +30,16 @@ pnpm --filter @happyvertical/payments clean
|
|
|
30
30
|
- Requires: @noble/curves, @noble/hashes, @scure/bip32
|
|
31
31
|
- Stability: stable (Primary package surface is described as implemented and production-oriented.)
|
|
32
32
|
<!-- END AGENT:GENERATED -->
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## Dispute transport
|
|
36
|
+
|
|
37
|
+
StripeAdapter verifies dispute webhooks before exposing `event.dispute` and
|
|
38
|
+
`event.connect.dispute`. `getDispute(id, { stripeAccount, expectedLivemode })`
|
|
39
|
+
is an authoritative scoped GET, preserving account/environment context and
|
|
40
|
+
expanded charge/PaymentIntent identities. Root `PaymentDispute` types expose
|
|
41
|
+
validated safe minor-unit amounts and balance transaction evidence without raw
|
|
42
|
+
parsing. Missing evidence throws; an empty array is valid. Unknown lifecycle
|
|
43
|
+
statuses map to `unknown`, unknown dispute event types throw. Never infer money
|
|
44
|
+
movement from lifecycle status; consumers own ledger postings, ownership,
|
|
45
|
+
durable deduplication, ordering, and recovery. See README dispute documentation.
|
package/README.md
CHANGED
|
@@ -180,6 +180,86 @@ refunded or failed. Duplicate detection records an event only after it
|
|
|
180
180
|
resolves, so a delivery rejected for an unmapped account is not reported as a
|
|
181
181
|
duplicate when Stripe retries it.
|
|
182
182
|
|
|
183
|
+
### Disputes: verified snapshots and authoritative rereads
|
|
184
|
+
|
|
185
|
+
Stripe normalizes `charge.dispute.created`, `.updated`, `.closed`,
|
|
186
|
+
`.funds_withdrawn`, and `.funds_reinstated` into `event.dispute` and
|
|
187
|
+
`event.connect = { type, dispute }` on both endpoint parsers. Connect events
|
|
188
|
+
retain the verified `account`; dispute events require a boolean event
|
|
189
|
+
`livemode` matching the object's environment and expose `createdAt` and
|
|
190
|
+
`livemode` without reading `raw`. Their generic payment `status` stays
|
|
191
|
+
`processing`: a dispute never marks the original payment refunded or failed.
|
|
192
|
+
Existing non-dispute event behavior is unchanged.
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
const { event, owner, account } = await platform.resolveConnectWebhookEvent(
|
|
196
|
+
rawBody, signature, { resolveAccount: findAccountOwner },
|
|
197
|
+
);
|
|
198
|
+
if (event.dispute) {
|
|
199
|
+
if (event.livemode !== owner.stripeLivemode) throw new Error('wrong environment');
|
|
200
|
+
// Authenticate/route the delivery first; reread after out-of-order delivery or
|
|
201
|
+
// restart. The request scope is preserved in current.account even though
|
|
202
|
+
// Stripe's dispute object normally omits it.
|
|
203
|
+
const current = await platform.getDispute(event.dispute.id, {
|
|
204
|
+
stripeAccount: account,
|
|
205
|
+
expectedLivemode: owner.stripeLivemode,
|
|
206
|
+
});
|
|
207
|
+
if (current.status === 'unknown') throw new Error('unsupported dispute status');
|
|
208
|
+
await owner.reconcileDispute(current); // consumer-owned durable/idempotent ledger
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
`PaymentDispute`, `PaymentDisputeStatus`, and
|
|
213
|
+
`PaymentDisputeBalanceTransaction` are root type exports. The Stripe subpath
|
|
214
|
+
exports `StripeDispute`, `StripeDisputeEventType`, and
|
|
215
|
+
`StripeGetDisputeOptions`. A dispute supplies `id`, `chargeId`, optional
|
|
216
|
+
`paymentIntentId`, `amount`, `currency`, `status`, `providerStatus`, `livemode`,
|
|
217
|
+
`createdAt`, and `balanceTransactions`. `getDispute(id, options?)` is a GET,
|
|
218
|
+
uses the explicit account or adapter's default account (otherwise platform),
|
|
219
|
+
and refuses an override of a fixed adapter account. The caller must select an
|
|
220
|
+
owned account; Stripe authenticates the read within that account. A reread
|
|
221
|
+
requests an expanded charge to recover `paymentIntentId` when absent on the
|
|
222
|
+
dispute. Both card `ch_` and non-card `py_` charge identities are accepted, as are
|
|
223
|
+
current `du_` and legacy `dp_` dispute identities. Some charges genuinely have no
|
|
224
|
+
PaymentIntent: that field remains
|
|
225
|
+
optional, and consumers must resolve charge ownership themselves or quarantine
|
|
226
|
+
unroutable snapshots. Conflicting expanded references are rejected.
|
|
227
|
+
|
|
228
|
+
All amounts are safe integers in minor units. Disputed `amount` is
|
|
229
|
+
non-negative. Balance evidence contains transaction `id`, signed `amount`,
|
|
230
|
+
`fee`, signed `net` (`amount - fee`), `currency`, `createdAt`, provider `type`,
|
|
231
|
+
and optional `reportingCategory`. Its currency may differ from the dispute's
|
|
232
|
+
after FX; do not combine currencies or silently apply the dispute's amount.
|
|
233
|
+
The transaction identifiers and actual deltas are the evidence for accounting;
|
|
234
|
+
statuses and event suffixes alone never prove an amount moved. A `won` or
|
|
235
|
+
`lost` status does not synthesize a credit or debit. Stripe describes zero,
|
|
236
|
+
one, or two balance transactions showing withdrawals and reinstatements.
|
|
237
|
+
|
|
238
|
+
A validated empty `balanceTransactions` means Stripe reported no balance
|
|
239
|
+
transactions in that snapshot. Missing/incomplete/malformed balance evidence
|
|
240
|
+
throws `PaymentProviderError`; it never becomes an empty array. Known core
|
|
241
|
+
fields with malformed values, unsafe amounts, duplicate transaction IDs,
|
|
242
|
+
inconsistent net values, missing environments, or mismatched identities fail
|
|
243
|
+
closed. Additional unrelated provider fields are ignored. Future lifecycle
|
|
244
|
+
statuses become `status: 'unknown'` with their original `providerStatus`;
|
|
245
|
+
consumers must quarantine those business decisions. Future `charge.dispute.*`
|
|
246
|
+
event types throw rather than falling through as an ignored payment.
|
|
247
|
+
|
|
248
|
+
Webhook signature verification occurs before parsing; Connect ownership
|
|
249
|
+
resolution occurs before the duplicate marker is recorded. Duplicate and older
|
|
250
|
+
events retain their original evidence; the adapter does not merge snapshots,
|
|
251
|
+
suppress stale events, journal funds, or guarantee durable deduplication.
|
|
252
|
+
Persist event and balance transaction identifiers in the consumer and reread
|
|
253
|
+
authoritatively for retry/crash recovery. Provider/transport errors propagate;
|
|
254
|
+
no dispute writes are exposed. Do not persist `raw`, which may contain PII.
|
|
255
|
+
|
|
256
|
+
Semantics checked against Stripe's official
|
|
257
|
+
[dispute object](https://docs.stripe.com/api/disputes/object),
|
|
258
|
+
[event types](https://docs.stripe.com/api/events/types),
|
|
259
|
+
[dispute retrieval](https://docs.stripe.com/api/disputes/retrieve), and
|
|
260
|
+
[balance transaction object](https://docs.stripe.com/api/balance_transactions/object)
|
|
261
|
+
on 2026-10-23.
|
|
262
|
+
|
|
183
263
|
### BTCPay Greenfield client
|
|
184
264
|
|
|
185
265
|
`BtcpayClient` is a stateless client for one BTCPay Server store (Greenfield
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FetchLike } from '../shared.js';
|
|
2
|
-
import { AuthorizationResult, AuthorizePaymentInput, CapturePaymentInput, CaptureResult, CreatePaymentOptionInput, CreateSetupSessionInput, GetSetupResultInput, PaymentBackend, PaymentBackendCapabilities, PaymentEvent, PaymentOption, PaymentStatus, PaymentStatusContext, PaymentStatusResult, PaymentWebhookEvent, PayoutResult, RefundPaymentInput, RefundResult, SavedPaymentMethod, SendPayoutInput, SetupSession, VoidPaymentInput, VoidResult, WatchPaymentInput } from '../types.js';
|
|
2
|
+
import { AuthorizationResult, AuthorizePaymentInput, CapturePaymentInput, CaptureResult, CreatePaymentOptionInput, CreateSetupSessionInput, GetSetupResultInput, PaymentBackend, PaymentBackendCapabilities, PaymentDispute, PaymentEvent, PaymentOption, PaymentStatus, PaymentStatusContext, PaymentStatusResult, PaymentWebhookEvent, PayoutResult, RefundPaymentInput, RefundResult, SavedPaymentMethod, SendPayoutInput, SetupSession, VoidPaymentInput, VoidResult, WatchPaymentInput } from '../types.js';
|
|
3
3
|
export declare const STRIPE_BACKEND_ID = "stripe";
|
|
4
4
|
export interface StripeAdapterOptions {
|
|
5
5
|
secretKey: string;
|
|
@@ -67,7 +67,11 @@ export interface StripeWebhookEvent extends PaymentWebhookEvent {
|
|
|
67
67
|
* platform-endpoint events never carry it.
|
|
68
68
|
*/
|
|
69
69
|
account?: string;
|
|
70
|
-
/**
|
|
70
|
+
/** Verified event environment and timestamp (required for dispute events). */
|
|
71
|
+
livemode?: boolean;
|
|
72
|
+
createdAt?: Date;
|
|
73
|
+
dispute?: StripeDispute;
|
|
74
|
+
/** Typed Connect account, application-fee, and dispute payloads. */
|
|
71
75
|
connect?: StripeConnectEventDetail;
|
|
72
76
|
raw: unknown;
|
|
73
77
|
}
|
|
@@ -81,7 +85,20 @@ export type StripeConnectEventDetail = {
|
|
|
81
85
|
} | {
|
|
82
86
|
type: 'application_fee.created' | 'application_fee.refunded';
|
|
83
87
|
applicationFee: StripeApplicationFee;
|
|
88
|
+
} | {
|
|
89
|
+
type: StripeDisputeEventType;
|
|
90
|
+
dispute: StripeDispute;
|
|
84
91
|
};
|
|
92
|
+
export type StripeDisputeEventType = 'charge.dispute.created' | 'charge.dispute.updated' | 'charge.dispute.closed' | 'charge.dispute.funds_withdrawn' | 'charge.dispute.funds_reinstated';
|
|
93
|
+
export interface StripeDispute extends PaymentDispute {
|
|
94
|
+
/** Verified webhook origin or authenticated request scope; absent for platform. */
|
|
95
|
+
account?: string;
|
|
96
|
+
raw: unknown;
|
|
97
|
+
}
|
|
98
|
+
export interface StripeGetDisputeOptions extends StripeAccountScope {
|
|
99
|
+
/** Reject an authoritative reread from a different environment. */
|
|
100
|
+
expectedLivemode?: boolean;
|
|
101
|
+
}
|
|
85
102
|
/** Connected account onboarding and capability state. */
|
|
86
103
|
export interface StripeConnectAccountStatus {
|
|
87
104
|
accountId: string;
|
|
@@ -239,6 +256,8 @@ export declare class StripeAdapter implements PaymentBackend {
|
|
|
239
256
|
* status, and outstanding requirements).
|
|
240
257
|
*/
|
|
241
258
|
getAccountCapabilities(accountId: string): Promise<StripeConnectAccountStatus>;
|
|
259
|
+
/** Authoritative read. No request or adapter account scope means platform. */
|
|
260
|
+
getDispute(disputeId: string, options?: StripeGetDisputeOptions): Promise<StripeDispute>;
|
|
242
261
|
private verifyWebhookEvent;
|
|
243
262
|
private recordWebhookEvent;
|
|
244
263
|
private assertAdapterAccount;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stripe.d.ts","sourceRoot":"","sources":["../../src/adapters/stripe.ts"],"names":[],"mappings":"AAOA,OAAO,EAEL,KAAK,SAAS,EAaf,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EACV,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,EACb,wBAAwB,EACxB,uBAAuB,EACvB,mBAAmB,EACnB,cAAc,EACd,0BAA0B,EAC1B,YAAY,EACZ,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAErB,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAM1C,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,cAA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C,CAAC,MAAM,CAAC,CAAC;IA2CrD;;;;OAIG;IACG,qBAAqB,CACzB,KAAK,GAAE,gCAAqC,GAC3C,OAAO,CAAC,0BAA0B,CAAC;IA2BtC;;;;;OAKG;IACG,oBAAoB,CACxB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,iCAAsC,GAC9C,OAAO,CAAC,oBAAoB,CAAC;IA2ChC;;;;OAIG;IACG,sBAAsB,CAC1B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,0BAA0B,CAAC;IAgBtC,8EAA8E;IACxE,UAAU,CACd,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,aAAa,CAAC;IAoCzB,OAAO,CAAC,kBAAkB;IAqH1B,OAAO,CAAC,kBAAkB;IAmB1B,OAAO,CAAC,oBAAoB;YAQd,aAAa;IAsC3B,OAAO,CAAC,uBAAuB;YAQjB,iCAAiC;IAyB/C,OAAO,CAAC,oBAAoB;IAS5B,OAAO,CAAC,2BAA2B;CAQpC;AA6bD,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,EACvB,MAAM,EAAE,MAAM,EACd,gBAAgB,SAAM,GACrB,IAAI,CA2FN"}
|
package/dist/adapters/stripe.js
CHANGED
|
@@ -495,6 +495,18 @@ var StripeAdapter = class {
|
|
|
495
495
|
if (status.accountId !== account) throw new PaymentVerificationError(`Stripe account response ${status.accountId} did not match ${account}.`);
|
|
496
496
|
return status;
|
|
497
497
|
}
|
|
498
|
+
/** Authoritative read. No request or adapter account scope means platform. */
|
|
499
|
+
async getDispute(disputeId, options = {}) {
|
|
500
|
+
const id = normalizeNonEmptyString(disputeId, "Stripe dispute id");
|
|
501
|
+
if (!/^(?:du|dp)_[A-Za-z0-9_]+$/.test(id)) throw new PaymentConfigurationError("Stripe dispute id is invalid.");
|
|
502
|
+
const scope = this.resolveStripeAccount(options.stripeAccount);
|
|
503
|
+
const account = scope === void 0 ? void 0 : normalizeStripeConnectedAccountId(scope);
|
|
504
|
+
if (account !== void 0) this.assertAdapterAccount(account);
|
|
505
|
+
if (options.expectedLivemode !== void 0 && typeof options.expectedLivemode !== "boolean") throw new PaymentConfigurationError("Stripe expectedLivemode must be boolean.");
|
|
506
|
+
const dispute = mapStripeDispute(await this.stripeRequest(`/disputes/${encodeURIComponent(id)}?expand[]=charge`, { stripeAccount: account }), account);
|
|
507
|
+
if (dispute.id !== id || options.expectedLivemode !== void 0 && dispute.livemode !== options.expectedLivemode) throw new PaymentVerificationError("Stripe dispute response identity or environment did not match the request.");
|
|
508
|
+
return dispute;
|
|
509
|
+
}
|
|
498
510
|
verifyWebhookEvent(payload, signature, endpoint) {
|
|
499
511
|
const secret = endpoint === "connect" ? this.connectWebhookSecret : this.webhookSecret;
|
|
500
512
|
if (!secret) throw new PaymentConfigurationError(endpoint === "connect" ? "StripeAdapter parseConnectWebhookEvent requires connectWebhookSecret." : "StripeAdapter parseWebhookEvent requires webhookSecret.");
|
|
@@ -511,7 +523,17 @@ var StripeAdapter = class {
|
|
|
511
523
|
this.assertAdapterAccount(account);
|
|
512
524
|
} else if (rawAccount !== void 0 && rawAccount !== null) throw new PaymentVerificationError("Stripe connected-account event received on the platform webhook endpoint; verify it with parseConnectWebhookEvent.");
|
|
513
525
|
const data = event.data?.object;
|
|
514
|
-
const
|
|
526
|
+
const dispute = type.startsWith("charge.dispute.") ? mapStripeDispute(data, account) : void 0;
|
|
527
|
+
let disputeType;
|
|
528
|
+
if (dispute !== void 0) {
|
|
529
|
+
disputeType = readStripeDisputeEventType(type);
|
|
530
|
+
if (typeof event.livemode !== "boolean" || event.livemode !== dispute.livemode) throw new PaymentVerificationError("Stripe dispute event environment is missing or inconsistent.");
|
|
531
|
+
}
|
|
532
|
+
const createdAt = dispute === void 0 ? void 0 : disputeDate(event.created);
|
|
533
|
+
const connect = disputeType && dispute ? {
|
|
534
|
+
type: disputeType,
|
|
535
|
+
dispute
|
|
536
|
+
} : mapStripeConnectEventDetail(type, data);
|
|
515
537
|
if (account !== void 0 && connect?.type === "account.updated" && connect.account.accountId !== account) throw new PaymentVerificationError("Stripe account.updated webhook object did not match the event account.");
|
|
516
538
|
return {
|
|
517
539
|
id,
|
|
@@ -522,6 +544,11 @@ var StripeAdapter = class {
|
|
|
522
544
|
duplicate: this.seenWebhookEventIds.has(id),
|
|
523
545
|
...account === void 0 ? {} : { account },
|
|
524
546
|
...connect === void 0 ? {} : { connect },
|
|
547
|
+
...dispute === void 0 ? {} : {
|
|
548
|
+
dispute,
|
|
549
|
+
livemode: dispute.livemode,
|
|
550
|
+
createdAt
|
|
551
|
+
},
|
|
525
552
|
raw: event
|
|
526
553
|
};
|
|
527
554
|
}
|
|
@@ -638,6 +665,111 @@ function mapStripeApplicationFee(fee) {
|
|
|
638
665
|
raw: fee
|
|
639
666
|
};
|
|
640
667
|
}
|
|
668
|
+
var STRIPE_DISPUTE_STATUSES = /* @__PURE__ */ new Set([
|
|
669
|
+
"warning_needs_response",
|
|
670
|
+
"warning_under_review",
|
|
671
|
+
"warning_closed",
|
|
672
|
+
"needs_response",
|
|
673
|
+
"under_review",
|
|
674
|
+
"won",
|
|
675
|
+
"lost",
|
|
676
|
+
"prevented"
|
|
677
|
+
]);
|
|
678
|
+
function readStripeDisputeEventType(type) {
|
|
679
|
+
switch (type) {
|
|
680
|
+
case "charge.dispute.created":
|
|
681
|
+
case "charge.dispute.updated":
|
|
682
|
+
case "charge.dispute.closed":
|
|
683
|
+
case "charge.dispute.funds_withdrawn":
|
|
684
|
+
case "charge.dispute.funds_reinstated": return type;
|
|
685
|
+
default: throw new PaymentProviderError("Unsupported Stripe dispute event type.");
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
function disputeError(field) {
|
|
689
|
+
throw new PaymentProviderError(`Stripe dispute has invalid or missing ${field}.`);
|
|
690
|
+
}
|
|
691
|
+
function disputeRecord(value, field) {
|
|
692
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return disputeError(field);
|
|
693
|
+
return value;
|
|
694
|
+
}
|
|
695
|
+
function disputeString(value, field) {
|
|
696
|
+
if (typeof value !== "string" || !value.trim() || value !== value.trim()) return disputeError(field);
|
|
697
|
+
return value;
|
|
698
|
+
}
|
|
699
|
+
function disputeId(value, prefix) {
|
|
700
|
+
const id = disputeString(typeof value === "object" && value !== null ? disputeRecord(value, prefix).id : value, prefix);
|
|
701
|
+
if (!new RegExp(`^${prefix === "ch" ? "(?:ch|py)" : prefix === "du" ? "(?:du|dp)" : prefix}_[A-Za-z0-9_]+$`).test(id)) return disputeError(prefix);
|
|
702
|
+
return id;
|
|
703
|
+
}
|
|
704
|
+
function disputeInteger(value, field) {
|
|
705
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value)) return disputeError(field);
|
|
706
|
+
return value;
|
|
707
|
+
}
|
|
708
|
+
function disputeDate(value) {
|
|
709
|
+
const seconds = disputeInteger(value, "created");
|
|
710
|
+
const date = /* @__PURE__ */ new Date(seconds * 1e3);
|
|
711
|
+
if (seconds < 0 || !Number.isSafeInteger(seconds * 1e3) || !Number.isFinite(date.getTime())) return disputeError("created");
|
|
712
|
+
return date;
|
|
713
|
+
}
|
|
714
|
+
function disputeCurrency(value) {
|
|
715
|
+
if (typeof value !== "string" || !/^[a-z]{3}$/.test(value)) return disputeError("currency");
|
|
716
|
+
return value.toUpperCase();
|
|
717
|
+
}
|
|
718
|
+
function mapStripeDispute(value, account) {
|
|
719
|
+
const object = disputeRecord(value, "object");
|
|
720
|
+
if (object.object !== "dispute") return disputeError("object");
|
|
721
|
+
const id = disputeId(object.id, "du");
|
|
722
|
+
const chargeId = disputeId(object.charge, "ch");
|
|
723
|
+
const expandedCharge = typeof object.charge === "object" ? disputeRecord(object.charge, "charge") : void 0;
|
|
724
|
+
const paymentIntent = object.payment_intent ?? expandedCharge?.payment_intent;
|
|
725
|
+
const paymentIntentId = paymentIntent == null ? void 0 : disputeId(paymentIntent, "pi");
|
|
726
|
+
if (object.payment_intent != null && expandedCharge?.payment_intent != null && paymentIntentId !== disputeId(expandedCharge.payment_intent, "pi")) return disputeError("payment_intent");
|
|
727
|
+
const amount = disputeInteger(object.amount, "amount");
|
|
728
|
+
if (amount < 0) return disputeError("amount");
|
|
729
|
+
const currency = disputeCurrency(object.currency);
|
|
730
|
+
const providerStatus = disputeString(object.status, "status");
|
|
731
|
+
const status = STRIPE_DISPUTE_STATUSES.has(providerStatus) ? providerStatus : "unknown";
|
|
732
|
+
if (typeof object.livemode !== "boolean") return disputeError("livemode");
|
|
733
|
+
if (object.account !== void 0 && object.account !== account) return disputeError("account");
|
|
734
|
+
if (expandedCharge?.livemode !== void 0 && expandedCharge.livemode !== object.livemode) return disputeError("charge.livemode");
|
|
735
|
+
if (!Array.isArray(object.balance_transactions)) return disputeError("balance_transactions");
|
|
736
|
+
const ids = /* @__PURE__ */ new Set();
|
|
737
|
+
const balanceTransactions = object.balance_transactions.map((value) => {
|
|
738
|
+
const transaction = disputeRecord(value, "balance_transaction");
|
|
739
|
+
if (transaction.object !== "balance_transaction") return disputeError("balance_transaction.object");
|
|
740
|
+
const id = disputeId(transaction.id, "txn");
|
|
741
|
+
if (ids.has(id)) return disputeError("duplicate balance_transaction");
|
|
742
|
+
ids.add(id);
|
|
743
|
+
const amount = disputeInteger(transaction.amount, "balance_transaction.amount");
|
|
744
|
+
const fee = disputeInteger(transaction.fee, "balance_transaction.fee");
|
|
745
|
+
const net = disputeInteger(transaction.net, "balance_transaction.net");
|
|
746
|
+
if (!Number.isSafeInteger(amount - fee) || amount - fee !== net) return disputeError("balance_transaction.net");
|
|
747
|
+
return {
|
|
748
|
+
id,
|
|
749
|
+
amount,
|
|
750
|
+
fee,
|
|
751
|
+
net,
|
|
752
|
+
currency: disputeCurrency(transaction.currency),
|
|
753
|
+
createdAt: disputeDate(transaction.created),
|
|
754
|
+
type: disputeString(transaction.type, "balance_transaction.type"),
|
|
755
|
+
reportingCategory: transaction.reporting_category === void 0 ? void 0 : disputeString(transaction.reporting_category, "balance_transaction.reporting_category")
|
|
756
|
+
};
|
|
757
|
+
});
|
|
758
|
+
return {
|
|
759
|
+
id,
|
|
760
|
+
chargeId,
|
|
761
|
+
paymentIntentId,
|
|
762
|
+
amount,
|
|
763
|
+
currency,
|
|
764
|
+
status,
|
|
765
|
+
providerStatus,
|
|
766
|
+
livemode: object.livemode,
|
|
767
|
+
createdAt: disputeDate(object.created),
|
|
768
|
+
balanceTransactions,
|
|
769
|
+
...account === void 0 ? {} : { account },
|
|
770
|
+
raw: object
|
|
771
|
+
};
|
|
772
|
+
}
|
|
641
773
|
function mapStripeConnectEventDetail(type, object) {
|
|
642
774
|
if (type === "account.updated") return {
|
|
643
775
|
type,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stripe.js","names":[],"sources":["../../src/adapters/stripe.ts"],"sourcesContent":["import { createHmac, timingSafeEqual } from 'node:crypto';\nimport {\n PaymentConfigurationError,\n PaymentNotOwnedError,\n PaymentProviderError,\n PaymentVerificationError,\n} from '../errors.js';\nimport {\n applyExpiryToPendingStatus,\n type FetchLike,\n formEncode,\n getFetch,\n normalizeDate,\n normalizeMaxStoredPaymentOptions,\n normalizeMinorUnitAmount,\n normalizeNonEmptyString,\n normalizePositiveMinorUnitAmount,\n normalizePositivePaymentAmount,\n normalizeUrlString,\n pollPaymentStatus,\n readJsonResponse,\n rememberPaymentOption,\n} from '../shared.js';\nimport type {\n AuthorizationResult,\n AuthorizePaymentInput,\n CapturePaymentInput,\n CaptureResult,\n CreatePaymentOptionInput,\n CreateSetupSessionInput,\n GetSetupResultInput,\n PaymentBackend,\n PaymentBackendCapabilities,\n PaymentEvent,\n PaymentOption,\n PaymentStatus,\n PaymentStatusContext,\n PaymentStatusResult,\n PaymentWebhookEvent,\n PayoutResult,\n RefundPaymentInput,\n RefundResult,\n SavedPaymentMethod,\n SendPayoutInput,\n SetupSession,\n VoidPaymentInput,\n VoidResult,\n WatchPaymentInput,\n} from '../types.js';\n\nexport const STRIPE_BACKEND_ID = 'stripe';\nconst STRIPE_CHECKOUT_MIN_EXPIRY_MS = 30 * 60 * 1_000;\nconst STRIPE_CHECKOUT_MAX_EXPIRY_MS = 24 * 60 * 60 * 1_000;\nconst DEFAULT_STRIPE_API_VERSION = '2024-06-20';\nconst DEFAULT_MAX_STORED_WEBHOOK_EVENT_IDS = 50_000;\n\nexport interface StripeAdapterOptions {\n secretKey: string;\n fetch?: FetchLike;\n apiBaseUrl?: string;\n apiVersion?: string;\n defaultCurrency?: string;\n supportedCurrencies?: string[];\n successUrl?: string;\n cancelUrl?: string;\n checkoutMode?: string;\n webhookSecret?: string;\n /**\n * Signing secret of the Stripe Connect webhook endpoint. Stripe signs\n * connected-account events with a different secret from the platform\n * endpoint; see {@link StripeAdapter.parseConnectWebhookEvent}.\n */\n connectWebhookSecret?: string;\n pollIntervalMs?: number;\n maxStoredPaymentOptions?: number;\n maxStoredWebhookEventIds?: number;\n /** Default Stripe Connect account for this adapter's provider requests. */\n stripeAccount?: string;\n}\n\n/** Stripe Connect account scope for a request; omit it for the platform. */\nexport interface StripeAccountScope {\n stripeAccount?: string;\n}\n\nexport interface StripeCreatePaymentOptionInput\n extends CreatePaymentOptionInput,\n StripeAccountScope {\n /** Stripe application fee in integer minor units for this direct charge. */\n applicationFeeAmount?: number;\n}\n\nexport interface StripePaymentStatusContext\n extends PaymentStatusContext,\n StripeAccountScope {}\n\nexport interface StripeRefundPaymentInput\n extends RefundPaymentInput,\n StripeAccountScope {\n /** Refund a Stripe application fee collected with the charge. */\n refundApplicationFee?: boolean;\n /** Reverse a destination transfer when the provider supports one. */\n reverseTransfer?: boolean;\n}\n\nexport interface StripeAuthorizePaymentInput\n extends AuthorizePaymentInput,\n StripeAccountScope {\n /** Stripe application fee in integer minor units for this PaymentIntent. */\n applicationFeeAmount?: number;\n}\n\nexport interface StripeCapturePaymentInput\n extends CapturePaymentInput,\n StripeAccountScope {}\n\nexport interface StripeVoidPaymentInput\n extends VoidPaymentInput,\n StripeAccountScope {}\n\nexport interface StripeCreateSetupSessionInput\n extends CreateSetupSessionInput,\n StripeAccountScope {}\n\nexport interface StripeGetSetupResultInput\n extends GetSetupResultInput,\n StripeAccountScope {}\n\nexport interface StripeWatchPaymentInput\n extends Omit<WatchPaymentInput, 'statusContext'> {\n statusContext?: StripePaymentStatusContext;\n}\n\nexport interface StripeWebhookEvent extends PaymentWebhookEvent {\n id: string;\n type: string;\n status: PaymentStatus;\n quoteId?: string;\n providerPaymentId?: string;\n /**\n * Connected account (`acct_...`) the event originated from. Set only on\n * events verified through {@link StripeAdapter.parseConnectWebhookEvent};\n * platform-endpoint events never carry it.\n */\n account?: string;\n /** Typed Connect payload for `account.updated` and `application_fee.*`. */\n connect?: StripeConnectEventDetail;\n raw: unknown;\n}\n\n/** A Connect endpoint event: always scoped to a connected account. */\nexport interface StripeConnectWebhookEvent extends StripeWebhookEvent {\n account: string;\n}\n\nexport type StripeConnectEventDetail =\n | {\n type: 'account.updated';\n account: StripeConnectAccountStatus;\n }\n | {\n type: 'application_fee.created' | 'application_fee.refunded';\n applicationFee: StripeApplicationFee;\n };\n\n/** Connected account onboarding and capability state. */\nexport interface StripeConnectAccountStatus {\n accountId: string;\n /** Stripe account type (`standard`, `express`, `custom`) when reported. */\n type?: string;\n /** Stripe `charges_enabled`. */\n chargesEnabled: boolean;\n /** Stripe `details_submitted`. */\n detailsSubmitted: boolean;\n /** Stripe `payouts_enabled`. */\n payoutsEnabled: boolean;\n /** Per-capability state, e.g. `{ card_payments: 'active' }`. */\n capabilities: Record<string, string>;\n requirements: {\n currentlyDue: string[];\n eventuallyDue: string[];\n pastDue: string[];\n disabledReason?: string;\n };\n country?: string;\n defaultCurrency?: string;\n raw: unknown;\n}\n\nexport interface StripeApplicationFee {\n id: string;\n /** Connected account the fee was collected from. */\n account?: string;\n /** Fee amount in integer minor units. */\n amount?: number;\n /** Refunded portion in integer minor units. */\n amountRefunded?: number;\n currency?: string;\n refunded: boolean;\n charge?: string;\n livemode?: boolean;\n raw: unknown;\n}\n\nexport interface StripeCreateStandardAccountInput {\n /** Two-letter ISO country code of the account holder. */\n country?: string;\n /** Prefills the account holder's email in Stripe onboarding. */\n email?: string;\n businessType?: 'individual' | 'company' | 'non_profit' | 'government_entity';\n metadata?: Record<string, string | number | boolean | null | undefined>;\n idempotencyKey?: string;\n}\n\nexport interface StripeOnboardingLink {\n /** Single-use Stripe-hosted onboarding URL; treat it as a bearer secret. */\n url: string;\n expiresAt?: Date;\n raw: unknown;\n}\n\nexport interface StripeCreateOnboardingLinkOptions {\n /** Which requirements to collect up front; Stripe defaults to `currently_due`. */\n collect?: 'currently_due' | 'eventually_due';\n idempotencyKey?: string;\n}\n\n/**\n * Host mapping from a connected account to its owner. Return `undefined` or\n * `null` for an account the host does not recognize; the event is then\n * rejected with {@link PaymentNotOwnedError}.\n */\nexport type StripeConnectAccountResolver<TOwner> = (\n account: string,\n event: StripeWebhookEvent,\n) => TOwner | null | undefined | Promise<TOwner | null | undefined>;\n\nexport interface StripeResolveConnectWebhookOptions<TOwner> {\n resolveAccount: StripeConnectAccountResolver<TOwner>;\n /**\n * Endpoint the delivery arrived on. `connect` (default) verifies with\n * `connectWebhookSecret` and routes by the event's `account`. `platform`\n * verifies with `webhookSecret` and routes `application_fee.*` events by the\n * fee's connected account; other platform events are rejected.\n */\n endpoint?: 'connect' | 'platform';\n}\n\nexport interface StripeResolvedConnectWebhookEvent<TOwner> {\n event: StripeWebhookEvent;\n /** Connected account the event was routed by. */\n account: string;\n owner: TOwner;\n}\n\nexport class StripeAdapter implements PaymentBackend {\n readonly capabilities: PaymentBackendCapabilities;\n\n private readonly fetch: FetchLike;\n private readonly secretKey: string;\n private readonly apiBaseUrl: string;\n private readonly apiVersion: string;\n private readonly defaultCurrency: string;\n private readonly supportedCurrencies: Set<string>;\n private readonly checkoutMode: string;\n private readonly webhookSecret: string | undefined;\n private readonly connectWebhookSecret: string | undefined;\n private readonly stripeAccount: string | undefined;\n private readonly maxStoredPaymentOptions: number;\n private readonly maxStoredWebhookEventIds: number;\n private readonly optionsByQuote = new Map<string, PaymentOption>();\n private readonly seenWebhookEventIds = new Set<string>();\n\n constructor(private readonly options: StripeAdapterOptions) {\n if (typeof options.secretKey !== 'string' || !options.secretKey.trim()) {\n throw new PaymentConfigurationError('StripeAdapter requires secretKey.');\n }\n\n assertOptionalSecret(options.webhookSecret, 'webhookSecret');\n assertOptionalSecret(options.connectWebhookSecret, 'connectWebhookSecret');\n\n if (options.apiBaseUrl !== undefined) {\n if (typeof options.apiBaseUrl !== 'string') {\n throw new PaymentConfigurationError(\n 'StripeAdapter apiBaseUrl must be a string when configured.',\n );\n }\n\n if (!options.apiBaseUrl.trim()) {\n throw new PaymentConfigurationError(\n 'StripeAdapter apiBaseUrl must not be empty when configured.',\n );\n }\n }\n\n this.fetch = getFetch(options.fetch);\n this.maxStoredPaymentOptions = normalizeMaxStoredPaymentOptions(\n options.maxStoredPaymentOptions,\n 'StripeAdapter maxStoredPaymentOptions',\n );\n this.maxStoredWebhookEventIds = normalizeMaxStoredPaymentOptions(\n options.maxStoredWebhookEventIds ?? DEFAULT_MAX_STORED_WEBHOOK_EVENT_IDS,\n 'StripeAdapter maxStoredWebhookEventIds',\n );\n this.secretKey = options.secretKey.trim();\n this.apiBaseUrl = normalizeUrlString(\n options.apiBaseUrl ?? 'https://api.stripe.com/v1',\n 'StripeAdapter apiBaseUrl',\n ).replace(/\\/$/, '');\n this.apiVersion = normalizeNonEmptyString(\n options.apiVersion ?? DEFAULT_STRIPE_API_VERSION,\n 'StripeAdapter apiVersion',\n );\n this.defaultCurrency = normalizeStripeCurrency(\n options.defaultCurrency ?? 'usd',\n );\n this.supportedCurrencies = normalizeSupportedStripeCurrencies(\n options.supportedCurrencies,\n this.defaultCurrency,\n );\n this.checkoutMode = options.checkoutMode ?? 'payment';\n\n if (this.checkoutMode !== 'payment') {\n throw new PaymentConfigurationError(\n 'StripeAdapter only supports payment Checkout mode.',\n );\n }\n\n this.webhookSecret = options.webhookSecret?.trim();\n this.connectWebhookSecret = options.connectWebhookSecret?.trim();\n this.stripeAccount = normalizeOptionalStripeAccount(\n options.stripeAccount,\n 'StripeAdapter stripeAccount',\n );\n this.capabilities = {\n id: STRIPE_BACKEND_ID,\n displayName: 'Stripe Checkout',\n settlementCurrency: this.defaultCurrency.toUpperCase(),\n supportedSettlementCurrencies: [...this.supportedCurrencies].map(\n (currency) => currency.toUpperCase(),\n ),\n chain: 'stripe',\n settlementShape: 'url',\n x402Capable: false,\n confirmationLatency: {\n expectedSeconds: 5,\n maxExpectedSeconds: 600,\n description:\n 'Card payments usually confirm in seconds; bank debits can remain processing while Stripe settles them.',\n },\n supportsRefunds: true,\n supportsPayouts: true,\n supportsWebhooks: true,\n supportsManualCapture: true,\n supportsSavedPaymentMethods: true,\n metadata: {\n provider: 'stripe',\n },\n };\n }\n\n async createPaymentOption(\n input: StripeCreatePaymentOptionInput,\n ): Promise<PaymentOption> {\n const quoteId = normalizeNonEmptyString(input.quoteId, 'Stripe quoteId');\n const rawSuccessUrl = input.successUrl ?? this.options.successUrl;\n const rawCancelUrl = input.cancelUrl ?? this.options.cancelUrl;\n\n if (rawSuccessUrl === undefined || rawCancelUrl === undefined) {\n throw new PaymentConfigurationError(\n 'StripeAdapter createPaymentOption requires successUrl and cancelUrl.',\n );\n }\n\n const successUrl = normalizeUrlString(rawSuccessUrl, 'Stripe successUrl');\n const cancelUrl = normalizeUrlString(rawCancelUrl, 'Stripe cancelUrl');\n const currency = normalizeStripeCurrency(input.currency);\n this.assertSupportedCurrency(currency);\n const amount = normalizePositivePaymentAmount(\n input.amount,\n currency,\n 'Stripe Checkout amount',\n );\n const applicationFeeAmount = normalizeApplicationFeeAmount(\n input.applicationFeeAmount,\n amount,\n 'Stripe Checkout applicationFeeAmount',\n );\n const expiresAt = normalizeDate(input.expiresAt);\n const stripeExpiresAt = normalizeStripeCheckoutExpiresAt(expiresAt);\n const params: Record<string, unknown> = {\n mode: this.checkoutMode,\n ...Object.fromEntries([\n ['success_url', successUrl],\n ['cancel_url', cancelUrl],\n ['client_reference_id', quoteId],\n ['customer_email', input.buyerEmail],\n ['expires_at', Math.floor(stripeExpiresAt.getTime() / 1_000)],\n ]),\n 'line_items[0][quantity]': 1,\n 'line_items[0][price_data][currency]': currency,\n 'line_items[0][price_data][unit_amount]': amount,\n 'line_items[0][price_data][product_data][name]':\n input.description ?? `Quote ${quoteId}`,\n ...(applicationFeeAmount === undefined\n ? {}\n : {\n 'payment_intent_data[application_fee_amount]': applicationFeeAmount,\n }),\n ...flattenStripeMetadata(input.metadata),\n 'metadata[quoteId]': quoteId,\n };\n\n const stripeAccount = this.resolveStripeAccount(input.stripeAccount);\n const session = await this.stripeRequest<Record<string, unknown>>(\n '/checkout/sessions',\n {\n method: 'POST',\n idempotencyKey: input.idempotencyKey,\n stripeAccount,\n body: formEncode(params),\n },\n );\n const sessionId = normalizeOptionalProviderString(\n readProviderString(session, 'id'),\n );\n const checkoutUrl = normalizeOptionalProviderString(\n readProviderString(session, 'url'),\n );\n\n if (!sessionId || !checkoutUrl) {\n throw new PaymentProviderError(\n 'Stripe Checkout Session response did not include id and url.',\n );\n }\n\n const option: PaymentOption = {\n backendId: this.capabilities.id,\n quoteId,\n payTo: checkoutUrl,\n settlementShape: 'url',\n settlementCurrency: currency.toUpperCase(),\n settlementAmount: amount,\n amount,\n currency: currency.toUpperCase(),\n expiresAt: stripeExpiresAt,\n providerPaymentId: sessionId,\n paymentUri: checkoutUrl,\n metadata: {\n sessionId,\n stripeAccount,\n paymentIntent: normalizeOptionalProviderString(\n readProviderString(session, 'payment_intent'),\n ),\n },\n };\n\n rememberPaymentOption(\n this.optionsByQuote,\n stripePaymentOptionKey(quoteId, stripeAccount),\n option,\n this.maxStoredPaymentOptions,\n );\n\n return option;\n }\n\n watchPayment(input: StripeWatchPaymentInput): AsyncIterable<PaymentEvent> {\n return pollPaymentStatus(\n {\n ...input,\n pollIntervalMs:\n input.pollIntervalMs ?? this.options.pollIntervalMs ?? 5_000,\n },\n () => this.getStatus(input.quoteId, input.payTo, input.statusContext),\n );\n }\n\n async getStatus(\n quoteId: string,\n payTo: string,\n context: StripePaymentStatusContext = {},\n ): Promise<PaymentStatusResult> {\n const normalizedQuoteId = normalizeNonEmptyString(\n quoteId,\n 'Stripe quoteId',\n );\n const normalizedPayTo = normalizeNonEmptyString(payTo, 'Stripe payTo');\n const contextProviderPaymentId =\n context.providerPaymentId === undefined\n ? undefined\n : normalizeNonEmptyString(\n context.providerPaymentId,\n 'Stripe providerPaymentId',\n );\n const contextStripeAccount = normalizeOptionalStripeAccount(\n context.stripeAccount,\n 'Stripe stripeAccount',\n );\n const scopedOption = this.optionsByQuote.get(\n stripePaymentOptionKey(\n normalizedQuoteId,\n contextStripeAccount ?? this.stripeAccount,\n ),\n );\n const sessionId =\n contextProviderPaymentId ??\n extractStripeSessionId(normalizedPayTo) ??\n scopedOption?.providerPaymentId;\n\n if (!sessionId) {\n throw new PaymentConfigurationError(\n 'Stripe getStatus requires a Checkout Session id or URL.',\n );\n }\n\n const storedOption = this.findStoredOptionBySessionId(sessionId);\n const stripeAccount =\n contextStripeAccount ??\n readStripeOptionAccount(storedOption) ??\n this.stripeAccount;\n const cachedOption = this.optionsByQuote.get(\n stripePaymentOptionKey(normalizedQuoteId, stripeAccount),\n );\n\n // A caller-supplied session id can deliberately select a later checkout\n // for the same quote. Cache-derived amount, currency, and expiry describe\n // only the session we created, never an explicitly selected replacement.\n const option =\n cachedOption?.providerPaymentId === sessionId ? cachedOption : undefined;\n\n const session = await this.stripeRequest<Record<string, unknown>>(\n `/checkout/sessions/${encodeURIComponent(sessionId)}`,\n { stripeAccount },\n );\n const sessionQuoteId = readStripeSessionQuoteId(session);\n\n if (sessionQuoteId !== undefined && sessionQuoteId !== normalizedQuoteId) {\n throw new PaymentVerificationError(\n `Stripe Checkout Session quoteId ${sessionQuoteId} did not match ${normalizedQuoteId}.`,\n );\n }\n\n const paymentStatus = readString(session, 'payment_status');\n const status = mapStripeStatus(\n readString(session, 'status'),\n paymentStatus,\n );\n\n const contextAmount =\n context.amount === undefined\n ? undefined\n : normalizeMinorUnitAmount(context.amount, 'Stripe status');\n const contextCurrency =\n context.currency === undefined\n ? undefined\n : normalizeStripeCurrency(context.currency).toUpperCase();\n const sessionCurrency =\n readString(session, 'currency') === undefined\n ? undefined\n : normalizeStripeCurrency(\n readString(session, 'currency') ?? '',\n ).toUpperCase();\n const sessionAmount = readSafeInteger(session, 'amount_total');\n const expiresAt =\n option?.expiresAt ??\n (context.expiresAt === undefined\n ? undefined\n : normalizeDate(context.expiresAt));\n const effectiveStatus = applyExpiryToPendingStatus(status, expiresAt);\n\n return {\n backendId: this.capabilities.id,\n quoteId: normalizedQuoteId,\n payTo: normalizedPayTo,\n status: effectiveStatus,\n settlementCurrency:\n sessionCurrency ??\n option?.settlementCurrency ??\n contextCurrency ??\n this.defaultCurrency.toUpperCase(),\n settlementAmount:\n sessionAmount ?? option?.settlementAmount ?? contextAmount,\n receivedAmount:\n paymentStatus === 'paid' || paymentStatus === 'no_payment_required'\n ? (sessionAmount ?? option?.settlementAmount ?? contextAmount)\n : undefined,\n amount: option?.amount ?? contextAmount,\n currency: option?.currency ?? contextCurrency,\n providerPaymentId: sessionId,\n transactionId: normalizeOptionalProviderString(\n readProviderString(session, 'payment_intent'),\n ),\n updatedAt: new Date(),\n raw: session,\n };\n }\n\n async sendPayout(input: SendPayoutInput): Promise<PayoutResult> {\n const currency = normalizeStripeCurrency(\n input.currency ?? this.defaultCurrency,\n );\n this.assertSupportedCurrency(currency);\n const destination = normalizeNonEmptyString(\n input.destination,\n 'Stripe payout destination',\n );\n const quoteId =\n input.quoteId === undefined\n ? undefined\n : normalizeNonEmptyString(input.quoteId, 'Stripe payout quoteId');\n const amount = normalizePositivePaymentAmount(\n input.amount,\n currency,\n 'Stripe payout amount',\n );\n const transfer = await this.stripeRequest<Record<string, unknown>>(\n '/transfers',\n {\n method: 'POST',\n idempotencyKey: input.idempotencyKey,\n body: formEncode({\n amount,\n currency,\n destination,\n description: input.memo,\n ...flattenStripeMetadata(input.metadata),\n ...(quoteId === undefined ? {} : { 'metadata[quoteId]': quoteId }),\n }),\n },\n );\n\n return {\n backendId: this.capabilities.id,\n status: 'submitted',\n payoutId: normalizeOptionalProviderString(\n readProviderString(transfer, 'id'),\n ),\n destination,\n amount,\n currency: currency.toUpperCase(),\n raw: transfer,\n };\n }\n\n async refundPayment(input: StripeRefundPaymentInput): Promise<RefundResult> {\n const rawPaymentReference = input.paymentId ?? input.transactionId;\n\n if (!rawPaymentReference) {\n throw new PaymentConfigurationError(\n 'Stripe refunds require paymentId or transactionId.',\n );\n }\n\n const paymentReference = normalizeNonEmptyString(\n rawPaymentReference,\n 'Stripe refund payment reference',\n );\n const currency = normalizeStripeCurrency(\n input.currency ?? this.defaultCurrency,\n );\n this.assertSupportedCurrency(currency);\n const amount =\n input.amount === undefined\n ? undefined\n : normalizePositivePaymentAmount(\n input.amount,\n currency,\n 'Stripe refund amount',\n );\n const stripeAccount = this.resolveStripeAccount(input.stripeAccount);\n const refundReferenceParam = await this.resolveStripeRefundReferenceParam(\n paymentReference,\n stripeAccount,\n );\n const refundParams: Record<string, unknown> = {\n ...refundReferenceParam,\n amount: amount === undefined ? undefined : amount,\n reason: input.reason,\n refund_application_fee: input.refundApplicationFee,\n reverse_transfer: input.reverseTransfer,\n ...flattenStripeMetadata(input.metadata),\n };\n\n const refund = await this.stripeRequest<Record<string, unknown>>(\n '/refunds',\n {\n method: 'POST',\n idempotencyKey: input.idempotencyKey,\n stripeAccount,\n body: formEncode(refundParams),\n },\n );\n\n return {\n backendId: this.capabilities.id,\n status: mapStripeRefundStatus(readString(refund, 'status')),\n refundId: normalizeOptionalProviderString(\n readProviderString(refund, 'id'),\n ),\n transactionId: paymentReference,\n // Read the settled amount and currency back from the refund object\n // (mirrors capturePayment) so a full refund — no `input.amount` supplied,\n // and possibly a currency differing from the adapter default when\n // `input.currency` is omitted — surfaces what Stripe actually refunded\n // instead of the request defaults.\n amount: readSafeInteger(refund, 'amount') ?? amount,\n currency: readStripeResultCurrency(refund) ?? currency.toUpperCase(),\n raw: refund,\n };\n }\n\n async authorizePayment(\n input: StripeAuthorizePaymentInput,\n ): Promise<AuthorizationResult> {\n const currency = normalizeStripeCurrency(input.currency);\n this.assertSupportedCurrency(currency);\n const amount = normalizePositivePaymentAmount(\n input.amount,\n currency,\n 'Stripe authorize amount',\n );\n const paymentMethod = normalizeNonEmptyString(\n input.providerPaymentMethodId,\n 'Stripe authorize providerPaymentMethodId',\n );\n const providerCustomerId =\n input.providerCustomerId === undefined\n ? undefined\n : normalizeNonEmptyString(\n input.providerCustomerId,\n 'Stripe authorize providerCustomerId',\n );\n const quoteId =\n input.quoteId === undefined\n ? undefined\n : normalizeNonEmptyString(input.quoteId, 'Stripe authorize quoteId');\n const applicationFeeAmount = normalizeApplicationFeeAmount(\n input.applicationFeeAmount,\n amount,\n 'Stripe PaymentIntent applicationFeeAmount',\n );\n\n const intent = await this.stripeRequest<Record<string, unknown>>(\n '/payment_intents',\n {\n method: 'POST',\n idempotencyKey: input.idempotencyKey,\n stripeAccount: this.resolveStripeAccount(input.stripeAccount),\n body: formEncode({\n amount,\n currency,\n confirm: true,\n 'payment_method_types[]': 'card',\n description: input.description,\n application_fee_amount: applicationFeeAmount,\n ...Object.fromEntries([\n ['payment_method', paymentMethod],\n ['capture_method', 'manual'],\n // Off-session (merchant-initiated) by default — the primary use is\n // charging a saved card while the buyer is absent. Without this,\n // Stripe treats it as on-session and may raise an SCA challenge the\n // absent buyer can't complete, so the hold is never placed.\n ['off_session', input.offSession ?? true],\n ]),\n ...(providerCustomerId === undefined\n ? {}\n : { customer: providerCustomerId }),\n ...flattenStripeMetadata(input.metadata),\n ...(quoteId === undefined ? {} : { 'metadata[quoteId]': quoteId }),\n }),\n },\n );\n\n const providerPaymentId = normalizeOptionalProviderString(\n readProviderString(intent, 'id'),\n );\n\n if (!providerPaymentId) {\n throw new PaymentProviderError(\n 'Stripe PaymentIntent response did not include an id.',\n );\n }\n\n const status = mapStripeAuthorizationStatus(readString(intent, 'status'));\n // Only surface the SCA fields when authentication is actually required — the\n // documented contract — even though Stripe returns client_secret regardless.\n // (Authorization progress is observed via `parseWebhookEvent`, which surfaces\n // the ready-to-capture transition as `processing` — there is no distinct\n // `requires_capture` webhook status; `getStatus` handles Checkout sessions,\n // not PaymentIntents.)\n const actionRequired = status === 'requires_action';\n\n return {\n backendId: this.capabilities.id,\n status,\n providerPaymentId,\n amount: readSafeInteger(intent, 'amount') ?? amount,\n currency: (readString(intent, 'currency') ?? currency).toUpperCase(),\n clientSecret: actionRequired\n ? normalizeOptionalProviderString(\n readProviderString(intent, 'client_secret'),\n )\n : undefined,\n nextAction: actionRequired\n ? (intent.next_action ?? undefined)\n : undefined,\n raw: intent,\n };\n }\n\n async capturePayment(\n input: StripeCapturePaymentInput,\n ): Promise<CaptureResult> {\n const providerPaymentId = normalizeNonEmptyString(\n input.providerPaymentId,\n 'Stripe capture providerPaymentId',\n );\n const amount =\n input.amount === undefined\n ? undefined\n : normalizePositiveMinorUnitAmount(\n input.amount,\n 'Stripe capture amount',\n );\n\n const intent = await this.stripeRequest<Record<string, unknown>>(\n `/payment_intents/${encodeURIComponent(providerPaymentId)}/capture`,\n {\n method: 'POST',\n idempotencyKey: input.idempotencyKey,\n stripeAccount: this.resolveStripeAccount(input.stripeAccount),\n body: formEncode({\n ...Object.fromEntries([['amount_to_capture', amount]]),\n ...flattenStripeMetadata(input.metadata),\n }),\n },\n );\n\n return {\n backendId: this.capabilities.id,\n status: mapStripeCaptureStatus(readString(intent, 'status')),\n providerPaymentId:\n normalizeOptionalProviderString(readProviderString(intent, 'id')) ??\n providerPaymentId,\n amount:\n readSafeInteger(intent, 'amount_received') ??\n readSafeInteger(intent, 'amount') ??\n amount,\n currency: readStripeResultCurrency(intent),\n raw: intent,\n };\n }\n\n async voidPayment(input: StripeVoidPaymentInput): Promise<VoidResult> {\n const providerPaymentId = normalizeNonEmptyString(\n input.providerPaymentId,\n 'Stripe void providerPaymentId',\n );\n const reason =\n input.reason === undefined\n ? undefined\n : normalizeNonEmptyString(input.reason, 'Stripe void reason');\n\n const intent = await this.stripeRequest<Record<string, unknown>>(\n `/payment_intents/${encodeURIComponent(providerPaymentId)}/cancel`,\n {\n method: 'POST',\n idempotencyKey: input.idempotencyKey,\n stripeAccount: this.resolveStripeAccount(input.stripeAccount),\n body: formEncode(Object.fromEntries([['cancellation_reason', reason]])),\n },\n );\n\n return {\n backendId: this.capabilities.id,\n status: mapStripeVoidStatus(readString(intent, 'status')),\n providerPaymentId:\n normalizeOptionalProviderString(readProviderString(intent, 'id')) ??\n providerPaymentId,\n amount: readSafeInteger(intent, 'amount'),\n currency: readStripeResultCurrency(intent),\n raw: intent,\n };\n }\n\n async createSetupSession(\n input: StripeCreateSetupSessionInput,\n ): Promise<SetupSession> {\n const rawSuccessUrl = input.successUrl ?? this.options.successUrl;\n const rawCancelUrl = input.cancelUrl ?? this.options.cancelUrl;\n\n if (rawSuccessUrl === undefined || rawCancelUrl === undefined) {\n throw new PaymentConfigurationError(\n 'StripeAdapter createSetupSession requires successUrl and cancelUrl.',\n );\n }\n\n const successUrl = normalizeUrlString(rawSuccessUrl, 'Stripe successUrl');\n const cancelUrl = normalizeUrlString(rawCancelUrl, 'Stripe cancelUrl');\n // Currency for the setup-mode session (defaults to the backend currency).\n // Redundant now that payment_method_types is always set, but harmless and\n // kept so the session is well-formed if that restriction is ever relaxed.\n const currency = normalizeStripeCurrency(\n input.currency ?? this.defaultCurrency,\n );\n this.assertSupportedCurrency(currency);\n const providerCustomerId =\n input.providerCustomerId === undefined\n ? undefined\n : normalizeNonEmptyString(\n input.providerCustomerId,\n 'Stripe setup customer',\n );\n\n // Either attach to an existing customer, or force Stripe to create one so\n // the saved method comes back with a reusable `cus_` reference. Setup-mode\n // sessions do NOT create a customer on their own — `customer_creation` must\n // be `always`. All snake_case keys go through Object.fromEntries.\n const customerParams: [string, unknown][] = [];\n if (providerCustomerId !== undefined) {\n customerParams.push(['customer', providerCustomerId]);\n } else {\n customerParams.push(['customer_creation', 'always']);\n if (input.customerEmail !== undefined) {\n customerParams.push([\n 'customer_email',\n normalizeNonEmptyString(\n input.customerEmail,\n 'Stripe setup customerEmail',\n ),\n ]);\n }\n }\n\n const params: Record<string, unknown> = {\n mode: 'setup',\n currency,\n // Restrict to cards: SavedPaymentMethod exposes card display fields\n // (brand/last4/expiry), so allowing SEPA/Bacs/etc. would yield saved\n // methods with no usable display detail.\n 'payment_method_types[]': 'card',\n ...Object.fromEntries([\n ['success_url', successUrl],\n ['cancel_url', cancelUrl],\n ...customerParams,\n ]),\n ...flattenStripeMetadata(input.metadata),\n };\n\n const session = await this.stripeRequest<Record<string, unknown>>(\n '/checkout/sessions',\n {\n method: 'POST',\n idempotencyKey: input.idempotencyKey,\n stripeAccount: this.resolveStripeAccount(input.stripeAccount),\n body: formEncode(params),\n },\n );\n\n const sessionId = normalizeOptionalProviderString(\n readProviderString(session, 'id'),\n );\n const url = normalizeOptionalProviderString(\n readProviderString(session, 'url'),\n );\n\n if (!sessionId || !url) {\n throw new PaymentProviderError(\n 'Stripe setup Checkout Session response did not include id and url.',\n );\n }\n\n return {\n backendId: this.capabilities.id,\n sessionId,\n url,\n providerCustomerId:\n providerCustomerId ??\n normalizeOptionalProviderString(\n readProviderString(session, 'customer'),\n ),\n raw: session,\n };\n }\n\n async getSetupResult(\n input: StripeGetSetupResultInput,\n ): Promise<SavedPaymentMethod> {\n const sessionId = normalizeNonEmptyString(\n input.sessionId,\n 'Stripe setup sessionId',\n );\n\n const query = new URLSearchParams();\n query.append('expand[]', 'setup_intent.payment_method');\n\n const session = await this.stripeRequest<Record<string, unknown>>(\n `/checkout/sessions/${encodeURIComponent(sessionId)}?${query.toString()}`,\n { stripeAccount: this.resolveStripeAccount(input.stripeAccount) },\n );\n\n const setupIntent = readObject(session, 'setup_intent');\n const paymentMethod = readObject(setupIntent, 'payment_method');\n const card = readObject(paymentMethod, 'card');\n\n // `customer` is a bare `cus_` string on the request path (only\n // setup_intent.payment_method is expanded), but read tolerantly of an\n // expanded object so a future `expand[]=customer` can't wrongly downgrade a\n // completed setup to a permanent `pending`.\n const providerCustomerId = normalizeOptionalProviderString(\n readProviderString(session, 'customer') ??\n readProviderString(readObject(session, 'customer'), 'id'),\n );\n const providerPaymentMethodId = normalizeOptionalProviderString(\n readProviderString(paymentMethod, 'id'),\n );\n\n let status = mapStripeSetupStatus(\n readString(session, 'status'),\n readString(setupIntent, 'status'),\n );\n // Never report `complete` without the reusable references a caller needs to\n // charge the method later — a `pm_` with no `cus_` can't be charged\n // off-session, so treat that as not-yet-ready rather than a false success.\n if (\n status === 'complete' &&\n (!providerCustomerId || !providerPaymentMethodId)\n ) {\n status = 'pending';\n }\n\n return {\n backendId: this.capabilities.id,\n status,\n providerCustomerId,\n providerPaymentMethodId,\n type: readString(paymentMethod, 'type'),\n brand: readString(card, 'brand'),\n last4: readString(card, 'last4'),\n expMonth: readSafeInteger(card, 'exp_month'),\n expYear: readSafeInteger(card, 'exp_year'),\n raw: session,\n };\n }\n\n /**\n * Verify and parse a delivery to the platform webhook endpoint. Events that\n * carry a connected `account` are rejected: they belong to the Connect\n * endpoint and must never be processed as platform-account events.\n */\n parseWebhookEvent(payload: string, signature?: string): StripeWebhookEvent {\n const event = this.verifyWebhookEvent(payload, signature, 'platform');\n this.recordWebhookEvent(event);\n return event;\n }\n\n /**\n * Verify a Stripe Connect endpoint delivery with `connectWebhookSecret`,\n * then parse it. The signature is checked before the payload is parsed, and\n * an event without a connected `account` is rejected. When this adapter is\n * scoped to a `stripeAccount`, events for any other account are rejected.\n * The payload, including `quoteId`, is controlled by the connected account:\n * bind `quoteId` to `account` before acting on it.\n */\n parseConnectWebhookEvent(\n payload: string,\n signature?: string,\n ): StripeConnectWebhookEvent {\n const event = this.verifyWebhookEvent(payload, signature, 'connect');\n this.recordWebhookEvent(event);\n return event as StripeConnectWebhookEvent;\n }\n\n /**\n * Verify a webhook delivery, then map its connected account to an owner\n * (for example a tenant) with the host's resolver. An account the resolver\n * does not recognize is rejected with {@link PaymentNotOwnedError}; there is\n * no fallback to the platform account. The event is recorded for duplicate\n * detection only after it resolves, so a retried delivery that failed to\n * resolve is not reported as a duplicate.\n *\n * Security: a connected account controls the objects it creates, so a\n * Connect event's `quoteId` (and every other payload field) is chosen by\n * that account. Resolving the account proves only who sent the event. The\n * host must check that `event.quoteId` belongs to the resolved owner (for\n * example inside `resolveAccount`, which receives the event, or before\n * settling) and must never settle another owner's quote from it.\n */\n async resolveConnectWebhookEvent<TOwner>(\n payload: string,\n signature: string | undefined,\n options: StripeResolveConnectWebhookOptions<TOwner>,\n ): Promise<StripeResolvedConnectWebhookEvent<TOwner>> {\n if (typeof options?.resolveAccount !== 'function') {\n throw new PaymentConfigurationError(\n 'Stripe resolveConnectWebhookEvent requires a resolveAccount function.',\n );\n }\n\n const endpoint = options.endpoint ?? 'connect';\n\n if (endpoint !== 'connect' && endpoint !== 'platform') {\n throw new PaymentConfigurationError(\n 'Stripe resolveConnectWebhookEvent endpoint must be connect or platform.',\n );\n }\n\n const event = this.verifyWebhookEvent(payload, signature, endpoint);\n const account =\n endpoint === 'connect'\n ? event.account\n : event.connect?.type === 'application_fee.created' ||\n event.connect?.type === 'application_fee.refunded'\n ? event.connect.applicationFee.account\n : undefined;\n\n if (account === undefined) {\n throw new PaymentNotOwnedError(\n `Stripe webhook event ${event.id} (${event.type}) has no connected account to route by.`,\n );\n }\n\n this.assertAdapterAccount(account);\n const owner = await options.resolveAccount(account, event);\n\n if (owner === undefined || owner === null) {\n throw new PaymentNotOwnedError(\n `Stripe connected account ${account} is not mapped to an owner.`,\n );\n }\n\n this.recordWebhookEvent(event);\n return { event, account, owner };\n }\n\n /**\n * Create a Stripe Connect **Standard** account. The account holder owns the\n * Stripe relationship and dashboard; the platform only connects to it.\n * Always issued on the platform account, never on a connected account.\n */\n async createStandardAccount(\n input: StripeCreateStandardAccountInput = {},\n ): Promise<StripeConnectAccountStatus> {\n const country =\n input.country === undefined\n ? undefined\n : normalizeStripeCountry(input.country);\n const email =\n input.email === undefined\n ? undefined\n : normalizeNonEmptyString(input.email, 'Stripe account email');\n const account = await this.stripeRequest<Record<string, unknown>>(\n '/accounts',\n {\n method: 'POST',\n idempotencyKey: input.idempotencyKey,\n body: formEncode({\n type: 'standard',\n country,\n email,\n ...Object.fromEntries([['business_type', input.businessType]]),\n ...flattenStripeMetadata(input.metadata),\n }),\n },\n );\n\n return mapStripeConnectAccount(account, 'Stripe account response');\n }\n\n /**\n * Create a single-use Account Link that sends the account holder through\n * Stripe-hosted onboarding. `refreshUrl` is visited when the link expires or\n * is reused, and should mint a new link; `returnUrl` does not mean\n * onboarding finished, so read {@link getAccountCapabilities} afterwards.\n */\n async createOnboardingLink(\n accountId: string,\n returnUrl: string,\n refreshUrl: string,\n options: StripeCreateOnboardingLinkOptions = {},\n ): Promise<StripeOnboardingLink> {\n const account = normalizeStripeConnectedAccountId(accountId);\n const link = await this.stripeRequest<Record<string, unknown>>(\n '/account_links',\n {\n method: 'POST',\n idempotencyKey: options.idempotencyKey,\n body: formEncode({\n account,\n type: 'account_onboarding',\n collect: options.collect,\n ...Object.fromEntries([\n ['return_url', normalizeUrlString(returnUrl, 'Stripe returnUrl')],\n [\n 'refresh_url',\n normalizeUrlString(refreshUrl, 'Stripe refreshUrl'),\n ],\n ]),\n }),\n },\n );\n const url = normalizeOptionalProviderString(\n readProviderString(link, 'url'),\n );\n\n if (!url) {\n throw new PaymentProviderError(\n 'Stripe Account Link response did not include a url.',\n );\n }\n\n const expiresAtSeconds = readSafeInteger(link, 'expires_at');\n\n return {\n url,\n expiresAt:\n expiresAtSeconds === undefined\n ? undefined\n : new Date(expiresAtSeconds * 1_000),\n raw: link,\n };\n }\n\n /**\n * Read a connected account's onboarding and capability state\n * (`charges_enabled`, `details_submitted`, `payouts_enabled`, per-capability\n * status, and outstanding requirements).\n */\n async getAccountCapabilities(\n accountId: string,\n ): Promise<StripeConnectAccountStatus> {\n const account = normalizeStripeConnectedAccountId(accountId);\n const response = await this.stripeRequest<Record<string, unknown>>(\n `/accounts/${encodeURIComponent(account)}`,\n );\n const status = mapStripeConnectAccount(response, 'Stripe account response');\n\n if (status.accountId !== account) {\n throw new PaymentVerificationError(\n `Stripe account response ${status.accountId} did not match ${account}.`,\n );\n }\n\n return status;\n }\n\n private verifyWebhookEvent(\n payload: string,\n signature: string | undefined,\n endpoint: 'connect' | 'platform',\n ): StripeWebhookEvent {\n const secret =\n endpoint === 'connect' ? this.connectWebhookSecret : this.webhookSecret;\n\n if (!secret) {\n throw new PaymentConfigurationError(\n endpoint === 'connect'\n ? 'StripeAdapter parseConnectWebhookEvent requires connectWebhookSecret.'\n : 'StripeAdapter parseWebhookEvent requires webhookSecret.',\n );\n }\n\n if (!signature) {\n throw new PaymentProviderError('Missing Stripe webhook signature.');\n }\n\n // Authenticate the raw bytes before anything reads the payload.\n verifyStripeWebhookSignature(payload, signature, secret);\n\n const event = parseStripeWebhookPayload(payload);\n const id = readRequiredWebhookString(\n event,\n 'id',\n 'Stripe webhook event id',\n );\n const type = readRequiredWebhookString(\n event,\n 'type',\n 'Stripe webhook event type',\n );\n const rawAccount = event.account;\n let account: string | undefined;\n\n if (endpoint === 'connect') {\n account = typeof rawAccount === 'string' ? rawAccount.trim() : undefined;\n\n if (!account || !STRIPE_CONNECTED_ACCOUNT_ID.test(account)) {\n throw new PaymentVerificationError(\n 'Stripe Connect webhook event did not include a valid connected account.',\n );\n }\n\n this.assertAdapterAccount(account);\n } else if (rawAccount !== undefined && rawAccount !== null) {\n throw new PaymentVerificationError(\n 'Stripe connected-account event received on the platform webhook endpoint; verify it with parseConnectWebhookEvent.',\n );\n }\n\n const data = (\n event.data as { object?: Record<string, unknown> } | undefined\n )?.object;\n const connect = mapStripeConnectEventDetail(type, data);\n\n if (\n account !== undefined &&\n connect?.type === 'account.updated' &&\n connect.account.accountId !== account\n ) {\n throw new PaymentVerificationError(\n 'Stripe account.updated webhook object did not match the event account.',\n );\n }\n\n return {\n id,\n type,\n status: mapStripeWebhookStatus(type, data),\n quoteId: normalizeOptionalWebhookString(\n // `client_reference_id` is a Checkout Session-only field; honor it only\n // for session events so a non-session object (a PaymentIntent / Charge /\n // Transfer, possibly from a malicious Connect account) can't spoof\n // correlation to another quote's id. Non-session events correlate only\n // via our own `metadata.quoteId`.\n (type.startsWith('checkout.session.')\n ? readString(data, 'client_reference_id')\n : undefined) ??\n readString(\n (data?.metadata as Record<string, unknown>) ?? {},\n 'quoteId',\n ),\n ),\n providerPaymentId: normalizeOptionalWebhookString(readString(data, 'id')),\n duplicate: this.seenWebhookEventIds.has(id),\n ...(account === undefined ? {} : { account }),\n ...(connect === undefined ? {} : { connect }),\n raw: event,\n };\n }\n\n private recordWebhookEvent(event: StripeWebhookEvent): void {\n if (this.seenWebhookEventIds.has(event.id)) {\n event.duplicate = true;\n return;\n }\n\n event.duplicate = false;\n this.seenWebhookEventIds.add(event.id);\n while (this.seenWebhookEventIds.size > this.maxStoredWebhookEventIds) {\n const oldest = this.seenWebhookEventIds.values().next().value;\n\n if (oldest === undefined) {\n break;\n }\n\n this.seenWebhookEventIds.delete(oldest);\n }\n }\n\n private assertAdapterAccount(account: string): void {\n if (this.stripeAccount !== undefined && account !== this.stripeAccount) {\n throw new PaymentNotOwnedError(\n `Stripe connected account ${account} does not match this adapter's account scope.`,\n );\n }\n }\n\n private async stripeRequest<T>(\n path: string,\n init: RequestInit & {\n idempotencyKey?: string;\n stripeAccount?: string;\n } = {},\n ): Promise<T> {\n const headers = new Headers(init.headers);\n headers.set('Authorization', `Bearer ${this.secretKey}`);\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n headers.set('Accept', 'application/json');\n headers.set('Stripe-Version', this.apiVersion);\n\n if (init.stripeAccount !== undefined) {\n headers.set('Stripe-Account', init.stripeAccount);\n }\n\n if (init.idempotencyKey !== undefined) {\n headers.set(\n 'Idempotency-Key',\n normalizeNonEmptyString(init.idempotencyKey, 'Stripe idempotencyKey'),\n );\n }\n\n const {\n idempotencyKey: _idempotencyKey,\n stripeAccount: _stripeAccount,\n ...requestInit\n } = init;\n const response = await this.fetch(`${this.apiBaseUrl}${path}`, {\n ...requestInit,\n method: init.method ?? 'GET',\n headers,\n });\n\n return readJsonResponse<T>(response, `Stripe ${path}`);\n }\n\n private assertSupportedCurrency(currency: string): void {\n if (!this.supportedCurrencies.has(currency)) {\n throw new PaymentConfigurationError(\n `StripeAdapter currency ${currency.toUpperCase()} is not configured as supported.`,\n );\n }\n }\n\n private async resolveStripeRefundReferenceParam(\n paymentReference: string,\n stripeAccount: string | undefined,\n ): Promise<Record<string, string>> {\n if (paymentReference.startsWith('cs_')) {\n const session = await this.stripeRequest<Record<string, unknown>>(\n `/checkout/sessions/${encodeURIComponent(paymentReference)}`,\n { stripeAccount },\n );\n const paymentIntent = normalizeOptionalProviderString(\n readProviderString(session, 'payment_intent'),\n );\n\n if (!paymentIntent) {\n throw new PaymentProviderError(\n 'Stripe Checkout Session did not include payment_intent for refund.',\n );\n }\n\n return Object.fromEntries([['payment_intent', paymentIntent]]);\n }\n\n return stripeRefundReferenceParam(paymentReference);\n }\n\n private resolveStripeAccount(\n override: string | undefined,\n ): string | undefined {\n return (\n normalizeOptionalStripeAccount(override, 'Stripe stripeAccount') ??\n this.stripeAccount\n );\n }\n\n private findStoredOptionBySessionId(\n sessionId: string,\n ): PaymentOption | undefined {\n for (const option of this.optionsByQuote.values()) {\n if (option.providerPaymentId === sessionId) return option;\n }\n return undefined;\n }\n}\n\nfunction assertOptionalSecret(value: unknown, name: string): void {\n if (value === undefined) return;\n\n if (typeof value !== 'string') {\n throw new PaymentConfigurationError(\n `StripeAdapter ${name} must be a string when configured.`,\n );\n }\n\n if (!value.trim()) {\n throw new PaymentConfigurationError(\n `StripeAdapter ${name} must not be empty when configured.`,\n );\n }\n}\n\nconst STRIPE_CONNECTED_ACCOUNT_ID = /^acct_[A-Za-z0-9]+$/;\n\nfunction normalizeStripeConnectedAccountId(value: unknown): string {\n const account = typeof value === 'string' ? value.trim() : undefined;\n\n if (!account || !STRIPE_CONNECTED_ACCOUNT_ID.test(account)) {\n throw new PaymentConfigurationError(\n 'Stripe connected account id must look like acct_...',\n );\n }\n\n return account;\n}\n\nfunction normalizeStripeCountry(value: string): string {\n const country = typeof value === 'string' ? value.trim().toUpperCase() : '';\n\n if (!/^[A-Z]{2}$/.test(country)) {\n throw new PaymentConfigurationError(\n 'Stripe account country must be a two-letter ISO country code.',\n );\n }\n\n return country;\n}\n\nfunction readStringArray(\n value: Record<string, unknown> | undefined,\n key: string,\n): string[] {\n const item = value?.[key];\n\n return Array.isArray(item)\n ? item.filter((entry): entry is string => typeof entry === 'string')\n : [];\n}\n\nfunction mapStripeConnectAccount(\n account: Record<string, unknown> | undefined,\n context: string,\n): StripeConnectAccountStatus {\n const accountId = readProviderString(account, 'id')?.trim();\n\n if (!account || !accountId || !STRIPE_CONNECTED_ACCOUNT_ID.test(accountId)) {\n throw new PaymentProviderError(`${context} did not include an account id.`);\n }\n\n const capabilities: Record<string, string> = {};\n\n for (const [name, state] of Object.entries(\n readObject(account, 'capabilities') ?? {},\n )) {\n if (typeof state === 'string') {\n capabilities[name] = state;\n }\n }\n\n const requirements = readObject(account, 'requirements');\n const disabledReason = normalizeOptionalProviderString(\n readProviderString(requirements, 'disabled_reason'),\n );\n const defaultCurrency = readProviderString(account, 'default_currency');\n\n return {\n accountId,\n type: normalizeOptionalProviderString(readProviderString(account, 'type')),\n chargesEnabled: account.charges_enabled === true,\n detailsSubmitted: account.details_submitted === true,\n payoutsEnabled: account.payouts_enabled === true,\n capabilities,\n requirements: {\n currentlyDue: readStringArray(requirements, 'currently_due'),\n eventuallyDue: readStringArray(requirements, 'eventually_due'),\n pastDue: readStringArray(requirements, 'past_due'),\n ...(disabledReason === undefined ? {} : { disabledReason }),\n },\n country: normalizeOptionalProviderString(\n readProviderString(account, 'country'),\n ),\n defaultCurrency: defaultCurrency?.toUpperCase(),\n raw: account,\n };\n}\n\nfunction mapStripeApplicationFee(\n fee: Record<string, unknown> | undefined,\n): StripeApplicationFee {\n const id = normalizeOptionalProviderString(readProviderString(fee, 'id'));\n\n if (!fee || !id) {\n throw new PaymentProviderError(\n 'Stripe application_fee webhook object did not include an id.',\n );\n }\n\n const account = normalizeOptionalProviderString(\n readProviderString(fee, 'account'),\n );\n\n if (account !== undefined && !STRIPE_CONNECTED_ACCOUNT_ID.test(account)) {\n throw new PaymentProviderError(\n 'Stripe application_fee webhook object has an invalid account id.',\n );\n }\n const livemode = fee.livemode;\n\n return {\n id,\n account,\n amount: readSafeInteger(fee, 'amount'),\n amountRefunded: readSafeInteger(fee, 'amount_refunded'),\n currency: readStripeResultCurrency(fee),\n refunded: fee.refunded === true,\n charge: normalizeOptionalProviderString(\n readProviderString(fee, 'charge') ??\n readProviderString(readObject(fee, 'charge'), 'id'),\n ),\n livemode: typeof livemode === 'boolean' ? livemode : undefined,\n raw: fee,\n };\n}\n\nfunction mapStripeConnectEventDetail(\n type: string,\n object: Record<string, unknown> | undefined,\n): StripeConnectEventDetail | undefined {\n if (type === 'account.updated') {\n return {\n type,\n account: mapStripeConnectAccount(\n object,\n 'Stripe account.updated webhook object',\n ),\n };\n }\n\n if (\n type === 'application_fee.created' ||\n type === 'application_fee.refunded'\n ) {\n return { type, applicationFee: mapStripeApplicationFee(object) };\n }\n\n return undefined;\n}\n\nfunction readStripeOptionAccount(\n option: PaymentOption | undefined,\n): string | undefined {\n const value = option?.metadata?.stripeAccount;\n return typeof value === 'string' ? value : undefined;\n}\n\nfunction normalizeOptionalStripeAccount(\n value: string | undefined,\n context: string,\n): string | undefined {\n return value === undefined\n ? undefined\n : normalizeNonEmptyString(value, context);\n}\n\nfunction normalizeApplicationFeeAmount(\n value: number | undefined,\n chargeAmount: number,\n context: string,\n): number | undefined {\n if (value === undefined) return undefined;\n\n const fee = normalizePositiveMinorUnitAmount(value, context);\n if (fee > chargeAmount) {\n throw new PaymentConfigurationError(\n `${context} must not exceed the charge amount.`,\n );\n }\n return fee;\n}\n\nfunction stripePaymentOptionKey(\n quoteId: string,\n stripeAccount: string | undefined,\n): string {\n // Platform entries retain their old quote-only keys. Connected-account ids\n // cannot contain NUL in an HTTP header, so it safely separates account scope\n // from the caller's quote id without collapsing tenant-local quote ids.\n return stripeAccount === undefined ? quoteId : `${stripeAccount}\\0${quoteId}`;\n}\n\nfunction stripeRefundReferenceParam(\n paymentReference: string,\n): Record<string, string> {\n if (paymentReference.startsWith('pi_')) {\n return Object.fromEntries([['payment_intent', paymentReference]]);\n }\n\n if (paymentReference.startsWith('ch_')) {\n return { charge: paymentReference };\n }\n\n throw new PaymentConfigurationError(\n 'Stripe refunds require a Checkout Session (cs_), payment_intent (pi_), or charge (ch_) reference.',\n );\n}\n\nfunction normalizeStripeCurrency(value: string): string {\n if (typeof value !== 'string') {\n throw new PaymentConfigurationError(\n `StripeAdapter currency must be a three-letter ISO currency code, received ${String(value)}.`,\n );\n }\n\n const normalized = value.trim().toLowerCase();\n\n if (!/^[a-z]{3}$/.test(normalized)) {\n throw new PaymentConfigurationError(\n `StripeAdapter currency must be a three-letter ISO currency code, received ${String(value)}.`,\n );\n }\n\n return normalized;\n}\n\nfunction normalizeSupportedStripeCurrencies(\n configuredCurrencies: string[] | undefined,\n defaultCurrency: string,\n): Set<string> {\n const normalized = new Set(\n (configuredCurrencies ?? ['usd', 'eur', 'gbp', 'cad']).map(\n normalizeStripeCurrency,\n ),\n );\n normalized.add(defaultCurrency);\n\n return normalized;\n}\n\nfunction normalizeStripeCheckoutExpiresAt(\n expiresAt: Date,\n now = Date.now(),\n): Date {\n if (expiresAt.getTime() <= now) {\n throw new PaymentProviderError('Stripe Checkout expiry is in the past.');\n }\n\n const min = now + STRIPE_CHECKOUT_MIN_EXPIRY_MS;\n const max = now + STRIPE_CHECKOUT_MAX_EXPIRY_MS;\n\n if (expiresAt.getTime() < min || expiresAt.getTime() > max) {\n throw new PaymentConfigurationError(\n 'Stripe Checkout expiry must be at least 30 minutes and no more than 24 hours from now.',\n );\n }\n\n return expiresAt;\n}\n\nexport function verifyStripeWebhookSignature(\n payload: string,\n signatureHeader: string,\n secret: string,\n toleranceSeconds = 300,\n): void {\n if (typeof payload !== 'string') {\n throw new PaymentProviderError('Stripe webhook payload must be a string.');\n }\n\n const normalizedSignatureHeader = normalizeNonEmptyString(\n signatureHeader,\n 'Stripe signature header',\n );\n const normalizedSecret = normalizeNonEmptyString(\n secret,\n 'Stripe webhook secret',\n );\n\n if (!Number.isFinite(toleranceSeconds) || toleranceSeconds < 0) {\n throw new PaymentConfigurationError(\n `Stripe webhook toleranceSeconds must be a non-negative finite number, received ${String(toleranceSeconds)}.`,\n );\n }\n\n const timestampCandidates: string[] = [];\n const signatures: string[] = [];\n\n for (const part of normalizedSignatureHeader.split(',')) {\n const [rawKey, ...rawValue] = part.split('=');\n const key = rawKey?.trim();\n const value = rawValue.join('=').trim();\n\n if (!key || !value) {\n continue;\n }\n\n if (key === 't') {\n timestampCandidates.push(value);\n }\n\n if (key === 'v1') {\n signatures.push(value);\n }\n }\n\n if (timestampCandidates.length !== 1 || signatures.length === 0) {\n throw new PaymentProviderError('Invalid Stripe signature header.');\n }\n\n const timestamp = timestampCandidates[0] ?? '';\n\n if (!/^\\d+$/.test(timestamp)) {\n throw new PaymentProviderError('Invalid Stripe signature header.');\n }\n\n const timestampSeconds = Number(timestamp);\n\n if (!Number.isSafeInteger(timestampSeconds)) {\n throw new PaymentProviderError('Invalid Stripe signature header.');\n }\n\n const nowSeconds = Date.now() / 1_000;\n const ageSeconds = nowSeconds - timestampSeconds;\n\n if (ageSeconds < -5) {\n throw new PaymentProviderError(\n 'Stripe webhook signature timestamp is in the future.',\n );\n }\n\n if (ageSeconds > toleranceSeconds) {\n throw new PaymentProviderError('Stripe webhook signature is too old.');\n }\n\n const expected = createHmac('sha256', normalizedSecret)\n .update(`${timestamp}.${payload}`)\n .digest('hex');\n const expectedBuffer = Buffer.from(expected, 'hex');\n\n for (const signature of signatures) {\n if (!/^[0-9a-f]+$/i.test(signature)) {\n throw new PaymentProviderError('Invalid Stripe signature header.');\n }\n\n const actualBuffer = Buffer.from(signature, 'hex');\n\n if (\n expectedBuffer.length === actualBuffer.length &&\n timingSafeEqual(expectedBuffer, actualBuffer)\n ) {\n return;\n }\n }\n\n throw new PaymentProviderError('Invalid Stripe webhook signature.');\n}\n\nfunction parseStripeWebhookPayload(payload: string): Record<string, unknown> {\n try {\n const event = JSON.parse(payload);\n\n if (!event || typeof event !== 'object' || Array.isArray(event)) {\n throw new PaymentProviderError('Invalid Stripe webhook JSON payload.');\n }\n\n return event as Record<string, unknown>;\n } catch (error) {\n if (error instanceof PaymentProviderError) {\n throw error;\n }\n\n throw new PaymentProviderError('Invalid Stripe webhook JSON payload.', {\n cause: error,\n });\n }\n}\n\nfunction normalizeOptionalWebhookString(\n value: string | undefined,\n): string | undefined {\n const normalized = value?.trim();\n\n return normalized ? normalized : undefined;\n}\n\nfunction normalizeOptionalProviderString(\n value: string | undefined,\n): string | undefined {\n const normalized = value?.trim();\n\n return normalized ? normalized : undefined;\n}\n\nfunction readProviderString(\n value: Record<string, unknown> | undefined,\n key: string,\n): string | undefined {\n if (!value) {\n return undefined;\n }\n\n const item = value[key];\n\n return typeof item === 'string' ? item : undefined;\n}\n\nfunction readRequiredWebhookString(\n value: Record<string, unknown>,\n key: string,\n context: string,\n): string {\n const item = value[key];\n\n if (typeof item !== 'string') {\n throw new PaymentProviderError(`${context} must be a string.`);\n }\n\n return normalizeNonEmptyString(item, context);\n}\n\nfunction readStripeSessionQuoteId(\n session: Record<string, unknown>,\n): string | undefined {\n return normalizeOptionalWebhookString(\n readString(session, 'client_reference_id') ??\n readString(\n (session.metadata as Record<string, unknown>) ?? {},\n 'quoteId',\n ),\n );\n}\n\nfunction mapStripeStatus(\n checkoutStatus: string | undefined,\n paymentStatus: string | undefined,\n): PaymentStatus {\n if (paymentStatus === 'paid' || paymentStatus === 'no_payment_required') {\n return 'confirmed';\n }\n\n if (checkoutStatus === 'expired') {\n return 'expired';\n }\n\n if (paymentStatus === 'unpaid' || checkoutStatus === 'open') {\n return 'pending';\n }\n\n if (checkoutStatus === 'complete') {\n return 'processing';\n }\n\n return 'pending';\n}\n\nfunction mapStripeWebhookStatus(\n type: string | undefined,\n object: Record<string, unknown> | undefined,\n): PaymentStatus {\n if (type === 'checkout.session.completed') {\n return mapStripeStatus(\n readString(object, 'status'),\n readString(object, 'payment_status'),\n );\n }\n\n if (type === 'checkout.session.async_payment_succeeded') {\n return 'confirmed';\n }\n\n if (type === 'checkout.session.async_payment_failed') {\n return 'failed';\n }\n\n if (type === 'checkout.session.expired') {\n return 'expired';\n }\n\n // Manual-capture PaymentIntent lifecycle (authorize → capture / void). Only\n // treat these as terminal for intents WE created and can correlate — i.e.\n // ones carrying our `quoteId` in metadata. Checkout Sessions create their own\n // PaymentIntents (which fire these same events with no quoteId on the intent);\n // those are handled via the `checkout.session.*` events above, so here they\n // stay non-terminal (`processing`) rather than emitting a spurious,\n // uncorrelatable terminal event. Handled before the generic `failed` catch\n // below so an un-owned `payment_intent.payment_failed` isn't reclassified.\n if (\n type === 'payment_intent.succeeded' ||\n type === 'payment_intent.canceled' ||\n type === 'payment_intent.payment_failed'\n ) {\n const metadata = (object?.metadata as Record<string, unknown>) ?? {};\n // Match parseWebhookEvent's normalization so an empty/blank quoteId is\n // treated as un-owned by both — gate and reporter must agree on ownership.\n const owned =\n normalizeOptionalWebhookString(readString(metadata, 'quoteId')) !==\n undefined;\n if (owned) {\n if (type === 'payment_intent.succeeded') {\n return 'confirmed';\n }\n // A manual-capture hold Stripe released automatically (it lapsed) is\n // `expired`, distinct from a deliberate void or hard decline (`failed`);\n // the shared PaymentStatus union has no `canceled`.\n if (\n type === 'payment_intent.canceled' &&\n readString(object, 'cancellation_reason') === 'automatic'\n ) {\n return 'expired';\n }\n return 'failed';\n }\n return 'processing';\n }\n\n // Terminal failure/refund only for payment-in objects (Checkout Session,\n // PaymentIntent, Charge). Money-out / unrelated events (transfer.failed,\n // payout.failed, refund.failed, application_fee.refunded, …) also match a\n // naive substring scan — and a failed Transfer even carries our quoteId\n // (sendPayout stamps it), which would miscorrelate a payout failure as a\n // payment failure — so they must not surface as a terminal payment status.\n const isPaymentInEvent =\n type?.startsWith('checkout.session.') === true ||\n type?.startsWith('payment_intent.') === true ||\n type?.startsWith('charge.') === true;\n\n if (isPaymentInEvent && type?.includes('refunded')) {\n return 'refunded';\n }\n\n if (isPaymentInEvent && type?.includes('failed')) {\n return 'failed';\n }\n\n return 'processing';\n}\n\nfunction mapStripeRefundStatus(\n status: string | undefined,\n): RefundResult['status'] {\n switch (status) {\n case 'succeeded':\n return 'succeeded';\n case 'failed':\n case 'canceled':\n return 'failed';\n case 'requires_action':\n return 'requires_action';\n default:\n return 'submitted';\n }\n}\n\nfunction mapStripeAuthorizationStatus(\n status: string | undefined,\n): AuthorizationResult['status'] {\n switch (status) {\n case 'requires_capture':\n return 'requires_capture';\n case 'succeeded':\n return 'succeeded';\n case 'requires_action':\n return 'requires_action';\n case 'processing':\n return 'processing';\n default:\n return 'failed';\n }\n}\n\nfunction mapStripeCaptureStatus(\n status: string | undefined,\n): CaptureResult['status'] {\n switch (status) {\n case 'succeeded':\n return 'succeeded';\n // Capturing an authorized intent shouldn't re-enter authentication; treat\n // any in-flight/action state as still processing rather than a failure.\n case 'processing':\n case 'requires_action':\n return 'processing';\n default:\n return 'failed';\n }\n}\n\nfunction mapStripeVoidStatus(status: string | undefined): VoidResult['status'] {\n return status === 'canceled' ? 'canceled' : 'failed';\n}\n\nfunction readStripeResultCurrency(\n value: Record<string, unknown>,\n): string | undefined {\n const currency = readString(value, 'currency');\n\n return currency === undefined ? undefined : currency.toUpperCase();\n}\n\nfunction mapStripeSetupStatus(\n sessionStatus: string | undefined,\n setupIntentStatus: string | undefined,\n): SavedPaymentMethod['status'] {\n if (sessionStatus === 'expired') {\n return 'expired';\n }\n\n if (sessionStatus === 'complete') {\n // The method is reusable only once the SetupIntent itself has succeeded —\n // the Session can be `complete` while the intent is still `processing`\n // (async setup methods via dynamic payment methods).\n if (setupIntentStatus === 'succeeded') {\n return 'complete';\n }\n // A finished session whose SetupIntent didn't succeed is a terminal\n // failure (card declined → `requires_payment_method`, or `canceled`), so\n // callers can stop polling instead of waiting on a `pending` that will\n // never resolve. Still-in-flight states (`processing`, `requires_action`)\n // remain `pending`.\n if (\n setupIntentStatus === 'canceled' ||\n setupIntentStatus === 'requires_payment_method'\n ) {\n return 'failed';\n }\n }\n\n return 'pending';\n}\n\nfunction readObject(\n value: Record<string, unknown> | undefined,\n key: string,\n): Record<string, unknown> | undefined {\n const item = value?.[key];\n\n return item && typeof item === 'object' && !Array.isArray(item)\n ? (item as Record<string, unknown>)\n : undefined;\n}\n\nfunction extractStripeSessionId(payTo: string): string | undefined {\n if (/^cs_(test_|live_)?[A-Za-z0-9_]+$/.test(payTo)) {\n return payTo;\n }\n\n try {\n const url = new URL(payTo);\n const match = url.pathname.match(/\\/pay\\/([^/?#]+)/);\n\n const sessionId = match?.[1];\n\n return sessionId && /^cs_(test_|live_)?[A-Za-z0-9_]+$/.test(sessionId)\n ? sessionId\n : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction flattenStripeMetadata(\n metadata:\n | Record<string, string | number | boolean | null | undefined>\n | undefined,\n): Record<string, string | number | boolean> {\n const result: Record<string, string | number | boolean> = {};\n\n for (const [key, value] of Object.entries(metadata ?? {})) {\n if (value !== undefined && value !== null) {\n result[`metadata[${key}]`] = value;\n }\n }\n\n return result;\n}\n\nfunction readString(\n value: Record<string, unknown> | undefined,\n key: string,\n): string | undefined {\n if (!value) {\n return undefined;\n }\n\n const item = value[key];\n\n if (typeof item === 'string') {\n return item;\n }\n\n if (typeof item === 'number') {\n return String(item);\n }\n\n return undefined;\n}\n\nfunction readSafeInteger(\n value: Record<string, unknown> | undefined,\n key: string,\n): number | undefined {\n if (!value) {\n return undefined;\n }\n\n const item = value[key];\n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;CAGF,MAAM,OAAO,MAAM;CAEnB,OAAO,OAAO,SAAS,YAAY,OAAO,cAAc,IAAI,KAAK,QAAQ,IACrE,OACA,KAAA;AACN"}
|
|
1
|
+
{"version":3,"file":"stripe.js","names":[],"sources":["../../src/adapters/stripe.ts"],"sourcesContent":["import { createHmac, timingSafeEqual } from 'node:crypto';\nimport {\n PaymentConfigurationError,\n PaymentNotOwnedError,\n PaymentProviderError,\n PaymentVerificationError,\n} from '../errors.js';\nimport {\n applyExpiryToPendingStatus,\n type FetchLike,\n formEncode,\n getFetch,\n normalizeDate,\n normalizeMaxStoredPaymentOptions,\n normalizeMinorUnitAmount,\n normalizeNonEmptyString,\n normalizePositiveMinorUnitAmount,\n normalizePositivePaymentAmount,\n normalizeUrlString,\n pollPaymentStatus,\n readJsonResponse,\n rememberPaymentOption,\n} from '../shared.js';\nimport type {\n AuthorizationResult,\n AuthorizePaymentInput,\n CapturePaymentInput,\n CaptureResult,\n CreatePaymentOptionInput,\n CreateSetupSessionInput,\n GetSetupResultInput,\n PaymentBackend,\n PaymentBackendCapabilities,\n PaymentDispute,\n PaymentDisputeStatus,\n PaymentEvent,\n PaymentOption,\n PaymentStatus,\n PaymentStatusContext,\n PaymentStatusResult,\n PaymentWebhookEvent,\n PayoutResult,\n RefundPaymentInput,\n RefundResult,\n SavedPaymentMethod,\n SendPayoutInput,\n SetupSession,\n VoidPaymentInput,\n VoidResult,\n WatchPaymentInput,\n} from '../types.js';\n\nexport const STRIPE_BACKEND_ID = 'stripe';\nconst STRIPE_CHECKOUT_MIN_EXPIRY_MS = 30 * 60 * 1_000;\nconst STRIPE_CHECKOUT_MAX_EXPIRY_MS = 24 * 60 * 60 * 1_000;\nconst DEFAULT_STRIPE_API_VERSION = '2024-06-20';\nconst DEFAULT_MAX_STORED_WEBHOOK_EVENT_IDS = 50_000;\n\nexport interface StripeAdapterOptions {\n secretKey: string;\n fetch?: FetchLike;\n apiBaseUrl?: string;\n apiVersion?: string;\n defaultCurrency?: string;\n supportedCurrencies?: string[];\n successUrl?: string;\n cancelUrl?: string;\n checkoutMode?: string;\n webhookSecret?: string;\n /**\n * Signing secret of the Stripe Connect webhook endpoint. Stripe signs\n * connected-account events with a different secret from the platform\n * endpoint; see {@link StripeAdapter.parseConnectWebhookEvent}.\n */\n connectWebhookSecret?: string;\n pollIntervalMs?: number;\n maxStoredPaymentOptions?: number;\n maxStoredWebhookEventIds?: number;\n /** Default Stripe Connect account for this adapter's provider requests. */\n stripeAccount?: string;\n}\n\n/** Stripe Connect account scope for a request; omit it for the platform. */\nexport interface StripeAccountScope {\n stripeAccount?: string;\n}\n\nexport interface StripeCreatePaymentOptionInput\n extends CreatePaymentOptionInput,\n StripeAccountScope {\n /** Stripe application fee in integer minor units for this direct charge. */\n applicationFeeAmount?: number;\n}\n\nexport interface StripePaymentStatusContext\n extends PaymentStatusContext,\n StripeAccountScope {}\n\nexport interface StripeRefundPaymentInput\n extends RefundPaymentInput,\n StripeAccountScope {\n /** Refund a Stripe application fee collected with the charge. */\n refundApplicationFee?: boolean;\n /** Reverse a destination transfer when the provider supports one. */\n reverseTransfer?: boolean;\n}\n\nexport interface StripeAuthorizePaymentInput\n extends AuthorizePaymentInput,\n StripeAccountScope {\n /** Stripe application fee in integer minor units for this PaymentIntent. */\n applicationFeeAmount?: number;\n}\n\nexport interface StripeCapturePaymentInput\n extends CapturePaymentInput,\n StripeAccountScope {}\n\nexport interface StripeVoidPaymentInput\n extends VoidPaymentInput,\n StripeAccountScope {}\n\nexport interface StripeCreateSetupSessionInput\n extends CreateSetupSessionInput,\n StripeAccountScope {}\n\nexport interface StripeGetSetupResultInput\n extends GetSetupResultInput,\n StripeAccountScope {}\n\nexport interface StripeWatchPaymentInput\n extends Omit<WatchPaymentInput, 'statusContext'> {\n statusContext?: StripePaymentStatusContext;\n}\n\nexport interface StripeWebhookEvent extends PaymentWebhookEvent {\n id: string;\n type: string;\n status: PaymentStatus;\n quoteId?: string;\n providerPaymentId?: string;\n /**\n * Connected account (`acct_...`) the event originated from. Set only on\n * events verified through {@link StripeAdapter.parseConnectWebhookEvent};\n * platform-endpoint events never carry it.\n */\n account?: string;\n /** Verified event environment and timestamp (required for dispute events). */\n livemode?: boolean;\n createdAt?: Date;\n dispute?: StripeDispute;\n /** Typed Connect account, application-fee, and dispute payloads. */\n connect?: StripeConnectEventDetail;\n raw: unknown;\n}\n\n/** A Connect endpoint event: always scoped to a connected account. */\nexport interface StripeConnectWebhookEvent extends StripeWebhookEvent {\n account: string;\n}\n\nexport type StripeConnectEventDetail =\n | {\n type: 'account.updated';\n account: StripeConnectAccountStatus;\n }\n | {\n type: 'application_fee.created' | 'application_fee.refunded';\n applicationFee: StripeApplicationFee;\n }\n | { type: StripeDisputeEventType; dispute: StripeDispute };\n\nexport type StripeDisputeEventType =\n | 'charge.dispute.created'\n | 'charge.dispute.updated'\n | 'charge.dispute.closed'\n | 'charge.dispute.funds_withdrawn'\n | 'charge.dispute.funds_reinstated';\n\nexport interface StripeDispute extends PaymentDispute {\n /** Verified webhook origin or authenticated request scope; absent for platform. */\n account?: string;\n raw: unknown;\n}\n\nexport interface StripeGetDisputeOptions extends StripeAccountScope {\n /** Reject an authoritative reread from a different environment. */\n expectedLivemode?: boolean;\n}\n\n/** Connected account onboarding and capability state. */\nexport interface StripeConnectAccountStatus {\n accountId: string;\n /** Stripe account type (`standard`, `express`, `custom`) when reported. */\n type?: string;\n /** Stripe `charges_enabled`. */\n chargesEnabled: boolean;\n /** Stripe `details_submitted`. */\n detailsSubmitted: boolean;\n /** Stripe `payouts_enabled`. */\n payoutsEnabled: boolean;\n /** Per-capability state, e.g. `{ card_payments: 'active' }`. */\n capabilities: Record<string, string>;\n requirements: {\n currentlyDue: string[];\n eventuallyDue: string[];\n pastDue: string[];\n disabledReason?: string;\n };\n country?: string;\n defaultCurrency?: string;\n raw: unknown;\n}\n\nexport interface StripeApplicationFee {\n id: string;\n /** Connected account the fee was collected from. */\n account?: string;\n /** Fee amount in integer minor units. */\n amount?: number;\n /** Refunded portion in integer minor units. */\n amountRefunded?: number;\n currency?: string;\n refunded: boolean;\n charge?: string;\n livemode?: boolean;\n raw: unknown;\n}\n\nexport interface StripeCreateStandardAccountInput {\n /** Two-letter ISO country code of the account holder. */\n country?: string;\n /** Prefills the account holder's email in Stripe onboarding. */\n email?: string;\n businessType?: 'individual' | 'company' | 'non_profit' | 'government_entity';\n metadata?: Record<string, string | number | boolean | null | undefined>;\n idempotencyKey?: string;\n}\n\nexport interface StripeOnboardingLink {\n /** Single-use Stripe-hosted onboarding URL; treat it as a bearer secret. */\n url: string;\n expiresAt?: Date;\n raw: unknown;\n}\n\nexport interface StripeCreateOnboardingLinkOptions {\n /** Which requirements to collect up front; Stripe defaults to `currently_due`. */\n collect?: 'currently_due' | 'eventually_due';\n idempotencyKey?: string;\n}\n\n/**\n * Host mapping from a connected account to its owner. Return `undefined` or\n * `null` for an account the host does not recognize; the event is then\n * rejected with {@link PaymentNotOwnedError}.\n */\nexport type StripeConnectAccountResolver<TOwner> = (\n account: string,\n event: StripeWebhookEvent,\n) => TOwner | null | undefined | Promise<TOwner | null | undefined>;\n\nexport interface StripeResolveConnectWebhookOptions<TOwner> {\n resolveAccount: StripeConnectAccountResolver<TOwner>;\n /**\n * Endpoint the delivery arrived on. `connect` (default) verifies with\n * `connectWebhookSecret` and routes by the event's `account`. `platform`\n * verifies with `webhookSecret` and routes `application_fee.*` events by the\n * fee's connected account; other platform events are rejected.\n */\n endpoint?: 'connect' | 'platform';\n}\n\nexport interface StripeResolvedConnectWebhookEvent<TOwner> {\n event: StripeWebhookEvent;\n /** Connected account the event was routed by. */\n account: string;\n owner: TOwner;\n}\n\nexport class StripeAdapter implements PaymentBackend {\n readonly capabilities: PaymentBackendCapabilities;\n\n private readonly fetch: FetchLike;\n private readonly secretKey: string;\n private readonly apiBaseUrl: string;\n private readonly apiVersion: string;\n private readonly defaultCurrency: string;\n private readonly supportedCurrencies: Set<string>;\n private readonly checkoutMode: string;\n private readonly webhookSecret: string | undefined;\n private readonly connectWebhookSecret: string | undefined;\n private readonly stripeAccount: string | undefined;\n private readonly maxStoredPaymentOptions: number;\n private readonly maxStoredWebhookEventIds: number;\n private readonly optionsByQuote = new Map<string, PaymentOption>();\n private readonly seenWebhookEventIds = new Set<string>();\n\n constructor(private readonly options: StripeAdapterOptions) {\n if (typeof options.secretKey !== 'string' || !options.secretKey.trim()) {\n throw new PaymentConfigurationError('StripeAdapter requires secretKey.');\n }\n\n assertOptionalSecret(options.webhookSecret, 'webhookSecret');\n assertOptionalSecret(options.connectWebhookSecret, 'connectWebhookSecret');\n\n if (options.apiBaseUrl !== undefined) {\n if (typeof options.apiBaseUrl !== 'string') {\n throw new PaymentConfigurationError(\n 'StripeAdapter apiBaseUrl must be a string when configured.',\n );\n }\n\n if (!options.apiBaseUrl.trim()) {\n throw new PaymentConfigurationError(\n 'StripeAdapter apiBaseUrl must not be empty when configured.',\n );\n }\n }\n\n this.fetch = getFetch(options.fetch);\n this.maxStoredPaymentOptions = normalizeMaxStoredPaymentOptions(\n options.maxStoredPaymentOptions,\n 'StripeAdapter maxStoredPaymentOptions',\n );\n this.maxStoredWebhookEventIds = normalizeMaxStoredPaymentOptions(\n options.maxStoredWebhookEventIds ?? DEFAULT_MAX_STORED_WEBHOOK_EVENT_IDS,\n 'StripeAdapter maxStoredWebhookEventIds',\n );\n this.secretKey = options.secretKey.trim();\n this.apiBaseUrl = normalizeUrlString(\n options.apiBaseUrl ?? 'https://api.stripe.com/v1',\n 'StripeAdapter apiBaseUrl',\n ).replace(/\\/$/, '');\n this.apiVersion = normalizeNonEmptyString(\n options.apiVersion ?? DEFAULT_STRIPE_API_VERSION,\n 'StripeAdapter apiVersion',\n );\n this.defaultCurrency = normalizeStripeCurrency(\n options.defaultCurrency ?? 'usd',\n );\n this.supportedCurrencies = normalizeSupportedStripeCurrencies(\n options.supportedCurrencies,\n this.defaultCurrency,\n );\n this.checkoutMode = options.checkoutMode ?? 'payment';\n\n if (this.checkoutMode !== 'payment') {\n throw new PaymentConfigurationError(\n 'StripeAdapter only supports payment Checkout mode.',\n );\n }\n\n this.webhookSecret = options.webhookSecret?.trim();\n this.connectWebhookSecret = options.connectWebhookSecret?.trim();\n this.stripeAccount = normalizeOptionalStripeAccount(\n options.stripeAccount,\n 'StripeAdapter stripeAccount',\n );\n this.capabilities = {\n id: STRIPE_BACKEND_ID,\n displayName: 'Stripe Checkout',\n settlementCurrency: this.defaultCurrency.toUpperCase(),\n supportedSettlementCurrencies: [...this.supportedCurrencies].map(\n (currency) => currency.toUpperCase(),\n ),\n chain: 'stripe',\n settlementShape: 'url',\n x402Capable: false,\n confirmationLatency: {\n expectedSeconds: 5,\n maxExpectedSeconds: 600,\n description:\n 'Card payments usually confirm in seconds; bank debits can remain processing while Stripe settles them.',\n },\n supportsRefunds: true,\n supportsPayouts: true,\n supportsWebhooks: true,\n supportsManualCapture: true,\n supportsSavedPaymentMethods: true,\n metadata: {\n provider: 'stripe',\n },\n };\n }\n\n async createPaymentOption(\n input: StripeCreatePaymentOptionInput,\n ): Promise<PaymentOption> {\n const quoteId = normalizeNonEmptyString(input.quoteId, 'Stripe quoteId');\n const rawSuccessUrl = input.successUrl ?? this.options.successUrl;\n const rawCancelUrl = input.cancelUrl ?? this.options.cancelUrl;\n\n if (rawSuccessUrl === undefined || rawCancelUrl === undefined) {\n throw new PaymentConfigurationError(\n 'StripeAdapter createPaymentOption requires successUrl and cancelUrl.',\n );\n }\n\n const successUrl = normalizeUrlString(rawSuccessUrl, 'Stripe successUrl');\n const cancelUrl = normalizeUrlString(rawCancelUrl, 'Stripe cancelUrl');\n const currency = normalizeStripeCurrency(input.currency);\n this.assertSupportedCurrency(currency);\n const amount = normalizePositivePaymentAmount(\n input.amount,\n currency,\n 'Stripe Checkout amount',\n );\n const applicationFeeAmount = normalizeApplicationFeeAmount(\n input.applicationFeeAmount,\n amount,\n 'Stripe Checkout applicationFeeAmount',\n );\n const expiresAt = normalizeDate(input.expiresAt);\n const stripeExpiresAt = normalizeStripeCheckoutExpiresAt(expiresAt);\n const params: Record<string, unknown> = {\n mode: this.checkoutMode,\n ...Object.fromEntries([\n ['success_url', successUrl],\n ['cancel_url', cancelUrl],\n ['client_reference_id', quoteId],\n ['customer_email', input.buyerEmail],\n ['expires_at', Math.floor(stripeExpiresAt.getTime() / 1_000)],\n ]),\n 'line_items[0][quantity]': 1,\n 'line_items[0][price_data][currency]': currency,\n 'line_items[0][price_data][unit_amount]': amount,\n 'line_items[0][price_data][product_data][name]':\n input.description ?? `Quote ${quoteId}`,\n ...(applicationFeeAmount === undefined\n ? {}\n : {\n 'payment_intent_data[application_fee_amount]': applicationFeeAmount,\n }),\n ...flattenStripeMetadata(input.metadata),\n 'metadata[quoteId]': quoteId,\n };\n\n const stripeAccount = this.resolveStripeAccount(input.stripeAccount);\n const session = await this.stripeRequest<Record<string, unknown>>(\n '/checkout/sessions',\n {\n method: 'POST',\n idempotencyKey: input.idempotencyKey,\n stripeAccount,\n body: formEncode(params),\n },\n );\n const sessionId = normalizeOptionalProviderString(\n readProviderString(session, 'id'),\n );\n const checkoutUrl = normalizeOptionalProviderString(\n readProviderString(session, 'url'),\n );\n\n if (!sessionId || !checkoutUrl) {\n throw new PaymentProviderError(\n 'Stripe Checkout Session response did not include id and url.',\n );\n }\n\n const option: PaymentOption = {\n backendId: this.capabilities.id,\n quoteId,\n payTo: checkoutUrl,\n settlementShape: 'url',\n settlementCurrency: currency.toUpperCase(),\n settlementAmount: amount,\n amount,\n currency: currency.toUpperCase(),\n expiresAt: stripeExpiresAt,\n providerPaymentId: sessionId,\n paymentUri: checkoutUrl,\n metadata: {\n sessionId,\n stripeAccount,\n paymentIntent: normalizeOptionalProviderString(\n readProviderString(session, 'payment_intent'),\n ),\n },\n };\n\n rememberPaymentOption(\n this.optionsByQuote,\n stripePaymentOptionKey(quoteId, stripeAccount),\n option,\n this.maxStoredPaymentOptions,\n );\n\n return option;\n }\n\n watchPayment(input: StripeWatchPaymentInput): AsyncIterable<PaymentEvent> {\n return pollPaymentStatus(\n {\n ...input,\n pollIntervalMs:\n input.pollIntervalMs ?? this.options.pollIntervalMs ?? 5_000,\n },\n () => this.getStatus(input.quoteId, input.payTo, input.statusContext),\n );\n }\n\n async getStatus(\n quoteId: string,\n payTo: string,\n context: StripePaymentStatusContext = {},\n ): Promise<PaymentStatusResult> {\n const normalizedQuoteId = normalizeNonEmptyString(\n quoteId,\n 'Stripe quoteId',\n );\n const normalizedPayTo = normalizeNonEmptyString(payTo, 'Stripe payTo');\n const contextProviderPaymentId =\n context.providerPaymentId === undefined\n ? undefined\n : normalizeNonEmptyString(\n context.providerPaymentId,\n 'Stripe providerPaymentId',\n );\n const contextStripeAccount = normalizeOptionalStripeAccount(\n context.stripeAccount,\n 'Stripe stripeAccount',\n );\n const scopedOption = this.optionsByQuote.get(\n stripePaymentOptionKey(\n normalizedQuoteId,\n contextStripeAccount ?? this.stripeAccount,\n ),\n );\n const sessionId =\n contextProviderPaymentId ??\n extractStripeSessionId(normalizedPayTo) ??\n scopedOption?.providerPaymentId;\n\n if (!sessionId) {\n throw new PaymentConfigurationError(\n 'Stripe getStatus requires a Checkout Session id or URL.',\n );\n }\n\n const storedOption = this.findStoredOptionBySessionId(sessionId);\n const stripeAccount =\n contextStripeAccount ??\n readStripeOptionAccount(storedOption) ??\n this.stripeAccount;\n const cachedOption = this.optionsByQuote.get(\n stripePaymentOptionKey(normalizedQuoteId, stripeAccount),\n );\n\n // A caller-supplied session id can deliberately select a later checkout\n // for the same quote. Cache-derived amount, currency, and expiry describe\n // only the session we created, never an explicitly selected replacement.\n const option =\n cachedOption?.providerPaymentId === sessionId ? cachedOption : undefined;\n\n const session = await this.stripeRequest<Record<string, unknown>>(\n `/checkout/sessions/${encodeURIComponent(sessionId)}`,\n { stripeAccount },\n );\n const sessionQuoteId = readStripeSessionQuoteId(session);\n\n if (sessionQuoteId !== undefined && sessionQuoteId !== normalizedQuoteId) {\n throw new PaymentVerificationError(\n `Stripe Checkout Session quoteId ${sessionQuoteId} did not match ${normalizedQuoteId}.`,\n );\n }\n\n const paymentStatus = readString(session, 'payment_status');\n const status = mapStripeStatus(\n readString(session, 'status'),\n paymentStatus,\n );\n\n const contextAmount =\n context.amount === undefined\n ? undefined\n : normalizeMinorUnitAmount(context.amount, 'Stripe status');\n const contextCurrency =\n context.currency === undefined\n ? undefined\n : normalizeStripeCurrency(context.currency).toUpperCase();\n const sessionCurrency =\n readString(session, 'currency') === undefined\n ? undefined\n : normalizeStripeCurrency(\n readString(session, 'currency') ?? '',\n ).toUpperCase();\n const sessionAmount = readSafeInteger(session, 'amount_total');\n const expiresAt =\n option?.expiresAt ??\n (context.expiresAt === undefined\n ? undefined\n : normalizeDate(context.expiresAt));\n const effectiveStatus = applyExpiryToPendingStatus(status, expiresAt);\n\n return {\n backendId: this.capabilities.id,\n quoteId: normalizedQuoteId,\n payTo: normalizedPayTo,\n status: effectiveStatus,\n settlementCurrency:\n sessionCurrency ??\n option?.settlementCurrency ??\n contextCurrency ??\n this.defaultCurrency.toUpperCase(),\n settlementAmount:\n sessionAmount ?? option?.settlementAmount ?? contextAmount,\n receivedAmount:\n paymentStatus === 'paid' || paymentStatus === 'no_payment_required'\n ? (sessionAmount ?? option?.settlementAmount ?? contextAmount)\n : undefined,\n amount: option?.amount ?? contextAmount,\n currency: option?.currency ?? contextCurrency,\n providerPaymentId: sessionId,\n transactionId: normalizeOptionalProviderString(\n readProviderString(session, 'payment_intent'),\n ),\n updatedAt: new Date(),\n raw: session,\n };\n }\n\n async sendPayout(input: SendPayoutInput): Promise<PayoutResult> {\n const currency = normalizeStripeCurrency(\n input.currency ?? this.defaultCurrency,\n );\n this.assertSupportedCurrency(currency);\n const destination = normalizeNonEmptyString(\n input.destination,\n 'Stripe payout destination',\n );\n const quoteId =\n input.quoteId === undefined\n ? undefined\n : normalizeNonEmptyString(input.quoteId, 'Stripe payout quoteId');\n const amount = normalizePositivePaymentAmount(\n input.amount,\n currency,\n 'Stripe payout amount',\n );\n const transfer = await this.stripeRequest<Record<string, unknown>>(\n '/transfers',\n {\n method: 'POST',\n idempotencyKey: input.idempotencyKey,\n body: formEncode({\n amount,\n currency,\n destination,\n description: input.memo,\n ...flattenStripeMetadata(input.metadata),\n ...(quoteId === undefined ? {} : { 'metadata[quoteId]': quoteId }),\n }),\n },\n );\n\n return {\n backendId: this.capabilities.id,\n status: 'submitted',\n payoutId: normalizeOptionalProviderString(\n readProviderString(transfer, 'id'),\n ),\n destination,\n amount,\n currency: currency.toUpperCase(),\n raw: transfer,\n };\n }\n\n async refundPayment(input: StripeRefundPaymentInput): Promise<RefundResult> {\n const rawPaymentReference = input.paymentId ?? input.transactionId;\n\n if (!rawPaymentReference) {\n throw new PaymentConfigurationError(\n 'Stripe refunds require paymentId or transactionId.',\n );\n }\n\n const paymentReference = normalizeNonEmptyString(\n rawPaymentReference,\n 'Stripe refund payment reference',\n );\n const currency = normalizeStripeCurrency(\n input.currency ?? this.defaultCurrency,\n );\n this.assertSupportedCurrency(currency);\n const amount =\n input.amount === undefined\n ? undefined\n : normalizePositivePaymentAmount(\n input.amount,\n currency,\n 'Stripe refund amount',\n );\n const stripeAccount = this.resolveStripeAccount(input.stripeAccount);\n const refundReferenceParam = await this.resolveStripeRefundReferenceParam(\n paymentReference,\n stripeAccount,\n );\n const refundParams: Record<string, unknown> = {\n ...refundReferenceParam,\n amount: amount === undefined ? undefined : amount,\n reason: input.reason,\n refund_application_fee: input.refundApplicationFee,\n reverse_transfer: input.reverseTransfer,\n ...flattenStripeMetadata(input.metadata),\n };\n\n const refund = await this.stripeRequest<Record<string, unknown>>(\n '/refunds',\n {\n method: 'POST',\n idempotencyKey: input.idempotencyKey,\n stripeAccount,\n body: formEncode(refundParams),\n },\n );\n\n return {\n backendId: this.capabilities.id,\n status: mapStripeRefundStatus(readString(refund, 'status')),\n refundId: normalizeOptionalProviderString(\n readProviderString(refund, 'id'),\n ),\n transactionId: paymentReference,\n // Read the settled amount and currency back from the refund object\n // (mirrors capturePayment) so a full refund — no `input.amount` supplied,\n // and possibly a currency differing from the adapter default when\n // `input.currency` is omitted — surfaces what Stripe actually refunded\n // instead of the request defaults.\n amount: readSafeInteger(refund, 'amount') ?? amount,\n currency: readStripeResultCurrency(refund) ?? currency.toUpperCase(),\n raw: refund,\n };\n }\n\n async authorizePayment(\n input: StripeAuthorizePaymentInput,\n ): Promise<AuthorizationResult> {\n const currency = normalizeStripeCurrency(input.currency);\n this.assertSupportedCurrency(currency);\n const amount = normalizePositivePaymentAmount(\n input.amount,\n currency,\n 'Stripe authorize amount',\n );\n const paymentMethod = normalizeNonEmptyString(\n input.providerPaymentMethodId,\n 'Stripe authorize providerPaymentMethodId',\n );\n const providerCustomerId =\n input.providerCustomerId === undefined\n ? undefined\n : normalizeNonEmptyString(\n input.providerCustomerId,\n 'Stripe authorize providerCustomerId',\n );\n const quoteId =\n input.quoteId === undefined\n ? undefined\n : normalizeNonEmptyString(input.quoteId, 'Stripe authorize quoteId');\n const applicationFeeAmount = normalizeApplicationFeeAmount(\n input.applicationFeeAmount,\n amount,\n 'Stripe PaymentIntent applicationFeeAmount',\n );\n\n const intent = await this.stripeRequest<Record<string, unknown>>(\n '/payment_intents',\n {\n method: 'POST',\n idempotencyKey: input.idempotencyKey,\n stripeAccount: this.resolveStripeAccount(input.stripeAccount),\n body: formEncode({\n amount,\n currency,\n confirm: true,\n 'payment_method_types[]': 'card',\n description: input.description,\n application_fee_amount: applicationFeeAmount,\n ...Object.fromEntries([\n ['payment_method', paymentMethod],\n ['capture_method', 'manual'],\n // Off-session (merchant-initiated) by default — the primary use is\n // charging a saved card while the buyer is absent. Without this,\n // Stripe treats it as on-session and may raise an SCA challenge the\n // absent buyer can't complete, so the hold is never placed.\n ['off_session', input.offSession ?? true],\n ]),\n ...(providerCustomerId === undefined\n ? {}\n : { customer: providerCustomerId }),\n ...flattenStripeMetadata(input.metadata),\n ...(quoteId === undefined ? {} : { 'metadata[quoteId]': quoteId }),\n }),\n },\n );\n\n const providerPaymentId = normalizeOptionalProviderString(\n readProviderString(intent, 'id'),\n );\n\n if (!providerPaymentId) {\n throw new PaymentProviderError(\n 'Stripe PaymentIntent response did not include an id.',\n );\n }\n\n const status = mapStripeAuthorizationStatus(readString(intent, 'status'));\n // Only surface the SCA fields when authentication is actually required — the\n // documented contract — even though Stripe returns client_secret regardless.\n // (Authorization progress is observed via `parseWebhookEvent`, which surfaces\n // the ready-to-capture transition as `processing` — there is no distinct\n // `requires_capture` webhook status; `getStatus` handles Checkout sessions,\n // not PaymentIntents.)\n const actionRequired = status === 'requires_action';\n\n return {\n backendId: this.capabilities.id,\n status,\n providerPaymentId,\n amount: readSafeInteger(intent, 'amount') ?? amount,\n currency: (readString(intent, 'currency') ?? currency).toUpperCase(),\n clientSecret: actionRequired\n ? normalizeOptionalProviderString(\n readProviderString(intent, 'client_secret'),\n )\n : undefined,\n nextAction: actionRequired\n ? (intent.next_action ?? undefined)\n : undefined,\n raw: intent,\n };\n }\n\n async capturePayment(\n input: StripeCapturePaymentInput,\n ): Promise<CaptureResult> {\n const providerPaymentId = normalizeNonEmptyString(\n input.providerPaymentId,\n 'Stripe capture providerPaymentId',\n );\n const amount =\n input.amount === undefined\n ? undefined\n : normalizePositiveMinorUnitAmount(\n input.amount,\n 'Stripe capture amount',\n );\n\n const intent = await this.stripeRequest<Record<string, unknown>>(\n `/payment_intents/${encodeURIComponent(providerPaymentId)}/capture`,\n {\n method: 'POST',\n idempotencyKey: input.idempotencyKey,\n stripeAccount: this.resolveStripeAccount(input.stripeAccount),\n body: formEncode({\n ...Object.fromEntries([['amount_to_capture', amount]]),\n ...flattenStripeMetadata(input.metadata),\n }),\n },\n );\n\n return {\n backendId: this.capabilities.id,\n status: mapStripeCaptureStatus(readString(intent, 'status')),\n providerPaymentId:\n normalizeOptionalProviderString(readProviderString(intent, 'id')) ??\n providerPaymentId,\n amount:\n readSafeInteger(intent, 'amount_received') ??\n readSafeInteger(intent, 'amount') ??\n amount,\n currency: readStripeResultCurrency(intent),\n raw: intent,\n };\n }\n\n async voidPayment(input: StripeVoidPaymentInput): Promise<VoidResult> {\n const providerPaymentId = normalizeNonEmptyString(\n input.providerPaymentId,\n 'Stripe void providerPaymentId',\n );\n const reason =\n input.reason === undefined\n ? undefined\n : normalizeNonEmptyString(input.reason, 'Stripe void reason');\n\n const intent = await this.stripeRequest<Record<string, unknown>>(\n `/payment_intents/${encodeURIComponent(providerPaymentId)}/cancel`,\n {\n method: 'POST',\n idempotencyKey: input.idempotencyKey,\n stripeAccount: this.resolveStripeAccount(input.stripeAccount),\n body: formEncode(Object.fromEntries([['cancellation_reason', reason]])),\n },\n );\n\n return {\n backendId: this.capabilities.id,\n status: mapStripeVoidStatus(readString(intent, 'status')),\n providerPaymentId:\n normalizeOptionalProviderString(readProviderString(intent, 'id')) ??\n providerPaymentId,\n amount: readSafeInteger(intent, 'amount'),\n currency: readStripeResultCurrency(intent),\n raw: intent,\n };\n }\n\n async createSetupSession(\n input: StripeCreateSetupSessionInput,\n ): Promise<SetupSession> {\n const rawSuccessUrl = input.successUrl ?? this.options.successUrl;\n const rawCancelUrl = input.cancelUrl ?? this.options.cancelUrl;\n\n if (rawSuccessUrl === undefined || rawCancelUrl === undefined) {\n throw new PaymentConfigurationError(\n 'StripeAdapter createSetupSession requires successUrl and cancelUrl.',\n );\n }\n\n const successUrl = normalizeUrlString(rawSuccessUrl, 'Stripe successUrl');\n const cancelUrl = normalizeUrlString(rawCancelUrl, 'Stripe cancelUrl');\n // Currency for the setup-mode session (defaults to the backend currency).\n // Redundant now that payment_method_types is always set, but harmless and\n // kept so the session is well-formed if that restriction is ever relaxed.\n const currency = normalizeStripeCurrency(\n input.currency ?? this.defaultCurrency,\n );\n this.assertSupportedCurrency(currency);\n const providerCustomerId =\n input.providerCustomerId === undefined\n ? undefined\n : normalizeNonEmptyString(\n input.providerCustomerId,\n 'Stripe setup customer',\n );\n\n // Either attach to an existing customer, or force Stripe to create one so\n // the saved method comes back with a reusable `cus_` reference. Setup-mode\n // sessions do NOT create a customer on their own — `customer_creation` must\n // be `always`. All snake_case keys go through Object.fromEntries.\n const customerParams: [string, unknown][] = [];\n if (providerCustomerId !== undefined) {\n customerParams.push(['customer', providerCustomerId]);\n } else {\n customerParams.push(['customer_creation', 'always']);\n if (input.customerEmail !== undefined) {\n customerParams.push([\n 'customer_email',\n normalizeNonEmptyString(\n input.customerEmail,\n 'Stripe setup customerEmail',\n ),\n ]);\n }\n }\n\n const params: Record<string, unknown> = {\n mode: 'setup',\n currency,\n // Restrict to cards: SavedPaymentMethod exposes card display fields\n // (brand/last4/expiry), so allowing SEPA/Bacs/etc. would yield saved\n // methods with no usable display detail.\n 'payment_method_types[]': 'card',\n ...Object.fromEntries([\n ['success_url', successUrl],\n ['cancel_url', cancelUrl],\n ...customerParams,\n ]),\n ...flattenStripeMetadata(input.metadata),\n };\n\n const session = await this.stripeRequest<Record<string, unknown>>(\n '/checkout/sessions',\n {\n method: 'POST',\n idempotencyKey: input.idempotencyKey,\n stripeAccount: this.resolveStripeAccount(input.stripeAccount),\n body: formEncode(params),\n },\n );\n\n const sessionId = normalizeOptionalProviderString(\n readProviderString(session, 'id'),\n );\n const url = normalizeOptionalProviderString(\n readProviderString(session, 'url'),\n );\n\n if (!sessionId || !url) {\n throw new PaymentProviderError(\n 'Stripe setup Checkout Session response did not include id and url.',\n );\n }\n\n return {\n backendId: this.capabilities.id,\n sessionId,\n url,\n providerCustomerId:\n providerCustomerId ??\n normalizeOptionalProviderString(\n readProviderString(session, 'customer'),\n ),\n raw: session,\n };\n }\n\n async getSetupResult(\n input: StripeGetSetupResultInput,\n ): Promise<SavedPaymentMethod> {\n const sessionId = normalizeNonEmptyString(\n input.sessionId,\n 'Stripe setup sessionId',\n );\n\n const query = new URLSearchParams();\n query.append('expand[]', 'setup_intent.payment_method');\n\n const session = await this.stripeRequest<Record<string, unknown>>(\n `/checkout/sessions/${encodeURIComponent(sessionId)}?${query.toString()}`,\n { stripeAccount: this.resolveStripeAccount(input.stripeAccount) },\n );\n\n const setupIntent = readObject(session, 'setup_intent');\n const paymentMethod = readObject(setupIntent, 'payment_method');\n const card = readObject(paymentMethod, 'card');\n\n // `customer` is a bare `cus_` string on the request path (only\n // setup_intent.payment_method is expanded), but read tolerantly of an\n // expanded object so a future `expand[]=customer` can't wrongly downgrade a\n // completed setup to a permanent `pending`.\n const providerCustomerId = normalizeOptionalProviderString(\n readProviderString(session, 'customer') ??\n readProviderString(readObject(session, 'customer'), 'id'),\n );\n const providerPaymentMethodId = normalizeOptionalProviderString(\n readProviderString(paymentMethod, 'id'),\n );\n\n let status = mapStripeSetupStatus(\n readString(session, 'status'),\n readString(setupIntent, 'status'),\n );\n // Never report `complete` without the reusable references a caller needs to\n // charge the method later — a `pm_` with no `cus_` can't be charged\n // off-session, so treat that as not-yet-ready rather than a false success.\n if (\n status === 'complete' &&\n (!providerCustomerId || !providerPaymentMethodId)\n ) {\n status = 'pending';\n }\n\n return {\n backendId: this.capabilities.id,\n status,\n providerCustomerId,\n providerPaymentMethodId,\n type: readString(paymentMethod, 'type'),\n brand: readString(card, 'brand'),\n last4: readString(card, 'last4'),\n expMonth: readSafeInteger(card, 'exp_month'),\n expYear: readSafeInteger(card, 'exp_year'),\n raw: session,\n };\n }\n\n /**\n * Verify and parse a delivery to the platform webhook endpoint. Events that\n * carry a connected `account` are rejected: they belong to the Connect\n * endpoint and must never be processed as platform-account events.\n */\n parseWebhookEvent(payload: string, signature?: string): StripeWebhookEvent {\n const event = this.verifyWebhookEvent(payload, signature, 'platform');\n this.recordWebhookEvent(event);\n return event;\n }\n\n /**\n * Verify a Stripe Connect endpoint delivery with `connectWebhookSecret`,\n * then parse it. The signature is checked before the payload is parsed, and\n * an event without a connected `account` is rejected. When this adapter is\n * scoped to a `stripeAccount`, events for any other account are rejected.\n * The payload, including `quoteId`, is controlled by the connected account:\n * bind `quoteId` to `account` before acting on it.\n */\n parseConnectWebhookEvent(\n payload: string,\n signature?: string,\n ): StripeConnectWebhookEvent {\n const event = this.verifyWebhookEvent(payload, signature, 'connect');\n this.recordWebhookEvent(event);\n return event as StripeConnectWebhookEvent;\n }\n\n /**\n * Verify a webhook delivery, then map its connected account to an owner\n * (for example a tenant) with the host's resolver. An account the resolver\n * does not recognize is rejected with {@link PaymentNotOwnedError}; there is\n * no fallback to the platform account. The event is recorded for duplicate\n * detection only after it resolves, so a retried delivery that failed to\n * resolve is not reported as a duplicate.\n *\n * Security: a connected account controls the objects it creates, so a\n * Connect event's `quoteId` (and every other payload field) is chosen by\n * that account. Resolving the account proves only who sent the event. The\n * host must check that `event.quoteId` belongs to the resolved owner (for\n * example inside `resolveAccount`, which receives the event, or before\n * settling) and must never settle another owner's quote from it.\n */\n async resolveConnectWebhookEvent<TOwner>(\n payload: string,\n signature: string | undefined,\n options: StripeResolveConnectWebhookOptions<TOwner>,\n ): Promise<StripeResolvedConnectWebhookEvent<TOwner>> {\n if (typeof options?.resolveAccount !== 'function') {\n throw new PaymentConfigurationError(\n 'Stripe resolveConnectWebhookEvent requires a resolveAccount function.',\n );\n }\n\n const endpoint = options.endpoint ?? 'connect';\n\n if (endpoint !== 'connect' && endpoint !== 'platform') {\n throw new PaymentConfigurationError(\n 'Stripe resolveConnectWebhookEvent endpoint must be connect or platform.',\n );\n }\n\n const event = this.verifyWebhookEvent(payload, signature, endpoint);\n const account =\n endpoint === 'connect'\n ? event.account\n : event.connect?.type === 'application_fee.created' ||\n event.connect?.type === 'application_fee.refunded'\n ? event.connect.applicationFee.account\n : undefined;\n\n if (account === undefined) {\n throw new PaymentNotOwnedError(\n `Stripe webhook event ${event.id} (${event.type}) has no connected account to route by.`,\n );\n }\n\n this.assertAdapterAccount(account);\n const owner = await options.resolveAccount(account, event);\n\n if (owner === undefined || owner === null) {\n throw new PaymentNotOwnedError(\n `Stripe connected account ${account} is not mapped to an owner.`,\n );\n }\n\n this.recordWebhookEvent(event);\n return { event, account, owner };\n }\n\n /**\n * Create a Stripe Connect **Standard** account. The account holder owns the\n * Stripe relationship and dashboard; the platform only connects to it.\n * Always issued on the platform account, never on a connected account.\n */\n async createStandardAccount(\n input: StripeCreateStandardAccountInput = {},\n ): Promise<StripeConnectAccountStatus> {\n const country =\n input.country === undefined\n ? undefined\n : normalizeStripeCountry(input.country);\n const email =\n input.email === undefined\n ? undefined\n : normalizeNonEmptyString(input.email, 'Stripe account email');\n const account = await this.stripeRequest<Record<string, unknown>>(\n '/accounts',\n {\n method: 'POST',\n idempotencyKey: input.idempotencyKey,\n body: formEncode({\n type: 'standard',\n country,\n email,\n ...Object.fromEntries([['business_type', input.businessType]]),\n ...flattenStripeMetadata(input.metadata),\n }),\n },\n );\n\n return mapStripeConnectAccount(account, 'Stripe account response');\n }\n\n /**\n * Create a single-use Account Link that sends the account holder through\n * Stripe-hosted onboarding. `refreshUrl` is visited when the link expires or\n * is reused, and should mint a new link; `returnUrl` does not mean\n * onboarding finished, so read {@link getAccountCapabilities} afterwards.\n */\n async createOnboardingLink(\n accountId: string,\n returnUrl: string,\n refreshUrl: string,\n options: StripeCreateOnboardingLinkOptions = {},\n ): Promise<StripeOnboardingLink> {\n const account = normalizeStripeConnectedAccountId(accountId);\n const link = await this.stripeRequest<Record<string, unknown>>(\n '/account_links',\n {\n method: 'POST',\n idempotencyKey: options.idempotencyKey,\n body: formEncode({\n account,\n type: 'account_onboarding',\n collect: options.collect,\n ...Object.fromEntries([\n ['return_url', normalizeUrlString(returnUrl, 'Stripe returnUrl')],\n [\n 'refresh_url',\n normalizeUrlString(refreshUrl, 'Stripe refreshUrl'),\n ],\n ]),\n }),\n },\n );\n const url = normalizeOptionalProviderString(\n readProviderString(link, 'url'),\n );\n\n if (!url) {\n throw new PaymentProviderError(\n 'Stripe Account Link response did not include a url.',\n );\n }\n\n const expiresAtSeconds = readSafeInteger(link, 'expires_at');\n\n return {\n url,\n expiresAt:\n expiresAtSeconds === undefined\n ? undefined\n : new Date(expiresAtSeconds * 1_000),\n raw: link,\n };\n }\n\n /**\n * Read a connected account's onboarding and capability state\n * (`charges_enabled`, `details_submitted`, `payouts_enabled`, per-capability\n * status, and outstanding requirements).\n */\n async getAccountCapabilities(\n accountId: string,\n ): Promise<StripeConnectAccountStatus> {\n const account = normalizeStripeConnectedAccountId(accountId);\n const response = await this.stripeRequest<Record<string, unknown>>(\n `/accounts/${encodeURIComponent(account)}`,\n );\n const status = mapStripeConnectAccount(response, 'Stripe account response');\n\n if (status.accountId !== account) {\n throw new PaymentVerificationError(\n `Stripe account response ${status.accountId} did not match ${account}.`,\n );\n }\n\n return status;\n }\n\n /** Authoritative read. No request or adapter account scope means platform. */\n async getDispute(\n disputeId: string,\n options: StripeGetDisputeOptions = {},\n ): Promise<StripeDispute> {\n const id = normalizeNonEmptyString(disputeId, 'Stripe dispute id');\n if (!/^(?:du|dp)_[A-Za-z0-9_]+$/.test(id)) {\n throw new PaymentConfigurationError('Stripe dispute id is invalid.');\n }\n const scope = this.resolveStripeAccount(options.stripeAccount);\n const account =\n scope === undefined\n ? undefined\n : normalizeStripeConnectedAccountId(scope);\n if (account !== undefined) this.assertAdapterAccount(account);\n if (\n options.expectedLivemode !== undefined &&\n typeof options.expectedLivemode !== 'boolean'\n ) {\n throw new PaymentConfigurationError(\n 'Stripe expectedLivemode must be boolean.',\n );\n }\n const response = await this.stripeRequest<Record<string, unknown>>(\n `/disputes/${encodeURIComponent(id)}?expand[]=charge`,\n { stripeAccount: account },\n );\n const dispute = mapStripeDispute(response, account);\n if (\n dispute.id !== id ||\n (options.expectedLivemode !== undefined &&\n dispute.livemode !== options.expectedLivemode)\n ) {\n throw new PaymentVerificationError(\n 'Stripe dispute response identity or environment did not match the request.',\n );\n }\n return dispute;\n }\n\n private verifyWebhookEvent(\n payload: string,\n signature: string | undefined,\n endpoint: 'connect' | 'platform',\n ): StripeWebhookEvent {\n const secret =\n endpoint === 'connect' ? this.connectWebhookSecret : this.webhookSecret;\n\n if (!secret) {\n throw new PaymentConfigurationError(\n endpoint === 'connect'\n ? 'StripeAdapter parseConnectWebhookEvent requires connectWebhookSecret.'\n : 'StripeAdapter parseWebhookEvent requires webhookSecret.',\n );\n }\n\n if (!signature) {\n throw new PaymentProviderError('Missing Stripe webhook signature.');\n }\n\n // Authenticate the raw bytes before anything reads the payload.\n verifyStripeWebhookSignature(payload, signature, secret);\n\n const event = parseStripeWebhookPayload(payload);\n const id = readRequiredWebhookString(\n event,\n 'id',\n 'Stripe webhook event id',\n );\n const type = readRequiredWebhookString(\n event,\n 'type',\n 'Stripe webhook event type',\n );\n const rawAccount = event.account;\n let account: string | undefined;\n\n if (endpoint === 'connect') {\n account = typeof rawAccount === 'string' ? rawAccount.trim() : undefined;\n\n if (!account || !STRIPE_CONNECTED_ACCOUNT_ID.test(account)) {\n throw new PaymentVerificationError(\n 'Stripe Connect webhook event did not include a valid connected account.',\n );\n }\n\n this.assertAdapterAccount(account);\n } else if (rawAccount !== undefined && rawAccount !== null) {\n throw new PaymentVerificationError(\n 'Stripe connected-account event received on the platform webhook endpoint; verify it with parseConnectWebhookEvent.',\n );\n }\n\n const data = (\n event.data as { object?: Record<string, unknown> } | undefined\n )?.object;\n const dispute = type.startsWith('charge.dispute.')\n ? mapStripeDispute(data, account)\n : undefined;\n let disputeType: StripeDisputeEventType | undefined;\n if (dispute !== undefined) {\n disputeType = readStripeDisputeEventType(type);\n if (\n typeof event.livemode !== 'boolean' ||\n event.livemode !== dispute.livemode\n ) {\n throw new PaymentVerificationError(\n 'Stripe dispute event environment is missing or inconsistent.',\n );\n }\n }\n const createdAt =\n dispute === undefined ? undefined : disputeDate(event.created);\n const connect: StripeConnectEventDetail | undefined =\n disputeType && dispute\n ? { type: disputeType, dispute }\n : mapStripeConnectEventDetail(type, data);\n\n if (\n account !== undefined &&\n connect?.type === 'account.updated' &&\n connect.account.accountId !== account\n ) {\n throw new PaymentVerificationError(\n 'Stripe account.updated webhook object did not match the event account.',\n );\n }\n\n return {\n id,\n type,\n status: mapStripeWebhookStatus(type, data),\n quoteId: normalizeOptionalWebhookString(\n // `client_reference_id` is a Checkout Session-only field; honor it only\n // for session events so a non-session object (a PaymentIntent / Charge /\n // Transfer, possibly from a malicious Connect account) can't spoof\n // correlation to another quote's id. Non-session events correlate only\n // via our own `metadata.quoteId`.\n (type.startsWith('checkout.session.')\n ? readString(data, 'client_reference_id')\n : undefined) ??\n readString(\n (data?.metadata as Record<string, unknown>) ?? {},\n 'quoteId',\n ),\n ),\n providerPaymentId: normalizeOptionalWebhookString(readString(data, 'id')),\n duplicate: this.seenWebhookEventIds.has(id),\n ...(account === undefined ? {} : { account }),\n ...(connect === undefined ? {} : { connect }),\n ...(dispute === undefined\n ? {}\n : { dispute, livemode: dispute.livemode, createdAt }),\n raw: event,\n };\n }\n\n private recordWebhookEvent(event: StripeWebhookEvent): void {\n if (this.seenWebhookEventIds.has(event.id)) {\n event.duplicate = true;\n return;\n }\n\n event.duplicate = false;\n this.seenWebhookEventIds.add(event.id);\n while (this.seenWebhookEventIds.size > this.maxStoredWebhookEventIds) {\n const oldest = this.seenWebhookEventIds.values().next().value;\n\n if (oldest === undefined) {\n break;\n }\n\n this.seenWebhookEventIds.delete(oldest);\n }\n }\n\n private assertAdapterAccount(account: string): void {\n if (this.stripeAccount !== undefined && account !== this.stripeAccount) {\n throw new PaymentNotOwnedError(\n `Stripe connected account ${account} does not match this adapter's account scope.`,\n );\n }\n }\n\n private async stripeRequest<T>(\n path: string,\n init: RequestInit & {\n idempotencyKey?: string;\n stripeAccount?: string;\n } = {},\n ): Promise<T> {\n const headers = new Headers(init.headers);\n headers.set('Authorization', `Bearer ${this.secretKey}`);\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n headers.set('Accept', 'application/json');\n headers.set('Stripe-Version', this.apiVersion);\n\n if (init.stripeAccount !== undefined) {\n headers.set('Stripe-Account', init.stripeAccount);\n }\n\n if (init.idempotencyKey !== undefined) {\n headers.set(\n 'Idempotency-Key',\n normalizeNonEmptyString(init.idempotencyKey, 'Stripe idempotencyKey'),\n );\n }\n\n const {\n idempotencyKey: _idempotencyKey,\n stripeAccount: _stripeAccount,\n ...requestInit\n } = init;\n const response = await this.fetch(`${this.apiBaseUrl}${path}`, {\n ...requestInit,\n method: init.method ?? 'GET',\n headers,\n });\n\n return readJsonResponse<T>(response, `Stripe ${path}`);\n }\n\n private assertSupportedCurrency(currency: string): void {\n if (!this.supportedCurrencies.has(currency)) {\n throw new PaymentConfigurationError(\n `StripeAdapter currency ${currency.toUpperCase()} is not configured as supported.`,\n );\n }\n }\n\n private async resolveStripeRefundReferenceParam(\n paymentReference: string,\n stripeAccount: string | undefined,\n ): Promise<Record<string, string>> {\n if (paymentReference.startsWith('cs_')) {\n const session = await this.stripeRequest<Record<string, unknown>>(\n `/checkout/sessions/${encodeURIComponent(paymentReference)}`,\n { stripeAccount },\n );\n const paymentIntent = normalizeOptionalProviderString(\n readProviderString(session, 'payment_intent'),\n );\n\n if (!paymentIntent) {\n throw new PaymentProviderError(\n 'Stripe Checkout Session did not include payment_intent for refund.',\n );\n }\n\n return Object.fromEntries([['payment_intent', paymentIntent]]);\n }\n\n return stripeRefundReferenceParam(paymentReference);\n }\n\n private resolveStripeAccount(\n override: string | undefined,\n ): string | undefined {\n return (\n normalizeOptionalStripeAccount(override, 'Stripe stripeAccount') ??\n this.stripeAccount\n );\n }\n\n private findStoredOptionBySessionId(\n sessionId: string,\n ): PaymentOption | undefined {\n for (const option of this.optionsByQuote.values()) {\n if (option.providerPaymentId === sessionId) return option;\n }\n return undefined;\n }\n}\n\nfunction assertOptionalSecret(value: unknown, name: string): void {\n if (value === undefined) return;\n\n if (typeof value !== 'string') {\n throw new PaymentConfigurationError(\n `StripeAdapter ${name} must be a string when configured.`,\n );\n }\n\n if (!value.trim()) {\n throw new PaymentConfigurationError(\n `StripeAdapter ${name} must not be empty when configured.`,\n );\n }\n}\n\nconst STRIPE_CONNECTED_ACCOUNT_ID = /^acct_[A-Za-z0-9]+$/;\n\nfunction normalizeStripeConnectedAccountId(value: unknown): string {\n const account = typeof value === 'string' ? value.trim() : undefined;\n\n if (!account || !STRIPE_CONNECTED_ACCOUNT_ID.test(account)) {\n throw new PaymentConfigurationError(\n 'Stripe connected account id must look like acct_...',\n );\n }\n\n return account;\n}\n\nfunction normalizeStripeCountry(value: string): string {\n const country = typeof value === 'string' ? value.trim().toUpperCase() : '';\n\n if (!/^[A-Z]{2}$/.test(country)) {\n throw new PaymentConfigurationError(\n 'Stripe account country must be a two-letter ISO country code.',\n );\n }\n\n return country;\n}\n\nfunction readStringArray(\n value: Record<string, unknown> | undefined,\n key: string,\n): string[] {\n const item = value?.[key];\n\n return Array.isArray(item)\n ? item.filter((entry): entry is string => typeof entry === 'string')\n : [];\n}\n\nfunction mapStripeConnectAccount(\n account: Record<string, unknown> | undefined,\n context: string,\n): StripeConnectAccountStatus {\n const accountId = readProviderString(account, 'id')?.trim();\n\n if (!account || !accountId || !STRIPE_CONNECTED_ACCOUNT_ID.test(accountId)) {\n throw new PaymentProviderError(`${context} did not include an account id.`);\n }\n\n const capabilities: Record<string, string> = {};\n\n for (const [name, state] of Object.entries(\n readObject(account, 'capabilities') ?? {},\n )) {\n if (typeof state === 'string') {\n capabilities[name] = state;\n }\n }\n\n const requirements = readObject(account, 'requirements');\n const disabledReason = normalizeOptionalProviderString(\n readProviderString(requirements, 'disabled_reason'),\n );\n const defaultCurrency = readProviderString(account, 'default_currency');\n\n return {\n accountId,\n type: normalizeOptionalProviderString(readProviderString(account, 'type')),\n chargesEnabled: account.charges_enabled === true,\n detailsSubmitted: account.details_submitted === true,\n payoutsEnabled: account.payouts_enabled === true,\n capabilities,\n requirements: {\n currentlyDue: readStringArray(requirements, 'currently_due'),\n eventuallyDue: readStringArray(requirements, 'eventually_due'),\n pastDue: readStringArray(requirements, 'past_due'),\n ...(disabledReason === undefined ? {} : { disabledReason }),\n },\n country: normalizeOptionalProviderString(\n readProviderString(account, 'country'),\n ),\n defaultCurrency: defaultCurrency?.toUpperCase(),\n raw: account,\n };\n}\n\nfunction mapStripeApplicationFee(\n fee: Record<string, unknown> | undefined,\n): StripeApplicationFee {\n const id = normalizeOptionalProviderString(readProviderString(fee, 'id'));\n\n if (!fee || !id) {\n throw new PaymentProviderError(\n 'Stripe application_fee webhook object did not include an id.',\n );\n }\n\n const account = normalizeOptionalProviderString(\n readProviderString(fee, 'account'),\n );\n\n if (account !== undefined && !STRIPE_CONNECTED_ACCOUNT_ID.test(account)) {\n throw new PaymentProviderError(\n 'Stripe application_fee webhook object has an invalid account id.',\n );\n }\n const livemode = fee.livemode;\n\n return {\n id,\n account,\n amount: readSafeInteger(fee, 'amount'),\n amountRefunded: readSafeInteger(fee, 'amount_refunded'),\n currency: readStripeResultCurrency(fee),\n refunded: fee.refunded === true,\n charge: normalizeOptionalProviderString(\n readProviderString(fee, 'charge') ??\n readProviderString(readObject(fee, 'charge'), 'id'),\n ),\n livemode: typeof livemode === 'boolean' ? livemode : undefined,\n raw: fee,\n };\n}\n\nconst STRIPE_DISPUTE_STATUSES: ReadonlySet<string> = new Set([\n 'warning_needs_response',\n 'warning_under_review',\n 'warning_closed',\n 'needs_response',\n 'under_review',\n 'won',\n 'lost',\n 'prevented',\n]);\n\nfunction readStripeDisputeEventType(type: string): StripeDisputeEventType {\n switch (type) {\n case 'charge.dispute.created':\n case 'charge.dispute.updated':\n case 'charge.dispute.closed':\n case 'charge.dispute.funds_withdrawn':\n case 'charge.dispute.funds_reinstated':\n return type;\n default:\n throw new PaymentProviderError('Unsupported Stripe dispute event type.');\n }\n}\n\nfunction disputeError(field: string): never {\n throw new PaymentProviderError(\n `Stripe dispute has invalid or missing ${field}.`,\n );\n}\n\nfunction disputeRecord(value: unknown, field: string): Record<string, unknown> {\n if (!value || typeof value !== 'object' || Array.isArray(value))\n return disputeError(field);\n return value as Record<string, unknown>;\n}\n\nfunction disputeString(value: unknown, field: string): string {\n if (typeof value !== 'string' || !value.trim() || value !== value.trim())\n return disputeError(field);\n return value;\n}\n\nfunction disputeId(value: unknown, prefix: string): string {\n const id = disputeString(\n typeof value === 'object' && value !== null\n ? disputeRecord(value, prefix).id\n : value,\n prefix,\n );\n // Charge IDs include non-card py_ identities; legacy disputes can use dp_.\n const prefixes =\n prefix === 'ch' ? '(?:ch|py)' : prefix === 'du' ? '(?:du|dp)' : prefix;\n if (!new RegExp(`^${prefixes}_[A-Za-z0-9_]+$`).test(id))\n return disputeError(prefix);\n return id;\n}\n\nfunction disputeInteger(value: unknown, field: string): number {\n if (typeof value !== 'number' || !Number.isSafeInteger(value))\n return disputeError(field);\n return value;\n}\n\nfunction disputeDate(value: unknown): Date {\n const seconds = disputeInteger(value, 'created');\n const date = new Date(seconds * 1000);\n if (\n seconds < 0 ||\n !Number.isSafeInteger(seconds * 1000) ||\n !Number.isFinite(date.getTime())\n )\n return disputeError('created');\n return date;\n}\n\nfunction disputeCurrency(value: unknown): string {\n if (typeof value !== 'string' || !/^[a-z]{3}$/.test(value))\n return disputeError('currency');\n return value.toUpperCase();\n}\n\nfunction mapStripeDispute(value: unknown, account?: string): StripeDispute {\n const object = disputeRecord(value, 'object');\n if (object.object !== 'dispute') return disputeError('object');\n const id = disputeId(object.id, 'du');\n const chargeId = disputeId(object.charge, 'ch');\n const expandedCharge =\n typeof object.charge === 'object'\n ? disputeRecord(object.charge, 'charge')\n : undefined;\n const paymentIntent = object.payment_intent ?? expandedCharge?.payment_intent;\n const paymentIntentId =\n paymentIntent == null ? undefined : disputeId(paymentIntent, 'pi');\n if (\n object.payment_intent != null &&\n expandedCharge?.payment_intent != null &&\n paymentIntentId !== disputeId(expandedCharge.payment_intent, 'pi')\n )\n return disputeError('payment_intent');\n const amount = disputeInteger(object.amount, 'amount');\n if (amount < 0) return disputeError('amount');\n const currency = disputeCurrency(object.currency);\n const providerStatus = disputeString(object.status, 'status');\n const status: PaymentDisputeStatus = STRIPE_DISPUTE_STATUSES.has(\n providerStatus,\n )\n ? (providerStatus as PaymentDisputeStatus)\n : 'unknown';\n if (typeof object.livemode !== 'boolean') return disputeError('livemode');\n // Stripe objects normally omit account; when supplied it must agree with the\n // authenticated scope, never replace it with a payload-provided account.\n if (object.account !== undefined && object.account !== account)\n return disputeError('account');\n if (\n expandedCharge?.livemode !== undefined &&\n expandedCharge.livemode !== object.livemode\n )\n return disputeError('charge.livemode');\n if (!Array.isArray(object.balance_transactions))\n return disputeError('balance_transactions');\n const ids = new Set<string>();\n const balanceTransactions = object.balance_transactions.map(\n (value: unknown) => {\n const transaction = disputeRecord(value, 'balance_transaction');\n if (transaction.object !== 'balance_transaction')\n return disputeError('balance_transaction.object');\n const id = disputeId(transaction.id, 'txn');\n if (ids.has(id)) return disputeError('duplicate balance_transaction');\n ids.add(id);\n const amount = disputeInteger(\n transaction.amount,\n 'balance_transaction.amount',\n );\n const fee = disputeInteger(transaction.fee, 'balance_transaction.fee');\n const net = disputeInteger(transaction.net, 'balance_transaction.net');\n if (!Number.isSafeInteger(amount - fee) || amount - fee !== net)\n return disputeError('balance_transaction.net');\n return {\n id,\n amount,\n fee,\n net,\n currency: disputeCurrency(transaction.currency),\n createdAt: disputeDate(transaction.created),\n type: disputeString(transaction.type, 'balance_transaction.type'),\n reportingCategory:\n transaction.reporting_category === undefined\n ? undefined\n : disputeString(\n transaction.reporting_category,\n 'balance_transaction.reporting_category',\n ),\n };\n },\n );\n return {\n id,\n chargeId,\n paymentIntentId,\n amount,\n currency,\n status,\n providerStatus,\n livemode: object.livemode,\n createdAt: disputeDate(object.created),\n balanceTransactions,\n ...(account === undefined ? {} : { account }),\n raw: object,\n };\n}\n\nfunction mapStripeConnectEventDetail(\n type: string,\n object: Record<string, unknown> | undefined,\n): StripeConnectEventDetail | undefined {\n if (type === 'account.updated') {\n return {\n type,\n account: mapStripeConnectAccount(\n object,\n 'Stripe account.updated webhook object',\n ),\n };\n }\n\n if (\n type === 'application_fee.created' ||\n type === 'application_fee.refunded'\n ) {\n return { type, applicationFee: mapStripeApplicationFee(object) };\n }\n\n return undefined;\n}\n\nfunction readStripeOptionAccount(\n option: PaymentOption | undefined,\n): string | undefined {\n const value = option?.metadata?.stripeAccount;\n return typeof value === 'string' ? value : undefined;\n}\n\nfunction normalizeOptionalStripeAccount(\n value: string | undefined,\n context: string,\n): string | undefined {\n return value === undefined\n ? undefined\n : normalizeNonEmptyString(value, context);\n}\n\nfunction normalizeApplicationFeeAmount(\n value: number | undefined,\n chargeAmount: number,\n context: string,\n): number | undefined {\n if (value === undefined) return undefined;\n\n const fee = normalizePositiveMinorUnitAmount(value, context);\n if (fee > chargeAmount) {\n throw new PaymentConfigurationError(\n `${context} must not exceed the charge amount.`,\n );\n }\n return fee;\n}\n\nfunction stripePaymentOptionKey(\n quoteId: string,\n stripeAccount: string | undefined,\n): string {\n // Platform entries retain their old quote-only keys. Connected-account ids\n // cannot contain NUL in an HTTP header, so it safely separates account scope\n // from the caller's quote id without collapsing tenant-local quote ids.\n return stripeAccount === undefined ? quoteId : `${stripeAccount}\\0${quoteId}`;\n}\n\nfunction stripeRefundReferenceParam(\n paymentReference: string,\n): Record<string, string> {\n if (paymentReference.startsWith('pi_')) {\n return Object.fromEntries([['payment_intent', paymentReference]]);\n }\n\n if (paymentReference.startsWith('ch_')) {\n return { charge: paymentReference };\n }\n\n throw new PaymentConfigurationError(\n 'Stripe refunds require a Checkout Session (cs_), payment_intent (pi_), or charge (ch_) reference.',\n );\n}\n\nfunction normalizeStripeCurrency(value: string): string {\n if (typeof value !== 'string') {\n throw new PaymentConfigurationError(\n `StripeAdapter currency must be a three-letter ISO currency code, received ${String(value)}.`,\n );\n }\n\n const normalized = value.trim().toLowerCase();\n\n if (!/^[a-z]{3}$/.test(normalized)) {\n throw new PaymentConfigurationError(\n `StripeAdapter currency must be a three-letter ISO currency code, received ${String(value)}.`,\n );\n }\n\n return normalized;\n}\n\nfunction normalizeSupportedStripeCurrencies(\n configuredCurrencies: string[] | undefined,\n defaultCurrency: string,\n): Set<string> {\n const normalized = new Set(\n (configuredCurrencies ?? ['usd', 'eur', 'gbp', 'cad']).map(\n normalizeStripeCurrency,\n ),\n );\n normalized.add(defaultCurrency);\n\n return normalized;\n}\n\nfunction normalizeStripeCheckoutExpiresAt(\n expiresAt: Date,\n now = Date.now(),\n): Date {\n if (expiresAt.getTime() <= now) {\n throw new PaymentProviderError('Stripe Checkout expiry is in the past.');\n }\n\n const min = now + STRIPE_CHECKOUT_MIN_EXPIRY_MS;\n const max = now + STRIPE_CHECKOUT_MAX_EXPIRY_MS;\n\n if (expiresAt.getTime() < min || expiresAt.getTime() > max) {\n throw new PaymentConfigurationError(\n 'Stripe Checkout expiry must be at least 30 minutes and no more than 24 hours from now.',\n );\n }\n\n return expiresAt;\n}\n\nexport function verifyStripeWebhookSignature(\n payload: string,\n signatureHeader: string,\n secret: string,\n toleranceSeconds = 300,\n): void {\n if (typeof payload !== 'string') {\n throw new PaymentProviderError('Stripe webhook payload must be a string.');\n }\n\n const normalizedSignatureHeader = normalizeNonEmptyString(\n signatureHeader,\n 'Stripe signature header',\n );\n const normalizedSecret = normalizeNonEmptyString(\n secret,\n 'Stripe webhook secret',\n );\n\n if (!Number.isFinite(toleranceSeconds) || toleranceSeconds < 0) {\n throw new PaymentConfigurationError(\n `Stripe webhook toleranceSeconds must be a non-negative finite number, received ${String(toleranceSeconds)}.`,\n );\n }\n\n const timestampCandidates: string[] = [];\n const signatures: string[] = [];\n\n for (const part of normalizedSignatureHeader.split(',')) {\n const [rawKey, ...rawValue] = part.split('=');\n const key = rawKey?.trim();\n const value = rawValue.join('=').trim();\n\n if (!key || !value) {\n continue;\n }\n\n if (key === 't') {\n timestampCandidates.push(value);\n }\n\n if (key === 'v1') {\n signatures.push(value);\n }\n }\n\n if (timestampCandidates.length !== 1 || signatures.length === 0) {\n throw new PaymentProviderError('Invalid Stripe signature header.');\n }\n\n const timestamp = timestampCandidates[0] ?? '';\n\n if (!/^\\d+$/.test(timestamp)) {\n throw new PaymentProviderError('Invalid Stripe signature header.');\n }\n\n const timestampSeconds = Number(timestamp);\n\n if (!Number.isSafeInteger(timestampSeconds)) {\n throw new PaymentProviderError('Invalid Stripe signature header.');\n }\n\n const nowSeconds = Date.now() / 1_000;\n const ageSeconds = nowSeconds - timestampSeconds;\n\n if (ageSeconds < -5) {\n throw new PaymentProviderError(\n 'Stripe webhook signature timestamp is in the future.',\n );\n }\n\n if (ageSeconds > toleranceSeconds) {\n throw new PaymentProviderError('Stripe webhook signature is too old.');\n }\n\n const expected = createHmac('sha256', normalizedSecret)\n .update(`${timestamp}.${payload}`)\n .digest('hex');\n const expectedBuffer = Buffer.from(expected, 'hex');\n\n for (const signature of signatures) {\n if (!/^[0-9a-f]+$/i.test(signature)) {\n throw new PaymentProviderError('Invalid Stripe signature header.');\n }\n\n const actualBuffer = Buffer.from(signature, 'hex');\n\n if (\n expectedBuffer.length === actualBuffer.length &&\n timingSafeEqual(expectedBuffer, actualBuffer)\n ) {\n return;\n }\n }\n\n throw new PaymentProviderError('Invalid Stripe webhook signature.');\n}\n\nfunction parseStripeWebhookPayload(payload: string): Record<string, unknown> {\n try {\n const event = JSON.parse(payload);\n\n if (!event || typeof event !== 'object' || Array.isArray(event)) {\n throw new PaymentProviderError('Invalid Stripe webhook JSON payload.');\n }\n\n return event as Record<string, unknown>;\n } catch (error) {\n if (error instanceof PaymentProviderError) {\n throw error;\n }\n\n throw new PaymentProviderError('Invalid Stripe webhook JSON payload.', {\n cause: error,\n });\n }\n}\n\nfunction normalizeOptionalWebhookString(\n value: string | undefined,\n): string | undefined {\n const normalized = value?.trim();\n\n return normalized ? normalized : undefined;\n}\n\nfunction normalizeOptionalProviderString(\n value: string | undefined,\n): string | undefined {\n const normalized = value?.trim();\n\n return normalized ? normalized : undefined;\n}\n\nfunction readProviderString(\n value: Record<string, unknown> | undefined,\n key: string,\n): string | undefined {\n if (!value) {\n return undefined;\n }\n\n const item = value[key];\n\n return typeof item === 'string' ? item : undefined;\n}\n\nfunction readRequiredWebhookString(\n value: Record<string, unknown>,\n key: string,\n context: string,\n): string {\n const item = value[key];\n\n if (typeof item !== 'string') {\n throw new PaymentProviderError(`${context} must be a string.`);\n }\n\n return normalizeNonEmptyString(item, context);\n}\n\nfunction readStripeSessionQuoteId(\n session: Record<string, unknown>,\n): string | undefined {\n return normalizeOptionalWebhookString(\n readString(session, 'client_reference_id') ??\n readString(\n (session.metadata as Record<string, unknown>) ?? {},\n 'quoteId',\n ),\n );\n}\n\nfunction mapStripeStatus(\n checkoutStatus: string | undefined,\n paymentStatus: string | undefined,\n): PaymentStatus {\n if (paymentStatus === 'paid' || paymentStatus === 'no_payment_required') {\n return 'confirmed';\n }\n\n if (checkoutStatus === 'expired') {\n return 'expired';\n }\n\n if (paymentStatus === 'unpaid' || checkoutStatus === 'open') {\n return 'pending';\n }\n\n if (checkoutStatus === 'complete') {\n return 'processing';\n }\n\n return 'pending';\n}\n\nfunction mapStripeWebhookStatus(\n type: string | undefined,\n object: Record<string, unknown> | undefined,\n): PaymentStatus {\n if (type === 'checkout.session.completed') {\n return mapStripeStatus(\n readString(object, 'status'),\n readString(object, 'payment_status'),\n );\n }\n\n if (type === 'checkout.session.async_payment_succeeded') {\n return 'confirmed';\n }\n\n if (type === 'checkout.session.async_payment_failed') {\n return 'failed';\n }\n\n if (type === 'checkout.session.expired') {\n return 'expired';\n }\n\n // Manual-capture PaymentIntent lifecycle (authorize → capture / void). Only\n // treat these as terminal for intents WE created and can correlate — i.e.\n // ones carrying our `quoteId` in metadata. Checkout Sessions create their own\n // PaymentIntents (which fire these same events with no quoteId on the intent);\n // those are handled via the `checkout.session.*` events above, so here they\n // stay non-terminal (`processing`) rather than emitting a spurious,\n // uncorrelatable terminal event. Handled before the generic `failed` catch\n // below so an un-owned `payment_intent.payment_failed` isn't reclassified.\n if (\n type === 'payment_intent.succeeded' ||\n type === 'payment_intent.canceled' ||\n type === 'payment_intent.payment_failed'\n ) {\n const metadata = (object?.metadata as Record<string, unknown>) ?? {};\n // Match parseWebhookEvent's normalization so an empty/blank quoteId is\n // treated as un-owned by both — gate and reporter must agree on ownership.\n const owned =\n normalizeOptionalWebhookString(readString(metadata, 'quoteId')) !==\n undefined;\n if (owned) {\n if (type === 'payment_intent.succeeded') {\n return 'confirmed';\n }\n // A manual-capture hold Stripe released automatically (it lapsed) is\n // `expired`, distinct from a deliberate void or hard decline (`failed`);\n // the shared PaymentStatus union has no `canceled`.\n if (\n type === 'payment_intent.canceled' &&\n readString(object, 'cancellation_reason') === 'automatic'\n ) {\n return 'expired';\n }\n return 'failed';\n }\n return 'processing';\n }\n\n // Terminal failure/refund only for payment-in objects (Checkout Session,\n // PaymentIntent, Charge). Money-out / unrelated events (transfer.failed,\n // payout.failed, refund.failed, application_fee.refunded, …) also match a\n // naive substring scan — and a failed Transfer even carries our quoteId\n // (sendPayout stamps it), which would miscorrelate a payout failure as a\n // payment failure — so they must not surface as a terminal payment status.\n const isPaymentInEvent =\n type?.startsWith('checkout.session.') === true ||\n type?.startsWith('payment_intent.') === true ||\n type?.startsWith('charge.') === true;\n\n if (isPaymentInEvent && type?.includes('refunded')) {\n return 'refunded';\n }\n\n if (isPaymentInEvent && type?.includes('failed')) {\n return 'failed';\n }\n\n return 'processing';\n}\n\nfunction mapStripeRefundStatus(\n status: string | undefined,\n): RefundResult['status'] {\n switch (status) {\n case 'succeeded':\n return 'succeeded';\n case 'failed':\n case 'canceled':\n return 'failed';\n case 'requires_action':\n return 'requires_action';\n default:\n return 'submitted';\n }\n}\n\nfunction mapStripeAuthorizationStatus(\n status: string | undefined,\n): AuthorizationResult['status'] {\n switch (status) {\n case 'requires_capture':\n return 'requires_capture';\n case 'succeeded':\n return 'succeeded';\n case 'requires_action':\n return 'requires_action';\n case 'processing':\n return 'processing';\n default:\n return 'failed';\n }\n}\n\nfunction mapStripeCaptureStatus(\n status: string | undefined,\n): CaptureResult['status'] {\n switch (status) {\n case 'succeeded':\n return 'succeeded';\n // Capturing an authorized intent shouldn't re-enter authentication; treat\n // any in-flight/action state as still processing rather than a failure.\n case 'processing':\n case 'requires_action':\n return 'processing';\n default:\n return 'failed';\n }\n}\n\nfunction mapStripeVoidStatus(status: string | undefined): VoidResult['status'] {\n return status === 'canceled' ? 'canceled' : 'failed';\n}\n\nfunction readStripeResultCurrency(\n value: Record<string, unknown>,\n): string | undefined {\n const currency = readString(value, 'currency');\n\n return currency === undefined ? undefined : currency.toUpperCase();\n}\n\nfunction mapStripeSetupStatus(\n sessionStatus: string | undefined,\n setupIntentStatus: string | undefined,\n): SavedPaymentMethod['status'] {\n if (sessionStatus === 'expired') {\n return 'expired';\n }\n\n if (sessionStatus === 'complete') {\n // The method is reusable only once the SetupIntent itself has succeeded —\n // the Session can be `complete` while the intent is still `processing`\n // (async setup methods via dynamic payment methods).\n if (setupIntentStatus === 'succeeded') {\n return 'complete';\n }\n // A finished session whose SetupIntent didn't succeed is a terminal\n // failure (card declined → `requires_payment_method`, or `canceled`), so\n // callers can stop polling instead of waiting on a `pending` that will\n // never resolve. Still-in-flight states (`processing`, `requires_action`)\n // remain `pending`.\n if (\n setupIntentStatus === 'canceled' ||\n setupIntentStatus === 'requires_payment_method'\n ) {\n return 'failed';\n }\n }\n\n return 'pending';\n}\n\nfunction readObject(\n value: Record<string, unknown> | undefined,\n key: string,\n): Record<string, unknown> | undefined {\n const item = value?.[key];\n\n return item && typeof item === 'object' && !Array.isArray(item)\n ? (item as Record<string, unknown>)\n : undefined;\n}\n\nfunction extractStripeSessionId(payTo: string): string | undefined {\n if (/^cs_(test_|live_)?[A-Za-z0-9_]+$/.test(payTo)) {\n return payTo;\n }\n\n try {\n const url = new URL(payTo);\n const match = url.pathname.match(/\\/pay\\/([^/?#]+)/);\n\n const sessionId = match?.[1];\n\n return sessionId && /^cs_(test_|live_)?[A-Za-z0-9_]+$/.test(sessionId)\n ? sessionId\n : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction flattenStripeMetadata(\n metadata:\n | Record<string, string | number | boolean | null | undefined>\n | undefined,\n): Record<string, string | number | boolean> {\n const result: Record<string, string | number | boolean> = {};\n\n for (const [key, value] of Object.entries(metadata ?? {})) {\n if (value !== undefined && value !== null) {\n result[`metadata[${key}]`] = value;\n }\n }\n\n return result;\n}\n\nfunction readString(\n value: Record<string, unknown> | undefined,\n key: string,\n): string | undefined {\n if (!value) {\n return undefined;\n }\n\n const item = value[key];\n\n if (typeof item === 'string') {\n return item;\n }\n\n if (typeof item === 'number') {\n return String(item);\n }\n\n return undefined;\n}\n\nfunction readSafeInteger(\n value: Record<string, unknown> | undefined,\n key: string,\n): number | undefined {\n if (!value) {\n return undefined;\n }\n\n const item = value[key];\n\n return typeof item === 'number' && Number.isSafeInteger(item) && item >= 0\n ? item\n : undefined;\n}\n"],"mappings":";;;;AAoDA,IAAa,oBAAoB;AACjC,IAAM,gCAAgC,OAAU;AAChD,IAAM,gCAAgC,OAAU,KAAK;AACrD,IAAM,6BAA6B;AACnC,IAAM,uCAAuC;AAgO7C,IAAa,gBAAb,MAAqD;CAkBtB;CAjB7B;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,iCAAkC,IAAI,IAA2B;CACjE,sCAAuC,IAAI,IAAY;CAEvD,YAAY,SAAgD;EAA/B,KAAA,UAAA;EAC3B,IAAI,OAAO,QAAQ,cAAc,YAAY,CAAC,QAAQ,UAAU,KAAK,GACnE,MAAM,IAAI,0BAA0B,mCAAmC;EAGzE,qBAAqB,QAAQ,eAAe,eAAe;EAC3D,qBAAqB,QAAQ,sBAAsB,sBAAsB;EAEzE,IAAI,QAAQ,eAAe,KAAA,GAAW;GACpC,IAAI,OAAO,QAAQ,eAAe,UAChC,MAAM,IAAI,0BACR,4DACF;GAGF,IAAI,CAAC,QAAQ,WAAW,KAAK,GAC3B,MAAM,IAAI,0BACR,6DACF;EAEJ;EAEA,KAAK,QAAQ,SAAS,QAAQ,KAAK;EACnC,KAAK,0BAA0B,iCAC7B,QAAQ,yBACR,uCACF;EACA,KAAK,2BAA2B,iCAC9B,QAAQ,4BAA4B,sCACpC,wCACF;EACA,KAAK,YAAY,QAAQ,UAAU,KAAK;EACxC,KAAK,aAAa,mBAChB,QAAQ,cAAc,6BACtB,0BACF,CAAC,CAAC,QAAQ,OA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ACA,mBAC8B;CAC9B,IAAI,kBAAkB,WACpB,OAAO;CAGT,IAAI,kBAAkB,YAAY;EAIhC,IAAI,sBAAsB,aACxB,OAAO;EAOT,IACE,sBAAsB,cACtB,sBAAsB,2BAEtB,OAAO;CAEX;CAEA,OAAO;AACT;AAEA,SAAS,WACP,OACA,KACqC;CACrC,MAAM,OAAO,QAAQ;CAErB,OAAO,QAAQ,OAAO,SAAS,YAAY,CAAC,MAAM,QAAQ,IAAI,IACzD,OACD,KAAA;AACN;AAEA,SAAS,uBAAuB,OAAmC;CACjE,IAAI,mCAAmC,KAAK,KAAK,GAC/C,OAAO;CAGT,IAAI;EAIF,MAAM,YAFQ,IADE,IAAI,KACN,CAAA,CAAI,SAAS,MAAM,kBAEf,CAAA,GAAQ;EAE1B,OAAO,aAAa,mCAAmC,KAAK,SAAS,IACjE,YACA,KAAA;CACN,QAAQ;EACN;CACF;AACF;AAEA,SAAS,sBACP,UAG2C;CAC3C,MAAM,SAAoD,CAAC;CAE3D,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,YAAY,CAAC,CAAC,GACtD,IAAI,UAAU,KAAA,KAAa,UAAU,MACnC,OAAO,YAAY,IAAI,MAAM;CAIjC,OAAO;AACT;AAEA,SAAS,WACP,OACA,KACoB;CACpB,IAAI,CAAC,OACH;CAGF,MAAM,OAAO,MAAM;CAEnB,IAAI,OAAO,SAAS,UAClB,OAAO;CAGT,IAAI,OAAO,SAAS,UAClB,OAAO,OAAO,IAAI;AAItB;AAEA,SAAS,gBACP,OACA,KACoB;CACpB,IAAI,CAAC,OACH;CAGF,MAAM,OAAO,MAAM;CAEnB,OAAO,OAAO,SAAS,YAAY,OAAO,cAAc,IAAI,KAAK,QAAQ,IACrE,OACA,KAAA;AACN"}
|
package/dist/types.d.ts
CHANGED
|
@@ -97,6 +97,39 @@ export interface WatchPaymentInput {
|
|
|
97
97
|
export interface PaymentEvent extends PaymentStatusResult {
|
|
98
98
|
event: 'status' | 'confirmed' | 'failed' | 'expired' | 'refunded' | 'timeout';
|
|
99
99
|
}
|
|
100
|
+
/** Provider lifecycle state; unknown values never imply settlement or money movement. */
|
|
101
|
+
export type PaymentDisputeStatus = 'warning_needs_response' | 'warning_under_review' | 'warning_closed' | 'needs_response' | 'under_review' | 'won' | 'lost' | 'prevented' | 'unknown';
|
|
102
|
+
/** Actual provider balance evidence, not a posting instruction. */
|
|
103
|
+
export interface PaymentDisputeBalanceTransaction {
|
|
104
|
+
id: string;
|
|
105
|
+
/** Signed integer minor units in this transaction's currency. */
|
|
106
|
+
amount: number;
|
|
107
|
+
/** Signed integer minor units in this transaction's currency. */
|
|
108
|
+
fee: number;
|
|
109
|
+
/** Signed integer minor units; amount minus fee. */
|
|
110
|
+
net: number;
|
|
111
|
+
currency: string;
|
|
112
|
+
createdAt: Date;
|
|
113
|
+
/** Provider value, retained without assigning accounting semantics. */
|
|
114
|
+
type: string;
|
|
115
|
+
reportingCategory?: string;
|
|
116
|
+
}
|
|
117
|
+
/** Read-only dispute snapshot. Consumers own routing, ledger, retries and ordering. */
|
|
118
|
+
export interface PaymentDispute {
|
|
119
|
+
id: string;
|
|
120
|
+
chargeId: string;
|
|
121
|
+
paymentIntentId?: string;
|
|
122
|
+
/** Non-negative safe integer minor units in currency. */
|
|
123
|
+
amount: number;
|
|
124
|
+
currency: string;
|
|
125
|
+
status: PaymentDisputeStatus;
|
|
126
|
+
/** Original status; quarantine unknown statuses before business decisions. */
|
|
127
|
+
providerStatus: string;
|
|
128
|
+
livemode: boolean;
|
|
129
|
+
createdAt: Date;
|
|
130
|
+
/** Complete validated evidence; [] means no balance transactions reported. */
|
|
131
|
+
balanceTransactions: PaymentDisputeBalanceTransaction[];
|
|
132
|
+
}
|
|
100
133
|
export interface PaymentWebhookEvent {
|
|
101
134
|
id?: string;
|
|
102
135
|
deliveryId?: string;
|
|
@@ -106,6 +139,8 @@ export interface PaymentWebhookEvent {
|
|
|
106
139
|
status: PaymentStatus;
|
|
107
140
|
providerPaymentId?: string;
|
|
108
141
|
duplicate?: boolean;
|
|
142
|
+
/** Typed dispute evidence when supported by the provider. */
|
|
143
|
+
dispute?: PaymentDispute;
|
|
109
144
|
raw: unknown;
|
|
110
145
|
}
|
|
111
146
|
export interface VerifyX402ProofInput {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,CAAC;AAEhE,MAAM,MAAM,aAAa,GACrB,SAAS,GACT,YAAY,GACZ,WAAW,GACX,QAAQ,GACR,SAAS,GACT,UAAU,GACV,iBAAiB,CAAC;AAEtB,MAAM,WAAW,0BAA0B;IACzC,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,0BAA0B;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,6BAA6B,CAAC,EAAE,MAAM,EAAE,CAAC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,sBAAsB,CAAC;IACxC,WAAW,EAAE,OAAO,CAAC;IACrB,mBAAmB,EAAE,0BAA0B,CAAC;IAChD,eAAe,EAAE,OAAO,CAAC;IACzB,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;;OAIG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,wBAAwB;I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