@fantastic.dev/better-stripe 0.84.0 → 0.86.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 +12 -0
- package/README.md +1 -1
- package/dist/client/billing/renewalAggregate/configure.d.ts.map +1 -1
- package/dist/client/billing/renewalAggregate/configure.js +4 -56
- package/dist/client/billing/renewalAggregate/configure.js.map +1 -1
- package/dist/client/billing/renewalAggregate/configureMaterial.d.ts +29 -0
- package/dist/client/billing/renewalAggregate/configureMaterial.d.ts.map +1 -0
- package/dist/client/billing/renewalAggregate/configureMaterial.js +63 -0
- package/dist/client/billing/renewalAggregate/configureMaterial.js.map +1 -0
- package/dist/client/billing/renewalAggregate/phases.d.ts +2 -2
- package/dist/client/billing/renewalAggregate/phases.d.ts.map +1 -1
- package/dist/client/billing/renewalAggregate/phases.js.map +1 -1
- package/dist/client/billing/renewalAggregate/preflight.d.ts +1 -118
- package/dist/client/billing/renewalAggregate/preflight.d.ts.map +1 -1
- package/dist/client/billing/renewalAggregate/preflight.js +3 -118
- package/dist/client/billing/renewalAggregate/preflight.js.map +1 -1
- package/dist/client/billing/renewalAggregate/readMaterial.d.ts +335 -0
- package/dist/client/billing/renewalAggregate/readMaterial.d.ts.map +1 -0
- package/dist/client/billing/renewalAggregate/readMaterial.js +121 -0
- package/dist/client/billing/renewalAggregate/readMaterial.js.map +1 -0
- package/dist/client/billing/renewalV2/binding.d.ts +1 -1
- package/dist/client/billing/renewalV2/binding.d.ts.map +1 -1
- package/dist/client/billing/renewalV2/binding.js.map +1 -1
- package/dist/client/billing/renewalV2/configureInput.d.ts +45 -0
- package/dist/client/billing/renewalV2/configureInput.d.ts.map +1 -0
- package/dist/client/billing/renewalV2/configureInput.js +69 -0
- package/dist/client/billing/renewalV2/configureInput.js.map +1 -0
- package/dist/client/billing/renewalV2/index.d.ts +46 -0
- package/dist/client/billing/renewalV2/index.d.ts.map +1 -1
- package/dist/client/billing/renewalV2/index.js +134 -1
- package/dist/client/billing/renewalV2/index.js.map +1 -1
- package/dist/client/billing/renewalV2/receipt.d.ts +37 -0
- package/dist/client/billing/renewalV2/receipt.d.ts.map +1 -0
- package/dist/client/billing/renewalV2/receipt.js +131 -0
- package/dist/client/billing/renewalV2/receipt.js.map +1 -0
- package/dist/client/renewal.d.ts +2 -2
- package/dist/client/renewal.d.ts.map +1 -1
- package/dist/client/renewal.js +1 -1
- package/dist/client/renewal.js.map +1 -1
- package/dist/client/usage/observationClient.d.ts +2 -2
- package/dist/client/usage/observationClient.d.ts.map +1 -1
- package/dist/component/payoutRelease/queries.d.ts +2 -2
- package/dist/component/payoutRelease/queries.d.ts.map +1 -1
- package/dist/component/processingCostReconciliation/rollback.d.ts +1 -1
- package/docs/renewal-context-reads.md +73 -3
- package/docs/renewal-phase-assembly.md +78 -0
- package/package.json +1 -1
- package/src/client/billing/renewalAggregate/configure.ts +12 -79
- package/src/client/billing/renewalAggregate/configureMaterial.ts +122 -0
- package/src/client/billing/renewalAggregate/phases.ts +2 -2
- package/src/client/billing/renewalAggregate/preflight.ts +6 -161
- package/src/client/billing/renewalAggregate/readMaterial.ts +173 -0
- package/src/client/billing/renewalV2/binding.ts +7 -1
- package/src/client/billing/renewalV2/configure.test.ts +362 -0
- package/src/client/billing/renewalV2/configureInput.ts +84 -0
- package/src/client/billing/renewalV2/index.ts +228 -1
- package/src/client/billing/renewalV2/receipt.test.ts +289 -0
- package/src/client/billing/renewalV2/receipt.ts +163 -0
- package/src/client/renewal.ts +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -26,6 +26,18 @@
|
|
|
26
26
|
- Remove internal tracker references from public documentation and add a
|
|
27
27
|
regression check that prevents their reintroduction.
|
|
28
28
|
|
|
29
|
+
## [0.86.0](https://github.com/FantasticDevHQ/better-stripe/compare/v0.85.0...v0.86.0) (2026-10-29)
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
- project V2 renewal configuration requests ([#408](https://github.com/FantasticDevHQ/better-stripe/issues/408)) ([fd0dac1](https://github.com/FantasticDevHQ/better-stripe/commit/fd0dac1806b12b8409669792ae4e8a36fe7c887e))
|
|
34
|
+
|
|
35
|
+
## [0.85.0](https://github.com/FantasticDevHQ/better-stripe/compare/v0.84.0...v0.85.0) (2026-10-29)
|
|
36
|
+
|
|
37
|
+
### Features
|
|
38
|
+
|
|
39
|
+
- add V2 renewal attachment receipts ([#406](https://github.com/FantasticDevHQ/better-stripe/issues/406)) ([573aee1](https://github.com/FantasticDevHQ/better-stripe/commit/573aee18d5e4502a1a28a1e1fb0f33b105638773))
|
|
40
|
+
|
|
29
41
|
## [0.84.0](https://github.com/FantasticDevHQ/better-stripe/compare/v0.83.1...v0.84.0) (2026-10-28)
|
|
30
42
|
|
|
31
43
|
### Features
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ billing, and Connect marketplaces. It provides checkout, subscriptions, webhook
|
|
|
5
5
|
syncing, marketplace fees and splits, payouts, refunds, and disputes, with React
|
|
6
6
|
hooks and headless UI components.
|
|
7
7
|
|
|
8
|
-
**Version**: `0.
|
|
8
|
+
**Version**: `0.86.0` <!-- x-release-please-version --> (pre-1.0). API may change between minor versions until 1.0.
|
|
9
9
|
|
|
10
10
|
Connect platforms use the default GA API version. Non-Connect merchants using
|
|
11
11
|
customer-only Accounts v2 need preview access and an explicit preview version.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalAggregate/configure.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalAggregate/configure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAQjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAKL,KAAK,OAAO,EACb,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,6BAA6B,GAAG;IAC1C,OAAO,EAAE,CAAC,CAAC;IACX,KAAK,EAAE,WAAW,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE;QACP,YAAY,EAAE,SAAS,CAAC;QACxB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,MAAM,EAAE;YACN,MAAM,CAAC,gCAAgC,CAAC,KAAK;YAC7C,MAAM,CAAC,gCAAgC,CAAC,KAAK;SAC9C,CAAC;KACH,CAAC;IACF,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,eAAe,EAAE,MAAM,CAAC;IACxB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,MAAM,EAAE,6BAA6B,CAAC;IACtC,qBAAqB,EAAE,UAAU,CAAC;IAClC,OAAO,EAAE,cAAc,CAAC;IACxB,eAAe,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACnD,CAAC;AAEF,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,OAAO,GACb,6BAA6B,GAAG,OAAO,CAiDzC"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { idempotencyOptions } from "../../core/idempotency.js";
|
|
3
1
|
import { renewalSnapshot } from "../renewalReplacementSnapshot.js";
|
|
4
2
|
import { retainedPreparation, validateReads } from "./preflight.js";
|
|
5
3
|
import { validateAttachReceipt } from "./receipt.js";
|
|
6
|
-
import {
|
|
7
|
-
import { binding,
|
|
4
|
+
import { configureMaterial, validateConfigureStart, } from "./configureMaterial.js";
|
|
5
|
+
import { binding, configureInput, failure, object, } from "./shared.js";
|
|
8
6
|
export function projectRenewalConfiguration(input) {
|
|
9
7
|
let ownedScheduleId;
|
|
10
8
|
try {
|
|
@@ -12,59 +10,9 @@ export function projectRenewalConfiguration(input) {
|
|
|
12
10
|
const prepared = retainedPreparation(args.prepared);
|
|
13
11
|
const receipt = validateAttachReceipt(args.attachReceipt, prepared, args.apiVersion, args.observedAt);
|
|
14
12
|
ownedScheduleId = receipt.scheduleId;
|
|
15
|
-
const key =
|
|
16
|
-
if (!key || key === receipt.request.requestIdentity.key)
|
|
17
|
-
unsupported("configure_key_must_be_distinct");
|
|
18
|
-
if (args.firstDispatchedAt > args.observedAt ||
|
|
19
|
-
args.firstDispatchedAt < receipt.request.firstDispatchedAt)
|
|
20
|
-
unsupported("invalid_retained_dispatch_time");
|
|
21
|
-
const rawSubscription = object(args.freshSubscription);
|
|
22
|
-
if (rawSubscription.schedule == null ||
|
|
23
|
-
referenceId(rawSubscription.schedule, "sub_sched", "subscription_schedule") !== receipt.scheduleId)
|
|
24
|
-
conflict("schedule_association_mismatch");
|
|
13
|
+
const key = validateConfigureStart(args, receipt);
|
|
25
14
|
const reads = validateReads(args, receipt.scheduleId);
|
|
26
|
-
const schedule = object(args.schedule);
|
|
27
|
-
if (!equal(schedule, receipt.providerSnapshot))
|
|
28
|
-
conflict("acknowledged_baseline_or_defaults_drift");
|
|
29
|
-
const expected = prepared.expected;
|
|
30
|
-
const referenceContext = {
|
|
31
|
-
livemode: expected.livemode,
|
|
32
|
-
customerAccountId: expected.customerAccountId,
|
|
33
|
-
};
|
|
34
|
-
if (schedule.id !== receipt.scheduleId ||
|
|
35
|
-
schedule.object !== "subscription_schedule" ||
|
|
36
|
-
schedule.customer_account !== expected.customerAccountId ||
|
|
37
|
-
schedule.livemode !== expected.livemode ||
|
|
38
|
-
referenceId(schedule.customer, "cus", "customer", referenceContext) !==
|
|
39
|
-
reads.customer.id ||
|
|
40
|
-
referenceId(schedule.subscription, "sub", "subscription", referenceContext) !== expected.subscriptionId)
|
|
41
|
-
conflict("acknowledged_schedule_identity_mismatch");
|
|
42
|
-
if (schedule.status !== "active" ||
|
|
43
|
-
schedule.end_behavior !== "release" ||
|
|
44
|
-
schedule.application !== null ||
|
|
45
|
-
schedule.canceled_at !== null ||
|
|
46
|
-
schedule.completed_at !== null ||
|
|
47
|
-
schedule.released_at !== null ||
|
|
48
|
-
schedule.released_subscription !== null ||
|
|
49
|
-
(schedule.pause_schedules !== undefined &&
|
|
50
|
-
(!Array.isArray(schedule.pause_schedules) ||
|
|
51
|
-
schedule.pause_schedules.length)))
|
|
52
|
-
unsupported("unsupported_acknowledged_schedule_state");
|
|
53
|
-
if (!equal(schedule.billing_mode, reads.subscription.billing_mode))
|
|
54
|
-
unsupported("schedule_billing_mode_mismatch");
|
|
55
|
-
const current = z
|
|
56
|
-
.object({ start_date: z.number(), end_date: z.number() })
|
|
57
|
-
.strict()
|
|
58
|
-
.parse(schedule.current_phase);
|
|
59
|
-
if (current.start_date !== expected.periodStart ||
|
|
60
|
-
current.end_date !== expected.periodEnd)
|
|
61
|
-
conflict("current_phase_period_drift");
|
|
62
|
-
const phases = assemblePhases(reads, schedule);
|
|
63
|
-
const payload = {
|
|
64
|
-
end_behavior: "release",
|
|
65
|
-
proration_behavior: "none",
|
|
66
|
-
phases,
|
|
67
|
-
};
|
|
15
|
+
const { schedule, payload } = configureMaterial(object(args.schedule), prepared, receipt, reads);
|
|
68
16
|
const request = {
|
|
69
17
|
version: 1,
|
|
70
18
|
stage: "configure",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configure.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalAggregate/configure.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"configure.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalAggregate/configure.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,gBAAgB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iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,oBAAoB,EAAE,OAAO,CAAC,OAAO;YACrC,eAAe,EAAE,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC,gBAAgB,CAAC;YACtE,sBAAsB,EAAE,OAAO,CAC7B,kBAAkB,EAClB,QAAQ,CAAC,gBAAgB,CAC1B;SACF,CAAC;QACF,OAAO,eAAe,CAAC;YACrB,GAAG,OAAO;YACV,MAAM,EAAE,6BAAsC;YAC9C,qBAAqB,EAAE,UAAmB;YAC1C,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,eAAe,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,mBAAmB,EAAE,OAAO,CAAC,EAAE;SACzE,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,OAAO,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;IACzC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type Stripe from "stripe";
|
|
3
|
+
import type { RenewalPreparationMaterial, RenewalReadMaterial } from "./readMaterial.js";
|
|
4
|
+
import { configureInput, type ObjectData } from "./shared.js";
|
|
5
|
+
type Args = Pick<z.infer<typeof configureInput>, "configureKey" | "firstDispatchedAt" | "observedAt" | "freshSubscription" | "schedule">;
|
|
6
|
+
type Receipt = {
|
|
7
|
+
scheduleId: string;
|
|
8
|
+
providerSnapshot: unknown;
|
|
9
|
+
request: {
|
|
10
|
+
firstDispatchedAt: number;
|
|
11
|
+
requestIdentity: {
|
|
12
|
+
key: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare function validateConfigureStart(args: Args, receipt: Receipt): string;
|
|
17
|
+
export declare function configureMaterial(schedule: ObjectData, prepared: RenewalPreparationMaterial, receipt: Receipt, reads: RenewalReadMaterial): {
|
|
18
|
+
schedule: ObjectData;
|
|
19
|
+
payload: {
|
|
20
|
+
end_behavior: "release";
|
|
21
|
+
proration_behavior: "none";
|
|
22
|
+
phases: [
|
|
23
|
+
Stripe.SubscriptionScheduleUpdateParams.Phase,
|
|
24
|
+
Stripe.SubscriptionScheduleUpdateParams.Phase
|
|
25
|
+
];
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=configureMaterial.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configureMaterial.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalAggregate/configureMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAGjC,OAAO,KAAK,EACV,0BAA0B,EAC1B,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,cAAc,EAKd,KAAK,UAAU,EAChB,MAAM,aAAa,CAAC;AACrB,KAAK,IAAI,GAAG,IAAI,CACd,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,EAC5B,cAAc,GACd,mBAAmB,GACnB,YAAY,GACZ,mBAAmB,GACnB,UAAU,CACb,CAAC;AACF,KAAK,OAAO,GAAG;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,OAAO,EAAE;QAAE,iBAAiB,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;CAC1E,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,UAoBlE;AACD,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,UAAU,EACpB,QAAQ,EAAE,0BAA0B,EACpC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,mBAAmB,GACzB;IACD,QAAQ,EAAE,UAAU,CAAC;IACrB,OAAO,EAAE;QACP,YAAY,EAAE,SAAS,CAAC;QACxB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,MAAM,EAAE;YACN,MAAM,CAAC,gCAAgC,CAAC,KAAK;YAC7C,MAAM,CAAC,gCAAgC,CAAC,KAAK;SAC9C,CAAC;KACH,CAAC;CACH,CAsDA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { idempotencyOptions } from "../../core/idempotency.js";
|
|
3
|
+
import { assemblePhases } from "./phases.js";
|
|
4
|
+
import { object, equal, conflict, unsupported, referenceId, } from "./shared.js";
|
|
5
|
+
// Internal only: all callers validate their own receipt before entering these predicates.
|
|
6
|
+
export function validateConfigureStart(args, receipt) {
|
|
7
|
+
const key = idempotencyOptions(args.configureKey)?.idempotencyKey;
|
|
8
|
+
if (!key || key === receipt.request.requestIdentity.key)
|
|
9
|
+
unsupported("configure_key_must_be_distinct");
|
|
10
|
+
if (args.firstDispatchedAt > args.observedAt ||
|
|
11
|
+
args.firstDispatchedAt < receipt.request.firstDispatchedAt)
|
|
12
|
+
unsupported("invalid_retained_dispatch_time");
|
|
13
|
+
const rawSubscription = object(args.freshSubscription);
|
|
14
|
+
if (rawSubscription.schedule == null ||
|
|
15
|
+
referenceId(rawSubscription.schedule, "sub_sched", "subscription_schedule") !== receipt.scheduleId)
|
|
16
|
+
conflict("schedule_association_mismatch");
|
|
17
|
+
return key;
|
|
18
|
+
}
|
|
19
|
+
export function configureMaterial(schedule, prepared, receipt, reads) {
|
|
20
|
+
if (!equal(schedule, receipt.providerSnapshot))
|
|
21
|
+
conflict("acknowledged_baseline_or_defaults_drift");
|
|
22
|
+
const expected = prepared.expected;
|
|
23
|
+
const referenceContext = {
|
|
24
|
+
livemode: expected.livemode,
|
|
25
|
+
customerAccountId: expected.customerAccountId,
|
|
26
|
+
};
|
|
27
|
+
if (schedule.id !== receipt.scheduleId ||
|
|
28
|
+
schedule.object !== "subscription_schedule" ||
|
|
29
|
+
schedule.customer_account !== expected.customerAccountId ||
|
|
30
|
+
schedule.livemode !== expected.livemode ||
|
|
31
|
+
referenceId(schedule.customer, "cus", "customer", referenceContext) !==
|
|
32
|
+
reads.customer.id ||
|
|
33
|
+
referenceId(schedule.subscription, "sub", "subscription", referenceContext) !== expected.subscriptionId)
|
|
34
|
+
conflict("acknowledged_schedule_identity_mismatch");
|
|
35
|
+
if (schedule.status !== "active" ||
|
|
36
|
+
schedule.end_behavior !== "release" ||
|
|
37
|
+
schedule.application !== null ||
|
|
38
|
+
schedule.canceled_at !== null ||
|
|
39
|
+
schedule.completed_at !== null ||
|
|
40
|
+
schedule.released_at !== null ||
|
|
41
|
+
schedule.released_subscription !== null ||
|
|
42
|
+
(schedule.pause_schedules !== undefined &&
|
|
43
|
+
(!Array.isArray(schedule.pause_schedules) ||
|
|
44
|
+
schedule.pause_schedules.length)))
|
|
45
|
+
unsupported("unsupported_acknowledged_schedule_state");
|
|
46
|
+
if (!equal(schedule.billing_mode, reads.subscription.billing_mode))
|
|
47
|
+
unsupported("schedule_billing_mode_mismatch");
|
|
48
|
+
const current = z
|
|
49
|
+
.object({ start_date: z.number(), end_date: z.number() })
|
|
50
|
+
.strict()
|
|
51
|
+
.parse(schedule.current_phase);
|
|
52
|
+
if (current.start_date !== expected.periodStart ||
|
|
53
|
+
current.end_date !== expected.periodEnd)
|
|
54
|
+
conflict("current_phase_period_drift");
|
|
55
|
+
const phases = assemblePhases(reads, schedule);
|
|
56
|
+
const payload = {
|
|
57
|
+
end_behavior: "release",
|
|
58
|
+
proration_behavior: "none",
|
|
59
|
+
phases,
|
|
60
|
+
};
|
|
61
|
+
return { schedule, payload };
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=configureMaterial.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configureMaterial.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalAggregate/configureMaterial.ts"],"names":[],"mappings":"AAAA,O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AAM,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;SACxD,MAAM,EAAE;SACR,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IACjC,IACE,OAAO,CAAC,UAAU,KAAK,QAAQ,CAAC,WAAW;QAC3C,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,SAAS;QAEvC,QAAQ,CAAC,4BAA4B,CAAC,CAAC;IACzC,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC/C,MAAM,OAAO,GAAG;QACd,YAAY,EAAE,SAAkB;QAChC,kBAAkB,EAAE,MAAe;QACnC,MAAM;KACP,CAAC;IACF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type Stripe from "stripe";
|
|
2
|
-
import type {
|
|
3
|
-
export declare function assemblePhases(reads:
|
|
2
|
+
import type { RenewalReadMaterial } from "./readMaterial.js";
|
|
3
|
+
export declare function assemblePhases(reads: RenewalReadMaterial, schedule: Record<string, unknown>): [
|
|
4
4
|
Stripe.SubscriptionScheduleUpdateParams.Phase,
|
|
5
5
|
Stripe.SubscriptionScheduleUpdateParams.Phase
|
|
6
6
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phases.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalAggregate/phases.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAejC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"phases.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalAggregate/phases.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAejC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAuE7D,wBAAgB,cAAc,CAC5B,KAAK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AE,aAAa,CAAC,SAAS;QAClC,GAAG,CAAC,oBAAoB,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,oBAAoB,EAAE,CAAC;KACnE,CAAC;IACF,MAAM,SAAS,GAAG,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC;IAC9C,MAAM,MAAM,GAAkD;QAC5D,GAAG,QAAQ,CAAC,QAAQ;QACpB,UAAU,EAAE,QAAQ;QACpB,QAAQ;QACR,kBAAkB,EAAE,MAAM;QAC1B,oBAAoB,EAClB,KAAK,CAAC,OAAO,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa;QAChE,QAAQ,EAAE;YACR,QAAQ,EAAE,SAAS,CAAC,QAAQ;YAC5B,cAAc,EAAE,SAAS,CAAC,cAAc;SACzC;QACD,KAAK,EAAE;YACL;gBACE,GAAG,YAAY,CAAC,QAAQ;gBACxB,KAAK,EAAE,QAAQ,CAAC,aAAa;gBAC7B,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,QAAQ;gBACjC,SAAS,EAAE,YAAY,CAAC,SAAS;aAClC;SACF;QACD,SAAS,EAAE,aAAa,CAAC,SAAS;KACnC,CAAC;IACF,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -119,124 +119,7 @@ export declare function retainedPreparation(value: unknown): {
|
|
|
119
119
|
};
|
|
120
120
|
};
|
|
121
121
|
export declare function validateReads(args: z.infer<typeof readInput>, scheduleId?: string): {
|
|
122
|
-
prepared:
|
|
123
|
-
version: 1;
|
|
124
|
-
scope: "platform";
|
|
125
|
-
expected: {
|
|
126
|
-
customerAccountId: string;
|
|
127
|
-
subscriptionId: string;
|
|
128
|
-
itemId: string;
|
|
129
|
-
currentPriceId: string;
|
|
130
|
-
currentProductId: string;
|
|
131
|
-
targetPriceId: string;
|
|
132
|
-
targetProductId: string;
|
|
133
|
-
periodStart: number;
|
|
134
|
-
periodEnd: number;
|
|
135
|
-
livemode: boolean;
|
|
136
|
-
};
|
|
137
|
-
quantity: number;
|
|
138
|
-
providerSnapshot: {
|
|
139
|
-
subscription: {
|
|
140
|
-
[x: string]: unknown;
|
|
141
|
-
id: string;
|
|
142
|
-
object: "subscription";
|
|
143
|
-
customer_account: string;
|
|
144
|
-
status: "active";
|
|
145
|
-
currency: string;
|
|
146
|
-
livemode: boolean;
|
|
147
|
-
schedule: null;
|
|
148
|
-
cancel_at: null;
|
|
149
|
-
cancel_at_period_end: false;
|
|
150
|
-
pause_collection: null;
|
|
151
|
-
pending_update: null;
|
|
152
|
-
default_source: null;
|
|
153
|
-
application_fee_percent: null;
|
|
154
|
-
payment_settings: {
|
|
155
|
-
payment_method_options: null;
|
|
156
|
-
payment_method_types: null;
|
|
157
|
-
save_default_payment_method: "off" | null;
|
|
158
|
-
} | null;
|
|
159
|
-
billing_schedules?: unknown[] | undefined;
|
|
160
|
-
items: {
|
|
161
|
-
[x: string]: unknown;
|
|
162
|
-
has_more: false;
|
|
163
|
-
data: [{
|
|
164
|
-
[x: string]: unknown;
|
|
165
|
-
id: string;
|
|
166
|
-
object: "subscription_item";
|
|
167
|
-
subscription: string;
|
|
168
|
-
current_period_start: number;
|
|
169
|
-
current_period_end: number;
|
|
170
|
-
quantity: number;
|
|
171
|
-
price: {
|
|
172
|
-
[x: string]: unknown;
|
|
173
|
-
id: string;
|
|
174
|
-
object: "price";
|
|
175
|
-
product: string | {
|
|
176
|
-
[x: string]: unknown;
|
|
177
|
-
id: string;
|
|
178
|
-
object: "product";
|
|
179
|
-
deleted?: false | undefined;
|
|
180
|
-
};
|
|
181
|
-
active: boolean;
|
|
182
|
-
livemode: boolean;
|
|
183
|
-
type: "recurring";
|
|
184
|
-
currency: string;
|
|
185
|
-
billing_scheme: "per_unit";
|
|
186
|
-
recurring: {
|
|
187
|
-
[x: string]: unknown;
|
|
188
|
-
interval: "day" | "month" | "week" | "year";
|
|
189
|
-
interval_count: number;
|
|
190
|
-
usage_type: "licensed";
|
|
191
|
-
};
|
|
192
|
-
};
|
|
193
|
-
}];
|
|
194
|
-
};
|
|
195
|
-
};
|
|
196
|
-
targetPrice: {
|
|
197
|
-
[x: string]: unknown;
|
|
198
|
-
id: string;
|
|
199
|
-
object: "price";
|
|
200
|
-
product: string | {
|
|
201
|
-
[x: string]: unknown;
|
|
202
|
-
id: string;
|
|
203
|
-
object: "product";
|
|
204
|
-
deleted?: false | undefined;
|
|
205
|
-
};
|
|
206
|
-
active: boolean;
|
|
207
|
-
livemode: boolean;
|
|
208
|
-
type: "recurring";
|
|
209
|
-
currency: string;
|
|
210
|
-
billing_scheme: "per_unit";
|
|
211
|
-
recurring: {
|
|
212
|
-
[x: string]: unknown;
|
|
213
|
-
interval: "day" | "month" | "week" | "year";
|
|
214
|
-
interval_count: number;
|
|
215
|
-
usage_type: "licensed";
|
|
216
|
-
};
|
|
217
|
-
};
|
|
218
|
-
billingCustomer?: {
|
|
219
|
-
[x: string]: unknown;
|
|
220
|
-
id: string;
|
|
221
|
-
object: "customer";
|
|
222
|
-
customer_account: string;
|
|
223
|
-
livemode: boolean;
|
|
224
|
-
deleted?: false | undefined;
|
|
225
|
-
discount: {
|
|
226
|
-
[x: string]: unknown;
|
|
227
|
-
id: string;
|
|
228
|
-
object: "discount";
|
|
229
|
-
deleted?: false | undefined;
|
|
230
|
-
} | null;
|
|
231
|
-
} | undefined;
|
|
232
|
-
};
|
|
233
|
-
status: "prepared";
|
|
234
|
-
preservation: "requires_schedule_validation";
|
|
235
|
-
requestIdentity: {
|
|
236
|
-
key: string;
|
|
237
|
-
binding: string;
|
|
238
|
-
};
|
|
239
|
-
};
|
|
122
|
+
prepared: import("./readMaterial.js").RenewalPreparationMaterial;
|
|
240
123
|
subscription: {
|
|
241
124
|
[x: string]: unknown;
|
|
242
125
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalAggregate/preflight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalAggregate/preflight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAU,SAAS,EAA4B,MAAM,aAAa,CAAC;AAE1E,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqBjD;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,EAC/B,UAAU,CAAC,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOpB;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO;;;;;;;;aAK3C,CAAC;YACF,4BAA4B;WAC7B,UAAU;;;;;;;;;;;;;;;2BAIM,UAAU;EAKtC"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { prepareRenewalPriceReplacement } from "../renewalPriceReplacement.js";
|
|
3
|
-
import { renewalSubscription, renewalPrice, renewalBillingCustomer, } from "../renewalReplacementSchema.js";
|
|
4
3
|
import { renewalSnapshot } from "../renewalReplacementSnapshot.js";
|
|
5
|
-
import { object, readInput,
|
|
6
|
-
import {
|
|
7
|
-
import { qualifySourceDiscounts } from "./sourceDiscounts.js";
|
|
8
|
-
import { qualifyOriginalSettings } from "./sourceSettings.js";
|
|
4
|
+
import { object, readInput, equal, conflict, failure } from "./shared.js";
|
|
5
|
+
import { validateReadMaterial } from "./readMaterial.js";
|
|
9
6
|
export function retainedPreparation(value) {
|
|
10
7
|
try {
|
|
11
8
|
const candidate = object(value);
|
|
@@ -28,120 +25,8 @@ export function retainedPreparation(value) {
|
|
|
28
25
|
return conflict("invalid_prepared_binding");
|
|
29
26
|
}
|
|
30
27
|
}
|
|
31
|
-
const attachedReference = z.union([
|
|
32
|
-
resourceId("sub_sched"),
|
|
33
|
-
z
|
|
34
|
-
.object({
|
|
35
|
-
id: resourceId("sub_sched"),
|
|
36
|
-
object: z.literal("subscription_schedule"),
|
|
37
|
-
deleted: z.literal(false).optional(),
|
|
38
|
-
customer_account: resourceId("acct").optional(),
|
|
39
|
-
livemode: z.boolean().optional(),
|
|
40
|
-
})
|
|
41
|
-
.passthrough(),
|
|
42
|
-
]);
|
|
43
28
|
export function validateReads(args, scheduleId) {
|
|
44
|
-
|
|
45
|
-
supportedVersion(args.apiVersion);
|
|
46
|
-
const subscription = renewalSubscription
|
|
47
|
-
.extend({ schedule: scheduleId ? attachedReference : z.null() })
|
|
48
|
-
.safeParse(args.freshSubscription);
|
|
49
|
-
if (!subscription.success)
|
|
50
|
-
unsupported("unsupported_original_subscription_state");
|
|
51
|
-
const source = subscription.data;
|
|
52
|
-
if (scheduleId) {
|
|
53
|
-
if (referenceId(source.schedule, "sub_sched", "subscription_schedule") !==
|
|
54
|
-
scheduleId)
|
|
55
|
-
conflict("schedule_association_mismatch");
|
|
56
|
-
if (typeof source.schedule === "object" &&
|
|
57
|
-
source.schedule !== null &&
|
|
58
|
-
((source.schedule.customer_account !== undefined &&
|
|
59
|
-
source.schedule.customer_account !==
|
|
60
|
-
prepared.expected.customerAccountId) ||
|
|
61
|
-
(source.schedule.livemode !== undefined &&
|
|
62
|
-
source.schedule.livemode !== prepared.expected.livemode)))
|
|
63
|
-
conflict("schedule_association_mismatch");
|
|
64
|
-
}
|
|
65
|
-
const { schedule: originalSchedule, ...original } = prepared.providerSnapshot.subscription;
|
|
66
|
-
const { schedule: freshSchedule, ...fresh } = source;
|
|
67
|
-
if (scheduleId ? originalSchedule !== null : freshSchedule !== null)
|
|
68
|
-
conflict("schedule_association_mismatch");
|
|
69
|
-
if (!equal(original, fresh))
|
|
70
|
-
conflict("original_source_drift");
|
|
71
|
-
const target = renewalPrice.safeParse(args.targetPrice);
|
|
72
|
-
if (!target.success || !target.data.active)
|
|
73
|
-
unsupported("unsupported_target_price");
|
|
74
|
-
if (!equal(target.data, prepared.providerSnapshot.targetPrice))
|
|
75
|
-
conflict("target_price_drift");
|
|
76
|
-
if (prepared.providerSnapshot.billingCustomer === undefined ||
|
|
77
|
-
args.billingCustomer === undefined)
|
|
78
|
-
unsupported("missing_retained_billing_customer");
|
|
79
|
-
const customer = renewalBillingCustomer.safeParse(args.billingCustomer);
|
|
80
|
-
if (!customer.success)
|
|
81
|
-
unsupported("unsupported_billing_customer");
|
|
82
|
-
if (!equal(customer.data, prepared.providerSnapshot.billingCustomer))
|
|
83
|
-
conflict("billing_customer_drift");
|
|
84
|
-
const referenceContext = {
|
|
85
|
-
customerAccountId: prepared.expected.customerAccountId,
|
|
86
|
-
livemode: prepared.expected.livemode,
|
|
87
|
-
};
|
|
88
|
-
if (referenceId(source.customer, "cus", "customer", referenceContext) !==
|
|
89
|
-
customer.data.id ||
|
|
90
|
-
customer.data.customer_account !== prepared.expected.customerAccountId ||
|
|
91
|
-
customer.data.livemode !== prepared.expected.livemode)
|
|
92
|
-
conflict("billing_customer_identity_mismatch");
|
|
93
|
-
const item = source.items.data[0];
|
|
94
|
-
if (productId(item.price.product, referenceContext) !==
|
|
95
|
-
prepared.expected.currentProductId ||
|
|
96
|
-
productId(target.data.product, referenceContext) !==
|
|
97
|
-
prepared.expected.targetProductId)
|
|
98
|
-
unsupported("product_identity_mismatch");
|
|
99
|
-
if (args.observedAt < prepared.expected.periodStart ||
|
|
100
|
-
args.observedAt >= prepared.expected.periodEnd)
|
|
101
|
-
unsupported("outside_original_paid_period");
|
|
102
|
-
for (const field of [
|
|
103
|
-
"billing_thresholds",
|
|
104
|
-
"managed_payments",
|
|
105
|
-
"next_pending_invoice_item_invoice",
|
|
106
|
-
"pending_invoice_item_interval",
|
|
107
|
-
"pending_setup_intent",
|
|
108
|
-
"canceled_at",
|
|
109
|
-
"ended_at",
|
|
110
|
-
"trial_settings",
|
|
111
|
-
])
|
|
112
|
-
if (source[field] !== null)
|
|
113
|
-
unsupported(`unsupported_original_${field}`);
|
|
114
|
-
if (item.billing_thresholds !== null)
|
|
115
|
-
unsupported("unsupported_item_billing_thresholds");
|
|
116
|
-
if (item.current_trial !== null)
|
|
117
|
-
unsupported("unsupported_or_missing_item_current_trial");
|
|
118
|
-
if (!Array.isArray(source.billing_schedules) ||
|
|
119
|
-
source.billing_schedules.length)
|
|
120
|
-
unsupported("unsupported_original_billing_schedules");
|
|
121
|
-
if (source.trial_end !== null &&
|
|
122
|
-
(!timestamp.safeParse(source.trial_end).success ||
|
|
123
|
-
Number(source.trial_end) > prepared.expected.periodStart))
|
|
124
|
-
unsupported("unsupported_original_trial");
|
|
125
|
-
if (source.status_details != null || source.presentment_details != null)
|
|
126
|
-
unsupported("unsupported_special_billing_state");
|
|
127
|
-
const originalSettings = qualifyOriginalSettings(source, item, customer.data);
|
|
128
|
-
const profile = profileOf(source, item.price, target.data, args.apiVersion);
|
|
129
|
-
const anchor = timestamp.parse(source.billing_cycle_anchor);
|
|
130
|
-
if (anchor > prepared.expected.periodStart)
|
|
131
|
-
unsupported("unqualified_anchor_after_paid_period_start");
|
|
132
|
-
const discounts = qualifySourceDiscounts(source.discounts, "subscription", prepared.expected, customer.data.id, args.observedAt);
|
|
133
|
-
const itemDiscounts = qualifySourceDiscounts(item.discounts, "item", prepared.expected, customer.data.id, args.observedAt);
|
|
134
|
-
return {
|
|
135
|
-
prepared,
|
|
136
|
-
subscription: source,
|
|
137
|
-
item,
|
|
138
|
-
customer: customer.data,
|
|
139
|
-
targetPrice: target.data,
|
|
140
|
-
profile,
|
|
141
|
-
discounts,
|
|
142
|
-
itemDiscounts,
|
|
143
|
-
originalSettings,
|
|
144
|
-
};
|
|
29
|
+
return validateReadMaterial(args, retainedPreparation(args.prepared), scheduleId);
|
|
145
30
|
}
|
|
146
31
|
export function preflightRenewalReplacement(input) {
|
|
147
32
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalAggregate/preflight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,
|
|
1
|
+
{"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalAggregate/preflight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAChC,MAAM,QAAQ,GAAG,MA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