@openlup/platform 0.22.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +440 -158
- package/README.md +141 -589
- package/dist/fulfillment/adapterConformance.js +1 -1
- package/dist/fulfillment/bindings.js +1 -1
- package/dist/fulfillment/contracts/conformance.d.ts +3 -1
- package/dist/fulfillment/contracts/dispatch.d.ts +45 -3
- package/dist/fulfillment/contracts/index.d.ts +3 -3
- package/dist/fulfillment/contracts/observation.d.ts +21 -1
- package/dist/fulfillment/contracts/readback.d.ts +21 -0
- package/dist/fulfillment/contracts/store.d.ts +3 -0
- package/dist/fulfillment/contracts/sync.d.ts +58 -2
- package/dist/fulfillment/dispatchProjection.d.ts +20 -1
- package/dist/fulfillment/dispatchProjection.js +97 -6
- package/dist/fulfillment/index.d.ts +3 -2
- package/dist/fulfillment/index.js +2 -2
- package/dist/fulfillment/migrations.d.ts +5 -0
- package/dist/fulfillment/migrations.js +1 -0
- package/dist/fulfillment/observationProjection.d.ts +24 -3
- package/dist/fulfillment/observationProjection.js +65 -12
- package/dist/fulfillment/omnipack/client.d.ts +3 -1
- package/dist/fulfillment/omnipack/client.js +31 -13
- package/dist/fulfillment/omnipack/index.d.ts +4 -1
- package/dist/fulfillment/omnipack/index.js +107 -45
- package/dist/fulfillment/omnipack/mappers.d.ts +7 -1
- package/dist/fulfillment/omnipack/mappers.js +24 -2
- package/dist/fulfillment/omnipack/observation.d.ts +11 -4
- package/dist/fulfillment/omnipack/observation.js +44 -29
- package/dist/fulfillment/omnipack/reconciliation.d.ts +15 -0
- package/dist/fulfillment/omnipack/reconciliation.js +55 -0
- package/dist/fulfillment/postgresDispatchStore.js +1 -1
- package/dist/fulfillment/postgresShipmentSpine.d.ts +8 -1
- package/dist/fulfillment/postgresShipmentSpine.js +17 -3
- package/dist/fulfillment/postgresStockSyncPort.js +6 -3
- package/dist/fulfillment/providerDispatchAcceptance.d.ts +1 -0
- package/dist/fulfillment/providerDispatchAcceptance.js +8 -2
- package/dist/fulfillment/providerDispatchWorker.d.ts +51 -0
- package/dist/fulfillment/providerDispatchWorker.js +65 -20
- package/dist/fulfillment/providerReconciliationWorker.d.ts +27 -19
- package/dist/fulfillment/providerReconciliationWorker.js +75 -19
- package/dist/fulfillment/providerStockSyncWorker.d.ts +5 -1
- package/dist/fulfillment/providerStockSyncWorker.js +229 -120
- package/dist/fulfillment/providerTrackingReferences.d.ts +3 -2
- package/dist/fulfillment/verifiedIngress.d.ts +38 -11
- package/dist/fulfillment/verifiedIngress.js +36 -8
- package/dist/invoicing/accountingCanonicalProviderLines.d.ts +5 -0
- package/dist/invoicing/accountingCanonicalProviderLines.js +104 -0
- package/dist/invoicing/accountingLineAllocation.d.ts +2 -0
- package/dist/invoicing/accountingLineAllocation.js +69 -0
- package/dist/invoicing/adapterConformance.d.ts +42 -0
- package/dist/invoicing/adapterConformance.js +296 -0
- package/dist/invoicing/artifacts.d.ts +7 -0
- package/dist/invoicing/artifacts.js +20 -0
- package/dist/invoicing/bindings.d.ts +46 -0
- package/dist/invoicing/bindings.js +69 -0
- package/dist/invoicing/capabilities.d.ts +11 -0
- package/dist/invoicing/capabilities.js +10 -0
- package/dist/invoicing/channelPolicy.d.ts +28 -0
- package/dist/invoicing/channelPolicy.js +27 -0
- package/dist/invoicing/continuity.d.ts +12 -0
- package/dist/invoicing/continuity.js +18 -0
- package/dist/invoicing/contracts/capabilities.d.ts +40 -0
- package/dist/invoicing/contracts/capabilities.js +1 -0
- package/dist/invoicing/contracts/companyLookup.d.ts +49 -0
- package/dist/invoicing/contracts/companyLookup.js +1 -0
- package/dist/invoicing/contracts/delivery.d.ts +74 -0
- package/dist/invoicing/contracts/delivery.js +1 -0
- package/dist/invoicing/contracts/facts.d.ts +110 -0
- package/dist/invoicing/contracts/facts.js +1 -0
- package/dist/invoicing/contracts/host.d.ts +245 -0
- package/dist/invoicing/contracts/host.js +1 -0
- package/dist/invoicing/contracts/index.d.ts +16 -0
- package/dist/invoicing/contracts/index.js +1 -0
- package/dist/invoicing/contracts/provider.d.ts +126 -0
- package/dist/invoicing/contracts/provider.js +1 -0
- package/dist/invoicing/contracts/settlement.d.ts +66 -0
- package/dist/invoicing/contracts/settlement.js +1 -0
- package/dist/invoicing/contracts/store.d.ts +277 -0
- package/dist/invoicing/contracts/store.js +1 -0
- package/dist/invoicing/contribution.d.ts +21 -0
- package/dist/invoicing/contribution.js +19 -0
- package/dist/invoicing/correction.d.ts +42 -0
- package/dist/invoicing/correction.js +44 -0
- package/dist/invoicing/delivery.d.ts +85 -0
- package/dist/invoicing/delivery.js +79 -0
- package/dist/invoicing/documentHistory.d.ts +50 -0
- package/dist/invoicing/documentHistory.js +213 -0
- package/dist/invoicing/documentSync.d.ts +24 -0
- package/dist/invoicing/documentSync.js +26 -0
- package/dist/invoicing/dutyCollector.d.ts +15 -0
- package/dist/invoicing/dutyCollector.js +35 -0
- package/dist/invoicing/fulfillmentTrigger.d.ts +56 -0
- package/dist/invoicing/fulfillmentTrigger.js +90 -0
- package/dist/invoicing/handoff.d.ts +37 -0
- package/dist/invoicing/handoff.js +62 -0
- package/dist/invoicing/index.d.ts +39 -0
- package/dist/invoicing/index.js +37 -0
- package/dist/invoicing/issue.d.ts +39 -0
- package/dist/invoicing/issue.js +55 -0
- package/dist/invoicing/migrations.d.ts +48 -0
- package/dist/invoicing/migrations.js +25 -0
- package/dist/invoicing/nativeUnsupported.d.ts +9 -0
- package/dist/invoicing/nativeUnsupported.js +22 -0
- package/dist/invoicing/paymentReadback.d.ts +20 -0
- package/dist/invoicing/paymentReadback.js +47 -0
- package/dist/invoicing/postgresInvoiceStore.d.ts +55 -0
- package/dist/invoicing/postgresInvoiceStore.js +344 -0
- package/dist/invoicing/readModel.d.ts +74 -0
- package/dist/invoicing/readModel.js +90 -0
- package/dist/invoicing/readback.d.ts +4 -0
- package/dist/invoicing/readback.js +30 -0
- package/dist/invoicing/reversal.d.ts +37 -0
- package/dist/invoicing/reversal.js +28 -0
- package/dist/invoicing/sellerRevision.d.ts +19 -0
- package/dist/invoicing/sellerRevision.js +14 -0
- package/dist/invoicing/settlementSync.d.ts +18 -0
- package/dist/invoicing/settlementSync.js +32 -0
- package/dist/invoicing/snapshot.d.ts +52 -0
- package/dist/invoicing/snapshot.js +141 -0
- package/dist/subscriptions/automaticRenewal.d.ts +44 -0
- package/dist/subscriptions/automaticRenewal.js +81 -0
- package/dist/subscriptions/automaticRenewalExecution.d.ts +21 -0
- package/dist/subscriptions/automaticRenewalExecution.js +44 -0
- package/dist/subscriptions/contracts/commands.d.ts +115 -0
- package/dist/subscriptions/contracts/commands.js +1 -0
- package/dist/subscriptions/contracts/dunning.d.ts +133 -0
- package/dist/subscriptions/contracts/dunning.js +1 -0
- package/dist/subscriptions/contracts/index.d.ts +6 -0
- package/dist/subscriptions/contracts/index.js +1 -0
- package/dist/subscriptions/contracts/messages.d.ts +43 -0
- package/dist/subscriptions/contracts/messages.js +1 -0
- package/dist/subscriptions/contracts/renewal.d.ts +533 -0
- package/dist/subscriptions/contracts/renewal.js +1 -0
- package/dist/subscriptions/contracts/stockWait.d.ts +73 -0
- package/dist/subscriptions/contracts/stockWait.js +1 -0
- package/dist/subscriptions/index.d.ts +39 -0
- package/dist/subscriptions/index.js +17 -0
- package/dist/subscriptions/paymentOutcomes.d.ts +8 -0
- package/dist/subscriptions/paymentOutcomes.js +27 -0
- package/dist/subscriptions/postgresRenewalStore.d.ts +20 -0
- package/dist/subscriptions/postgresRenewalStore.js +61 -0
- package/dist/subscriptions/postgresRetryStore.d.ts +78 -0
- package/dist/subscriptions/postgresRetryStore.js +142 -0
- package/dist/subscriptions/renewalCycleFailureMechanism.d.ts +34 -0
- package/dist/subscriptions/renewalCycleFailureMechanism.js +79 -0
- package/dist/subscriptions/renewalCycleMechanism.d.ts +46 -0
- package/dist/subscriptions/renewalCycleMechanism.js +157 -0
- package/dist/subscriptions/renewalCycleRefusalMechanism.d.ts +41 -0
- package/dist/subscriptions/renewalCycleRefusalMechanism.js +160 -0
- package/dist/subscriptions/renewalIdentity.d.ts +3 -0
- package/dist/subscriptions/renewalIdentity.js +4 -0
- package/package.json +23 -3
- package/release-gates.json +74 -7
- package/sql/20260809210000_accounting_document_rail.sql +889 -0
- package/sql/20260811150000_accounting_payout_rail.sql +333 -0
- package/sql/20260812130000_accounting_document_lifecycle_rail.sql +460 -0
- package/sql/20261022160000_subscription_retry_lifecycle.sql +328 -0
- package/sql/20261022165000_fulfillment_stock_evidence_replay_reopen.sql +30 -0
- package/sql/20261022190000_invoicing_durable_duties.sql +494 -0
- package/sql/20261022191000_invoicing_document_effects.sql +249 -0
- package/sql/20261022192000_invoicing_payment_decoupling.sql +144 -0
- package/sql/20261022195000_invoicing_seller_revision.sql +65 -0
- package/src/fulfillment/adapterConformance.ts +1 -1
- package/src/fulfillment/bindings.ts +1 -1
- package/src/fulfillment/contracts/conformance.ts +3 -1
- package/src/fulfillment/contracts/dispatch.ts +24 -5
- package/src/fulfillment/contracts/index.ts +3 -3
- package/src/fulfillment/contracts/observation.ts +11 -3
- package/src/fulfillment/contracts/readback.ts +13 -0
- package/src/fulfillment/contracts/store.ts +1 -0
- package/src/fulfillment/contracts/sync.ts +13 -2
- package/src/fulfillment/dispatchProjection.ts +94 -7
- package/src/fulfillment/index.ts +3 -2
- package/src/fulfillment/migrations.ts +1 -0
- package/src/fulfillment/observationProjection.ts +64 -13
- package/src/fulfillment/omnipack/client.ts +32 -13
- package/src/fulfillment/omnipack/index.ts +99 -39
- package/src/fulfillment/omnipack/mappers.ts +23 -2
- package/src/fulfillment/omnipack/observation.ts +45 -27
- package/src/fulfillment/omnipack/reconciliation.ts +56 -0
- package/src/fulfillment/postgresDispatchStore.ts +1 -1
- package/src/fulfillment/postgresShipmentSpine.ts +21 -4
- package/src/fulfillment/postgresStockSyncPort.ts +6 -3
- package/src/fulfillment/providerDispatchAcceptance.ts +9 -3
- package/src/fulfillment/providerDispatchWorker.ts +61 -20
- package/src/fulfillment/providerReconciliationWorker.ts +81 -25
- package/src/fulfillment/providerStockSyncWorker.ts +222 -126
- package/src/fulfillment/providerTrackingReferences.ts +3 -2
- package/src/fulfillment/verifiedIngress.ts +44 -11
- package/src/invoicing/accountingCanonicalProviderLines.ts +134 -0
- package/src/invoicing/accountingLineAllocation.ts +69 -0
- package/src/invoicing/adapterConformance.ts +249 -0
- package/src/invoicing/artifacts.ts +19 -0
- package/src/invoicing/bindings.ts +80 -0
- package/src/invoicing/capabilities.ts +9 -0
- package/src/invoicing/channelPolicy.ts +50 -0
- package/src/invoicing/continuity.ts +15 -0
- package/src/invoicing/contracts/capabilities.ts +15 -0
- package/src/invoicing/contracts/companyLookup.ts +13 -0
- package/src/invoicing/contracts/delivery.ts +24 -0
- package/src/invoicing/contracts/facts.ts +71 -0
- package/src/invoicing/contracts/host.ts +84 -0
- package/src/invoicing/contracts/index.ts +16 -0
- package/src/invoicing/contracts/provider.ts +78 -0
- package/src/invoicing/contracts/settlement.ts +39 -0
- package/src/invoicing/contracts/store.ts +102 -0
- package/src/invoicing/contribution.ts +28 -0
- package/src/invoicing/correction.ts +56 -0
- package/src/invoicing/delivery.ts +122 -0
- package/src/invoicing/documentHistory.ts +301 -0
- package/src/invoicing/documentSync.ts +51 -0
- package/src/invoicing/dutyCollector.ts +31 -0
- package/src/invoicing/fulfillmentTrigger.ts +144 -0
- package/src/invoicing/handoff.ts +71 -0
- package/src/invoicing/index.ts +39 -0
- package/src/invoicing/issue.ts +64 -0
- package/src/invoicing/migrations.ts +25 -0
- package/src/invoicing/nativeUnsupported.ts +24 -0
- package/src/invoicing/paymentReadback.ts +70 -0
- package/src/invoicing/postgresInvoiceStore.ts +334 -0
- package/src/invoicing/readModel.ts +80 -0
- package/src/invoicing/readback.ts +26 -0
- package/src/invoicing/reversal.ts +34 -0
- package/src/invoicing/sellerRevision.ts +20 -0
- package/src/invoicing/settlementSync.ts +37 -0
- package/src/invoicing/snapshot.ts +192 -0
- package/src/subscriptions/automaticRenewal.ts +87 -0
- package/src/subscriptions/automaticRenewalExecution.ts +39 -0
- package/src/subscriptions/contracts/commands.ts +46 -0
- package/src/subscriptions/contracts/dunning.ts +48 -0
- package/src/subscriptions/contracts/index.ts +6 -0
- package/src/subscriptions/contracts/messages.ts +18 -0
- package/src/subscriptions/contracts/renewal.ts +325 -0
- package/src/subscriptions/contracts/stockWait.ts +34 -0
- package/src/subscriptions/index.ts +24 -0
- package/src/subscriptions/paymentOutcomes.ts +23 -0
- package/src/subscriptions/postgresRenewalStore.ts +76 -0
- package/src/subscriptions/postgresRetryStore.ts +174 -0
- package/src/subscriptions/renewalCycleFailureMechanism.ts +119 -0
- package/src/subscriptions/renewalCycleMechanism.ts +225 -0
- package/src/subscriptions/renewalCycleRefusalMechanism.ts +215 -0
- package/src/subscriptions/renewalIdentity.ts +5 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { PaymentAttemptStatus, PaymentExecutionProviderDecline, ProviderAttemptIdentity } from "@openlup/core/payment";
|
|
2
|
+
import type { HostedRenewalDue, SubscriptionRenewalChargeResult, SubscriptionCycleSnapshotResult, SubscriptionCycleOrderResult, RenewalIntentResult, RenewalPreflightDeps, RenewalFailureDeps, RenewalOutcomeContext, RenewalReplayContext, FailurePropagationResult } from "./contracts/renewal.js";
|
|
3
|
+
import { type RenewalFailurePolicy } from "./renewalCycleFailureMechanism.js";
|
|
4
|
+
export interface RenewalPreflightPolicy<D extends HostedRenewalDue, CI, IR extends RenewalIntentResult> {
|
|
5
|
+
isOperatorOnly(reason: string): boolean;
|
|
6
|
+
logOperatorBlock(fields: {
|
|
7
|
+
subscriptionId: string;
|
|
8
|
+
providerKind: string;
|
|
9
|
+
reason: string;
|
|
10
|
+
}): void;
|
|
11
|
+
readTotal(snapshot: Record<string, unknown>): number | null;
|
|
12
|
+
cycleKey(due: D): string;
|
|
13
|
+
executionKey(cycleKey: string, retry: number, sequence: number): string;
|
|
14
|
+
intentInput(due: D, key: string, snapshots: SubscriptionCycleSnapshotResult, order: SubscriptionCycleOrderResult, total: number, reason: string): CI;
|
|
15
|
+
identity(due: D, key: string, intent: IR, order: SubscriptionCycleOrderResult, total: number): ProviderAttemptIdentity;
|
|
16
|
+
normalizedProvider(provider: string): string;
|
|
17
|
+
failed(due: D, cycleId: string | null, cycleNumber: number | null, orderId: string | null, intentId: string | null, reason: string, propagation?: FailurePropagationResult): SubscriptionRenewalChargeResult;
|
|
18
|
+
invalidTotalsReason: string;
|
|
19
|
+
defaultNow(): string;
|
|
20
|
+
failure: RenewalFailurePolicy;
|
|
21
|
+
}
|
|
22
|
+
export interface RenewalOutcomePolicy {
|
|
23
|
+
declineReason(decline: PaymentExecutionProviderDecline): string;
|
|
24
|
+
classifyDecline(decline: PaymentExecutionProviderDecline): {
|
|
25
|
+
failureClass: string;
|
|
26
|
+
decidedBy: string;
|
|
27
|
+
};
|
|
28
|
+
scaReason: string;
|
|
29
|
+
defaultNow(): string;
|
|
30
|
+
failure: RenewalFailurePolicy;
|
|
31
|
+
}
|
|
32
|
+
export interface RenewalReplayPolicy extends Pick<RenewalOutcomePolicy, "scaReason" | "defaultNow" | "failure"> {
|
|
33
|
+
unacknowledgedReason(status: PaymentAttemptStatus): string;
|
|
34
|
+
}
|
|
35
|
+
/** Alternate preflight owns its full order/intent/failure chain, without reservation or dispatch. */
|
|
36
|
+
export declare function recordRenewalPreflightBlock<D extends HostedRenewalDue, CI, IR extends RenewalIntentResult, M extends string | null | undefined>(deps: RenewalPreflightDeps<CI, IR, M>, due: D, reason: string, policy: RenewalPreflightPolicy<D, CI, IR>): Promise<SubscriptionRenewalChargeResult>;
|
|
37
|
+
export declare function declinedRenewalOutcome<D extends HostedRenewalDue>(deps: RenewalFailureDeps, due: D, context: RenewalOutcomeContext & {
|
|
38
|
+
decline: PaymentExecutionProviderDecline;
|
|
39
|
+
}, policy: RenewalOutcomePolicy): Promise<SubscriptionRenewalChargeResult>;
|
|
40
|
+
export declare function requiresActionRenewalOutcome<D extends HostedRenewalDue>(deps: RenewalFailureDeps, due: D, context: RenewalOutcomeContext, policy: RenewalOutcomePolicy): Promise<SubscriptionRenewalChargeResult>;
|
|
41
|
+
export declare function replayRenewalAttempt<D extends HostedRenewalDue>(deps: RenewalFailureDeps, due: D, ctx: RenewalReplayContext, status: PaymentAttemptStatus, policy: RenewalReplayPolicy): Promise<SubscriptionRenewalChargeResult>;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { propagateRenewalFailure } from "./renewalCycleFailureMechanism.js";
|
|
2
|
+
/** Alternate preflight owns its full order/intent/failure chain, without reservation or dispatch. */
|
|
3
|
+
export async function recordRenewalPreflightBlock(deps, due, reason, policy) {
|
|
4
|
+
if (policy.isOperatorOnly(reason)) {
|
|
5
|
+
policy.logOperatorBlock({ subscriptionId: due.subscriptionId, providerKind: due.providerKind, reason });
|
|
6
|
+
return policy.failed(due, null, null, null, null, reason);
|
|
7
|
+
}
|
|
8
|
+
const snapshots = await deps.persistence.buildCycleSnapshots({
|
|
9
|
+
subscriptionId: due.subscriptionId,
|
|
10
|
+
scheduledAt: due.nextCycleAt,
|
|
11
|
+
});
|
|
12
|
+
const totalGrossMinor = policy.readTotal(snapshots.orderSnapshot);
|
|
13
|
+
if (totalGrossMinor === null) {
|
|
14
|
+
return policy.failed(due, null, snapshots.cycleNumber, null, null, policy.invalidTotalsReason);
|
|
15
|
+
}
|
|
16
|
+
const cycleKey = policy.cycleKey(due);
|
|
17
|
+
const cycleOrder = await deps.persistence.createCycleOrder({
|
|
18
|
+
idempotencyKey: cycleKey,
|
|
19
|
+
subscriptionId: due.subscriptionId,
|
|
20
|
+
cycleNumber: snapshots.cycleNumber,
|
|
21
|
+
scheduledAt: due.nextCycleAt,
|
|
22
|
+
templateSnapshot: snapshots.templateSnapshot,
|
|
23
|
+
pricingSnapshot: snapshots.pricingSnapshot,
|
|
24
|
+
orderSnapshot: snapshots.orderSnapshot,
|
|
25
|
+
});
|
|
26
|
+
const intent = await deps.paymentPort.createIntent(policy.intentInput(due, cycleKey, snapshots, cycleOrder, totalGrossMinor, reason));
|
|
27
|
+
const executionKey = policy.executionKey(cycleKey, snapshots.retryAttempt, snapshots.providerAttemptSequence);
|
|
28
|
+
const attempt = policy.identity(due, executionKey, intent, cycleOrder, totalGrossMinor);
|
|
29
|
+
const propagation = await propagateRenewalFailure(deps.chargeFailurePropagation, {
|
|
30
|
+
kind: "preflight_block",
|
|
31
|
+
executionIdempotencyKey: executionKey,
|
|
32
|
+
providerIdempotencyKey: attempt.providerIdempotencyKey,
|
|
33
|
+
providerRequestFingerprint: attempt.providerRequestFingerprint,
|
|
34
|
+
paymentIntentId: intent.paymentIntentId,
|
|
35
|
+
cycleId: cycleOrder.cycleId,
|
|
36
|
+
subscriptionId: due.subscriptionId,
|
|
37
|
+
orderUuid: cycleOrder.orderUuid,
|
|
38
|
+
providerKind: policy.normalizedProvider(due.providerKind),
|
|
39
|
+
failureReason: reason,
|
|
40
|
+
occurredAt: (deps.now ?? policy.defaultNow)(),
|
|
41
|
+
}, policy.failure);
|
|
42
|
+
return policy.failed(due, cycleOrder.cycleId, snapshots.cycleNumber, cycleOrder.orderUuid, intent.paymentIntentId, reason, propagation);
|
|
43
|
+
}
|
|
44
|
+
export async function declinedRenewalOutcome(deps, due, context, policy) {
|
|
45
|
+
const propagation = await propagateRenewalFailure(deps.chargeFailurePropagation, {
|
|
46
|
+
kind: "provider_declined",
|
|
47
|
+
executionIdempotencyKey: context.executionIdempotencyKey,
|
|
48
|
+
providerIdempotencyKey: context.attemptIdentity.providerIdempotencyKey,
|
|
49
|
+
providerRequestFingerprint: context.attemptIdentity.providerRequestFingerprint,
|
|
50
|
+
paymentIntentId: context.intent.paymentIntentId,
|
|
51
|
+
cycleId: context.cycleOrder.cycleId,
|
|
52
|
+
subscriptionId: due.subscriptionId,
|
|
53
|
+
orderUuid: context.cycleOrder.orderUuid,
|
|
54
|
+
providerKind: due.providerKind,
|
|
55
|
+
failureReason: policy.declineReason(context.decline),
|
|
56
|
+
failureClassification: policy.classifyDecline(context.decline),
|
|
57
|
+
occurredAt: (deps.now ?? policy.defaultNow)(),
|
|
58
|
+
attemptAlreadyPrepared: true,
|
|
59
|
+
}, policy.failure);
|
|
60
|
+
return {
|
|
61
|
+
subscriptionId: due.subscriptionId,
|
|
62
|
+
outcome: "failed",
|
|
63
|
+
cycleId: context.cycleOrder.cycleId,
|
|
64
|
+
cycleNumber: context.snapshots.cycleNumber,
|
|
65
|
+
orderId: context.cycleOrder.orderUuid,
|
|
66
|
+
paymentIntentId: context.intent.paymentIntentId,
|
|
67
|
+
attemptStatus: "failed",
|
|
68
|
+
replayed: context.cycleOrder.replayed || context.intent.replayed,
|
|
69
|
+
dunningCaseId: propagation.dunningCaseId,
|
|
70
|
+
retryAttempt: propagation.retryAttempt,
|
|
71
|
+
applyReplayed: propagation.applyReplayed,
|
|
72
|
+
dunningPropagationFailed: propagation.dunningPropagationFailed,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export async function requiresActionRenewalOutcome(deps, due, context, policy) {
|
|
76
|
+
const propagation = await propagateRenewalFailure(deps.chargeFailurePropagation, {
|
|
77
|
+
kind: "off_session_requires_action",
|
|
78
|
+
executionIdempotencyKey: context.executionIdempotencyKey,
|
|
79
|
+
providerIdempotencyKey: context.attemptIdentity.providerIdempotencyKey,
|
|
80
|
+
providerRequestFingerprint: context.attemptIdentity.providerRequestFingerprint,
|
|
81
|
+
paymentIntentId: context.intent.paymentIntentId,
|
|
82
|
+
cycleId: context.cycleOrder.cycleId,
|
|
83
|
+
subscriptionId: due.subscriptionId,
|
|
84
|
+
orderUuid: context.cycleOrder.orderUuid,
|
|
85
|
+
providerKind: due.providerKind,
|
|
86
|
+
failureReason: policy.scaReason,
|
|
87
|
+
occurredAt: (deps.now ?? policy.defaultNow)(),
|
|
88
|
+
attemptAlreadyPrepared: true,
|
|
89
|
+
}, policy.failure);
|
|
90
|
+
return {
|
|
91
|
+
subscriptionId: due.subscriptionId,
|
|
92
|
+
outcome: "requires_action",
|
|
93
|
+
cycleId: context.cycleOrder.cycleId,
|
|
94
|
+
cycleNumber: context.snapshots.cycleNumber,
|
|
95
|
+
orderId: context.cycleOrder.orderUuid,
|
|
96
|
+
paymentIntentId: context.intent.paymentIntentId,
|
|
97
|
+
attemptStatus: context.finalizedAttempt.status,
|
|
98
|
+
replayed: context.cycleOrder.replayed || context.intent.replayed,
|
|
99
|
+
dunningCaseId: propagation.dunningCaseId,
|
|
100
|
+
retryAttempt: propagation.retryAttempt,
|
|
101
|
+
applyReplayed: propagation.applyReplayed,
|
|
102
|
+
dunningPropagationFailed: propagation.dunningPropagationFailed,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
export async function replayRenewalAttempt(deps, due, ctx, status, policy) {
|
|
106
|
+
if (status === "requires_action") {
|
|
107
|
+
const propagation = await propagateRenewalFailure(deps.chargeFailurePropagation, {
|
|
108
|
+
kind: "off_session_requires_action",
|
|
109
|
+
executionIdempotencyKey: ctx.executionIdempotencyKey,
|
|
110
|
+
providerIdempotencyKey: ctx.providerIdempotencyKey,
|
|
111
|
+
providerRequestFingerprint: ctx.providerRequestFingerprint,
|
|
112
|
+
paymentIntentId: ctx.paymentIntentId,
|
|
113
|
+
cycleId: ctx.cycleId,
|
|
114
|
+
subscriptionId: due.subscriptionId,
|
|
115
|
+
orderUuid: ctx.orderId,
|
|
116
|
+
providerKind: ctx.providerKind,
|
|
117
|
+
failureReason: policy.scaReason,
|
|
118
|
+
occurredAt: (deps.now ?? policy.defaultNow)(),
|
|
119
|
+
attemptAlreadyPrepared: true,
|
|
120
|
+
}, policy.failure);
|
|
121
|
+
return {
|
|
122
|
+
subscriptionId: due.subscriptionId,
|
|
123
|
+
outcome: "requires_action",
|
|
124
|
+
cycleId: ctx.cycleId,
|
|
125
|
+
cycleNumber: ctx.cycleNumber,
|
|
126
|
+
orderId: ctx.orderId,
|
|
127
|
+
paymentIntentId: ctx.paymentIntentId,
|
|
128
|
+
attemptStatus: status,
|
|
129
|
+
replayed: true,
|
|
130
|
+
dunningCaseId: propagation.dunningCaseId,
|
|
131
|
+
retryAttempt: propagation.retryAttempt,
|
|
132
|
+
applyReplayed: propagation.applyReplayed,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
if (status === "sent_to_provider" || status === "processing") {
|
|
136
|
+
return {
|
|
137
|
+
subscriptionId: due.subscriptionId,
|
|
138
|
+
outcome: "charged",
|
|
139
|
+
cycleId: ctx.cycleId,
|
|
140
|
+
cycleNumber: ctx.cycleNumber,
|
|
141
|
+
orderId: ctx.orderId,
|
|
142
|
+
paymentIntentId: ctx.paymentIntentId,
|
|
143
|
+
attemptStatus: status,
|
|
144
|
+
replayed: true,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
subscriptionId: due.subscriptionId,
|
|
149
|
+
outcome: "failed",
|
|
150
|
+
cycleId: ctx.cycleId,
|
|
151
|
+
cycleNumber: ctx.cycleNumber,
|
|
152
|
+
orderId: ctx.orderId,
|
|
153
|
+
paymentIntentId: ctx.paymentIntentId,
|
|
154
|
+
attemptStatus: status,
|
|
155
|
+
replayed: true,
|
|
156
|
+
dunningCaseId: null,
|
|
157
|
+
retryAttempt: null,
|
|
158
|
+
reason: policy.unacknowledgedReason(status),
|
|
159
|
+
};
|
|
160
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { RenewalIdentity, RenewalSchedule } from "./contracts/renewal.js";
|
|
2
|
+
/** The host's existing dialect owns every byte; no normalization or new prefix. */
|
|
3
|
+
export declare function renewalIdentity(schedule: RenewalSchedule, keys: (schedule: RenewalSchedule) => RenewalIdentity): RenewalIdentity;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openlup/platform",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Runnable server substrate: Node HTTP runtime, BFF dispatch, scheduler, storage, data gateways and bundle composition; development preview.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"api:update": "npm run build && node --experimental-strip-types ./scripts/api-contract.ts --update"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@openlup/core": "0.
|
|
34
|
+
"@openlup/core": "0.24.0",
|
|
35
35
|
"pg": "^8.22.0",
|
|
36
36
|
"@aws-sdk/client-s3": "^3.1144.0",
|
|
37
37
|
"@types/pg": "^8.20.0"
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"zod": "^4.
|
|
51
|
+
"zod": "^4.6.6"
|
|
52
52
|
},
|
|
53
53
|
"exports": {
|
|
54
54
|
"./http": {
|
|
@@ -210,6 +210,26 @@
|
|
|
210
210
|
"types": "./dist/fulfillment/omnipack/index.d.ts",
|
|
211
211
|
"import": "./dist/fulfillment/omnipack/index.js",
|
|
212
212
|
"default": "./dist/fulfillment/omnipack/index.js"
|
|
213
|
+
},
|
|
214
|
+
"./subscriptions": {
|
|
215
|
+
"types": "./dist/subscriptions/index.d.ts",
|
|
216
|
+
"import": "./dist/subscriptions/index.js",
|
|
217
|
+
"default": "./dist/subscriptions/index.js"
|
|
218
|
+
},
|
|
219
|
+
"./subscriptions/contracts": {
|
|
220
|
+
"types": "./dist/subscriptions/contracts/index.d.ts",
|
|
221
|
+
"import": "./dist/subscriptions/contracts/index.js",
|
|
222
|
+
"default": "./dist/subscriptions/contracts/index.js"
|
|
223
|
+
},
|
|
224
|
+
"./invoicing": {
|
|
225
|
+
"types": "./dist/invoicing/index.d.ts",
|
|
226
|
+
"import": "./dist/invoicing/index.js",
|
|
227
|
+
"default": "./dist/invoicing/index.js"
|
|
228
|
+
},
|
|
229
|
+
"./invoicing/contracts": {
|
|
230
|
+
"types": "./dist/invoicing/contracts/index.d.ts",
|
|
231
|
+
"import": "./dist/invoicing/contracts/index.js",
|
|
232
|
+
"default": "./dist/invoicing/contracts/index.js"
|
|
213
233
|
}
|
|
214
234
|
},
|
|
215
235
|
"repository": {
|
package/release-gates.json
CHANGED
|
@@ -455,23 +455,88 @@
|
|
|
455
455
|
],
|
|
456
456
|
"entrypoint": "dist/fulfillment/omnipack/index.d.ts",
|
|
457
457
|
"snapshot": "api/fulfillment-omnipack.api.md"
|
|
458
|
+
},
|
|
459
|
+
"./subscriptions": {
|
|
460
|
+
"role": "capability",
|
|
461
|
+
"maturity": "experimental",
|
|
462
|
+
"compatibilityPolicy": "internal-candidate",
|
|
463
|
+
"packageSmokeEvidence": [
|
|
464
|
+
"test/packageBoundary.test.ts",
|
|
465
|
+
"test/subscriptions/contracts.test.ts",
|
|
466
|
+
"test/subscriptions/portFit.test.ts",
|
|
467
|
+
"test/subscriptions/renewalKeys.test.ts",
|
|
468
|
+
"test/subscriptions/renewalCycleMechanism.test.ts"
|
|
469
|
+
],
|
|
470
|
+
"entrypoint": "dist/subscriptions/index.d.ts",
|
|
471
|
+
"snapshot": "api/subscriptions.api.md"
|
|
472
|
+
},
|
|
473
|
+
"./subscriptions/contracts": {
|
|
474
|
+
"role": "capability",
|
|
475
|
+
"maturity": "experimental",
|
|
476
|
+
"compatibilityPolicy": "internal-candidate",
|
|
477
|
+
"packageSmokeEvidence": [
|
|
478
|
+
"test/packageBoundary.test.ts",
|
|
479
|
+
"test/subscriptions/contracts.test.ts",
|
|
480
|
+
"test/subscriptions/portFit.test.ts",
|
|
481
|
+
"test/subscriptions/renewalKeys.test.ts"
|
|
482
|
+
],
|
|
483
|
+
"entrypoint": "dist/subscriptions/contracts/index.d.ts",
|
|
484
|
+
"snapshot": "api/subscriptions-contracts.api.md"
|
|
485
|
+
},
|
|
486
|
+
"./invoicing": {
|
|
487
|
+
"role": "capability",
|
|
488
|
+
"maturity": "experimental",
|
|
489
|
+
"compatibilityPolicy": "internal-candidate",
|
|
490
|
+
"packageSmokeEvidence": [
|
|
491
|
+
"test/packageBoundary.test.ts",
|
|
492
|
+
"test/invoicing/contracts.test.ts",
|
|
493
|
+
"test/invoicing/portFit.test.ts",
|
|
494
|
+
"test/invoicing/adapterConformance.test.ts",
|
|
495
|
+
"test/invoicing/issue.test.ts",
|
|
496
|
+
"test/invoicing/canonicalLines.test.ts",
|
|
497
|
+
"test/invoicing/paymentReadback.test.ts",
|
|
498
|
+
"test/invoicing/handoff.test.ts",
|
|
499
|
+
"test/invoicing/postgresStore.test.ts",
|
|
500
|
+
"test/invoicing/continuity.test.ts",
|
|
501
|
+
"test/invoicing/artifacts.test.ts",
|
|
502
|
+
"test/invoicing/delivery.test.ts",
|
|
503
|
+
"test/invoicing/readback.test.ts",
|
|
504
|
+
"test/invoicing/settlementSync.test.ts",
|
|
505
|
+
"test/invoicing/readModel.test.ts",
|
|
506
|
+
"test/invoicing/bindings.test.ts",
|
|
507
|
+
"test/invoicing/sellerRevision.test.ts"
|
|
508
|
+
],
|
|
509
|
+
"entrypoint": "dist/invoicing/index.d.ts",
|
|
510
|
+
"snapshot": "api/invoicing.api.md"
|
|
511
|
+
},
|
|
512
|
+
"./invoicing/contracts": {
|
|
513
|
+
"role": "capability",
|
|
514
|
+
"maturity": "experimental",
|
|
515
|
+
"compatibilityPolicy": "internal-candidate",
|
|
516
|
+
"packageSmokeEvidence": [
|
|
517
|
+
"test/packageBoundary.test.ts",
|
|
518
|
+
"test/invoicing/contracts.test.ts",
|
|
519
|
+
"test/invoicing/portFit.test.ts"
|
|
520
|
+
],
|
|
521
|
+
"entrypoint": "dist/invoicing/contracts/index.d.ts",
|
|
522
|
+
"snapshot": "api/invoicing-contracts.api.md"
|
|
458
523
|
}
|
|
459
524
|
},
|
|
460
525
|
"pack": {
|
|
461
526
|
"code": {
|
|
462
|
-
"maxPackedBytes":
|
|
527
|
+
"maxPackedBytes": 1228800,
|
|
463
528
|
"maxFiles": 2000
|
|
464
529
|
},
|
|
465
530
|
"docs": {
|
|
466
|
-
"maxPackedBytes":
|
|
531
|
+
"maxPackedBytes": 57344,
|
|
467
532
|
"maxFiles": 10
|
|
468
533
|
},
|
|
469
|
-
"maxPackedBytes":
|
|
470
|
-
"maxUnpackedBytes":
|
|
534
|
+
"maxPackedBytes": 1474560,
|
|
535
|
+
"maxUnpackedBytes": 6553600,
|
|
471
536
|
"maxFiles": 2100,
|
|
472
537
|
"baseline": {
|
|
473
|
-
"version": "0.
|
|
474
|
-
"packedBytes":
|
|
538
|
+
"version": "0.23.0",
|
|
539
|
+
"packedBytes": 1251425
|
|
475
540
|
},
|
|
476
541
|
"browserEntries": {
|
|
477
542
|
"./catalog/contracts": 4096,
|
|
@@ -482,7 +547,9 @@
|
|
|
482
547
|
"./promotions/contracts": 32,
|
|
483
548
|
"./shipping/contracts": 32,
|
|
484
549
|
"./payments/contracts": 32,
|
|
485
|
-
"./fulfillment/contracts": 32
|
|
550
|
+
"./fulfillment/contracts": 32,
|
|
551
|
+
"./subscriptions/contracts": 32,
|
|
552
|
+
"./invoicing/contracts": 32
|
|
486
553
|
}
|
|
487
554
|
}
|
|
488
555
|
}
|