@happyvertical/accounting 0.95.0 → 0.96.1
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/README.md +48 -0
- package/dist/chunks/{stripe-yrlSgLLl.js → stripe-CZlx1zrs.js} +123 -10
- package/dist/chunks/stripe-CZlx1zrs.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/providers/stripe/index.d.ts.map +1 -1
- package/dist/types.d.ts +55 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/stripe-yrlSgLLl.js.map +0 -1
package/README.md
CHANGED
|
@@ -199,6 +199,54 @@ charged. Pass `paymentMethodExternalId` to keep retries identical when the
|
|
|
199
199
|
customer's default card may change in between. Payment webhooks (`payment_intent.*`) carry a normalized `WebhookEvent.payment`
|
|
200
200
|
summary with the status, minor-unit amount, and `chargeKey`.
|
|
201
201
|
|
|
202
|
+
### Tax on off-session charges
|
|
203
|
+
|
|
204
|
+
Set `automaticTax: true` to tax the charge with Stripe Tax, the way a Checkout
|
|
205
|
+
purchase of the same thing is taxed. `amountMinor` is then the pre-tax
|
|
206
|
+
subtotal: the adapter calculates tax (Stripe Tax Calculations API) from the
|
|
207
|
+
customer's saved address and tax-exempt status, charges subtotal plus tax,
|
|
208
|
+
and links the calculation to the PaymentIntent
|
|
209
|
+
(`hooks[inputs][tax][calculation]`), so Stripe records the tax transaction
|
|
210
|
+
when the payment succeeds, including a `processing` payment that settles
|
|
211
|
+
later, and reverses it on refunds. `taxCode` (a Stripe product tax code)
|
|
212
|
+
classifies the charge instead of the account default.
|
|
213
|
+
|
|
214
|
+
```ts
|
|
215
|
+
const charge = await stripe.payments.chargeSavedPaymentMethod?.({
|
|
216
|
+
customerExternalId: 'cus_123',
|
|
217
|
+
amountMinor: 2500, // the credit, before tax
|
|
218
|
+
currency: 'USD',
|
|
219
|
+
idempotencyKey: `topup:${policyId}:${sequence}`,
|
|
220
|
+
automaticTax: true,
|
|
221
|
+
taxCode: 'txcd_10000000',
|
|
222
|
+
});
|
|
223
|
+
// charge.amountMinor = 2500 + tax (what was charged)
|
|
224
|
+
// charge.subtotalMinor = 2500 (grant this as credit)
|
|
225
|
+
// charge.taxMinor = tax (book as tax payable)
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
With `automaticTax`, `amountMinor` in the result and in the payment webhook
|
|
229
|
+
summary is the amount charged, tax included; `subtotalMinor` and `taxMinor`
|
|
230
|
+
report the two parts separately (webhooks read them from the PaymentIntent's
|
|
231
|
+
`hv_subtotal_amount` / `hv_tax_amount` metadata, in Stripe units, so settle
|
|
232
|
+
credit from `subtotalMinor`). A customer whose tax location Stripe cannot
|
|
233
|
+
determine yields `status: 'failed'` with
|
|
234
|
+
`failureCode: 'customer_tax_location_invalid'` and no charge; other Stripe Tax
|
|
235
|
+
errors (for example Stripe Tax not activated) throw. The payment method is
|
|
236
|
+
resolved before tax is calculated, so a customer without a card costs no
|
|
237
|
+
calculation. Every attempt calculates afresh, so a retry with the same key
|
|
238
|
+
succeeds once the customer's address is fixed (a calculation alone records
|
|
239
|
+
no tax). Exactly-once charging is unchanged: the PaymentIntent keeps its
|
|
240
|
+
`<key>:payment_intent` Stripe idempotency key, and the adapter first returns
|
|
241
|
+
any charge already made under the key by `hv_charge_key`. A retry that races
|
|
242
|
+
Stripe's search index (seconds after a lost response) can fail with Stripe's
|
|
243
|
+
`idempotency_error` instead of charging twice; retry it later. A key first used
|
|
244
|
+
with `automaticTax` is refused for an untaxed retry, and the reverse, as is a
|
|
245
|
+
different subtotal. Caller metadata may not use the adapter's tax keys
|
|
246
|
+
(`hv_tax_calculation`, `hv_subtotal_amount`, `hv_tax_amount`). A provider that implements
|
|
247
|
+
`chargeSavedPaymentMethod` without tax support throws on `automaticTax`
|
|
248
|
+
rather than charging untaxed.
|
|
249
|
+
|
|
202
250
|
Minor-unit amounts (`amountMinor`, `unitAmountMinor`, and the `*Minor` read
|
|
203
251
|
fields) use ISO 4217 exponents from an explicit table, not the runtime's
|
|
204
252
|
`Intl` display digits, which differ for some currencies (for example RSD,
|
|
@@ -357,20 +357,32 @@ var StripePaymentOperations = class {
|
|
|
357
357
|
const currency = normalizeCurrencyCode(input.currency);
|
|
358
358
|
const stripeAmount = minorUnitsToStripeAmount(input.amountMinor, currency);
|
|
359
359
|
if (stripeAmount <= 0) throw new Error("Charge amount must be a positive integer of minor units");
|
|
360
|
+
const automaticTax = input.automaticTax === true;
|
|
361
|
+
const taxCode = optionalTaxCode(input.taxCode);
|
|
362
|
+
if (taxCode && !automaticTax) throw new Error("taxCode requires automaticTax");
|
|
363
|
+
const reserved = Object.keys(input.metadata ?? {}).filter((key) => RESERVED_CHARGE_METADATA.has(key));
|
|
364
|
+
if (reserved.length > 0) throw new Error(`Charge metadata keys ${reserved.join(", ")} are reserved by the adapter`);
|
|
360
365
|
const chargeKey = input.idempotencyKey;
|
|
361
366
|
const base = {
|
|
362
367
|
provider: "stripe",
|
|
363
368
|
customerExternalId: input.customerExternalId,
|
|
364
369
|
amountMinor: input.amountMinor,
|
|
365
370
|
currency,
|
|
366
|
-
chargeKey
|
|
371
|
+
chargeKey,
|
|
372
|
+
...automaticTax ? { subtotalMinor: input.amountMinor } : {}
|
|
367
373
|
};
|
|
368
374
|
const existing = await this.findByChargeKey(chargeKey);
|
|
369
375
|
if (existing) {
|
|
370
|
-
assertSameCharge(existing,
|
|
376
|
+
assertSameCharge(existing, {
|
|
377
|
+
customerExternalId: input.customerExternalId,
|
|
378
|
+
stripeAmount,
|
|
379
|
+
currency,
|
|
380
|
+
automaticTax,
|
|
381
|
+
paymentMethodExternalId: input.paymentMethodExternalId
|
|
382
|
+
});
|
|
371
383
|
return {
|
|
372
384
|
...base,
|
|
373
|
-
...mapChargeOutcome(existing)
|
|
385
|
+
...mapChargeOutcome(existing, currency)
|
|
374
386
|
};
|
|
375
387
|
}
|
|
376
388
|
let paymentMethod = input.paymentMethodExternalId;
|
|
@@ -383,30 +395,61 @@ var StripePaymentOperations = class {
|
|
|
383
395
|
failureMessage: "The customer has no default payment method."
|
|
384
396
|
};
|
|
385
397
|
}
|
|
398
|
+
let amount = stripeAmount;
|
|
399
|
+
let taxMetadata = {};
|
|
400
|
+
let taxCalculation;
|
|
401
|
+
if (automaticTax) {
|
|
402
|
+
let calculation;
|
|
403
|
+
try {
|
|
404
|
+
calculation = await this.calculateTax(input.customerExternalId, stripeAmount, currency, chargeKey, taxCode);
|
|
405
|
+
} catch (error) {
|
|
406
|
+
if (error instanceof StripeApiError && error.code === "customer_tax_location_invalid") return {
|
|
407
|
+
...base,
|
|
408
|
+
paymentMethodExternalId: paymentMethod,
|
|
409
|
+
status: "failed",
|
|
410
|
+
failureCode: error.code,
|
|
411
|
+
failureMessage: error.stripeMessage
|
|
412
|
+
};
|
|
413
|
+
throw error;
|
|
414
|
+
}
|
|
415
|
+
amount = calculation.amount_total;
|
|
416
|
+
taxCalculation = calculation.id;
|
|
417
|
+
taxMetadata = {
|
|
418
|
+
[TAX_CALCULATION_METADATA]: calculation.id,
|
|
419
|
+
[SUBTOTAL_AMOUNT_METADATA]: String(stripeAmount),
|
|
420
|
+
[TAX_AMOUNT_METADATA]: String(calculation.tax_amount_exclusive)
|
|
421
|
+
};
|
|
422
|
+
}
|
|
386
423
|
try {
|
|
387
424
|
const paymentIntent = await this.provider.request("POST", "/v1/payment_intents", {
|
|
388
|
-
amount
|
|
425
|
+
amount,
|
|
389
426
|
currency: currency.toLowerCase(),
|
|
390
427
|
customer: input.customerExternalId,
|
|
391
428
|
payment_method: paymentMethod,
|
|
392
429
|
off_session: true,
|
|
393
430
|
confirm: true,
|
|
394
431
|
description: input.description,
|
|
432
|
+
hooks: taxCalculation ? { inputs: { tax: { calculation: taxCalculation } } } : void 0,
|
|
395
433
|
metadata: normalizeMetadata({
|
|
396
434
|
...input.metadata,
|
|
435
|
+
...taxMetadata,
|
|
397
436
|
[CHARGE_KEY_METADATA]: chargeKey
|
|
398
437
|
})
|
|
399
438
|
}, { idempotencyKey: `${chargeKey}:payment_intent` });
|
|
400
439
|
return {
|
|
401
440
|
...base,
|
|
402
|
-
...mapChargeOutcome(paymentIntent)
|
|
441
|
+
...mapChargeOutcome(paymentIntent, currency)
|
|
403
442
|
};
|
|
404
443
|
} catch (error) {
|
|
405
444
|
if (error instanceof StripeApiError && error.status === 402 && error.type === "card_error") {
|
|
406
445
|
const paymentIntent = isRecord(error.paymentIntent) ? error.paymentIntent : void 0;
|
|
407
446
|
return {
|
|
408
447
|
...base,
|
|
409
|
-
...
|
|
448
|
+
...taxCalculation ? chargeTaxFields({
|
|
449
|
+
amount,
|
|
450
|
+
metadata: taxMetadata
|
|
451
|
+
}, currency) : {},
|
|
452
|
+
...paymentIntent ? mapChargeOutcome(paymentIntent, currency) : {},
|
|
410
453
|
paymentMethodExternalId: idOf(paymentIntent?.payment_method) ?? paymentMethod,
|
|
411
454
|
status: error.code === "authentication_required" ? "requires_action" : "failed",
|
|
412
455
|
failureCode: error.code,
|
|
@@ -418,6 +461,34 @@ var StripePaymentOperations = class {
|
|
|
418
461
|
throw error;
|
|
419
462
|
}
|
|
420
463
|
}
|
|
464
|
+
/**
|
|
465
|
+
* Stripe Tax calculation for one tax-exclusive line of `stripeAmount`,
|
|
466
|
+
* from the customer's saved address and tax status. Each attempt makes
|
|
467
|
+
* a fresh calculation: Stripe replays a saved error for a reused
|
|
468
|
+
* idempotency key, so a key per charge would keep failing with
|
|
469
|
+
* `customer_tax_location_invalid` after the customer's address is fixed.
|
|
470
|
+
* A calculation creates no tax transaction until a PaymentIntent linked
|
|
471
|
+
* to it succeeds, so an unused one is harmless; if an earlier attempt's
|
|
472
|
+
* PaymentIntent exists but is not yet searchable, the changed
|
|
473
|
+
* PaymentIntent request is refused by Stripe's idempotency check (the
|
|
474
|
+
* `<key>:payment_intent` key) instead of charging again.
|
|
475
|
+
*/
|
|
476
|
+
async calculateTax(customerExternalId, stripeAmount, currency, chargeKey, taxCode) {
|
|
477
|
+
const calculation = await this.provider.request("POST", "/v1/tax/calculations", {
|
|
478
|
+
currency: currency.toLowerCase(),
|
|
479
|
+
customer: customerExternalId,
|
|
480
|
+
line_items: [{
|
|
481
|
+
amount: stripeAmount,
|
|
482
|
+
quantity: 1,
|
|
483
|
+
reference: "off_session_charge",
|
|
484
|
+
tax_behavior: "exclusive",
|
|
485
|
+
tax_code: taxCode
|
|
486
|
+
}]
|
|
487
|
+
}, { idempotencyKey: `hv_tax_calculation:${randomUUID()}` });
|
|
488
|
+
const tax = calculation.tax_amount_exclusive;
|
|
489
|
+
if (!calculation.id || !Number.isSafeInteger(tax) || tax < 0 || calculation.amount_total !== stripeAmount + tax) throw new Error(`Stripe tax calculation ${calculation.id ?? "(no id)"} does not add up to the charge amount plus exclusive tax`);
|
|
490
|
+
return calculation;
|
|
491
|
+
}
|
|
421
492
|
async findByChargeKey(chargeKey) {
|
|
422
493
|
return (await this.provider.request("GET", "/v1/payment_intents/search", {
|
|
423
494
|
query: `metadata['${CHARGE_KEY_METADATA}']:'${escapeSearchValue(chargeKey)}'`,
|
|
@@ -986,6 +1057,17 @@ function stripeMinorUnitsToMoney(amount, currency) {
|
|
|
986
1057
|
return amount / stripeCurrencyMinorUnitFactor(currency);
|
|
987
1058
|
}
|
|
988
1059
|
var CHARGE_KEY_METADATA = "hv_charge_key";
|
|
1060
|
+
/** Stripe Tax calculation linked to an `automaticTax` charge. */
|
|
1061
|
+
var TAX_CALCULATION_METADATA = "hv_tax_calculation";
|
|
1062
|
+
/** Pre-tax amount of an `automaticTax` charge, in Stripe units. */
|
|
1063
|
+
var SUBTOTAL_AMOUNT_METADATA = "hv_subtotal_amount";
|
|
1064
|
+
/** Exclusive tax of an `automaticTax` charge, in Stripe units. */
|
|
1065
|
+
var TAX_AMOUNT_METADATA = "hv_tax_amount";
|
|
1066
|
+
var RESERVED_CHARGE_METADATA = /* @__PURE__ */ new Set([
|
|
1067
|
+
TAX_CALCULATION_METADATA,
|
|
1068
|
+
SUBTOTAL_AMOUNT_METADATA,
|
|
1069
|
+
TAX_AMOUNT_METADATA
|
|
1070
|
+
]);
|
|
989
1071
|
/** A caller-supplied product tax code, trimmed; blank is refused. */
|
|
990
1072
|
function optionalTaxCode(taxCode) {
|
|
991
1073
|
if (taxCode === void 0) return;
|
|
@@ -993,6 +1075,25 @@ function optionalTaxCode(taxCode) {
|
|
|
993
1075
|
if (!code) throw new Error("taxCode must be a non-empty string when set");
|
|
994
1076
|
return code;
|
|
995
1077
|
}
|
|
1078
|
+
/**
|
|
1079
|
+
* Amount, subtotal, and tax of an `automaticTax` charge from its
|
|
1080
|
+
* PaymentIntent metadata, in ISO minor units. Empty for untaxed charges.
|
|
1081
|
+
*/
|
|
1082
|
+
function chargeTaxFields(paymentIntent, currency) {
|
|
1083
|
+
const metadata = paymentIntent.metadata ?? {};
|
|
1084
|
+
const calculation = metadata[TAX_CALCULATION_METADATA];
|
|
1085
|
+
if (!calculation || !currency) return {};
|
|
1086
|
+
const minor = (value) => {
|
|
1087
|
+
const amount = typeof value === "string" ? Number(value) : value;
|
|
1088
|
+
return typeof amount === "number" && Number.isSafeInteger(amount) ? stripeAmountToMinorUnitsOrUndefined(amount, currency) : void 0;
|
|
1089
|
+
};
|
|
1090
|
+
return {
|
|
1091
|
+
amountMinor: minor(paymentIntent.amount),
|
|
1092
|
+
subtotalMinor: minor(metadata[SUBTOTAL_AMOUNT_METADATA]),
|
|
1093
|
+
taxMinor: minor(metadata[TAX_AMOUNT_METADATA]),
|
|
1094
|
+
taxCalculationExternalId: calculation
|
|
1095
|
+
};
|
|
1096
|
+
}
|
|
996
1097
|
function assertIdempotencyKey(key) {
|
|
997
1098
|
if (typeof key !== "string" || key.trim() === "") throw new Error("idempotencyKey must be a non-empty string");
|
|
998
1099
|
}
|
|
@@ -1023,10 +1124,14 @@ function lineServicePeriod(lineItem) {
|
|
|
1023
1124
|
end: periodEnd
|
|
1024
1125
|
};
|
|
1025
1126
|
}
|
|
1026
|
-
function mapChargeOutcome(paymentIntent) {
|
|
1127
|
+
function mapChargeOutcome(paymentIntent, currency) {
|
|
1027
1128
|
const error = paymentIntent.last_payment_error;
|
|
1028
1129
|
const status = mapPaymentIntentChargeStatus(paymentIntent.status, error?.code);
|
|
1130
|
+
const tax = chargeTaxFields(paymentIntent, currency);
|
|
1131
|
+
const amountMinor = tax.amountMinor ?? (typeof paymentIntent.amount === "number" ? stripeAmountToMinorUnitsOrUndefined(paymentIntent.amount, currency) : void 0);
|
|
1029
1132
|
return {
|
|
1133
|
+
...omitAmount(tax),
|
|
1134
|
+
...amountMinor === void 0 ? {} : { amountMinor },
|
|
1030
1135
|
status,
|
|
1031
1136
|
paymentExternalId: paymentIntent.id,
|
|
1032
1137
|
paymentMethodExternalId: idOf(paymentIntent.payment_method),
|
|
@@ -1041,10 +1146,13 @@ function mapChargeOutcome(paymentIntent) {
|
|
|
1041
1146
|
* be the charge this call describes; a key reused for a different amount,
|
|
1042
1147
|
* currency, or customer is refused instead of reporting the wrong charge.
|
|
1043
1148
|
*/
|
|
1044
|
-
function assertSameCharge(paymentIntent,
|
|
1149
|
+
function assertSameCharge(paymentIntent, expected) {
|
|
1045
1150
|
const customer = idOf(paymentIntent.customer);
|
|
1046
1151
|
const paymentMethod = idOf(paymentIntent.payment_method);
|
|
1047
|
-
|
|
1152
|
+
const metadata = paymentIntent.metadata ?? {};
|
|
1153
|
+
const taxed = Boolean(metadata[TAX_CALCULATION_METADATA]);
|
|
1154
|
+
const requestedAmount = taxed ? Number(metadata[SUBTOTAL_AMOUNT_METADATA]) : paymentIntent.amount;
|
|
1155
|
+
if (taxed !== expected.automaticTax || requestedAmount !== expected.stripeAmount || (paymentIntent.currency || "").toUpperCase() !== expected.currency || customer !== void 0 && customer !== expected.customerExternalId || expected.paymentMethodExternalId !== void 0 && paymentMethod !== void 0 && paymentMethod !== expected.paymentMethodExternalId) throw new Error(`idempotencyKey was already used for a different charge (${paymentIntent.id}); use a new key for a new charge`);
|
|
1048
1156
|
}
|
|
1049
1157
|
/** Remove `client_secret` from a Stripe object and its expanded intents. */
|
|
1050
1158
|
function withoutClientSecrets(value) {
|
|
@@ -1089,6 +1197,7 @@ function mapWebhookPayment(paymentIntent, eventType) {
|
|
|
1089
1197
|
customerExternalId: idOf(paymentIntent.customer),
|
|
1090
1198
|
amountMinor: currency && typeof paymentIntent.amount === "number" ? stripeAmountToMinorUnitsOrUndefined(paymentIntent.amount, currency) : void 0,
|
|
1091
1199
|
currency,
|
|
1200
|
+
...omitAmount(chargeTaxFields(paymentIntent, currency)),
|
|
1092
1201
|
chargeKey: metadata[CHARGE_KEY_METADATA],
|
|
1093
1202
|
failureCode: status === "succeeded" ? void 0 : error?.code || void 0,
|
|
1094
1203
|
declineCode: status === "succeeded" ? void 0 : error?.decline_code || void 0,
|
|
@@ -1096,6 +1205,10 @@ function mapWebhookPayment(paymentIntent, eventType) {
|
|
|
1096
1205
|
metadata
|
|
1097
1206
|
};
|
|
1098
1207
|
}
|
|
1208
|
+
function omitAmount(fields) {
|
|
1209
|
+
const { amountMinor: _amount, ...rest } = fields;
|
|
1210
|
+
return rest;
|
|
1211
|
+
}
|
|
1099
1212
|
function idOf(value) {
|
|
1100
1213
|
if (typeof value === "string") return value || void 0;
|
|
1101
1214
|
return value?.id || void 0;
|
|
@@ -1185,4 +1298,4 @@ function sleep(ms) {
|
|
|
1185
1298
|
//#endregion
|
|
1186
1299
|
export { StripeProvider };
|
|
1187
1300
|
|
|
1188
|
-
//# sourceMappingURL=stripe-
|
|
1301
|
+
//# sourceMappingURL=stripe-CZlx1zrs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-CZlx1zrs.js","names":[],"sources":["../../src/providers/stripe/index.ts"],"sourcesContent":["/**\n * Stripe Provider\n *\n * Implements Stripe AR, payment, webhook, and billing operations using the\n * Stripe HTTP API directly. The SDK keeps Stripe as an optional runtime\n * dependency by relying on the platform fetch implementation.\n */\n\nimport { createHmac, randomUUID, timingSafeEqual } from 'node:crypto';\nimport { StripeApiError } from '../../errors.js';\nimport type {\n AccountingProviderType,\n AuditMatch,\n AuditOperations,\n AuditReport,\n BillInput,\n BillOperations,\n CustomerInput,\n CustomerOperations,\n DateRange,\n ExternalBill,\n ExternalCustomer,\n ExternalInvoice,\n ExternalPayment,\n ExternalRecord,\n ExternalVendor,\n FieldDiff,\n InvoiceInput,\n InvoiceOperations,\n ListOptions,\n PaymentChargeStatus,\n PaymentInput,\n PaymentOperations,\n SavedPaymentMethodChargeInput,\n SavedPaymentMethodChargeResult,\n StripeAccountingProvider,\n StripeBillingOperations,\n StripeCheckoutLineItem,\n StripeCheckoutSession,\n StripeCheckoutSessionDetails,\n StripeCheckoutSessionInput,\n StripeCustomerPortalSession,\n StripeCustomerPortalSessionInput,\n StripeOptions,\n StripeSubscriptionStatus,\n StripeSubscriptionStatusResult,\n SyncResult,\n VendorInput,\n VendorOperations,\n WebhookEvent,\n WebhookOperations,\n WebhookPaymentSummary,\n} from '../../types.js';\n\ntype StripePrimitive = string | number | boolean | Date | null | undefined;\ntype StripeFormValue =\n | StripePrimitive\n | StripeFormValue[]\n | { [key: string]: StripeFormValue };\n\ninterface StripeListResponse<T> {\n object: 'list';\n data: T[];\n has_more?: boolean;\n}\n\ninterface StripeCustomer {\n id: string;\n created?: number | null;\n name?: string | null;\n email?: string | null;\n phone?: string | null;\n address?: StripeAddress | null;\n balance?: number | null;\n currency?: string | null;\n metadata?: Record<string, string> | null;\n invoice_settings?: {\n default_payment_method?: string | { id: string } | null;\n } | null;\n}\n\ninterface StripeSearchResponse<T> {\n object: 'search_result';\n data: T[];\n has_more?: boolean;\n next_page?: string | null;\n}\n\ninterface StripeCoupon {\n id: string;\n amount_off?: number | null;\n currency?: string | null;\n percent_off?: number | null;\n valid?: boolean | null;\n}\n\ninterface StripeAddress {\n line1?: string | null;\n line2?: string | null;\n city?: string | null;\n state?: string | null;\n postal_code?: string | null;\n country?: string | null;\n}\n\ninterface StripeInvoice {\n id: string;\n number?: string | null;\n customer?: string | StripeCustomer | null;\n created?: number | null;\n due_date?: number | null;\n subtotal?: number | null;\n tax?: number | null;\n total_taxes?: Array<{ amount?: number | null }> | null;\n total?: number | null;\n amount_paid?: number | null;\n amount_remaining?: number | null;\n status?: string | null;\n currency?: string | null;\n collection_method?: string | null;\n auto_advance?: boolean | null;\n paid_out_of_band?: boolean | null;\n metadata?: Record<string, string> | null;\n}\n\ninterface StripeInvoiceItem {\n id: string;\n metadata?: Record<string, string> | null;\n}\n\ninterface StripePaymentIntent {\n id: string;\n object?: string | null;\n amount?: number | null;\n currency?: string | null;\n created?: number | null;\n status?: string | null;\n invoice?: string | null;\n customer?: string | { id: string } | null;\n payment_method?: string | { id: string } | null;\n payment_method_types?: string[] | null;\n latest_charge?: string | null;\n metadata?: Record<string, string> | null;\n last_payment_error?: {\n code?: string | null;\n decline_code?: string | null;\n message?: string | null;\n } | null;\n}\n\ninterface StripeTaxCalculation {\n id: string;\n amount_total: number;\n tax_amount_exclusive: number;\n tax_amount_inclusive?: number | null;\n}\n\ninterface StripeSetupIntent {\n id: string;\n payment_method?: string | { id: string } | null;\n}\n\ninterface StripeCheckoutSessionResponse {\n id: string;\n url?: string | null;\n mode?: string | null;\n status?: string | null;\n payment_status?: string | null;\n customer?: string | { id: string } | null;\n subscription?: string | { id: string } | null;\n payment_intent?: string | StripePaymentIntent | null;\n setup_intent?: string | StripeSetupIntent | null;\n currency?: string | null;\n amount_subtotal?: number | null;\n amount_total?: number | null;\n total_details?: { amount_tax?: number | null } | null;\n metadata?: Record<string, string> | null;\n}\n\ninterface StripePortalSessionResponse {\n id: string;\n url: string;\n}\n\ninterface StripeSubscription {\n id: string;\n status: StripeSubscriptionStatus;\n customer: string | StripeCustomer;\n current_period_start?: number | null;\n current_period_end?: number | null;\n cancel_at_period_end?: boolean | null;\n canceled_at?: number | null;\n trial_end?: number | null;\n}\n\ninterface StripeWebhookPayload {\n id?: string | null;\n type?: string | null;\n created?: number | null;\n data?: {\n object?: {\n id?: string | null;\n object?: string | null;\n [key: string]: unknown;\n } | null;\n } | null;\n}\n\n/**\n * Stripe accounting provider.\n */\nexport class StripeProvider implements StripeAccountingProvider {\n readonly type = 'stripe' as const;\n\n private readonly options: StripeOptions;\n private readonly fetchImpl: typeof fetch;\n private readonly couponIds = new Map<string, string>();\n\n readonly customers: CustomerOperations;\n readonly invoices: InvoiceOperations;\n readonly vendors: VendorOperations;\n readonly bills: BillOperations;\n readonly payments: PaymentOperations;\n readonly audit: AuditOperations;\n readonly webhooks: WebhookOperations;\n readonly billing: Required<StripeBillingOperations>;\n\n constructor(options: StripeOptions) {\n this.options = {\n timeout: 30000,\n maxRetries: 3,\n apiBaseUrl: 'https://api.stripe.com',\n webhookTolerance: 300,\n ...options,\n };\n this.fetchImpl = options.fetch || fetch;\n\n this.customers = new StripeCustomerOperations(this);\n this.invoices = new StripeInvoiceOperations(this);\n this.vendors = new UnsupportedVendorOperations();\n this.bills = new UnsupportedBillOperations();\n this.payments = new StripePaymentOperations(this);\n this.audit = new StripeAuditOperations(this);\n this.webhooks = new StripeWebhookOperations(this.options);\n this.billing = new StripeBillingOperationsImpl(this);\n }\n\n async request<T>(\n method: 'GET' | 'POST' | 'DELETE',\n endpoint: string,\n params?: Record<string, StripeFormValue>,\n options: { idempotencyKey?: string } = {},\n ): Promise<T> {\n const timeout = this.options.timeout || 30000;\n const maxRetries = this.options.maxRetries ?? 3;\n const idempotencyKey =\n method === 'POST'\n ? (options.idempotencyKey ?? `sdk-${randomUUID()}`)\n : null;\n let lastError: Error | null = null;\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), timeout);\n\n try {\n const url = this.buildUrl(endpoint, method === 'GET' ? params : {});\n const body =\n method === 'POST' && params\n ? encodeStripeForm(params).toString()\n : undefined;\n\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.options.secretKey}`,\n Accept: 'application/json',\n };\n if (method === 'POST') {\n headers['Content-Type'] = 'application/x-www-form-urlencoded';\n if (idempotencyKey) {\n headers['Idempotency-Key'] = idempotencyKey;\n }\n }\n if (this.options.apiVersion) {\n headers['Stripe-Version'] = this.options.apiVersion;\n }\n\n const response = await this.fetchImpl(url, {\n method,\n headers,\n body,\n signal: controller.signal,\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n const error = new StripeApiError(response.status, errorText);\n\n if (response.status < 500 && response.status !== 429) {\n throw error;\n }\n\n lastError = error;\n } else {\n const text = await response.text();\n return (text ? JSON.parse(text) : {}) as T;\n }\n } catch (error) {\n lastError = error instanceof Error ? error : new Error(String(error));\n\n const statusMatch = lastError.message.match(\n /Stripe API error \\((\\d+)\\)/,\n );\n if (statusMatch) {\n const status = Number.parseInt(statusMatch[1], 10);\n if (status >= 400 && status < 500 && status !== 429) {\n throw lastError;\n }\n }\n } finally {\n clearTimeout(timeoutId);\n }\n\n if (attempt < maxRetries) {\n await sleep(2 ** attempt * 500);\n }\n }\n\n throw lastError || new Error('Stripe request failed after retries');\n }\n\n /**\n * @internal\n * A reusable amount-off coupon for a line discount, created on first use.\n * Its id is derived from the currency and amount, so every replay and every\n * invoice with the same discount shares one coupon instead of creating one\n * per line.\n */\n async amountOffCoupon(currency: string, amount: number): Promise<string> {\n const normalized = currency.toLowerCase();\n const id = `hv_amount_off_${normalized}_${amount}`;\n const cached = this.couponIds.get(id);\n if (cached) {\n return cached;\n }\n\n const path = `/v1/coupons/${encodeURIComponent(id)}`;\n let coupon: StripeCoupon;\n try {\n coupon = await this.request<StripeCoupon>('GET', path);\n } catch (error) {\n if (!(error instanceof StripeApiError) || error.status !== 404) {\n throw error;\n }\n try {\n coupon = await this.request<StripeCoupon>('POST', '/v1/coupons', {\n id,\n amount_off: amount,\n currency: normalized,\n duration: 'forever',\n name: 'Discount',\n metadata: { hv_purpose: 'invoice_line_discount' },\n });\n } catch (createError) {\n // A concurrent push created it first.\n if (\n !(createError instanceof StripeApiError) ||\n createError.code !== 'resource_already_exists'\n ) {\n throw createError;\n }\n coupon = await this.request<StripeCoupon>('GET', path);\n }\n }\n\n if (\n coupon.amount_off !== amount ||\n (coupon.currency || '').toLowerCase() !== normalized ||\n coupon.percent_off ||\n coupon.valid === false\n ) {\n throw new Error(\n `Stripe coupon ${id} exists but is not a valid ${amount} ${normalized} amount-off coupon`,\n );\n }\n this.couponIds.set(id, coupon.id);\n return coupon.id;\n }\n\n private buildUrl(\n endpoint: string,\n params?: Record<string, StripeFormValue>,\n ): string {\n const baseUrl = this.options.apiBaseUrl || 'https://api.stripe.com';\n const url = new URL(endpoint, baseUrl);\n\n if (params && Object.keys(params).length > 0) {\n for (const [key, value] of encodeStripeForm(params).entries()) {\n url.searchParams.append(key, value);\n }\n }\n\n return url.toString();\n }\n}\n\nclass StripeCustomerOperations implements CustomerOperations {\n constructor(private readonly provider: StripeProvider) {}\n\n async push(customer: CustomerInput): Promise<SyncResult> {\n if (customer.idempotencyKey !== undefined) {\n assertIdempotencyKey(customer.idempotencyKey);\n // After Stripe's idempotency window a replayed key creates a new\n // customer, so first look for the one an earlier attempt created.\n const existing = await this.findByLocalId(customer.id);\n if (existing) {\n return {\n action: 'created',\n externalId: existing.id,\n syncedAt: new Date(),\n };\n }\n }\n\n const response = await this.provider.request<StripeCustomer>(\n 'POST',\n '/v1/customers',\n mapCustomerToStripe(customer),\n {\n idempotencyKey: customer.idempotencyKey\n ? `${customer.idempotencyKey}:customer`\n : undefined,\n },\n );\n\n return {\n action: 'created',\n externalId: response.id,\n syncedAt: new Date(),\n };\n }\n\n /**\n * The oldest customer tagged with this local id. Stripe search is\n * eventually consistent (normally under a minute); inside that lag the\n * idempotency key, retained for at least 24 hours, covers the replay.\n */\n private async findByLocalId(\n localId: string,\n ): Promise<StripeCustomer | undefined> {\n const matches: StripeCustomer[] = [];\n let page: string | undefined;\n do {\n const response = await this.provider.request<\n StripeSearchResponse<StripeCustomer>\n >('GET', '/v1/customers/search', {\n query: `metadata['local_id']:'${escapeSearchValue(localId)}'`,\n limit: 100,\n page,\n });\n matches.push(\n ...response.data.filter(\n (customer) => customer.metadata?.local_id === localId,\n ),\n );\n page = response.has_more ? response.next_page || undefined : undefined;\n } while (page);\n\n return matches.sort(\n (left, right) =>\n (left.created ?? 0) - (right.created ?? 0) ||\n left.id.localeCompare(right.id),\n )[0];\n }\n\n async pull(externalId: string): Promise<ExternalCustomer> {\n const customer = await this.provider.request<StripeCustomer>(\n 'GET',\n `/v1/customers/${encodeURIComponent(externalId)}`,\n );\n return mapStripeCustomer(customer);\n }\n\n async list(options: ListOptions = {}): Promise<ExternalCustomer[]> {\n const response = await this.provider.request<\n StripeListResponse<StripeCustomer>\n >('GET', '/v1/customers', mapListOptions(options));\n return response.data.map(mapStripeCustomer);\n }\n\n async sync(customer: CustomerInput): Promise<SyncResult> {\n if (!customer.externalId) {\n return this.push(customer);\n }\n\n await this.provider.request<StripeCustomer>(\n 'POST',\n `/v1/customers/${encodeURIComponent(customer.externalId)}`,\n mapCustomerToStripe(customer),\n );\n\n return {\n action: 'updated',\n externalId: customer.externalId,\n syncedAt: new Date(),\n };\n }\n}\n\nclass StripeInvoiceOperations implements InvoiceOperations {\n constructor(private readonly provider: StripeProvider) {}\n\n async push(invoice: InvoiceInput): Promise<SyncResult> {\n if (!invoice.customerExternalId) {\n throw new Error('Stripe invoices require customerExternalId');\n }\n\n const currency = invoice.currency || 'usd';\n const collectionMethod = resolveCollectionMethod(invoice);\n // Validate every line before any provider request.\n const lines = invoice.lineItems.map((lineItem) => ({\n lineItem,\n unitAmount: moneyToStripeMinorUnits(lineItem.unitPrice, currency),\n discount: lineDiscountToStripe(lineItem, currency),\n period: lineServicePeriod(lineItem),\n taxCode: optionalTaxCode(lineItem.taxCode),\n }));\n\n const existingInvoice = invoice.idempotencyKey\n ? await this.findInvoiceByLocalId(invoice.customerExternalId, invoice.id)\n : undefined;\n if (existingInvoice) {\n return {\n action: 'created',\n externalId: existingInvoice.id,\n syncedAt: new Date(),\n };\n }\n\n const existingLineItemIndexes = invoice.idempotencyKey\n ? await this.findPendingLineItemIndexes(\n invoice.customerExternalId,\n invoice.id,\n )\n : new Set<number>();\n\n for (const [index, line] of lines.entries()) {\n if (existingLineItemIndexes.has(index)) {\n continue;\n }\n const { lineItem, unitAmount, discount, period, taxCode } = line;\n const coupon = discount\n ? await this.provider.amountOffCoupon(currency, discount)\n : undefined;\n await this.provider.request(\n 'POST',\n '/v1/invoiceitems',\n {\n customer: invoice.customerExternalId,\n currency,\n description: lineItem.description,\n quantity: lineItem.quantity,\n unit_amount_decimal: String(unitAmount),\n period,\n discounts: coupon ? [{ coupon }] : undefined,\n tax_behavior: invoice.automaticTax ? 'exclusive' : undefined,\n tax_code: taxCode,\n metadata: normalizeMetadata({\n local_invoice_id: invoice.id,\n local_line_index: index,\n local_sku: lineItem.sku,\n local_discount: lineItem.discount,\n local_tax_rate: lineItem.taxRate,\n }),\n },\n {\n idempotencyKey: invoice.idempotencyKey\n ? `${invoice.idempotencyKey}:item:${index}`\n : undefined,\n },\n );\n }\n\n const response = await this.provider.request<StripeInvoice>(\n 'POST',\n '/v1/invoices',\n mapInvoiceToStripe(invoice, collectionMethod),\n {\n idempotencyKey: invoice.idempotencyKey\n ? `${invoice.idempotencyKey}:invoice`\n : undefined,\n },\n );\n\n return {\n action: 'created',\n externalId: response.id,\n syncedAt: new Date(),\n };\n }\n\n async pull(externalId: string): Promise<ExternalInvoice> {\n const invoice = await this.provider.request<StripeInvoice>(\n 'GET',\n `/v1/invoices/${encodeURIComponent(externalId)}`,\n );\n return mapStripeInvoice(invoice);\n }\n\n async list(options: ListOptions = {}): Promise<ExternalInvoice[]> {\n const response = await this.provider.request<\n StripeListResponse<StripeInvoice>\n >('GET', '/v1/invoices', mapListOptions(options));\n return response.data.map(mapStripeInvoice);\n }\n\n async sync(invoice: InvoiceInput): Promise<SyncResult> {\n if (!invoice.externalId) {\n return this.push(invoice);\n }\n\n await this.provider.request<StripeInvoice>(\n 'POST',\n `/v1/invoices/${encodeURIComponent(invoice.externalId)}`,\n mapInvoiceUpdateToStripe(invoice, resolveCollectionMethod(invoice)),\n );\n\n return {\n action: 'updated',\n externalId: invoice.externalId,\n syncedAt: new Date(),\n };\n }\n\n /**\n * `send_invoice` invoices are emailed through Stripe's send endpoint.\n * `charge_automatically` invoices are finalized with automatic collection\n * on, so Stripe charges the customer's default payment method and applies\n * its retry settings; the outcome arrives as `invoice.paid` or\n * `invoice.payment_failed`.\n */\n async send(externalId: string): Promise<void> {\n const path = `/v1/invoices/${encodeURIComponent(externalId)}`;\n const invoice = await this.provider.request<StripeInvoice>('GET', path);\n if (invoice.collection_method !== 'charge_automatically') {\n await this.provider.request('POST', `${path}/send`);\n return;\n }\n if (invoice.status === 'draft') {\n await this.provider.request(\n 'POST',\n `${path}/finalize`,\n { auto_advance: true },\n { idempotencyKey: `${externalId}:finalize` },\n );\n return;\n }\n if (invoice.status === 'open' && invoice.auto_advance === false) {\n await this.provider.request(\n 'POST',\n path,\n { auto_advance: true },\n { idempotencyKey: `${externalId}:auto_advance` },\n );\n }\n }\n\n async markUncollectible(externalId: string): Promise<void> {\n await this.provider.request(\n 'POST',\n `/v1/invoices/${encodeURIComponent(externalId)}/mark_uncollectible`,\n undefined,\n { idempotencyKey: `${externalId}:mark_uncollectible` },\n );\n }\n\n /**\n * Close an invoice paid on another rail (`paid_out_of_band`). An invoice\n * already marked paid out of band, or paid with nothing collected, is left\n * as is; one Stripe collected money for itself throws (a second collection needs a refund, not a silent close).\n * A draft is finalized first without automatic collection, and refused if\n * finalization raised the amount due. A void invoice throws; an\n * uncollectible one can still be paid, as in Stripe.\n */\n async markPaidOutOfBand(externalId: string): Promise<void> {\n const path = `/v1/invoices/${encodeURIComponent(externalId)}`;\n let invoice = await this.provider.request<StripeInvoice>('GET', path);\n if (invoice.status === 'paid') {\n // Closed out of band before, or settled with nothing collected (a\n // zero or credit-balance invoice): nothing more to do.\n if (invoice.paid_out_of_band === true || !(invoice.amount_paid ?? 0)) {\n return;\n }\n // Stripe collected it itself: closing it again would hide a second\n // collection. The caller must refund or credit the other payment.\n throw new Error(\n `Stripe invoice ${externalId} was already paid through Stripe; it was not marked paid out of band.`,\n );\n }\n if (invoice.status === 'void') {\n throw new Error(\n `Stripe invoice ${externalId} is void and cannot be marked paid.`,\n );\n }\n if (invoice.status === 'draft') {\n const draftDue = invoice.amount_remaining ?? invoice.total ?? 0;\n invoice = await this.provider.request<StripeInvoice>(\n 'POST',\n `${path}/finalize`,\n { auto_advance: false },\n { idempotencyKey: `${externalId}:finalize_out_of_band` },\n );\n // Finalizing settles zero-balance invoices on its own.\n if (invoice.status === 'paid') return;\n // Finalization computes tax, credits, and discounts; never forgive an\n // amount larger than the one the caller saw.\n if ((invoice.amount_remaining ?? 0) > draftDue) {\n throw new Error(\n `Stripe invoice ${externalId} grew from ${draftDue} to ${invoice.amount_remaining} on finalization; not marking it paid out of band.`,\n );\n }\n }\n await this.provider.request(\n 'POST',\n `${path}/pay`,\n { paid_out_of_band: true },\n { idempotencyKey: `${externalId}:paid_out_of_band` },\n );\n }\n\n async void(externalId: string): Promise<void> {\n await this.provider.request(\n 'POST',\n `/v1/invoices/${encodeURIComponent(externalId)}/void`,\n );\n }\n\n private async findInvoiceByLocalId(\n customerExternalId: string,\n localInvoiceId: string,\n ): Promise<StripeInvoice | undefined> {\n let startingAfter: string | undefined;\n do {\n const response = await this.provider.request<\n StripeListResponse<StripeInvoice>\n >('GET', '/v1/invoices', {\n customer: customerExternalId,\n limit: 100,\n starting_after: startingAfter,\n });\n const existing = response.data.find(\n (invoice) => invoice.metadata?.local_id === localInvoiceId,\n );\n if (existing) {\n return existing;\n }\n startingAfter = response.has_more ? response.data.at(-1)?.id : undefined;\n } while (startingAfter);\n\n return undefined;\n }\n\n private async findPendingLineItemIndexes(\n customerExternalId: string,\n localInvoiceId: string,\n ): Promise<Set<number>> {\n const indexes = new Set<number>();\n let startingAfter: string | undefined;\n do {\n const response = await this.provider.request<\n StripeListResponse<StripeInvoiceItem>\n >('GET', '/v1/invoiceitems', {\n customer: customerExternalId,\n pending: true,\n limit: 100,\n starting_after: startingAfter,\n });\n for (const item of response.data) {\n if (item.metadata?.local_invoice_id !== localInvoiceId) {\n continue;\n }\n const index = Number(item.metadata.local_line_index);\n if (Number.isSafeInteger(index) && index >= 0) {\n indexes.add(index);\n }\n }\n startingAfter = response.has_more ? response.data.at(-1)?.id : undefined;\n } while (startingAfter);\n\n return indexes;\n }\n}\n\nclass StripePaymentOperations implements PaymentOperations {\n constructor(private readonly provider: StripeProvider) {}\n\n async pull(externalId: string): Promise<ExternalPayment> {\n const paymentIntent = await this.provider.request<StripePaymentIntent>(\n 'GET',\n `/v1/payment_intents/${encodeURIComponent(externalId)}`,\n );\n return mapStripePaymentIntent(paymentIntent);\n }\n\n async list(options: ListOptions = {}): Promise<ExternalPayment[]> {\n const response = await this.provider.request<\n StripeListResponse<StripePaymentIntent>\n >('GET', '/v1/payment_intents', mapListOptions(options));\n return response.data.map(mapStripePaymentIntent);\n }\n\n async chargeSavedPaymentMethod(\n input: SavedPaymentMethodChargeInput,\n ): Promise<SavedPaymentMethodChargeResult> {\n assertIdempotencyKey(input.idempotencyKey);\n if (!input.customerExternalId) {\n throw new Error('Saved payment method charges require a customer');\n }\n const currency = normalizeCurrencyCode(input.currency);\n const stripeAmount = minorUnitsToStripeAmount(input.amountMinor, currency);\n if (stripeAmount <= 0) {\n throw new Error(\n 'Charge amount must be a positive integer of minor units',\n );\n }\n const automaticTax = input.automaticTax === true;\n const taxCode = optionalTaxCode(input.taxCode);\n if (taxCode && !automaticTax) {\n throw new Error('taxCode requires automaticTax');\n }\n const reserved = Object.keys(input.metadata ?? {}).filter((key) =>\n RESERVED_CHARGE_METADATA.has(key),\n );\n if (reserved.length > 0) {\n throw new Error(\n `Charge metadata keys ${reserved.join(', ')} are reserved by the adapter`,\n );\n }\n const chargeKey = input.idempotencyKey;\n const base = {\n provider: 'stripe' as const,\n customerExternalId: input.customerExternalId,\n amountMinor: input.amountMinor,\n currency,\n chargeKey,\n ...(automaticTax ? { subtotalMinor: input.amountMinor } : {}),\n };\n\n // After Stripe's idempotency window a replayed key would charge again, so\n // first look for the PaymentIntent an earlier attempt created.\n const existing = await this.findByChargeKey(chargeKey);\n if (existing) {\n assertSameCharge(existing, {\n customerExternalId: input.customerExternalId,\n stripeAmount,\n currency,\n automaticTax,\n paymentMethodExternalId: input.paymentMethodExternalId,\n });\n return { ...base, ...mapChargeOutcome(existing, currency) };\n }\n\n let paymentMethod = input.paymentMethodExternalId;\n if (!paymentMethod) {\n const customer = await this.provider.request<StripeCustomer>(\n 'GET',\n `/v1/customers/${encodeURIComponent(input.customerExternalId)}`,\n );\n paymentMethod = idOf(customer.invoice_settings?.default_payment_method);\n if (!paymentMethod) {\n return {\n ...base,\n status: 'failed',\n failureCode: 'payment_method_missing',\n failureMessage: 'The customer has no default payment method.',\n };\n }\n }\n\n let amount = stripeAmount;\n let taxMetadata: Record<string, string> = {};\n let taxCalculation: string | undefined;\n if (automaticTax) {\n let calculation: StripeTaxCalculation;\n try {\n calculation = await this.calculateTax(\n input.customerExternalId,\n stripeAmount,\n currency,\n chargeKey,\n taxCode,\n );\n } catch (error) {\n // A customer without a usable tax location is a charge outcome the\n // host can act on (ask for an address), not a transport failure.\n if (\n error instanceof StripeApiError &&\n error.code === 'customer_tax_location_invalid'\n ) {\n return {\n ...base,\n paymentMethodExternalId: paymentMethod,\n status: 'failed',\n failureCode: error.code,\n failureMessage: error.stripeMessage,\n };\n }\n throw error;\n }\n amount = calculation.amount_total;\n taxCalculation = calculation.id;\n taxMetadata = {\n [TAX_CALCULATION_METADATA]: calculation.id,\n [SUBTOTAL_AMOUNT_METADATA]: String(stripeAmount),\n [TAX_AMOUNT_METADATA]: String(calculation.tax_amount_exclusive),\n };\n }\n\n try {\n const paymentIntent = await this.provider.request<StripePaymentIntent>(\n 'POST',\n '/v1/payment_intents',\n {\n amount,\n currency: currency.toLowerCase(),\n customer: input.customerExternalId,\n payment_method: paymentMethod,\n off_session: true,\n confirm: true,\n description: input.description,\n // Stripe records the tax transaction from the linked calculation\n // when the payment succeeds, and reverses it on refunds.\n hooks: taxCalculation\n ? { inputs: { tax: { calculation: taxCalculation } } }\n : undefined,\n metadata: normalizeMetadata({\n ...input.metadata,\n ...taxMetadata,\n [CHARGE_KEY_METADATA]: chargeKey,\n }),\n },\n { idempotencyKey: `${chargeKey}:payment_intent` },\n );\n return { ...base, ...mapChargeOutcome(paymentIntent, currency) };\n } catch (error) {\n // A decline or an authentication requirement is a charge outcome, not\n // a transport failure: Stripe returns 402 with the failed PaymentIntent.\n if (\n error instanceof StripeApiError &&\n error.status === 402 &&\n error.type === 'card_error'\n ) {\n const paymentIntent = isRecord(error.paymentIntent)\n ? (error.paymentIntent as unknown as StripePaymentIntent)\n : undefined;\n return {\n ...base,\n ...(taxCalculation\n ? chargeTaxFields({ amount, metadata: taxMetadata }, currency)\n : {}),\n ...(paymentIntent ? mapChargeOutcome(paymentIntent, currency) : {}),\n paymentMethodExternalId:\n idOf(paymentIntent?.payment_method) ?? paymentMethod,\n status:\n error.code === 'authentication_required'\n ? 'requires_action'\n : 'failed',\n failureCode: error.code,\n declineCode: error.declineCode,\n failureMessage: error.stripeMessage,\n raw: paymentIntent ? withoutClientSecret(paymentIntent) : undefined,\n };\n }\n throw error;\n }\n }\n\n /**\n * Stripe Tax calculation for one tax-exclusive line of `stripeAmount`,\n * from the customer's saved address and tax status. Each attempt makes\n * a fresh calculation: Stripe replays a saved error for a reused\n * idempotency key, so a key per charge would keep failing with\n * `customer_tax_location_invalid` after the customer's address is fixed.\n * A calculation creates no tax transaction until a PaymentIntent linked\n * to it succeeds, so an unused one is harmless; if an earlier attempt's\n * PaymentIntent exists but is not yet searchable, the changed\n * PaymentIntent request is refused by Stripe's idempotency check (the\n * `<key>:payment_intent` key) instead of charging again.\n */\n private async calculateTax(\n customerExternalId: string,\n stripeAmount: number,\n currency: string,\n chargeKey: string,\n taxCode: string | undefined,\n ): Promise<StripeTaxCalculation> {\n const calculation = await this.provider.request<StripeTaxCalculation>(\n 'POST',\n '/v1/tax/calculations',\n {\n currency: currency.toLowerCase(),\n customer: customerExternalId,\n line_items: [\n {\n amount: stripeAmount,\n quantity: 1,\n reference: 'off_session_charge',\n tax_behavior: 'exclusive',\n tax_code: taxCode,\n },\n ],\n },\n // Not derived from the charge key: a fixed-length key stays within\n // Stripe's 255-character limit for any caller key.\n { idempotencyKey: `hv_tax_calculation:${randomUUID()}` },\n );\n const tax = calculation.tax_amount_exclusive;\n if (\n !calculation.id ||\n !Number.isSafeInteger(tax) ||\n tax < 0 ||\n calculation.amount_total !== stripeAmount + tax\n ) {\n throw new Error(\n `Stripe tax calculation ${calculation.id ?? '(no id)'} does not add up to the charge amount plus exclusive tax`,\n );\n }\n return calculation;\n }\n\n private async findByChargeKey(\n chargeKey: string,\n ): Promise<StripePaymentIntent | undefined> {\n const response = await this.provider.request<\n StripeSearchResponse<StripePaymentIntent>\n >('GET', '/v1/payment_intents/search', {\n query: `metadata['${CHARGE_KEY_METADATA}']:'${escapeSearchValue(chargeKey)}'`,\n limit: 10,\n });\n return response.data\n .filter((intent) => intent.metadata?.[CHARGE_KEY_METADATA] === chargeKey)\n .sort(\n (left, right) =>\n (left.created ?? 0) - (right.created ?? 0) ||\n left.id.localeCompare(right.id),\n )[0];\n }\n}\n\nclass StripeBillingOperationsImpl implements StripeBillingOperations {\n constructor(private readonly provider: StripeProvider) {}\n\n async createCheckoutSession(\n input: StripeCheckoutSessionInput,\n ): Promise<StripeCheckoutSession> {\n const response = await this.provider.request<StripeCheckoutSessionResponse>(\n 'POST',\n '/v1/checkout/sessions',\n mapCheckoutSessionToStripe(input),\n { idempotencyKey: input.idempotencyKey },\n );\n\n return mapCheckoutSessionResponse(response);\n }\n\n async retrieveCheckoutSession(\n sessionExternalId: string,\n ): Promise<StripeCheckoutSessionDetails> {\n const session = await this.provider.request<StripeCheckoutSessionResponse>(\n 'GET',\n `/v1/checkout/sessions/${encodeURIComponent(sessionExternalId)}`,\n { expand: ['setup_intent', 'payment_intent'] },\n );\n const intent =\n typeof session.setup_intent === 'object' && session.setup_intent\n ? session.setup_intent\n : typeof session.payment_intent === 'object' && session.payment_intent\n ? session.payment_intent\n : undefined;\n const currency = session.currency\n ? session.currency.toUpperCase()\n : undefined;\n const minor = (amount?: number | null) =>\n currency && typeof amount === 'number'\n ? stripeAmountToMinorUnitsOrUndefined(amount, currency)\n : undefined;\n\n return {\n ...mapCheckoutSessionResponse(session),\n raw: withoutClientSecrets(session),\n status: oneOf(session.status, ['open', 'complete', 'expired'] as const),\n paymentStatus: oneOf(session.payment_status, [\n 'paid',\n 'unpaid',\n 'no_payment_required',\n ] as const),\n paymentMethodExternalId: idOf(intent?.payment_method),\n currency,\n amountSubtotalMinor: minor(session.amount_subtotal),\n amountTaxMinor: minor(session.total_details?.amount_tax),\n amountTotalMinor: minor(session.amount_total),\n metadata: { ...(session.metadata || {}) },\n };\n }\n\n async setDefaultPaymentMethod(\n customerExternalId: string,\n paymentMethodExternalId: string,\n ): Promise<void> {\n if (!customerExternalId || !paymentMethodExternalId) {\n throw new Error(\n 'setDefaultPaymentMethod requires a customer and a payment method',\n );\n }\n await this.provider.request(\n 'POST',\n `/v1/customers/${encodeURIComponent(customerExternalId)}`,\n { invoice_settings: { default_payment_method: paymentMethodExternalId } },\n );\n }\n\n async createCustomerPortalSession(\n input: StripeCustomerPortalSessionInput,\n ): Promise<StripeCustomerPortalSession> {\n const response = await this.provider.request<StripePortalSessionResponse>(\n 'POST',\n '/v1/billing_portal/sessions',\n {\n customer: input.customerExternalId,\n return_url: input.returnUrl,\n configuration: input.configurationExternalId,\n },\n );\n\n return {\n externalId: response.id,\n url: response.url,\n raw: response,\n };\n }\n\n async retrieveSubscriptionStatus(\n subscriptionExternalId: string,\n ): Promise<StripeSubscriptionStatusResult> {\n const subscription = await this.provider.request<StripeSubscription>(\n 'GET',\n `/v1/subscriptions/${encodeURIComponent(subscriptionExternalId)}`,\n );\n\n return mapStripeSubscription(subscription);\n }\n\n async listCustomerSubscriptions(\n customerExternalId: string,\n ): Promise<StripeSubscriptionStatusResult[]> {\n const response = await this.provider.request<\n StripeListResponse<StripeSubscription>\n >('GET', '/v1/subscriptions', {\n customer: customerExternalId,\n status: 'all',\n limit: 100,\n });\n\n return response.data.map(mapStripeSubscription);\n }\n}\n\nclass UnsupportedVendorOperations implements VendorOperations {\n async push(_vendor: VendorInput): Promise<SyncResult> {\n throw new Error('Stripe does not support vendor operations');\n }\n\n async pull(_externalId: string): Promise<ExternalVendor> {\n throw new Error('Stripe does not support vendor operations');\n }\n\n async list(_options?: ListOptions): Promise<ExternalVendor[]> {\n throw new Error('Stripe does not support vendor operations');\n }\n\n async sync(_vendor: VendorInput): Promise<SyncResult> {\n throw new Error('Stripe does not support vendor operations');\n }\n}\n\nclass UnsupportedBillOperations implements BillOperations {\n async push(_bill: BillInput): Promise<SyncResult> {\n throw new Error('Stripe does not support bill operations');\n }\n\n async pull(_externalId: string): Promise<ExternalBill> {\n throw new Error('Stripe does not support bill operations');\n }\n\n async list(_options?: ListOptions): Promise<ExternalBill[]> {\n throw new Error('Stripe does not support bill operations');\n }\n\n async sync(_bill: BillInput): Promise<SyncResult> {\n throw new Error('Stripe does not support bill operations');\n }\n}\n\nclass StripeAuditOperations implements AuditOperations {\n constructor(private readonly provider: StripeProvider) {}\n\n async reconcileCustomers(\n locals: CustomerInput[],\n ): Promise<AuditReport<CustomerInput>> {\n const externals = await this.provider.customers.list({ limit: 100 });\n return reconcileRecords('stripe', locals, externals, compareCustomer);\n }\n\n async reconcileInvoices(\n locals: InvoiceInput[],\n dateRange?: DateRange,\n ): Promise<AuditReport<InvoiceInput>> {\n const externals = await this.provider.invoices.list({\n limit: 100,\n startDate: dateRange?.start,\n endDate: dateRange?.end,\n });\n return reconcileRecords('stripe', locals, externals, compareInvoice);\n }\n\n async reconcileVendors(\n _locals: VendorInput[],\n ): Promise<AuditReport<VendorInput>> {\n throw new Error('Stripe does not support vendor operations');\n }\n\n async reconcileBills(_locals: BillInput[]): Promise<AuditReport<BillInput>> {\n throw new Error('Stripe does not support bill operations');\n }\n\n async reconcilePayments(\n locals: PaymentInput[],\n dateRange?: DateRange,\n ): Promise<AuditReport<PaymentInput>> {\n const externals = await this.provider.payments.list({\n limit: 100,\n startDate: dateRange?.start,\n endDate: dateRange?.end,\n });\n return reconcileRecords('stripe', locals, externals, comparePayment);\n }\n}\n\nclass StripeWebhookOperations implements WebhookOperations {\n constructor(private readonly options: StripeOptions) {}\n\n verify(payload: string, signature: string, secret: string): boolean {\n const endpointSecret = secret || this.options.webhookSecret;\n if (!endpointSecret) {\n throw new Error(\n 'Stripe webhook secret not provided. Pass it as the secret parameter or configure webhookSecret in options.',\n );\n }\n\n const parsed = parseStripeSignatureHeader(signature);\n if (!parsed.timestamp || parsed.signatures.length === 0) {\n return false;\n }\n\n const tolerance = this.options.webhookTolerance ?? 300;\n const timestamp = Number.parseInt(parsed.timestamp, 10);\n if (\n !Number.isFinite(timestamp) ||\n Math.abs(Date.now() / 1000 - timestamp) > tolerance\n ) {\n return false;\n }\n\n const signedPayload = `${parsed.timestamp}.${payload}`;\n const expected = createHmac('sha256', endpointSecret)\n .update(signedPayload)\n .digest('hex');\n\n return parsed.signatures.some((value) =>\n constantTimeEqualHex(value, expected),\n );\n }\n\n parse(payload: string): WebhookEvent {\n let event: StripeWebhookPayload;\n try {\n event = JSON.parse(payload) as StripeWebhookPayload;\n } catch (error) {\n const message =\n error instanceof Error ? error.message : 'Unknown JSON parse error';\n throw new Error(`Invalid Stripe webhook payload: ${message}`);\n }\n\n const resource = event?.data?.object;\n const payment =\n resource?.object === 'payment_intent' && typeof resource.id === 'string'\n ? mapWebhookPayment(\n resource as unknown as StripePaymentIntent,\n event?.type || undefined,\n )\n : undefined;\n return {\n ...(payment ? { payment } : {}),\n type: event?.type || 'unknown',\n id: typeof event?.id === 'string' ? event.id : undefined,\n provider: 'stripe',\n timestamp: unixToDate(event?.created) || new Date(),\n payload: event,\n resourceType: mapStripeResourceType(\n resource?.object || undefined,\n event?.type || undefined,\n ),\n resourceId: typeof resource?.id === 'string' ? resource.id : undefined,\n };\n }\n}\n\nfunction encodeStripeForm(params: Record<string, StripeFormValue>) {\n const form = new URLSearchParams();\n\n for (const [key, value] of Object.entries(params)) {\n appendStripeFormValue(form, key, value);\n }\n\n return form;\n}\n\nfunction appendStripeFormValue(\n form: URLSearchParams,\n key: string,\n value: StripeFormValue,\n): void {\n if (value === undefined || value === null) {\n return;\n }\n\n if (value instanceof Date) {\n form.append(key, String(toUnixSeconds(value)));\n return;\n }\n\n if (Array.isArray(value)) {\n value.forEach((item, index) => {\n appendStripeFormValue(form, `${key}[${index}]`, item);\n });\n return;\n }\n\n if (typeof value === 'object') {\n for (const [childKey, childValue] of Object.entries(value)) {\n appendStripeFormValue(form, `${key}[${childKey}]`, childValue);\n }\n return;\n }\n\n form.append(key, String(value));\n}\n\nfunction mapCustomerToStripe(\n customer: CustomerInput,\n): Record<string, StripeFormValue> {\n const stripeCustomer: Record<string, StripeFormValue> = {\n name: customer.name,\n email: customer.email,\n phone: customer.phone,\n address: customer.billingAddress\n ? {\n line1: customer.billingAddress.street1,\n line2: customer.billingAddress.street2,\n city: customer.billingAddress.city,\n state: customer.billingAddress.state,\n postal_code: customer.billingAddress.postalCode,\n country: customer.billingAddress.country,\n }\n : undefined,\n metadata: normalizeMetadata({\n payment_terms: customer.paymentTerms,\n ...customer.metadata,\n // Written last: idempotent creation reconciles customers by it.\n local_id: customer.id,\n }),\n };\n\n if (customer.taxExempt !== undefined) {\n stripeCustomer.tax_exempt = customer.taxExempt ? 'exempt' : 'none';\n }\n\n return stripeCustomer;\n}\n\nfunction mapInvoiceToStripe(\n invoice: InvoiceInput,\n collectionMethod: 'send_invoice' | 'charge_automatically',\n): Record<string, StripeFormValue> {\n return {\n customer: invoice.customerExternalId,\n collection_method: collectionMethod,\n // Stripe rejects a due date on automatically charged invoices.\n due_date: collectionMethod === 'send_invoice' ? invoice.dueDate : undefined,\n auto_advance: false,\n pending_invoice_items_behavior: 'include',\n automatic_tax: invoice.automaticTax ? { enabled: true } : undefined,\n metadata: normalizeMetadata({\n local_id: invoice.id,\n invoice_number: invoice.invoiceNumber,\n reference: invoice.reference,\n memo: invoice.memo,\n tax_amount: invoice.taxAmount,\n subtotal: invoice.subtotal,\n total_amount: invoice.totalAmount,\n ...invoice.metadata,\n }),\n };\n}\n\nfunction mapInvoiceUpdateToStripe(\n invoice: InvoiceInput,\n collectionMethod: 'send_invoice' | 'charge_automatically',\n): Record<string, StripeFormValue> {\n return {\n // Sent only when the caller sets it, so existing updates are unchanged.\n // Stripe accepts a collection method change on draft invoices and rejects\n // it on finalized ones rather than ignoring it.\n collection_method: invoice.collectionMethod ? collectionMethod : undefined,\n due_date: collectionMethod === 'send_invoice' ? invoice.dueDate : undefined,\n metadata: normalizeMetadata({\n local_id: invoice.id,\n invoice_number: invoice.invoiceNumber,\n reference: invoice.reference,\n memo: invoice.memo,\n ...invoice.metadata,\n }),\n };\n}\n\nfunction mapCheckoutSessionToStripe(\n input: StripeCheckoutSessionInput,\n): Record<string, StripeFormValue> {\n const mode = input.mode || 'subscription';\n const lineItems = input.lineItems || [];\n if (mode === 'setup') {\n if (lineItems.length > 0) {\n throw new Error('Stripe setup-mode Checkout does not accept line items');\n }\n if (!input.currency && !input.paymentMethodTypes?.length) {\n throw new Error(\n 'Stripe setup-mode Checkout requires currency or paymentMethodTypes',\n );\n }\n if (input.automaticTax) {\n throw new Error('Stripe setup-mode Checkout does not calculate tax');\n }\n } else if (lineItems.length === 0) {\n throw new Error(`Stripe ${mode}-mode Checkout requires line items`);\n }\n if (input.setupFutureUsage && mode !== 'payment') {\n throw new Error('setupFutureUsage applies only to payment-mode Checkout');\n }\n if (input.customerUpdate && !input.customerExternalId) {\n throw new Error('customerUpdate requires customerExternalId');\n }\n\n return {\n mode,\n success_url: input.successUrl,\n cancel_url: input.cancelUrl,\n customer: input.customerExternalId,\n customer_email: input.customerExternalId ? undefined : input.customerEmail,\n client_reference_id: input.clientReferenceId,\n allow_promotion_codes: input.allowPromotionCodes,\n currency: input.currency ? input.currency.toLowerCase() : undefined,\n payment_method_types: input.paymentMethodTypes,\n automatic_tax: input.automaticTax ? { enabled: true } : undefined,\n billing_address_collection: input.billingAddressCollection,\n customer_update: input.customerUpdate\n ? {\n address: input.customerUpdate.address,\n name: input.customerUpdate.name,\n shipping: input.customerUpdate.shipping,\n }\n : undefined,\n payment_intent_data: input.setupFutureUsage\n ? { setup_future_usage: input.setupFutureUsage }\n : undefined,\n line_items:\n mode === 'setup'\n ? undefined\n : lineItems.map((lineItem) =>\n mapCheckoutLineItem(lineItem, Boolean(input.automaticTax)),\n ),\n metadata: normalizeMetadata(input.metadata || {}),\n };\n}\n\nfunction mapCheckoutSessionResponse(\n response: StripeCheckoutSessionResponse,\n): StripeCheckoutSession {\n return {\n externalId: response.id,\n url: response.url || null,\n mode: oneOf(response.mode, ['payment', 'setup', 'subscription'] as const),\n customerExternalId: idOf(response.customer),\n subscriptionExternalId: idOf(response.subscription),\n paymentIntentExternalId: idOf(response.payment_intent),\n setupIntentExternalId: idOf(response.setup_intent),\n raw: withoutClientSecrets(response),\n };\n}\n\nfunction mapCheckoutLineItem(\n lineItem: StripeCheckoutLineItem,\n automaticTax = false,\n): Record<string, StripeFormValue> {\n if (lineItem.price) {\n return {\n price: lineItem.price,\n quantity: lineItem.quantity || 1,\n };\n }\n\n if (!lineItem.priceData) {\n throw new Error('Stripe checkout line item requires price or priceData');\n }\n\n const { priceData } = lineItem;\n const taxCode = optionalTaxCode(priceData.taxCode);\n if (taxCode && priceData.product) {\n throw new Error(\n 'Stripe checkout priceData.taxCode applies to ad-hoc products only; set the tax code on the existing product instead',\n );\n }\n const productData = priceData.product\n ? undefined\n : { name: priceData.productName || 'Subscription', tax_code: taxCode };\n const hasStripeAmount = priceData.unitAmount !== undefined;\n const hasMinorAmount = priceData.unitAmountMinor !== undefined;\n if (hasStripeAmount === hasMinorAmount) {\n throw new Error(\n 'Stripe checkout priceData requires exactly one of unitAmount or unitAmountMinor',\n );\n }\n const unitAmount = hasMinorAmount\n ? minorUnitsToStripeAmount(\n priceData.unitAmountMinor as number,\n normalizeCurrencyCode(priceData.currency),\n )\n : priceData.unitAmount;\n\n return {\n quantity: lineItem.quantity || 1,\n price_data: {\n currency: priceData.currency.toLowerCase(),\n unit_amount: unitAmount,\n tax_behavior:\n priceData.taxBehavior ?? (automaticTax ? 'exclusive' : undefined),\n product: priceData.product,\n product_data: productData,\n recurring: priceData.recurring\n ? {\n interval: priceData.recurring.interval,\n interval_count: priceData.recurring.intervalCount,\n }\n : undefined,\n },\n };\n}\n\nfunction mapListOptions(options: ListOptions): Record<string, StripeFormValue> {\n return {\n limit: options.limit,\n starting_after:\n typeof options.offset === 'string' ? options.offset : undefined,\n created: {\n gte: options.startDate,\n lte: options.endDate,\n },\n status: options.status,\n };\n}\n\nfunction mapStripeCustomer(customer: StripeCustomer): ExternalCustomer {\n return {\n externalId: customer.id,\n provider: 'stripe',\n syncedAt: new Date(),\n name: customer.name || '',\n email: customer.email || undefined,\n phone: customer.phone || undefined,\n billingAddress: customer.address\n ? {\n street1: customer.address.line1 || undefined,\n street2: customer.address.line2 || undefined,\n city: customer.address.city || undefined,\n state: customer.address.state || undefined,\n postalCode: customer.address.postal_code || undefined,\n country: customer.address.country || undefined,\n }\n : undefined,\n balance:\n customer.balance === null || customer.balance === undefined\n ? undefined\n : stripeMinorUnitsToMoney(customer.balance, customer.currency),\n currency: customer.currency || undefined,\n raw: customer,\n };\n}\n\nfunction mapStripeInvoice(invoice: StripeInvoice): ExternalInvoice {\n return {\n externalId: invoice.id,\n provider: 'stripe',\n syncedAt: new Date(),\n invoiceNumber: invoice.number || invoice.id,\n customerExternalId:\n typeof invoice.customer === 'string'\n ? invoice.customer\n : invoice.customer?.id || '',\n issueDate: unixToDate(invoice.created) || new Date(),\n dueDate:\n unixToDate(invoice.due_date) || unixToDate(invoice.created) || new Date(),\n subtotal: stripeMinorUnitsToMoney(invoice.subtotal || 0, invoice.currency),\n taxAmount: stripeMinorUnitsToMoney(\n stripeInvoiceTaxAmount(invoice),\n invoice.currency,\n ),\n totalAmount: stripeMinorUnitsToMoney(invoice.total || 0, invoice.currency),\n amountPaid: stripeMinorUnitsToMoney(\n invoice.amount_paid || 0,\n invoice.currency,\n ),\n balance: stripeMinorUnitsToMoney(\n invoice.amount_remaining || 0,\n invoice.currency,\n ),\n status: mapStripeInvoiceStatus(invoice.status, invoice.due_date),\n currency: invoice.currency || 'usd',\n paidOutOfBand: invoice.paid_out_of_band === true,\n raw: invoice,\n };\n}\n\nfunction mapStripePaymentIntent(\n paymentIntent: StripePaymentIntent,\n): ExternalPayment {\n return {\n externalId: paymentIntent.id,\n provider: 'stripe',\n syncedAt: new Date(),\n amount: stripeMinorUnitsToMoney(\n paymentIntent.amount || 0,\n paymentIntent.currency,\n ),\n currency: paymentIntent.currency || 'usd',\n paidAt: unixToDate(paymentIntent.created) || new Date(),\n method: paymentIntent.payment_method_types?.[0],\n transactionId: paymentIntent.latest_charge || paymentIntent.id,\n invoiceExternalIds: paymentIntent.invoice\n ? [paymentIntent.invoice]\n : undefined,\n status: mapStripePaymentStatus(paymentIntent.status),\n raw: paymentIntent,\n };\n}\n\nfunction mapStripeSubscription(\n subscription: StripeSubscription,\n): StripeSubscriptionStatusResult {\n return {\n externalId: subscription.id,\n status: subscription.status,\n customerExternalId:\n typeof subscription.customer === 'string'\n ? subscription.customer\n : subscription.customer.id,\n currentPeriodStart: unixToDate(subscription.current_period_start),\n currentPeriodEnd: unixToDate(subscription.current_period_end),\n cancelAtPeriodEnd: Boolean(subscription.cancel_at_period_end),\n canceledAt: unixToDate(subscription.canceled_at),\n trialEnd: unixToDate(subscription.trial_end),\n raw: subscription,\n };\n}\n\nfunction mapStripeInvoiceStatus(\n status?: string | null,\n dueDate?: number | null,\n): ExternalInvoice['status'] {\n switch (status) {\n case 'draft':\n return 'draft';\n case 'paid':\n return 'paid';\n case 'void':\n return 'voided';\n case 'uncollectible':\n return 'uncollectible';\n case 'open':\n if (dueDate && dueDate * 1000 < Date.now()) {\n return 'overdue';\n }\n return 'sent';\n default:\n return 'sent';\n }\n}\n\nfunction mapStripePaymentStatus(\n status?: string | null,\n): ExternalPayment['status'] {\n switch (status) {\n case 'succeeded':\n return 'completed';\n case 'processing':\n case 'requires_action':\n case 'requires_capture':\n case 'requires_confirmation':\n return 'pending';\n case 'canceled':\n case 'requires_payment_method':\n return 'failed';\n default:\n return 'pending';\n }\n}\n\nfunction mapStripeResourceType(\n object?: string,\n eventType?: string,\n): WebhookEvent['resourceType'] | undefined {\n if (object === 'customer' || eventType?.startsWith('customer.')) {\n return 'customer';\n }\n if (object === 'invoice' || eventType?.startsWith('invoice.')) {\n return 'invoice';\n }\n if (\n object === 'payment_intent' ||\n object === 'charge' ||\n eventType?.startsWith('payment_intent.') ||\n eventType?.startsWith('charge.')\n ) {\n return 'payment';\n }\n return undefined;\n}\n\nfunction normalizeMetadata(\n metadata: Record<string, unknown>,\n): Record<string, string> {\n const normalized: Record<string, string> = {};\n\n for (const [key, value] of Object.entries(metadata)) {\n if (value !== undefined && value !== null) {\n normalized[key] = String(value);\n }\n }\n\n return normalized;\n}\n\nfunction parseStripeSignatureHeader(signature: string): {\n timestamp?: string;\n signatures: string[];\n} {\n const parts = signature.split(',').map((part) => part.trim());\n const parsed: { timestamp?: string; signatures: string[] } = {\n signatures: [],\n };\n\n for (const part of parts) {\n const separatorIndex = part.indexOf('=');\n if (separatorIndex === -1) {\n continue;\n }\n\n const key = part.slice(0, separatorIndex);\n const value = part.slice(separatorIndex + 1);\n if (key === 't') {\n parsed.timestamp = value;\n }\n if (key === 'v1' && value) {\n parsed.signatures.push(value);\n }\n }\n\n return parsed;\n}\n\nfunction constantTimeEqualHex(left: string, right: string): boolean {\n try {\n const leftBuffer = Buffer.from(left, 'hex');\n const rightBuffer = Buffer.from(right, 'hex');\n return (\n leftBuffer.length === rightBuffer.length &&\n timingSafeEqual(leftBuffer, rightBuffer)\n );\n } catch {\n return false;\n }\n}\n\nfunction reconcileRecords<TLocal extends { externalId?: string }>(\n provider: AccountingProviderType,\n locals: TLocal[],\n externals: ExternalRecord[],\n compare: (local: TLocal, external: ExternalRecord) => FieldDiff[],\n): AuditReport<TLocal> {\n const externalById = new Map(\n externals.map((external) => [external.externalId, external]),\n );\n const matched: AuditMatch<TLocal>[] = [];\n const discrepancies: AuditReport<TLocal>['discrepancies'] = [];\n const localOnly: TLocal[] = [];\n const seenExternalIds = new Set<string>();\n\n for (const local of locals) {\n const external = local.externalId\n ? externalById.get(local.externalId)\n : undefined;\n\n if (!external) {\n localOnly.push(local);\n continue;\n }\n\n seenExternalIds.add(external.externalId);\n const differences = compare(local, external);\n if (differences.length === 0) {\n matched.push({ local, external, status: 'identical' });\n } else {\n discrepancies.push({ local, external, differences });\n }\n }\n\n const externalOnly = externals.filter(\n (external) => !seenExternalIds.has(external.externalId),\n );\n\n return {\n provider,\n auditedAt: new Date(),\n matched,\n localOnly,\n externalOnly,\n discrepancies,\n summary: {\n total: locals.length + externalOnly.length,\n matched: matched.length,\n localOnly: localOnly.length,\n externalOnly: externalOnly.length,\n discrepancies: discrepancies.length,\n },\n };\n}\n\nfunction compareCustomer(\n local: CustomerInput,\n external: ExternalRecord,\n): FieldDiff[] {\n const customer = external as ExternalCustomer;\n return [\n compareField('name', local.name, customer.name),\n compareField('email', local.email, customer.email),\n ].filter((diff): diff is FieldDiff => Boolean(diff));\n}\n\nfunction compareInvoice(\n local: InvoiceInput,\n external: ExternalRecord,\n): FieldDiff[] {\n const invoice = external as ExternalInvoice;\n return [\n compareField('totalAmount', local.totalAmount, invoice.totalAmount),\n compareField('currency', local.currency || 'usd', invoice.currency),\n ].filter((diff): diff is FieldDiff => Boolean(diff));\n}\n\nfunction comparePayment(\n local: PaymentInput,\n external: ExternalRecord,\n): FieldDiff[] {\n const payment = external as ExternalPayment;\n return [\n compareField('amount', local.amount, payment.amount),\n compareField('currency', local.currency || 'usd', payment.currency),\n ].filter((diff): diff is FieldDiff => Boolean(diff));\n}\n\nfunction compareField(\n field: string,\n localValue: unknown,\n externalValue: unknown,\n): FieldDiff | null {\n if (valuesEqual(localValue, externalValue)) {\n return null;\n }\n return { field, localValue, externalValue };\n}\n\nfunction valuesEqual(left: unknown, right: unknown): boolean {\n if (left === right) {\n return true;\n }\n if (typeof left === 'number' && typeof right === 'number') {\n return Math.abs(left - right) < 0.01;\n }\n return false;\n}\n\nfunction stripeInvoiceTaxAmount(invoice: StripeInvoice): number {\n if (typeof invoice.tax === 'number') {\n return invoice.tax;\n }\n return (invoice.total_taxes || []).reduce(\n (total, tax) => total + (tax.amount || 0),\n 0,\n );\n}\n\nconst STRIPE_ZERO_DECIMAL_CURRENCIES = new Set([\n 'BIF',\n 'CLP',\n 'DJF',\n 'GNF',\n 'JPY',\n 'KMF',\n 'KRW',\n 'MGA',\n 'PYG',\n 'RWF',\n 'VND',\n 'VUV',\n 'XAF',\n 'XOF',\n 'XPF',\n]);\nconst STRIPE_THREE_DECIMAL_CURRENCIES = new Set([\n 'BHD',\n 'IQD',\n 'JOD',\n 'KWD',\n 'LYD',\n 'OMR',\n 'TND',\n]);\n\nfunction stripeCurrencyMinorUnitFactor(currency?: string | null): number {\n const normalized = (currency || 'usd').toUpperCase();\n if (STRIPE_ZERO_DECIMAL_CURRENCIES.has(normalized)) {\n return 1;\n }\n if (STRIPE_THREE_DECIMAL_CURRENCIES.has(normalized)) {\n return 1_000;\n }\n return 100;\n}\n\nfunction moneyToStripeMinorUnits(amount: number, currency: string): number {\n return Math.round(amount * stripeCurrencyMinorUnitFactor(currency));\n}\n\nfunction stripeMinorUnitsToMoney(\n amount: number,\n currency?: string | null,\n): number {\n return amount / stripeCurrencyMinorUnitFactor(currency);\n}\n\nconst CHARGE_KEY_METADATA = 'hv_charge_key';\n/** Stripe Tax calculation linked to an `automaticTax` charge. */\nconst TAX_CALCULATION_METADATA = 'hv_tax_calculation';\n/** Pre-tax amount of an `automaticTax` charge, in Stripe units. */\nconst SUBTOTAL_AMOUNT_METADATA = 'hv_subtotal_amount';\n/** Exclusive tax of an `automaticTax` charge, in Stripe units. */\nconst TAX_AMOUNT_METADATA = 'hv_tax_amount';\nconst RESERVED_CHARGE_METADATA = new Set([\n TAX_CALCULATION_METADATA,\n SUBTOTAL_AMOUNT_METADATA,\n TAX_AMOUNT_METADATA,\n]);\n\n/** A caller-supplied product tax code, trimmed; blank is refused. */\nfunction optionalTaxCode(taxCode: string | undefined): string | undefined {\n if (taxCode === undefined) {\n return undefined;\n }\n const code = typeof taxCode === 'string' ? taxCode.trim() : '';\n if (!code) {\n throw new Error('taxCode must be a non-empty string when set');\n }\n return code;\n}\n\n/**\n * Amount, subtotal, and tax of an `automaticTax` charge from its\n * PaymentIntent metadata, in ISO minor units. Empty for untaxed charges.\n */\nfunction chargeTaxFields(\n paymentIntent: Pick<StripePaymentIntent, 'amount' | 'metadata'>,\n currency: string | undefined,\n): Pick<\n SavedPaymentMethodChargeResult,\n 'subtotalMinor' | 'taxMinor' | 'taxCalculationExternalId'\n> & { amountMinor?: number } {\n const metadata = paymentIntent.metadata ?? {};\n const calculation = metadata[TAX_CALCULATION_METADATA];\n if (!calculation || !currency) {\n return {};\n }\n const minor = (value?: string | number | null) => {\n const amount = typeof value === 'string' ? Number(value) : value;\n return typeof amount === 'number' && Number.isSafeInteger(amount)\n ? stripeAmountToMinorUnitsOrUndefined(amount, currency)\n : undefined;\n };\n return {\n amountMinor: minor(paymentIntent.amount),\n subtotalMinor: minor(metadata[SUBTOTAL_AMOUNT_METADATA]),\n taxMinor: minor(metadata[TAX_AMOUNT_METADATA]),\n taxCalculationExternalId: calculation,\n };\n}\n\nfunction assertIdempotencyKey(key: string): void {\n if (typeof key !== 'string' || key.trim() === '') {\n throw new Error('idempotencyKey must be a non-empty string');\n }\n}\n\n/** Escape a value for a single-quoted Stripe Search Query Language string. */\nfunction escapeSearchValue(value: string): string {\n return value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\");\n}\n\nfunction resolveCollectionMethod(\n invoice: InvoiceInput,\n): 'send_invoice' | 'charge_automatically' {\n const method = invoice.collectionMethod ?? 'send_invoice';\n if (method !== 'send_invoice' && method !== 'charge_automatically') {\n throw new Error(`Unsupported invoice collectionMethod '${method}'`);\n }\n return method;\n}\n\n/** The line's discount in Stripe units, validated against the line total. */\nfunction lineDiscountToStripe(\n lineItem: InvoiceInput['lineItems'][number],\n currency: string,\n): number | undefined {\n if (lineItem.discount === undefined || lineItem.discount === 0) {\n return undefined;\n }\n if (!Number.isFinite(lineItem.discount) || lineItem.discount < 0) {\n throw new Error(\n `Invoice line '${lineItem.description}' discount must be a non-negative amount`,\n );\n }\n const discount = moneyToStripeMinorUnits(lineItem.discount, currency);\n const lineTotal = Math.round(\n moneyToStripeMinorUnits(lineItem.unitPrice, currency) * lineItem.quantity,\n );\n if (discount > lineTotal) {\n throw new Error(\n `Invoice line '${lineItem.description}' discount exceeds the line total`,\n );\n }\n return discount > 0 ? discount : undefined;\n}\n\nfunction lineServicePeriod(\n lineItem: InvoiceInput['lineItems'][number],\n): { start: Date; end: Date } | undefined {\n const { periodStart, periodEnd } = lineItem;\n if (!periodStart && !periodEnd) {\n return undefined;\n }\n if (!(periodStart instanceof Date) || !(periodEnd instanceof Date)) {\n throw new Error(\n `Invoice line '${lineItem.description}' needs both periodStart and periodEnd`,\n );\n }\n if (\n Number.isNaN(periodStart.getTime()) ||\n Number.isNaN(periodEnd.getTime()) ||\n periodEnd.getTime() < periodStart.getTime()\n ) {\n throw new Error(\n `Invoice line '${lineItem.description}' has an invalid service period`,\n );\n }\n return { start: periodStart, end: periodEnd };\n}\n\nfunction mapChargeOutcome(\n paymentIntent: StripePaymentIntent,\n currency: string,\n): Partial<Pick<SavedPaymentMethodChargeResult, 'amountMinor'>> &\n Pick<\n SavedPaymentMethodChargeResult,\n | 'subtotalMinor'\n | 'taxMinor'\n | 'taxCalculationExternalId'\n | 'status'\n | 'paymentExternalId'\n | 'paymentMethodExternalId'\n | 'failureCode'\n | 'declineCode'\n | 'failureMessage'\n | 'raw'\n > {\n const error = paymentIntent.last_payment_error;\n const status = mapPaymentIntentChargeStatus(\n paymentIntent.status,\n error?.code,\n );\n const tax = chargeTaxFields(paymentIntent, currency);\n const amountMinor =\n tax.amountMinor ??\n (typeof paymentIntent.amount === 'number'\n ? stripeAmountToMinorUnitsOrUndefined(paymentIntent.amount, currency)\n : undefined);\n return {\n ...omitAmount(tax),\n // Keep the caller's amount when the PaymentIntent amount is unreadable.\n ...(amountMinor === undefined ? {} : { amountMinor }),\n status,\n paymentExternalId: paymentIntent.id,\n paymentMethodExternalId: idOf(paymentIntent.payment_method),\n failureCode: status === 'succeeded' ? undefined : error?.code || undefined,\n declineCode:\n status === 'succeeded' ? undefined : error?.decline_code || undefined,\n failureMessage:\n status === 'succeeded' ? undefined : error?.message || undefined,\n raw: withoutClientSecret(paymentIntent),\n };\n}\n\n/**\n * A PaymentIntent found by charge key after Stripe's idempotency window must\n * be the charge this call describes; a key reused for a different amount,\n * currency, or customer is refused instead of reporting the wrong charge.\n */\nfunction assertSameCharge(\n paymentIntent: StripePaymentIntent,\n expected: {\n customerExternalId: string;\n stripeAmount: number;\n currency: string;\n automaticTax: boolean;\n paymentMethodExternalId?: string;\n },\n): void {\n const customer = idOf(paymentIntent.customer);\n const paymentMethod = idOf(paymentIntent.payment_method);\n const metadata = paymentIntent.metadata ?? {};\n const taxed = Boolean(metadata[TAX_CALCULATION_METADATA]);\n // A taxed charge's PaymentIntent amount includes tax; the requested\n // amount is its recorded subtotal.\n const requestedAmount = taxed\n ? Number(metadata[SUBTOTAL_AMOUNT_METADATA])\n : paymentIntent.amount;\n if (\n taxed !== expected.automaticTax ||\n requestedAmount !== expected.stripeAmount ||\n (paymentIntent.currency || '').toUpperCase() !== expected.currency ||\n (customer !== undefined && customer !== expected.customerExternalId) ||\n (expected.paymentMethodExternalId !== undefined &&\n paymentMethod !== undefined &&\n paymentMethod !== expected.paymentMethodExternalId)\n ) {\n throw new Error(\n `idempotencyKey was already used for a different charge (${paymentIntent.id}); use a new key for a new charge`,\n );\n }\n}\n\n/** Remove `client_secret` from a Stripe object and its expanded intents. */\nfunction withoutClientSecrets<T extends object>(value: T): T {\n const copy = withoutClientSecret(value) as Record<string, unknown>;\n for (const key of ['payment_intent', 'setup_intent']) {\n const nested = copy[key];\n if (isRecord(nested)) {\n copy[key] = withoutClientSecret(nested);\n }\n }\n return copy as T;\n}\n\n/**\n * Drop the intent client secret before handing objects to callers, including\n * `next_action`, whose redirect URL and SDK payload embed the same secret.\n */\nfunction withoutClientSecret<T extends object>(value: T): T {\n const {\n client_secret: _secret,\n next_action: _nextAction,\n ...rest\n } = value as T & { client_secret?: unknown; next_action?: unknown };\n return rest as T;\n}\n\nfunction mapPaymentIntentChargeStatus(\n status?: string | null,\n errorCode?: string | null,\n): PaymentChargeStatus {\n switch (status) {\n case 'succeeded':\n return 'succeeded';\n case 'processing':\n case 'requires_capture':\n return 'processing';\n case 'requires_action':\n case 'requires_confirmation':\n return 'requires_action';\n case 'canceled':\n return 'canceled';\n case 'requires_payment_method':\n return errorCode === 'authentication_required'\n ? 'requires_action'\n : 'failed';\n default:\n return 'processing';\n }\n}\n\nfunction mapWebhookPayment(\n paymentIntent: StripePaymentIntent,\n eventType?: string,\n): WebhookPaymentSummary {\n const error = paymentIntent.last_payment_error;\n let status = mapPaymentIntentChargeStatus(paymentIntent.status, error?.code);\n if (eventType === 'payment_intent.succeeded') status = 'succeeded';\n if (eventType === 'payment_intent.canceled') status = 'canceled';\n if (eventType === 'payment_intent.payment_failed') {\n status =\n error?.code === 'authentication_required' ? 'requires_action' : 'failed';\n }\n const currency = paymentIntent.currency\n ? paymentIntent.currency.toUpperCase()\n : undefined;\n const metadata = { ...(paymentIntent.metadata || {}) };\n return {\n status,\n paymentExternalId: paymentIntent.id,\n customerExternalId: idOf(paymentIntent.customer),\n amountMinor:\n currency && typeof paymentIntent.amount === 'number'\n ? stripeAmountToMinorUnitsOrUndefined(paymentIntent.amount, currency)\n : undefined,\n currency,\n ...omitAmount(chargeTaxFields(paymentIntent, currency)),\n chargeKey: metadata[CHARGE_KEY_METADATA],\n failureCode: status === 'succeeded' ? undefined : error?.code || undefined,\n declineCode:\n status === 'succeeded' ? undefined : error?.decline_code || undefined,\n failureMessage:\n status === 'succeeded' ? undefined : error?.message || undefined,\n metadata,\n };\n}\n\nfunction omitAmount<T extends { amountMinor?: number }>(\n fields: T,\n): Omit<T, 'amountMinor'> {\n const { amountMinor: _amount, ...rest } = fields;\n return rest;\n}\n\nfunction idOf(\n value: string | { id?: string | null } | null | undefined,\n): string | undefined {\n if (typeof value === 'string') {\n return value || undefined;\n }\n return value?.id || undefined;\n}\n\nfunction oneOf<const T extends string>(\n value: string | null | undefined,\n allowed: readonly T[],\n): T | undefined {\n return allowed.find((candidate) => candidate === value);\n}\n\nfunction stringOrUndefined(value: unknown): string | undefined {\n return typeof value === 'string' && value ? value : undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\nfunction normalizeCurrencyCode(currency: string): string {\n const code = String(currency ?? '')\n .trim()\n .toUpperCase();\n if (!/^[A-Z]{3}$/.test(code)) {\n throw new Error(`Currency '${currency}' must be a three-letter code`);\n }\n return code;\n}\n\n/** ISO 4217 minor-unit exponents other than 2. */\nconst ISO_ZERO_DECIMAL_CURRENCIES = new Set([\n 'BIF',\n 'CLP',\n 'DJF',\n 'GNF',\n 'ISK',\n 'JPY',\n 'KMF',\n 'KRW',\n 'PYG',\n 'RWF',\n 'UGX',\n 'UYI',\n 'VND',\n 'VUV',\n 'XAF',\n 'XOF',\n 'XPF',\n]);\nconst ISO_THREE_DECIMAL_CURRENCIES = new Set([\n 'BHD',\n 'IQD',\n 'JOD',\n 'KWD',\n 'LYD',\n 'OMR',\n 'TND',\n]);\nconst ISO_FOUR_DECIMAL_CURRENCIES = new Set(['CLF', 'UYW']);\n\n/**\n * ISO 4217 minor-unit exponent (2 for USD, 0 for JPY and ISK), from the\n * explicit tables above rather than the runtime's `Intl`/CLDR display digits,\n * which differ for some currencies (for example RSD, IQD, MGA) and change\n * between ICU releases.\n */\nfunction isoMinorUnitExponent(currency: string): number {\n if (ISO_ZERO_DECIMAL_CURRENCIES.has(currency)) return 0;\n if (ISO_THREE_DECIMAL_CURRENCIES.has(currency)) return 3;\n if (ISO_FOUR_DECIMAL_CURRENCIES.has(currency)) return 4;\n return 2;\n}\n\n/**\n * Integer ISO minor units → Stripe's smallest unit. They differ where Stripe\n * keeps a two-decimal representation for a zero-decimal currency (ISK, UGX).\n */\nfunction minorUnitsToStripeAmount(\n amountMinor: number,\n currency: string,\n): number {\n if (!Number.isSafeInteger(amountMinor)) {\n throw new Error(\n `Amount ${amountMinor} must be a safe integer number of minor units`,\n );\n }\n const iso = 10 ** isoMinorUnitExponent(currency);\n const stripe = stripeCurrencyMinorUnitFactor(currency);\n if (stripe >= iso) {\n return amountMinor * (stripe / iso);\n }\n const divisor = iso / stripe;\n if (amountMinor % divisor !== 0) {\n throw new Error(\n `Amount ${amountMinor} ${currency} minor units is not representable in Stripe's currency unit`,\n );\n }\n return amountMinor / divisor;\n}\n\nfunction stripeAmountToMinorUnitsOrUndefined(\n amount: number,\n currency: string,\n): number | undefined {\n if (!Number.isSafeInteger(amount)) {\n return undefined;\n }\n // Reads (webhooks, session totals) omit an amount that is not a whole\n // number of ISO minor units instead of failing a verified event.\n const iso = 10 ** isoMinorUnitExponent(currency);\n const stripe = stripeCurrencyMinorUnitFactor(currency);\n const minor = (amount * iso) / stripe;\n return Number.isSafeInteger(minor) ? minor : undefined;\n}\n\nfunction centsToMoney(cents: number): number {\n return cents / 100;\n}\n\nfunction toUnixSeconds(date: Date): number {\n return Math.floor(date.getTime() / 1000);\n}\n\nfunction unixToDate(value?: number | null): Date | undefined {\n return value === null || value === undefined\n ? undefined\n : new Date(value * 1000);\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n"],"mappings":";;;;;;;;;;;;;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ACT;;;;;AAMA,SAAS,yBACP,aACA,UACQ;CACR,IAAI,CAAC,OAAO,cAAc,WAAW,GACnC,MAAM,IAAI,MACR,UAAU,YAAY,8CACxB;CAEF,MAAM,MAAM,MAAM,qBAAqB,QAAQ;CAC/C,MAAM,SAAS,8BAA8B,QAAQ;CACrD,IAAI,UAAU,KACZ,OAAO,eAAe,SAAS;CAEjC,MAAM,UAAU,MAAM;CACtB,IAAI,cAAc,YAAY,GAC5B,MAAM,IAAI,MACR,UAAU,YAAY,GAAG,SAAS,4DACpC;CAEF,OAAO,cAAc;AACvB;AAEA,SAAS,oCACP,QACA,UACoB;CACpB,IAAI,CAAC,OAAO,cAAc,MAAM,GAC9B;CAIF,MAAM,MAAM,MAAM,qBAAqB,QAAQ;CAC/C,MAAM,SAAS,8BAA8B,QAAQ;CACrD,MAAM,QAAS,SAAS,MAAO;CAC/B,OAAO,OAAO,cAAc,KAAK,IAAI,QAAQ,KAAA;AAC/C;AAMA,SAAS,cAAc,MAAoB;CACzC,OAAO,KAAK,MAAM,KAAK,QAAQ,IAAI,GAAI;AACzC;AAEA,SAAS,WAAW,OAAyC;CAC3D,OAAO,UAAU,QAAQ,UAAU,KAAA,IAC/B,KAAA,oBACA,IAAI,KAAK,QAAQ,GAAI;AAC3B;AAEA,SAAS,MAAM,IAA2B;CACxC,OAAO,IAAI,SAAS,YAAY,WAAW,SAAS,EAAE,CAAC;AACzD"}
|
package/dist/index.js
CHANGED
|
@@ -109,7 +109,7 @@ async function getAccountingProvider(userOptions) {
|
|
|
109
109
|
}
|
|
110
110
|
case "stripe": {
|
|
111
111
|
if (!isStripeOptions(options)) throw new Error("Invalid Stripe options");
|
|
112
|
-
const { StripeProvider } = await import("./chunks/stripe-
|
|
112
|
+
const { StripeProvider } = await import("./chunks/stripe-CZlx1zrs.js");
|
|
113
113
|
return new StripeProvider(options);
|
|
114
114
|
}
|
|
115
115
|
case "paypal": throw new Error("PayPal provider not yet implemented");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/stripe/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAGV,eAAe,EAGf,cAAc,EAEd,kBAAkB,EAUlB,iBAAiB,EAIjB,iBAAiB,EAGjB,wBAAwB,EACxB,uBAAuB,EAOvB,aAAa,EAKb,gBAAgB,EAEhB,iBAAiB,EAElB,MAAM,gBAAgB,CAAC;AAExB,KAAK,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC;AAC3E,KAAK,eAAe,GAChB,eAAe,GACf,eAAe,EAAE,GACjB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAA;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/stripe/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAGV,eAAe,EAGf,cAAc,EAEd,kBAAkB,EAUlB,iBAAiB,EAIjB,iBAAiB,EAGjB,wBAAwB,EACxB,uBAAuB,EAOvB,aAAa,EAKb,gBAAgB,EAEhB,iBAAiB,EAElB,MAAM,gBAAgB,CAAC;AAExB,KAAK,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC;AAC3E,KAAK,eAAe,GAChB,eAAe,GACf,eAAe,EAAE,GACjB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAA;CAAE,CAAC;AAsJvC;;GAEG;AACH,qBAAa,cAAe,YAAW,wBAAwB;IAC7D,QAAQ,CAAC,IAAI,EAAG,QAAQ,CAAU;IAElC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;IACzC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA6B;IAEvD,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,uBAAuB,CAAC,CAAC;gBAExC,OAAO,EAAE,aAAa;IAoB5B,OAAO,CAAC,CAAC,EACb,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,EACjC,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EACxC,OAAO,GAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAA;KAAO,GACxC,OAAO,CAAC,CAAC,CAAC;IA8Eb;;;;;;OAMG;IACG,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAmDxE,OAAO,CAAC,QAAQ;CAejB"}
|
package/dist/types.d.ts
CHANGED
|
@@ -500,8 +500,32 @@ export interface SavedPaymentMethodChargeInput {
|
|
|
500
500
|
idempotencyKey: string;
|
|
501
501
|
/** Statement/description text shown to the customer where supported. */
|
|
502
502
|
description?: string;
|
|
503
|
-
/**
|
|
503
|
+
/**
|
|
504
|
+
* Opaque values stored on the provider charge and returned by webhooks.
|
|
505
|
+
* The adapter's own bookkeeping keys win over caller values, and its tax
|
|
506
|
+
* keys (Stripe: `hv_tax_calculation`, `hv_subtotal_amount`,
|
|
507
|
+
* `hv_tax_amount`) are refused.
|
|
508
|
+
*/
|
|
504
509
|
metadata?: Record<string, string | number | boolean | null | undefined>;
|
|
510
|
+
/**
|
|
511
|
+
* Add provider-calculated tax on top of `amountMinor`, from the customer's
|
|
512
|
+
* saved tax location and tax status (Stripe Tax). `amountMinor` is then
|
|
513
|
+
* the pre-tax subtotal and the customer is charged subtotal plus tax; the
|
|
514
|
+
* result and payment webhooks report `subtotalMinor` and `taxMinor`
|
|
515
|
+
* separately. The provider records the tax for reporting when the payment
|
|
516
|
+
* succeeds (and reverses it on refunds). A customer whose tax location
|
|
517
|
+
* cannot be determined yields a `failed` result with
|
|
518
|
+
* `failureCode: 'customer_tax_location_invalid'` and no charge. A provider
|
|
519
|
+
* that implements `chargeSavedPaymentMethod` but cannot calculate tax
|
|
520
|
+
* throws instead of charging untaxed.
|
|
521
|
+
*/
|
|
522
|
+
automaticTax?: boolean;
|
|
523
|
+
/**
|
|
524
|
+
* Product tax code for the charge (Stripe: `txcd_...`); requires
|
|
525
|
+
* `automaticTax`. Omit to use the provider account's default product tax
|
|
526
|
+
* code.
|
|
527
|
+
*/
|
|
528
|
+
taxCode?: string;
|
|
505
529
|
}
|
|
506
530
|
export interface SavedPaymentMethodChargeResult {
|
|
507
531
|
status: PaymentChargeStatus;
|
|
@@ -510,10 +534,29 @@ export interface SavedPaymentMethodChargeResult {
|
|
|
510
534
|
paymentExternalId?: string;
|
|
511
535
|
customerExternalId: string;
|
|
512
536
|
paymentMethodExternalId?: string;
|
|
513
|
-
/**
|
|
537
|
+
/**
|
|
538
|
+
* Integer minor units of `currency` charged: the provider charge's amount,
|
|
539
|
+
* which includes tax for an `automaticTax` charge. Before a provider
|
|
540
|
+
* charge exists (a `failed` result without `paymentExternalId`), the
|
|
541
|
+
* requested `amountMinor`.
|
|
542
|
+
*/
|
|
514
543
|
amountMinor: number;
|
|
515
544
|
/** Upper-case ISO 4217 code. */
|
|
516
545
|
currency: string;
|
|
546
|
+
/**
|
|
547
|
+
* `automaticTax` charges only: the pre-tax amount (the requested
|
|
548
|
+
* `amountMinor`), in integer minor units.
|
|
549
|
+
*/
|
|
550
|
+
subtotalMinor?: number;
|
|
551
|
+
/**
|
|
552
|
+
* `automaticTax` charges only: the provider-calculated tax added to
|
|
553
|
+
* `subtotalMinor`, in integer minor units (`0` for an exempt customer or
|
|
554
|
+
* a location without a tax registration). Absent when no tax was
|
|
555
|
+
* calculated, for example after a tax location failure.
|
|
556
|
+
*/
|
|
557
|
+
taxMinor?: number;
|
|
558
|
+
/** Provider tax calculation id (Stripe `taxcalc_...`), when one was made. */
|
|
559
|
+
taxCalculationExternalId?: string;
|
|
517
560
|
/** The caller's `idempotencyKey`. */
|
|
518
561
|
chargeKey: string;
|
|
519
562
|
/** Provider failure code (for example `card_declined`, `authentication_required`). */
|
|
@@ -532,10 +575,19 @@ export interface WebhookPaymentSummary {
|
|
|
532
575
|
status: PaymentChargeStatus;
|
|
533
576
|
paymentExternalId: string;
|
|
534
577
|
customerExternalId?: string;
|
|
535
|
-
/**
|
|
578
|
+
/**
|
|
579
|
+
* Integer minor units charged (including tax for an `automaticTax`
|
|
580
|
+
* charge), when the provider amount converts exactly.
|
|
581
|
+
*/
|
|
536
582
|
amountMinor?: number;
|
|
537
583
|
/** Upper-case ISO 4217 code. */
|
|
538
584
|
currency?: string;
|
|
585
|
+
/** Pre-tax amount of an `automaticTax` charge, in integer minor units. */
|
|
586
|
+
subtotalMinor?: number;
|
|
587
|
+
/** Tax of an `automaticTax` charge, in integer minor units. */
|
|
588
|
+
taxMinor?: number;
|
|
589
|
+
/** Provider tax calculation id of an `automaticTax` charge. */
|
|
590
|
+
taxCalculationExternalId?: string;
|
|
539
591
|
/** `idempotencyKey` of the `chargeSavedPaymentMethod` call that created it. */
|
|
540
592
|
chargeKey?: string;
|
|
541
593
|
failureCode?: string;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAC9B,YAAY,GACZ,QAAQ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,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IACpE,4BAA4B;IAC5B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,oBAAoB;IACpB,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAC;IAGtC,0BAA0B;IAC1B,SAAS,EAAE,kBAAkB,CAAC;IAC9B,yBAAyB;IACzB,QAAQ,EAAE,iBAAiB,CAAC;IAG5B,wBAAwB;IACxB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,sBAAsB;IACtB,KAAK,EAAE,cAAc,CAAC;IAGtB,yBAAyB;IACzB,QAAQ,EAAE,iBAAiB,CAAC;IAG5B,uBAAuB;IACvB,KAAK,EAAE,eAAe,CAAC;IAGvB,yBAAyB;IACzB,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,kBAAkB;IAClE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,OAAO,EAAE,uBAAuB,CAAC;CAClC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/accounting",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.96.1",
|
|
4
4
|
"description": "Multi-provider accounting integration for AR/AP sync and audit with QuickBooks, Stripe, and more",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"license": "MIT",
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"intuit-oauth": "^4.2.3",
|
|
40
|
-
"@happyvertical/utils": "0.
|
|
40
|
+
"@happyvertical/utils": "0.96.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "25.0.10",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stripe-yrlSgLLl.js","names":[],"sources":["../../src/providers/stripe/index.ts"],"sourcesContent":["/**\n * Stripe Provider\n *\n * Implements Stripe AR, payment, webhook, and billing operations using the\n * Stripe HTTP API directly. The SDK keeps Stripe as an optional runtime\n * dependency by relying on the platform fetch implementation.\n */\n\nimport { createHmac, randomUUID, timingSafeEqual } from 'node:crypto';\nimport { StripeApiError } from '../../errors.js';\nimport type {\n AccountingProviderType,\n AuditMatch,\n AuditOperations,\n AuditReport,\n BillInput,\n BillOperations,\n CustomerInput,\n CustomerOperations,\n DateRange,\n ExternalBill,\n ExternalCustomer,\n ExternalInvoice,\n ExternalPayment,\n ExternalRecord,\n ExternalVendor,\n FieldDiff,\n InvoiceInput,\n InvoiceOperations,\n ListOptions,\n PaymentChargeStatus,\n PaymentInput,\n PaymentOperations,\n SavedPaymentMethodChargeInput,\n SavedPaymentMethodChargeResult,\n StripeAccountingProvider,\n StripeBillingOperations,\n StripeCheckoutLineItem,\n StripeCheckoutSession,\n StripeCheckoutSessionDetails,\n StripeCheckoutSessionInput,\n StripeCustomerPortalSession,\n StripeCustomerPortalSessionInput,\n StripeOptions,\n StripeSubscriptionStatus,\n StripeSubscriptionStatusResult,\n SyncResult,\n VendorInput,\n VendorOperations,\n WebhookEvent,\n WebhookOperations,\n WebhookPaymentSummary,\n} from '../../types.js';\n\ntype StripePrimitive = string | number | boolean | Date | null | undefined;\ntype StripeFormValue =\n | StripePrimitive\n | StripeFormValue[]\n | { [key: string]: StripeFormValue };\n\ninterface StripeListResponse<T> {\n object: 'list';\n data: T[];\n has_more?: boolean;\n}\n\ninterface StripeCustomer {\n id: string;\n created?: number | null;\n name?: string | null;\n email?: string | null;\n phone?: string | null;\n address?: StripeAddress | null;\n balance?: number | null;\n currency?: string | null;\n metadata?: Record<string, string> | null;\n invoice_settings?: {\n default_payment_method?: string | { id: string } | null;\n } | null;\n}\n\ninterface StripeSearchResponse<T> {\n object: 'search_result';\n data: T[];\n has_more?: boolean;\n next_page?: string | null;\n}\n\ninterface StripeCoupon {\n id: string;\n amount_off?: number | null;\n currency?: string | null;\n percent_off?: number | null;\n valid?: boolean | null;\n}\n\ninterface StripeAddress {\n line1?: string | null;\n line2?: string | null;\n city?: string | null;\n state?: string | null;\n postal_code?: string | null;\n country?: string | null;\n}\n\ninterface StripeInvoice {\n id: string;\n number?: string | null;\n customer?: string | StripeCustomer | null;\n created?: number | null;\n due_date?: number | null;\n subtotal?: number | null;\n tax?: number | null;\n total_taxes?: Array<{ amount?: number | null }> | null;\n total?: number | null;\n amount_paid?: number | null;\n amount_remaining?: number | null;\n status?: string | null;\n currency?: string | null;\n collection_method?: string | null;\n auto_advance?: boolean | null;\n paid_out_of_band?: boolean | null;\n metadata?: Record<string, string> | null;\n}\n\ninterface StripeInvoiceItem {\n id: string;\n metadata?: Record<string, string> | null;\n}\n\ninterface StripePaymentIntent {\n id: string;\n object?: string | null;\n amount?: number | null;\n currency?: string | null;\n created?: number | null;\n status?: string | null;\n invoice?: string | null;\n customer?: string | { id: string } | null;\n payment_method?: string | { id: string } | null;\n payment_method_types?: string[] | null;\n latest_charge?: string | null;\n metadata?: Record<string, string> | null;\n last_payment_error?: {\n code?: string | null;\n decline_code?: string | null;\n message?: string | null;\n } | null;\n}\n\ninterface StripeSetupIntent {\n id: string;\n payment_method?: string | { id: string } | null;\n}\n\ninterface StripeCheckoutSessionResponse {\n id: string;\n url?: string | null;\n mode?: string | null;\n status?: string | null;\n payment_status?: string | null;\n customer?: string | { id: string } | null;\n subscription?: string | { id: string } | null;\n payment_intent?: string | StripePaymentIntent | null;\n setup_intent?: string | StripeSetupIntent | null;\n currency?: string | null;\n amount_subtotal?: number | null;\n amount_total?: number | null;\n total_details?: { amount_tax?: number | null } | null;\n metadata?: Record<string, string> | null;\n}\n\ninterface StripePortalSessionResponse {\n id: string;\n url: string;\n}\n\ninterface StripeSubscription {\n id: string;\n status: StripeSubscriptionStatus;\n customer: string | StripeCustomer;\n current_period_start?: number | null;\n current_period_end?: number | null;\n cancel_at_period_end?: boolean | null;\n canceled_at?: number | null;\n trial_end?: number | null;\n}\n\ninterface StripeWebhookPayload {\n id?: string | null;\n type?: string | null;\n created?: number | null;\n data?: {\n object?: {\n id?: string | null;\n object?: string | null;\n [key: string]: unknown;\n } | null;\n } | null;\n}\n\n/**\n * Stripe accounting provider.\n */\nexport class StripeProvider implements StripeAccountingProvider {\n readonly type = 'stripe' as const;\n\n private readonly options: StripeOptions;\n private readonly fetchImpl: typeof fetch;\n private readonly couponIds = new Map<string, string>();\n\n readonly customers: CustomerOperations;\n readonly invoices: InvoiceOperations;\n readonly vendors: VendorOperations;\n readonly bills: BillOperations;\n readonly payments: PaymentOperations;\n readonly audit: AuditOperations;\n readonly webhooks: WebhookOperations;\n readonly billing: Required<StripeBillingOperations>;\n\n constructor(options: StripeOptions) {\n this.options = {\n timeout: 30000,\n maxRetries: 3,\n apiBaseUrl: 'https://api.stripe.com',\n webhookTolerance: 300,\n ...options,\n };\n this.fetchImpl = options.fetch || fetch;\n\n this.customers = new StripeCustomerOperations(this);\n this.invoices = new StripeInvoiceOperations(this);\n this.vendors = new UnsupportedVendorOperations();\n this.bills = new UnsupportedBillOperations();\n this.payments = new StripePaymentOperations(this);\n this.audit = new StripeAuditOperations(this);\n this.webhooks = new StripeWebhookOperations(this.options);\n this.billing = new StripeBillingOperationsImpl(this);\n }\n\n async request<T>(\n method: 'GET' | 'POST' | 'DELETE',\n endpoint: string,\n params?: Record<string, StripeFormValue>,\n options: { idempotencyKey?: string } = {},\n ): Promise<T> {\n const timeout = this.options.timeout || 30000;\n const maxRetries = this.options.maxRetries ?? 3;\n const idempotencyKey =\n method === 'POST'\n ? (options.idempotencyKey ?? `sdk-${randomUUID()}`)\n : null;\n let lastError: Error | null = null;\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), timeout);\n\n try {\n const url = this.buildUrl(endpoint, method === 'GET' ? params : {});\n const body =\n method === 'POST' && params\n ? encodeStripeForm(params).toString()\n : undefined;\n\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.options.secretKey}`,\n Accept: 'application/json',\n };\n if (method === 'POST') {\n headers['Content-Type'] = 'application/x-www-form-urlencoded';\n if (idempotencyKey) {\n headers['Idempotency-Key'] = idempotencyKey;\n }\n }\n if (this.options.apiVersion) {\n headers['Stripe-Version'] = this.options.apiVersion;\n }\n\n const response = await this.fetchImpl(url, {\n method,\n headers,\n body,\n signal: controller.signal,\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n const error = new StripeApiError(response.status, errorText);\n\n if (response.status < 500 && response.status !== 429) {\n throw error;\n }\n\n lastError = error;\n } else {\n const text = await response.text();\n return (text ? JSON.parse(text) : {}) as T;\n }\n } catch (error) {\n lastError = error instanceof Error ? error : new Error(String(error));\n\n const statusMatch = lastError.message.match(\n /Stripe API error \\((\\d+)\\)/,\n );\n if (statusMatch) {\n const status = Number.parseInt(statusMatch[1], 10);\n if (status >= 400 && status < 500 && status !== 429) {\n throw lastError;\n }\n }\n } finally {\n clearTimeout(timeoutId);\n }\n\n if (attempt < maxRetries) {\n await sleep(2 ** attempt * 500);\n }\n }\n\n throw lastError || new Error('Stripe request failed after retries');\n }\n\n /**\n * @internal\n * A reusable amount-off coupon for a line discount, created on first use.\n * Its id is derived from the currency and amount, so every replay and every\n * invoice with the same discount shares one coupon instead of creating one\n * per line.\n */\n async amountOffCoupon(currency: string, amount: number): Promise<string> {\n const normalized = currency.toLowerCase();\n const id = `hv_amount_off_${normalized}_${amount}`;\n const cached = this.couponIds.get(id);\n if (cached) {\n return cached;\n }\n\n const path = `/v1/coupons/${encodeURIComponent(id)}`;\n let coupon: StripeCoupon;\n try {\n coupon = await this.request<StripeCoupon>('GET', path);\n } catch (error) {\n if (!(error instanceof StripeApiError) || error.status !== 404) {\n throw error;\n }\n try {\n coupon = await this.request<StripeCoupon>('POST', '/v1/coupons', {\n id,\n amount_off: amount,\n currency: normalized,\n duration: 'forever',\n name: 'Discount',\n metadata: { hv_purpose: 'invoice_line_discount' },\n });\n } catch (createError) {\n // A concurrent push created it first.\n if (\n !(createError instanceof StripeApiError) ||\n createError.code !== 'resource_already_exists'\n ) {\n throw createError;\n }\n coupon = await this.request<StripeCoupon>('GET', path);\n }\n }\n\n if (\n coupon.amount_off !== amount ||\n (coupon.currency || '').toLowerCase() !== normalized ||\n coupon.percent_off ||\n coupon.valid === false\n ) {\n throw new Error(\n `Stripe coupon ${id} exists but is not a valid ${amount} ${normalized} amount-off coupon`,\n );\n }\n this.couponIds.set(id, coupon.id);\n return coupon.id;\n }\n\n private buildUrl(\n endpoint: string,\n params?: Record<string, StripeFormValue>,\n ): string {\n const baseUrl = this.options.apiBaseUrl || 'https://api.stripe.com';\n const url = new URL(endpoint, baseUrl);\n\n if (params && Object.keys(params).length > 0) {\n for (const [key, value] of encodeStripeForm(params).entries()) {\n url.searchParams.append(key, value);\n }\n }\n\n return url.toString();\n }\n}\n\nclass StripeCustomerOperations implements CustomerOperations {\n constructor(private readonly provider: StripeProvider) {}\n\n async push(customer: CustomerInput): Promise<SyncResult> {\n if (customer.idempotencyKey !== undefined) {\n assertIdempotencyKey(customer.idempotencyKey);\n // After Stripe's idempotency window a replayed key creates a new\n // customer, so first look for the one an earlier attempt created.\n const existing = await this.findByLocalId(customer.id);\n if (existing) {\n return {\n action: 'created',\n externalId: existing.id,\n syncedAt: new Date(),\n };\n }\n }\n\n const response = await this.provider.request<StripeCustomer>(\n 'POST',\n '/v1/customers',\n mapCustomerToStripe(customer),\n {\n idempotencyKey: customer.idempotencyKey\n ? `${customer.idempotencyKey}:customer`\n : undefined,\n },\n );\n\n return {\n action: 'created',\n externalId: response.id,\n syncedAt: new Date(),\n };\n }\n\n /**\n * The oldest customer tagged with this local id. Stripe search is\n * eventually consistent (normally under a minute); inside that lag the\n * idempotency key, retained for at least 24 hours, covers the replay.\n */\n private async findByLocalId(\n localId: string,\n ): Promise<StripeCustomer | undefined> {\n const matches: StripeCustomer[] = [];\n let page: string | undefined;\n do {\n const response = await this.provider.request<\n StripeSearchResponse<StripeCustomer>\n >('GET', '/v1/customers/search', {\n query: `metadata['local_id']:'${escapeSearchValue(localId)}'`,\n limit: 100,\n page,\n });\n matches.push(\n ...response.data.filter(\n (customer) => customer.metadata?.local_id === localId,\n ),\n );\n page = response.has_more ? response.next_page || undefined : undefined;\n } while (page);\n\n return matches.sort(\n (left, right) =>\n (left.created ?? 0) - (right.created ?? 0) ||\n left.id.localeCompare(right.id),\n )[0];\n }\n\n async pull(externalId: string): Promise<ExternalCustomer> {\n const customer = await this.provider.request<StripeCustomer>(\n 'GET',\n `/v1/customers/${encodeURIComponent(externalId)}`,\n );\n return mapStripeCustomer(customer);\n }\n\n async list(options: ListOptions = {}): Promise<ExternalCustomer[]> {\n const response = await this.provider.request<\n StripeListResponse<StripeCustomer>\n >('GET', '/v1/customers', mapListOptions(options));\n return response.data.map(mapStripeCustomer);\n }\n\n async sync(customer: CustomerInput): Promise<SyncResult> {\n if (!customer.externalId) {\n return this.push(customer);\n }\n\n await this.provider.request<StripeCustomer>(\n 'POST',\n `/v1/customers/${encodeURIComponent(customer.externalId)}`,\n mapCustomerToStripe(customer),\n );\n\n return {\n action: 'updated',\n externalId: customer.externalId,\n syncedAt: new Date(),\n };\n }\n}\n\nclass StripeInvoiceOperations implements InvoiceOperations {\n constructor(private readonly provider: StripeProvider) {}\n\n async push(invoice: InvoiceInput): Promise<SyncResult> {\n if (!invoice.customerExternalId) {\n throw new Error('Stripe invoices require customerExternalId');\n }\n\n const currency = invoice.currency || 'usd';\n const collectionMethod = resolveCollectionMethod(invoice);\n // Validate every line before any provider request.\n const lines = invoice.lineItems.map((lineItem) => ({\n lineItem,\n unitAmount: moneyToStripeMinorUnits(lineItem.unitPrice, currency),\n discount: lineDiscountToStripe(lineItem, currency),\n period: lineServicePeriod(lineItem),\n taxCode: optionalTaxCode(lineItem.taxCode),\n }));\n\n const existingInvoice = invoice.idempotencyKey\n ? await this.findInvoiceByLocalId(invoice.customerExternalId, invoice.id)\n : undefined;\n if (existingInvoice) {\n return {\n action: 'created',\n externalId: existingInvoice.id,\n syncedAt: new Date(),\n };\n }\n\n const existingLineItemIndexes = invoice.idempotencyKey\n ? await this.findPendingLineItemIndexes(\n invoice.customerExternalId,\n invoice.id,\n )\n : new Set<number>();\n\n for (const [index, line] of lines.entries()) {\n if (existingLineItemIndexes.has(index)) {\n continue;\n }\n const { lineItem, unitAmount, discount, period, taxCode } = line;\n const coupon = discount\n ? await this.provider.amountOffCoupon(currency, discount)\n : undefined;\n await this.provider.request(\n 'POST',\n '/v1/invoiceitems',\n {\n customer: invoice.customerExternalId,\n currency,\n description: lineItem.description,\n quantity: lineItem.quantity,\n unit_amount_decimal: String(unitAmount),\n period,\n discounts: coupon ? [{ coupon }] : undefined,\n tax_behavior: invoice.automaticTax ? 'exclusive' : undefined,\n tax_code: taxCode,\n metadata: normalizeMetadata({\n local_invoice_id: invoice.id,\n local_line_index: index,\n local_sku: lineItem.sku,\n local_discount: lineItem.discount,\n local_tax_rate: lineItem.taxRate,\n }),\n },\n {\n idempotencyKey: invoice.idempotencyKey\n ? `${invoice.idempotencyKey}:item:${index}`\n : undefined,\n },\n );\n }\n\n const response = await this.provider.request<StripeInvoice>(\n 'POST',\n '/v1/invoices',\n mapInvoiceToStripe(invoice, collectionMethod),\n {\n idempotencyKey: invoice.idempotencyKey\n ? `${invoice.idempotencyKey}:invoice`\n : undefined,\n },\n );\n\n return {\n action: 'created',\n externalId: response.id,\n syncedAt: new Date(),\n };\n }\n\n async pull(externalId: string): Promise<ExternalInvoice> {\n const invoice = await this.provider.request<StripeInvoice>(\n 'GET',\n `/v1/invoices/${encodeURIComponent(externalId)}`,\n );\n return mapStripeInvoice(invoice);\n }\n\n async list(options: ListOptions = {}): Promise<ExternalInvoice[]> {\n const response = await this.provider.request<\n StripeListResponse<StripeInvoice>\n >('GET', '/v1/invoices', mapListOptions(options));\n return response.data.map(mapStripeInvoice);\n }\n\n async sync(invoice: InvoiceInput): Promise<SyncResult> {\n if (!invoice.externalId) {\n return this.push(invoice);\n }\n\n await this.provider.request<StripeInvoice>(\n 'POST',\n `/v1/invoices/${encodeURIComponent(invoice.externalId)}`,\n mapInvoiceUpdateToStripe(invoice, resolveCollectionMethod(invoice)),\n );\n\n return {\n action: 'updated',\n externalId: invoice.externalId,\n syncedAt: new Date(),\n };\n }\n\n /**\n * `send_invoice` invoices are emailed through Stripe's send endpoint.\n * `charge_automatically` invoices are finalized with automatic collection\n * on, so Stripe charges the customer's default payment method and applies\n * its retry settings; the outcome arrives as `invoice.paid` or\n * `invoice.payment_failed`.\n */\n async send(externalId: string): Promise<void> {\n const path = `/v1/invoices/${encodeURIComponent(externalId)}`;\n const invoice = await this.provider.request<StripeInvoice>('GET', path);\n if (invoice.collection_method !== 'charge_automatically') {\n await this.provider.request('POST', `${path}/send`);\n return;\n }\n if (invoice.status === 'draft') {\n await this.provider.request(\n 'POST',\n `${path}/finalize`,\n { auto_advance: true },\n { idempotencyKey: `${externalId}:finalize` },\n );\n return;\n }\n if (invoice.status === 'open' && invoice.auto_advance === false) {\n await this.provider.request(\n 'POST',\n path,\n { auto_advance: true },\n { idempotencyKey: `${externalId}:auto_advance` },\n );\n }\n }\n\n async markUncollectible(externalId: string): Promise<void> {\n await this.provider.request(\n 'POST',\n `/v1/invoices/${encodeURIComponent(externalId)}/mark_uncollectible`,\n undefined,\n { idempotencyKey: `${externalId}:mark_uncollectible` },\n );\n }\n\n /**\n * Close an invoice paid on another rail (`paid_out_of_band`). An invoice\n * already marked paid out of band, or paid with nothing collected, is left\n * as is; one Stripe collected money for itself throws (a second collection needs a refund, not a silent close).\n * A draft is finalized first without automatic collection, and refused if\n * finalization raised the amount due. A void invoice throws; an\n * uncollectible one can still be paid, as in Stripe.\n */\n async markPaidOutOfBand(externalId: string): Promise<void> {\n const path = `/v1/invoices/${encodeURIComponent(externalId)}`;\n let invoice = await this.provider.request<StripeInvoice>('GET', path);\n if (invoice.status === 'paid') {\n // Closed out of band before, or settled with nothing collected (a\n // zero or credit-balance invoice): nothing more to do.\n if (invoice.paid_out_of_band === true || !(invoice.amount_paid ?? 0)) {\n return;\n }\n // Stripe collected it itself: closing it again would hide a second\n // collection. The caller must refund or credit the other payment.\n throw new Error(\n `Stripe invoice ${externalId} was already paid through Stripe; it was not marked paid out of band.`,\n );\n }\n if (invoice.status === 'void') {\n throw new Error(\n `Stripe invoice ${externalId} is void and cannot be marked paid.`,\n );\n }\n if (invoice.status === 'draft') {\n const draftDue = invoice.amount_remaining ?? invoice.total ?? 0;\n invoice = await this.provider.request<StripeInvoice>(\n 'POST',\n `${path}/finalize`,\n { auto_advance: false },\n { idempotencyKey: `${externalId}:finalize_out_of_band` },\n );\n // Finalizing settles zero-balance invoices on its own.\n if (invoice.status === 'paid') return;\n // Finalization computes tax, credits, and discounts; never forgive an\n // amount larger than the one the caller saw.\n if ((invoice.amount_remaining ?? 0) > draftDue) {\n throw new Error(\n `Stripe invoice ${externalId} grew from ${draftDue} to ${invoice.amount_remaining} on finalization; not marking it paid out of band.`,\n );\n }\n }\n await this.provider.request(\n 'POST',\n `${path}/pay`,\n { paid_out_of_band: true },\n { idempotencyKey: `${externalId}:paid_out_of_band` },\n );\n }\n\n async void(externalId: string): Promise<void> {\n await this.provider.request(\n 'POST',\n `/v1/invoices/${encodeURIComponent(externalId)}/void`,\n );\n }\n\n private async findInvoiceByLocalId(\n customerExternalId: string,\n localInvoiceId: string,\n ): Promise<StripeInvoice | undefined> {\n let startingAfter: string | undefined;\n do {\n const response = await this.provider.request<\n StripeListResponse<StripeInvoice>\n >('GET', '/v1/invoices', {\n customer: customerExternalId,\n limit: 100,\n starting_after: startingAfter,\n });\n const existing = response.data.find(\n (invoice) => invoice.metadata?.local_id === localInvoiceId,\n );\n if (existing) {\n return existing;\n }\n startingAfter = response.has_more ? response.data.at(-1)?.id : undefined;\n } while (startingAfter);\n\n return undefined;\n }\n\n private async findPendingLineItemIndexes(\n customerExternalId: string,\n localInvoiceId: string,\n ): Promise<Set<number>> {\n const indexes = new Set<number>();\n let startingAfter: string | undefined;\n do {\n const response = await this.provider.request<\n StripeListResponse<StripeInvoiceItem>\n >('GET', '/v1/invoiceitems', {\n customer: customerExternalId,\n pending: true,\n limit: 100,\n starting_after: startingAfter,\n });\n for (const item of response.data) {\n if (item.metadata?.local_invoice_id !== localInvoiceId) {\n continue;\n }\n const index = Number(item.metadata.local_line_index);\n if (Number.isSafeInteger(index) && index >= 0) {\n indexes.add(index);\n }\n }\n startingAfter = response.has_more ? response.data.at(-1)?.id : undefined;\n } while (startingAfter);\n\n return indexes;\n }\n}\n\nclass StripePaymentOperations implements PaymentOperations {\n constructor(private readonly provider: StripeProvider) {}\n\n async pull(externalId: string): Promise<ExternalPayment> {\n const paymentIntent = await this.provider.request<StripePaymentIntent>(\n 'GET',\n `/v1/payment_intents/${encodeURIComponent(externalId)}`,\n );\n return mapStripePaymentIntent(paymentIntent);\n }\n\n async list(options: ListOptions = {}): Promise<ExternalPayment[]> {\n const response = await this.provider.request<\n StripeListResponse<StripePaymentIntent>\n >('GET', '/v1/payment_intents', mapListOptions(options));\n return response.data.map(mapStripePaymentIntent);\n }\n\n async chargeSavedPaymentMethod(\n input: SavedPaymentMethodChargeInput,\n ): Promise<SavedPaymentMethodChargeResult> {\n assertIdempotencyKey(input.idempotencyKey);\n if (!input.customerExternalId) {\n throw new Error('Saved payment method charges require a customer');\n }\n const currency = normalizeCurrencyCode(input.currency);\n const stripeAmount = minorUnitsToStripeAmount(input.amountMinor, currency);\n if (stripeAmount <= 0) {\n throw new Error(\n 'Charge amount must be a positive integer of minor units',\n );\n }\n const chargeKey = input.idempotencyKey;\n const base = {\n provider: 'stripe' as const,\n customerExternalId: input.customerExternalId,\n amountMinor: input.amountMinor,\n currency,\n chargeKey,\n };\n\n // After Stripe's idempotency window a replayed key would charge again, so\n // first look for the PaymentIntent an earlier attempt created.\n const existing = await this.findByChargeKey(chargeKey);\n if (existing) {\n assertSameCharge(\n existing,\n input.customerExternalId,\n stripeAmount,\n currency,\n input.paymentMethodExternalId,\n );\n return { ...base, ...mapChargeOutcome(existing) };\n }\n\n let paymentMethod = input.paymentMethodExternalId;\n if (!paymentMethod) {\n const customer = await this.provider.request<StripeCustomer>(\n 'GET',\n `/v1/customers/${encodeURIComponent(input.customerExternalId)}`,\n );\n paymentMethod = idOf(customer.invoice_settings?.default_payment_method);\n if (!paymentMethod) {\n return {\n ...base,\n status: 'failed',\n failureCode: 'payment_method_missing',\n failureMessage: 'The customer has no default payment method.',\n };\n }\n }\n\n try {\n const paymentIntent = await this.provider.request<StripePaymentIntent>(\n 'POST',\n '/v1/payment_intents',\n {\n amount: stripeAmount,\n currency: currency.toLowerCase(),\n customer: input.customerExternalId,\n payment_method: paymentMethod,\n off_session: true,\n confirm: true,\n description: input.description,\n metadata: normalizeMetadata({\n ...input.metadata,\n [CHARGE_KEY_METADATA]: chargeKey,\n }),\n },\n { idempotencyKey: `${chargeKey}:payment_intent` },\n );\n return { ...base, ...mapChargeOutcome(paymentIntent) };\n } catch (error) {\n // A decline or an authentication requirement is a charge outcome, not\n // a transport failure: Stripe returns 402 with the failed PaymentIntent.\n if (\n error instanceof StripeApiError &&\n error.status === 402 &&\n error.type === 'card_error'\n ) {\n const paymentIntent = isRecord(error.paymentIntent)\n ? (error.paymentIntent as unknown as StripePaymentIntent)\n : undefined;\n return {\n ...base,\n ...(paymentIntent ? mapChargeOutcome(paymentIntent) : {}),\n paymentMethodExternalId:\n idOf(paymentIntent?.payment_method) ?? paymentMethod,\n status:\n error.code === 'authentication_required'\n ? 'requires_action'\n : 'failed',\n failureCode: error.code,\n declineCode: error.declineCode,\n failureMessage: error.stripeMessage,\n raw: paymentIntent ? withoutClientSecret(paymentIntent) : undefined,\n };\n }\n throw error;\n }\n }\n\n private async findByChargeKey(\n chargeKey: string,\n ): Promise<StripePaymentIntent | undefined> {\n const response = await this.provider.request<\n StripeSearchResponse<StripePaymentIntent>\n >('GET', '/v1/payment_intents/search', {\n query: `metadata['${CHARGE_KEY_METADATA}']:'${escapeSearchValue(chargeKey)}'`,\n limit: 10,\n });\n return response.data\n .filter((intent) => intent.metadata?.[CHARGE_KEY_METADATA] === chargeKey)\n .sort(\n (left, right) =>\n (left.created ?? 0) - (right.created ?? 0) ||\n left.id.localeCompare(right.id),\n )[0];\n }\n}\n\nclass StripeBillingOperationsImpl implements StripeBillingOperations {\n constructor(private readonly provider: StripeProvider) {}\n\n async createCheckoutSession(\n input: StripeCheckoutSessionInput,\n ): Promise<StripeCheckoutSession> {\n const response = await this.provider.request<StripeCheckoutSessionResponse>(\n 'POST',\n '/v1/checkout/sessions',\n mapCheckoutSessionToStripe(input),\n { idempotencyKey: input.idempotencyKey },\n );\n\n return mapCheckoutSessionResponse(response);\n }\n\n async retrieveCheckoutSession(\n sessionExternalId: string,\n ): Promise<StripeCheckoutSessionDetails> {\n const session = await this.provider.request<StripeCheckoutSessionResponse>(\n 'GET',\n `/v1/checkout/sessions/${encodeURIComponent(sessionExternalId)}`,\n { expand: ['setup_intent', 'payment_intent'] },\n );\n const intent =\n typeof session.setup_intent === 'object' && session.setup_intent\n ? session.setup_intent\n : typeof session.payment_intent === 'object' && session.payment_intent\n ? session.payment_intent\n : undefined;\n const currency = session.currency\n ? session.currency.toUpperCase()\n : undefined;\n const minor = (amount?: number | null) =>\n currency && typeof amount === 'number'\n ? stripeAmountToMinorUnitsOrUndefined(amount, currency)\n : undefined;\n\n return {\n ...mapCheckoutSessionResponse(session),\n raw: withoutClientSecrets(session),\n status: oneOf(session.status, ['open', 'complete', 'expired'] as const),\n paymentStatus: oneOf(session.payment_status, [\n 'paid',\n 'unpaid',\n 'no_payment_required',\n ] as const),\n paymentMethodExternalId: idOf(intent?.payment_method),\n currency,\n amountSubtotalMinor: minor(session.amount_subtotal),\n amountTaxMinor: minor(session.total_details?.amount_tax),\n amountTotalMinor: minor(session.amount_total),\n metadata: { ...(session.metadata || {}) },\n };\n }\n\n async setDefaultPaymentMethod(\n customerExternalId: string,\n paymentMethodExternalId: string,\n ): Promise<void> {\n if (!customerExternalId || !paymentMethodExternalId) {\n throw new Error(\n 'setDefaultPaymentMethod requires a customer and a payment method',\n );\n }\n await this.provider.request(\n 'POST',\n `/v1/customers/${encodeURIComponent(customerExternalId)}`,\n { invoice_settings: { default_payment_method: paymentMethodExternalId } },\n );\n }\n\n async createCustomerPortalSession(\n input: StripeCustomerPortalSessionInput,\n ): Promise<StripeCustomerPortalSession> {\n const response = await this.provider.request<StripePortalSessionResponse>(\n 'POST',\n '/v1/billing_portal/sessions',\n {\n customer: input.customerExternalId,\n return_url: input.returnUrl,\n configuration: input.configurationExternalId,\n },\n );\n\n return {\n externalId: response.id,\n url: response.url,\n raw: response,\n };\n }\n\n async retrieveSubscriptionStatus(\n subscriptionExternalId: string,\n ): Promise<StripeSubscriptionStatusResult> {\n const subscription = await this.provider.request<StripeSubscription>(\n 'GET',\n `/v1/subscriptions/${encodeURIComponent(subscriptionExternalId)}`,\n );\n\n return mapStripeSubscription(subscription);\n }\n\n async listCustomerSubscriptions(\n customerExternalId: string,\n ): Promise<StripeSubscriptionStatusResult[]> {\n const response = await this.provider.request<\n StripeListResponse<StripeSubscription>\n >('GET', '/v1/subscriptions', {\n customer: customerExternalId,\n status: 'all',\n limit: 100,\n });\n\n return response.data.map(mapStripeSubscription);\n }\n}\n\nclass UnsupportedVendorOperations implements VendorOperations {\n async push(_vendor: VendorInput): Promise<SyncResult> {\n throw new Error('Stripe does not support vendor operations');\n }\n\n async pull(_externalId: string): Promise<ExternalVendor> {\n throw new Error('Stripe does not support vendor operations');\n }\n\n async list(_options?: ListOptions): Promise<ExternalVendor[]> {\n throw new Error('Stripe does not support vendor operations');\n }\n\n async sync(_vendor: VendorInput): Promise<SyncResult> {\n throw new Error('Stripe does not support vendor operations');\n }\n}\n\nclass UnsupportedBillOperations implements BillOperations {\n async push(_bill: BillInput): Promise<SyncResult> {\n throw new Error('Stripe does not support bill operations');\n }\n\n async pull(_externalId: string): Promise<ExternalBill> {\n throw new Error('Stripe does not support bill operations');\n }\n\n async list(_options?: ListOptions): Promise<ExternalBill[]> {\n throw new Error('Stripe does not support bill operations');\n }\n\n async sync(_bill: BillInput): Promise<SyncResult> {\n throw new Error('Stripe does not support bill operations');\n }\n}\n\nclass StripeAuditOperations implements AuditOperations {\n constructor(private readonly provider: StripeProvider) {}\n\n async reconcileCustomers(\n locals: CustomerInput[],\n ): Promise<AuditReport<CustomerInput>> {\n const externals = await this.provider.customers.list({ limit: 100 });\n return reconcileRecords('stripe', locals, externals, compareCustomer);\n }\n\n async reconcileInvoices(\n locals: InvoiceInput[],\n dateRange?: DateRange,\n ): Promise<AuditReport<InvoiceInput>> {\n const externals = await this.provider.invoices.list({\n limit: 100,\n startDate: dateRange?.start,\n endDate: dateRange?.end,\n });\n return reconcileRecords('stripe', locals, externals, compareInvoice);\n }\n\n async reconcileVendors(\n _locals: VendorInput[],\n ): Promise<AuditReport<VendorInput>> {\n throw new Error('Stripe does not support vendor operations');\n }\n\n async reconcileBills(_locals: BillInput[]): Promise<AuditReport<BillInput>> {\n throw new Error('Stripe does not support bill operations');\n }\n\n async reconcilePayments(\n locals: PaymentInput[],\n dateRange?: DateRange,\n ): Promise<AuditReport<PaymentInput>> {\n const externals = await this.provider.payments.list({\n limit: 100,\n startDate: dateRange?.start,\n endDate: dateRange?.end,\n });\n return reconcileRecords('stripe', locals, externals, comparePayment);\n }\n}\n\nclass StripeWebhookOperations implements WebhookOperations {\n constructor(private readonly options: StripeOptions) {}\n\n verify(payload: string, signature: string, secret: string): boolean {\n const endpointSecret = secret || this.options.webhookSecret;\n if (!endpointSecret) {\n throw new Error(\n 'Stripe webhook secret not provided. Pass it as the secret parameter or configure webhookSecret in options.',\n );\n }\n\n const parsed = parseStripeSignatureHeader(signature);\n if (!parsed.timestamp || parsed.signatures.length === 0) {\n return false;\n }\n\n const tolerance = this.options.webhookTolerance ?? 300;\n const timestamp = Number.parseInt(parsed.timestamp, 10);\n if (\n !Number.isFinite(timestamp) ||\n Math.abs(Date.now() / 1000 - timestamp) > tolerance\n ) {\n return false;\n }\n\n const signedPayload = `${parsed.timestamp}.${payload}`;\n const expected = createHmac('sha256', endpointSecret)\n .update(signedPayload)\n .digest('hex');\n\n return parsed.signatures.some((value) =>\n constantTimeEqualHex(value, expected),\n );\n }\n\n parse(payload: string): WebhookEvent {\n let event: StripeWebhookPayload;\n try {\n event = JSON.parse(payload) as StripeWebhookPayload;\n } catch (error) {\n const message =\n error instanceof Error ? error.message : 'Unknown JSON parse error';\n throw new Error(`Invalid Stripe webhook payload: ${message}`);\n }\n\n const resource = event?.data?.object;\n const payment =\n resource?.object === 'payment_intent' && typeof resource.id === 'string'\n ? mapWebhookPayment(\n resource as unknown as StripePaymentIntent,\n event?.type || undefined,\n )\n : undefined;\n return {\n ...(payment ? { payment } : {}),\n type: event?.type || 'unknown',\n id: typeof event?.id === 'string' ? event.id : undefined,\n provider: 'stripe',\n timestamp: unixToDate(event?.created) || new Date(),\n payload: event,\n resourceType: mapStripeResourceType(\n resource?.object || undefined,\n event?.type || undefined,\n ),\n resourceId: typeof resource?.id === 'string' ? resource.id : undefined,\n };\n }\n}\n\nfunction encodeStripeForm(params: Record<string, StripeFormValue>) {\n const form = new URLSearchParams();\n\n for (const [key, value] of Object.entries(params)) {\n appendStripeFormValue(form, key, value);\n }\n\n return form;\n}\n\nfunction appendStripeFormValue(\n form: URLSearchParams,\n key: string,\n value: StripeFormValue,\n): void {\n if (value === undefined || value === null) {\n return;\n }\n\n if (value instanceof Date) {\n form.append(key, String(toUnixSeconds(value)));\n return;\n }\n\n if (Array.isArray(value)) {\n value.forEach((item, index) => {\n appendStripeFormValue(form, `${key}[${index}]`, item);\n });\n return;\n }\n\n if (typeof value === 'object') {\n for (const [childKey, childValue] of Object.entries(value)) {\n appendStripeFormValue(form, `${key}[${childKey}]`, childValue);\n }\n return;\n }\n\n form.append(key, String(value));\n}\n\nfunction mapCustomerToStripe(\n customer: CustomerInput,\n): Record<string, StripeFormValue> {\n const stripeCustomer: Record<string, StripeFormValue> = {\n name: customer.name,\n email: customer.email,\n phone: customer.phone,\n address: customer.billingAddress\n ? {\n line1: customer.billingAddress.street1,\n line2: customer.billingAddress.street2,\n city: customer.billingAddress.city,\n state: customer.billingAddress.state,\n postal_code: customer.billingAddress.postalCode,\n country: customer.billingAddress.country,\n }\n : undefined,\n metadata: normalizeMetadata({\n payment_terms: customer.paymentTerms,\n ...customer.metadata,\n // Written last: idempotent creation reconciles customers by it.\n local_id: customer.id,\n }),\n };\n\n if (customer.taxExempt !== undefined) {\n stripeCustomer.tax_exempt = customer.taxExempt ? 'exempt' : 'none';\n }\n\n return stripeCustomer;\n}\n\nfunction mapInvoiceToStripe(\n invoice: InvoiceInput,\n collectionMethod: 'send_invoice' | 'charge_automatically',\n): Record<string, StripeFormValue> {\n return {\n customer: invoice.customerExternalId,\n collection_method: collectionMethod,\n // Stripe rejects a due date on automatically charged invoices.\n due_date: collectionMethod === 'send_invoice' ? invoice.dueDate : undefined,\n auto_advance: false,\n pending_invoice_items_behavior: 'include',\n automatic_tax: invoice.automaticTax ? { enabled: true } : undefined,\n metadata: normalizeMetadata({\n local_id: invoice.id,\n invoice_number: invoice.invoiceNumber,\n reference: invoice.reference,\n memo: invoice.memo,\n tax_amount: invoice.taxAmount,\n subtotal: invoice.subtotal,\n total_amount: invoice.totalAmount,\n ...invoice.metadata,\n }),\n };\n}\n\nfunction mapInvoiceUpdateToStripe(\n invoice: InvoiceInput,\n collectionMethod: 'send_invoice' | 'charge_automatically',\n): Record<string, StripeFormValue> {\n return {\n // Sent only when the caller sets it, so existing updates are unchanged.\n // Stripe accepts a collection method change on draft invoices and rejects\n // it on finalized ones rather than ignoring it.\n collection_method: invoice.collectionMethod ? collectionMethod : undefined,\n due_date: collectionMethod === 'send_invoice' ? invoice.dueDate : undefined,\n metadata: normalizeMetadata({\n local_id: invoice.id,\n invoice_number: invoice.invoiceNumber,\n reference: invoice.reference,\n memo: invoice.memo,\n ...invoice.metadata,\n }),\n };\n}\n\nfunction mapCheckoutSessionToStripe(\n input: StripeCheckoutSessionInput,\n): Record<string, StripeFormValue> {\n const mode = input.mode || 'subscription';\n const lineItems = input.lineItems || [];\n if (mode === 'setup') {\n if (lineItems.length > 0) {\n throw new Error('Stripe setup-mode Checkout does not accept line items');\n }\n if (!input.currency && !input.paymentMethodTypes?.length) {\n throw new Error(\n 'Stripe setup-mode Checkout requires currency or paymentMethodTypes',\n );\n }\n if (input.automaticTax) {\n throw new Error('Stripe setup-mode Checkout does not calculate tax');\n }\n } else if (lineItems.length === 0) {\n throw new Error(`Stripe ${mode}-mode Checkout requires line items`);\n }\n if (input.setupFutureUsage && mode !== 'payment') {\n throw new Error('setupFutureUsage applies only to payment-mode Checkout');\n }\n if (input.customerUpdate && !input.customerExternalId) {\n throw new Error('customerUpdate requires customerExternalId');\n }\n\n return {\n mode,\n success_url: input.successUrl,\n cancel_url: input.cancelUrl,\n customer: input.customerExternalId,\n customer_email: input.customerExternalId ? undefined : input.customerEmail,\n client_reference_id: input.clientReferenceId,\n allow_promotion_codes: input.allowPromotionCodes,\n currency: input.currency ? input.currency.toLowerCase() : undefined,\n payment_method_types: input.paymentMethodTypes,\n automatic_tax: input.automaticTax ? { enabled: true } : undefined,\n billing_address_collection: input.billingAddressCollection,\n customer_update: input.customerUpdate\n ? {\n address: input.customerUpdate.address,\n name: input.customerUpdate.name,\n shipping: input.customerUpdate.shipping,\n }\n : undefined,\n payment_intent_data: input.setupFutureUsage\n ? { setup_future_usage: input.setupFutureUsage }\n : undefined,\n line_items:\n mode === 'setup'\n ? undefined\n : lineItems.map((lineItem) =>\n mapCheckoutLineItem(lineItem, Boolean(input.automaticTax)),\n ),\n metadata: normalizeMetadata(input.metadata || {}),\n };\n}\n\nfunction mapCheckoutSessionResponse(\n response: StripeCheckoutSessionResponse,\n): StripeCheckoutSession {\n return {\n externalId: response.id,\n url: response.url || null,\n mode: oneOf(response.mode, ['payment', 'setup', 'subscription'] as const),\n customerExternalId: idOf(response.customer),\n subscriptionExternalId: idOf(response.subscription),\n paymentIntentExternalId: idOf(response.payment_intent),\n setupIntentExternalId: idOf(response.setup_intent),\n raw: withoutClientSecrets(response),\n };\n}\n\nfunction mapCheckoutLineItem(\n lineItem: StripeCheckoutLineItem,\n automaticTax = false,\n): Record<string, StripeFormValue> {\n if (lineItem.price) {\n return {\n price: lineItem.price,\n quantity: lineItem.quantity || 1,\n };\n }\n\n if (!lineItem.priceData) {\n throw new Error('Stripe checkout line item requires price or priceData');\n }\n\n const { priceData } = lineItem;\n const taxCode = optionalTaxCode(priceData.taxCode);\n if (taxCode && priceData.product) {\n throw new Error(\n 'Stripe checkout priceData.taxCode applies to ad-hoc products only; set the tax code on the existing product instead',\n );\n }\n const productData = priceData.product\n ? undefined\n : { name: priceData.productName || 'Subscription', tax_code: taxCode };\n const hasStripeAmount = priceData.unitAmount !== undefined;\n const hasMinorAmount = priceData.unitAmountMinor !== undefined;\n if (hasStripeAmount === hasMinorAmount) {\n throw new Error(\n 'Stripe checkout priceData requires exactly one of unitAmount or unitAmountMinor',\n );\n }\n const unitAmount = hasMinorAmount\n ? minorUnitsToStripeAmount(\n priceData.unitAmountMinor as number,\n normalizeCurrencyCode(priceData.currency),\n )\n : priceData.unitAmount;\n\n return {\n quantity: lineItem.quantity || 1,\n price_data: {\n currency: priceData.currency.toLowerCase(),\n unit_amount: unitAmount,\n tax_behavior:\n priceData.taxBehavior ?? (automaticTax ? 'exclusive' : undefined),\n product: priceData.product,\n product_data: productData,\n recurring: priceData.recurring\n ? {\n interval: priceData.recurring.interval,\n interval_count: priceData.recurring.intervalCount,\n }\n : undefined,\n },\n };\n}\n\nfunction mapListOptions(options: ListOptions): Record<string, StripeFormValue> {\n return {\n limit: options.limit,\n starting_after:\n typeof options.offset === 'string' ? options.offset : undefined,\n created: {\n gte: options.startDate,\n lte: options.endDate,\n },\n status: options.status,\n };\n}\n\nfunction mapStripeCustomer(customer: StripeCustomer): ExternalCustomer {\n return {\n externalId: customer.id,\n provider: 'stripe',\n syncedAt: new Date(),\n name: customer.name || '',\n email: customer.email || undefined,\n phone: customer.phone || undefined,\n billingAddress: customer.address\n ? {\n street1: customer.address.line1 || undefined,\n street2: customer.address.line2 || undefined,\n city: customer.address.city || undefined,\n state: customer.address.state || undefined,\n postalCode: customer.address.postal_code || undefined,\n country: customer.address.country || undefined,\n }\n : undefined,\n balance:\n customer.balance === null || customer.balance === undefined\n ? undefined\n : stripeMinorUnitsToMoney(customer.balance, customer.currency),\n currency: customer.currency || undefined,\n raw: customer,\n };\n}\n\nfunction mapStripeInvoice(invoice: StripeInvoice): ExternalInvoice {\n return {\n externalId: invoice.id,\n provider: 'stripe',\n syncedAt: new Date(),\n invoiceNumber: invoice.number || invoice.id,\n customerExternalId:\n typeof invoice.customer === 'string'\n ? invoice.customer\n : invoice.customer?.id || '',\n issueDate: unixToDate(invoice.created) || new Date(),\n dueDate:\n unixToDate(invoice.due_date) || unixToDate(invoice.created) || new Date(),\n subtotal: stripeMinorUnitsToMoney(invoice.subtotal || 0, invoice.currency),\n taxAmount: stripeMinorUnitsToMoney(\n stripeInvoiceTaxAmount(invoice),\n invoice.currency,\n ),\n totalAmount: stripeMinorUnitsToMoney(invoice.total || 0, invoice.currency),\n amountPaid: stripeMinorUnitsToMoney(\n invoice.amount_paid || 0,\n invoice.currency,\n ),\n balance: stripeMinorUnitsToMoney(\n invoice.amount_remaining || 0,\n invoice.currency,\n ),\n status: mapStripeInvoiceStatus(invoice.status, invoice.due_date),\n currency: invoice.currency || 'usd',\n paidOutOfBand: invoice.paid_out_of_band === true,\n raw: invoice,\n };\n}\n\nfunction mapStripePaymentIntent(\n paymentIntent: StripePaymentIntent,\n): ExternalPayment {\n return {\n externalId: paymentIntent.id,\n provider: 'stripe',\n syncedAt: new Date(),\n amount: stripeMinorUnitsToMoney(\n paymentIntent.amount || 0,\n paymentIntent.currency,\n ),\n currency: paymentIntent.currency || 'usd',\n paidAt: unixToDate(paymentIntent.created) || new Date(),\n method: paymentIntent.payment_method_types?.[0],\n transactionId: paymentIntent.latest_charge || paymentIntent.id,\n invoiceExternalIds: paymentIntent.invoice\n ? [paymentIntent.invoice]\n : undefined,\n status: mapStripePaymentStatus(paymentIntent.status),\n raw: paymentIntent,\n };\n}\n\nfunction mapStripeSubscription(\n subscription: StripeSubscription,\n): StripeSubscriptionStatusResult {\n return {\n externalId: subscription.id,\n status: subscription.status,\n customerExternalId:\n typeof subscription.customer === 'string'\n ? subscription.customer\n : subscription.customer.id,\n currentPeriodStart: unixToDate(subscription.current_period_start),\n currentPeriodEnd: unixToDate(subscription.current_period_end),\n cancelAtPeriodEnd: Boolean(subscription.cancel_at_period_end),\n canceledAt: unixToDate(subscription.canceled_at),\n trialEnd: unixToDate(subscription.trial_end),\n raw: subscription,\n };\n}\n\nfunction mapStripeInvoiceStatus(\n status?: string | null,\n dueDate?: number | null,\n): ExternalInvoice['status'] {\n switch (status) {\n case 'draft':\n return 'draft';\n case 'paid':\n return 'paid';\n case 'void':\n return 'voided';\n case 'uncollectible':\n return 'uncollectible';\n case 'open':\n if (dueDate && dueDate * 1000 < Date.now()) {\n return 'overdue';\n }\n return 'sent';\n default:\n return 'sent';\n }\n}\n\nfunction mapStripePaymentStatus(\n status?: string | null,\n): ExternalPayment['status'] {\n switch (status) {\n case 'succeeded':\n return 'completed';\n case 'processing':\n case 'requires_action':\n case 'requires_capture':\n case 'requires_confirmation':\n return 'pending';\n case 'canceled':\n case 'requires_payment_method':\n return 'failed';\n default:\n return 'pending';\n }\n}\n\nfunction mapStripeResourceType(\n object?: string,\n eventType?: string,\n): WebhookEvent['resourceType'] | undefined {\n if (object === 'customer' || eventType?.startsWith('customer.')) {\n return 'customer';\n }\n if (object === 'invoice' || eventType?.startsWith('invoice.')) {\n return 'invoice';\n }\n if (\n object === 'payment_intent' ||\n object === 'charge' ||\n eventType?.startsWith('payment_intent.') ||\n eventType?.startsWith('charge.')\n ) {\n return 'payment';\n }\n return undefined;\n}\n\nfunction normalizeMetadata(\n metadata: Record<string, unknown>,\n): Record<string, string> {\n const normalized: Record<string, string> = {};\n\n for (const [key, value] of Object.entries(metadata)) {\n if (value !== undefined && value !== null) {\n normalized[key] = String(value);\n }\n }\n\n return normalized;\n}\n\nfunction parseStripeSignatureHeader(signature: string): {\n timestamp?: string;\n signatures: string[];\n} {\n const parts = signature.split(',').map((part) => part.trim());\n const parsed: { timestamp?: string; signatures: string[] } = {\n signatures: [],\n };\n\n for (const part of parts) {\n const separatorIndex = part.indexOf('=');\n if (separatorIndex === -1) {\n continue;\n }\n\n const key = part.slice(0, separatorIndex);\n const value = part.slice(separatorIndex + 1);\n if (key === 't') {\n parsed.timestamp = value;\n }\n if (key === 'v1' && value) {\n parsed.signatures.push(value);\n }\n }\n\n return parsed;\n}\n\nfunction constantTimeEqualHex(left: string, right: string): boolean {\n try {\n const leftBuffer = Buffer.from(left, 'hex');\n const rightBuffer = Buffer.from(right, 'hex');\n return (\n leftBuffer.length === rightBuffer.length &&\n timingSafeEqual(leftBuffer, rightBuffer)\n );\n } catch {\n return false;\n }\n}\n\nfunction reconcileRecords<TLocal extends { externalId?: string }>(\n provider: AccountingProviderType,\n locals: TLocal[],\n externals: ExternalRecord[],\n compare: (local: TLocal, external: ExternalRecord) => FieldDiff[],\n): AuditReport<TLocal> {\n const externalById = new Map(\n externals.map((external) => [external.externalId, external]),\n );\n const matched: AuditMatch<TLocal>[] = [];\n const discrepancies: AuditReport<TLocal>['discrepancies'] = [];\n const localOnly: TLocal[] = [];\n const seenExternalIds = new Set<string>();\n\n for (const local of locals) {\n const external = local.externalId\n ? externalById.get(local.externalId)\n : undefined;\n\n if (!external) {\n localOnly.push(local);\n continue;\n }\n\n seenExternalIds.add(external.externalId);\n const differences = compare(local, external);\n if (differences.length === 0) {\n matched.push({ local, external, status: 'identical' });\n } else {\n discrepancies.push({ local, external, differences });\n }\n }\n\n const externalOnly = externals.filter(\n (external) => !seenExternalIds.has(external.externalId),\n );\n\n return {\n provider,\n auditedAt: new Date(),\n matched,\n localOnly,\n externalOnly,\n discrepancies,\n summary: {\n total: locals.length + externalOnly.length,\n matched: matched.length,\n localOnly: localOnly.length,\n externalOnly: externalOnly.length,\n discrepancies: discrepancies.length,\n },\n };\n}\n\nfunction compareCustomer(\n local: CustomerInput,\n external: ExternalRecord,\n): FieldDiff[] {\n const customer = external as ExternalCustomer;\n return [\n compareField('name', local.name, customer.name),\n compareField('email', local.email, customer.email),\n ].filter((diff): diff is FieldDiff => Boolean(diff));\n}\n\nfunction compareInvoice(\n local: InvoiceInput,\n external: ExternalRecord,\n): FieldDiff[] {\n const invoice = external as ExternalInvoice;\n return [\n compareField('totalAmount', local.totalAmount, invoice.totalAmount),\n compareField('currency', local.currency || 'usd', invoice.currency),\n ].filter((diff): diff is FieldDiff => Boolean(diff));\n}\n\nfunction comparePayment(\n local: PaymentInput,\n external: ExternalRecord,\n): FieldDiff[] {\n const payment = external as ExternalPayment;\n return [\n compareField('amount', local.amount, payment.amount),\n compareField('currency', local.currency || 'usd', payment.currency),\n ].filter((diff): diff is FieldDiff => Boolean(diff));\n}\n\nfunction compareField(\n field: string,\n localValue: unknown,\n externalValue: unknown,\n): FieldDiff | null {\n if (valuesEqual(localValue, externalValue)) {\n return null;\n }\n return { field, localValue, externalValue };\n}\n\nfunction valuesEqual(left: unknown, right: unknown): boolean {\n if (left === right) {\n return true;\n }\n if (typeof left === 'number' && typeof right === 'number') {\n return Math.abs(left - right) < 0.01;\n }\n return false;\n}\n\nfunction stripeInvoiceTaxAmount(invoice: StripeInvoice): number {\n if (typeof invoice.tax === 'number') {\n return invoice.tax;\n }\n return (invoice.total_taxes || []).reduce(\n (total, tax) => total + (tax.amount || 0),\n 0,\n );\n}\n\nconst STRIPE_ZERO_DECIMAL_CURRENCIES = new Set([\n 'BIF',\n 'CLP',\n 'DJF',\n 'GNF',\n 'JPY',\n 'KMF',\n 'KRW',\n 'MGA',\n 'PYG',\n 'RWF',\n 'VND',\n 'VUV',\n 'XAF',\n 'XOF',\n 'XPF',\n]);\nconst STRIPE_THREE_DECIMAL_CURRENCIES = new Set([\n 'BHD',\n 'IQD',\n 'JOD',\n 'KWD',\n 'LYD',\n 'OMR',\n 'TND',\n]);\n\nfunction stripeCurrencyMinorUnitFactor(currency?: string | null): number {\n const normalized = (currency || 'usd').toUpperCase();\n if (STRIPE_ZERO_DECIMAL_CURRENCIES.has(normalized)) {\n return 1;\n }\n if (STRIPE_THREE_DECIMAL_CURRENCIES.has(normalized)) {\n return 1_000;\n }\n return 100;\n}\n\nfunction moneyToStripeMinorUnits(amount: number, currency: string): number {\n return Math.round(amount * stripeCurrencyMinorUnitFactor(currency));\n}\n\nfunction stripeMinorUnitsToMoney(\n amount: number,\n currency?: string | null,\n): number {\n return amount / stripeCurrencyMinorUnitFactor(currency);\n}\n\nconst CHARGE_KEY_METADATA = 'hv_charge_key';\n\n/** A caller-supplied product tax code, trimmed; blank is refused. */\nfunction optionalTaxCode(taxCode: string | undefined): string | undefined {\n if (taxCode === undefined) {\n return undefined;\n }\n const code = typeof taxCode === 'string' ? taxCode.trim() : '';\n if (!code) {\n throw new Error('taxCode must be a non-empty string when set');\n }\n return code;\n}\n\nfunction assertIdempotencyKey(key: string): void {\n if (typeof key !== 'string' || key.trim() === '') {\n throw new Error('idempotencyKey must be a non-empty string');\n }\n}\n\n/** Escape a value for a single-quoted Stripe Search Query Language string. */\nfunction escapeSearchValue(value: string): string {\n return value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\");\n}\n\nfunction resolveCollectionMethod(\n invoice: InvoiceInput,\n): 'send_invoice' | 'charge_automatically' {\n const method = invoice.collectionMethod ?? 'send_invoice';\n if (method !== 'send_invoice' && method !== 'charge_automatically') {\n throw new Error(`Unsupported invoice collectionMethod '${method}'`);\n }\n return method;\n}\n\n/** The line's discount in Stripe units, validated against the line total. */\nfunction lineDiscountToStripe(\n lineItem: InvoiceInput['lineItems'][number],\n currency: string,\n): number | undefined {\n if (lineItem.discount === undefined || lineItem.discount === 0) {\n return undefined;\n }\n if (!Number.isFinite(lineItem.discount) || lineItem.discount < 0) {\n throw new Error(\n `Invoice line '${lineItem.description}' discount must be a non-negative amount`,\n );\n }\n const discount = moneyToStripeMinorUnits(lineItem.discount, currency);\n const lineTotal = Math.round(\n moneyToStripeMinorUnits(lineItem.unitPrice, currency) * lineItem.quantity,\n );\n if (discount > lineTotal) {\n throw new Error(\n `Invoice line '${lineItem.description}' discount exceeds the line total`,\n );\n }\n return discount > 0 ? discount : undefined;\n}\n\nfunction lineServicePeriod(\n lineItem: InvoiceInput['lineItems'][number],\n): { start: Date; end: Date } | undefined {\n const { periodStart, periodEnd } = lineItem;\n if (!periodStart && !periodEnd) {\n return undefined;\n }\n if (!(periodStart instanceof Date) || !(periodEnd instanceof Date)) {\n throw new Error(\n `Invoice line '${lineItem.description}' needs both periodStart and periodEnd`,\n );\n }\n if (\n Number.isNaN(periodStart.getTime()) ||\n Number.isNaN(periodEnd.getTime()) ||\n periodEnd.getTime() < periodStart.getTime()\n ) {\n throw new Error(\n `Invoice line '${lineItem.description}' has an invalid service period`,\n );\n }\n return { start: periodStart, end: periodEnd };\n}\n\nfunction mapChargeOutcome(\n paymentIntent: StripePaymentIntent,\n): Pick<\n SavedPaymentMethodChargeResult,\n | 'status'\n | 'paymentExternalId'\n | 'paymentMethodExternalId'\n | 'failureCode'\n | 'declineCode'\n | 'failureMessage'\n | 'raw'\n> {\n const error = paymentIntent.last_payment_error;\n const status = mapPaymentIntentChargeStatus(\n paymentIntent.status,\n error?.code,\n );\n return {\n status,\n paymentExternalId: paymentIntent.id,\n paymentMethodExternalId: idOf(paymentIntent.payment_method),\n failureCode: status === 'succeeded' ? undefined : error?.code || undefined,\n declineCode:\n status === 'succeeded' ? undefined : error?.decline_code || undefined,\n failureMessage:\n status === 'succeeded' ? undefined : error?.message || undefined,\n raw: withoutClientSecret(paymentIntent),\n };\n}\n\n/**\n * A PaymentIntent found by charge key after Stripe's idempotency window must\n * be the charge this call describes; a key reused for a different amount,\n * currency, or customer is refused instead of reporting the wrong charge.\n */\nfunction assertSameCharge(\n paymentIntent: StripePaymentIntent,\n customerExternalId: string,\n stripeAmount: number,\n currency: string,\n paymentMethodExternalId?: string,\n): void {\n const customer = idOf(paymentIntent.customer);\n const paymentMethod = idOf(paymentIntent.payment_method);\n if (\n paymentIntent.amount !== stripeAmount ||\n (paymentIntent.currency || '').toUpperCase() !== currency ||\n (customer !== undefined && customer !== customerExternalId) ||\n (paymentMethodExternalId !== undefined &&\n paymentMethod !== undefined &&\n paymentMethod !== paymentMethodExternalId)\n ) {\n throw new Error(\n `idempotencyKey was already used for a different charge (${paymentIntent.id}); use a new key for a new charge`,\n );\n }\n}\n\n/** Remove `client_secret` from a Stripe object and its expanded intents. */\nfunction withoutClientSecrets<T extends object>(value: T): T {\n const copy = withoutClientSecret(value) as Record<string, unknown>;\n for (const key of ['payment_intent', 'setup_intent']) {\n const nested = copy[key];\n if (isRecord(nested)) {\n copy[key] = withoutClientSecret(nested);\n }\n }\n return copy as T;\n}\n\n/**\n * Drop the intent client secret before handing objects to callers, including\n * `next_action`, whose redirect URL and SDK payload embed the same secret.\n */\nfunction withoutClientSecret<T extends object>(value: T): T {\n const {\n client_secret: _secret,\n next_action: _nextAction,\n ...rest\n } = value as T & { client_secret?: unknown; next_action?: unknown };\n return rest as T;\n}\n\nfunction mapPaymentIntentChargeStatus(\n status?: string | null,\n errorCode?: string | null,\n): PaymentChargeStatus {\n switch (status) {\n case 'succeeded':\n return 'succeeded';\n case 'processing':\n case 'requires_capture':\n return 'processing';\n case 'requires_action':\n case 'requires_confirmation':\n return 'requires_action';\n case 'canceled':\n return 'canceled';\n case 'requires_payment_method':\n return errorCode === 'authentication_required'\n ? 'requires_action'\n : 'failed';\n default:\n return 'processing';\n }\n}\n\nfunction mapWebhookPayment(\n paymentIntent: StripePaymentIntent,\n eventType?: string,\n): WebhookPaymentSummary {\n const error = paymentIntent.last_payment_error;\n let status = mapPaymentIntentChargeStatus(paymentIntent.status, error?.code);\n if (eventType === 'payment_intent.succeeded') status = 'succeeded';\n if (eventType === 'payment_intent.canceled') status = 'canceled';\n if (eventType === 'payment_intent.payment_failed') {\n status =\n error?.code === 'authentication_required' ? 'requires_action' : 'failed';\n }\n const currency = paymentIntent.currency\n ? paymentIntent.currency.toUpperCase()\n : undefined;\n const metadata = { ...(paymentIntent.metadata || {}) };\n return {\n status,\n paymentExternalId: paymentIntent.id,\n customerExternalId: idOf(paymentIntent.customer),\n amountMinor:\n currency && typeof paymentIntent.amount === 'number'\n ? stripeAmountToMinorUnitsOrUndefined(paymentIntent.amount, currency)\n : undefined,\n currency,\n chargeKey: metadata[CHARGE_KEY_METADATA],\n failureCode: status === 'succeeded' ? undefined : error?.code || undefined,\n declineCode:\n status === 'succeeded' ? undefined : error?.decline_code || undefined,\n failureMessage:\n status === 'succeeded' ? undefined : error?.message || undefined,\n metadata,\n };\n}\n\nfunction idOf(\n value: string | { id?: string | null } | null | undefined,\n): string | undefined {\n if (typeof value === 'string') {\n return value || undefined;\n }\n return value?.id || undefined;\n}\n\nfunction oneOf<const T extends string>(\n value: string | null | undefined,\n allowed: readonly T[],\n): T | undefined {\n return allowed.find((candidate) => candidate === value);\n}\n\nfunction stringOrUndefined(value: unknown): string | undefined {\n return typeof value === 'string' && value ? value : undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\nfunction normalizeCurrencyCode(currency: string): string {\n const code = String(currency ?? '')\n .trim()\n .toUpperCase();\n if (!/^[A-Z]{3}$/.test(code)) {\n throw new Error(`Currency '${currency}' must be a three-letter code`);\n }\n return code;\n}\n\n/** ISO 4217 minor-unit exponents other than 2. */\nconst ISO_ZERO_DECIMAL_CURRENCIES = new Set([\n 'BIF',\n 'CLP',\n 'DJF',\n 'GNF',\n 'ISK',\n 'JPY',\n 'KMF',\n 'KRW',\n 'PYG',\n 'RWF',\n 'UGX',\n 'UYI',\n 'VND',\n 'VUV',\n 'XAF',\n 'XOF',\n 'XPF',\n]);\nconst ISO_THREE_DECIMAL_CURRENCIES = new Set([\n 'BHD',\n 'IQD',\n 'JOD',\n 'KWD',\n 'LYD',\n 'OMR',\n 'TND',\n]);\nconst ISO_FOUR_DECIMAL_CURRENCIES = new Set(['CLF', 'UYW']);\n\n/**\n * ISO 4217 minor-unit exponent (2 for USD, 0 for JPY and ISK), from the\n * explicit tables above rather than the runtime's `Intl`/CLDR display digits,\n * which differ for some currencies (for example RSD, IQD, MGA) and change\n * between ICU releases.\n */\nfunction isoMinorUnitExponent(currency: string): number {\n if (ISO_ZERO_DECIMAL_CURRENCIES.has(currency)) return 0;\n if (ISO_THREE_DECIMAL_CURRENCIES.has(currency)) return 3;\n if (ISO_FOUR_DECIMAL_CURRENCIES.has(currency)) return 4;\n return 2;\n}\n\n/**\n * Integer ISO minor units → Stripe's smallest unit. They differ where Stripe\n * keeps a two-decimal representation for a zero-decimal currency (ISK, UGX).\n */\nfunction minorUnitsToStripeAmount(\n amountMinor: number,\n currency: string,\n): number {\n if (!Number.isSafeInteger(amountMinor)) {\n throw new Error(\n `Amount ${amountMinor} must be a safe integer number of minor units`,\n );\n }\n const iso = 10 ** isoMinorUnitExponent(currency);\n const stripe = stripeCurrencyMinorUnitFactor(currency);\n if (stripe >= iso) {\n return amountMinor * (stripe / iso);\n }\n const divisor = iso / stripe;\n if (amountMinor % divisor !== 0) {\n throw new Error(\n `Amount ${amountMinor} ${currency} minor units is not representable in Stripe's currency unit`,\n );\n }\n return amountMinor / divisor;\n}\n\nfunction stripeAmountToMinorUnitsOrUndefined(\n amount: number,\n currency: string,\n): number | undefined {\n if (!Number.isSafeInteger(amount)) {\n return undefined;\n }\n // Reads (webhooks, session totals) omit an amount that is not a whole\n // number of ISO minor units instead of failing a verified event.\n const iso = 10 ** isoMinorUnitExponent(currency);\n const stripe = stripeCurrencyMinorUnitFactor(currency);\n const minor = (amount * iso) / stripe;\n return Number.isSafeInteger(minor) ? minor : undefined;\n}\n\nfunction centsToMoney(cents: number): number {\n return cents / 100;\n}\n\nfunction toUnixSeconds(date: Date): number {\n return Math.floor(date.getTime() / 1000);\n}\n\nfunction unixToDate(value?: number | null): Date | undefined {\n return value === null || value === undefined\n ? undefined\n : new Date(value * 1000);\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n"],"mappings":";;;;;;;;;;;;;AA4MA,IAAa,iBAAb,MAAgE;CAC9D,OAAgB;CAEhB;CACA;CACA,4BAA6B,IAAI,IAAoB;CAErD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA,YAAY,SAAwB;EAClC,KAAK,UAAU;GACb,SAAS;GACT,YAAY;GACZ,YAAY;GACZ,kBAAkB;GAClB,GAAG;EACL;EACA,KAAK,YAAY,QAAQ,SAAS;EAElC,KAAK,YAAY,IAAI,yBAAyB,IAAI;EAClD,KAAK,WAAW,IAAI,wBAAwB,IAAI;EAChD,KAAK,UAAU,IAAI,4BAA4B;EAC/C,KAAK,QAAQ,IAAI,0BAA0B;EAC3C,KAAK,WAAW,IAAI,wBAAwB,IAAI;EAChD,KAAK,QAAQ,IAAI,sBAAsB,IAAI;EAC3C,KAAK,WAAW,IAAI,wBAAwB,KAAK,OAAO;EACxD,KAAK,UAAU,IAAI,4BAA4B,IAAI;CACrD;CAEA,MAAM,QACJ,QACA,UACA,QACA,UAAuC,CAAC,GAC5B;EACZ,MAAM,UAAU,KAAK,QAAQ,WAAW;EACxC,MAAM,aAAa,KAAK,QAAQ,cAAc;EAC9C,MAAM,iBACJ,WAAW,SACN,QAAQ,kBAAkB,OAAO,WAAW,MAC7C;EACN,IAAI,YAA0B;EAE9B,KAAK,IAAI,UAAU,GAAG,WAAW,YAAY,WAAW;GACtD,MAAM,aAAa,IAAI,gBAAgB;GACvC,MAAM,YAAY,iBAAiB,WAAW,MAAM,GAAG,OAAO;GAE9D,IAAI;IACF,MAAM,MAAM,KAAK,SAAS,UAAU,WAAW,QAAQ,SAAS,CAAC,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