@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
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { PreparedRenewalPriceReplacement } from "../renewalPriceReplacement.js";
|
|
3
|
+
import { readInput } from "./shared.js";
|
|
4
|
+
export type RenewalPreparationMaterial = Pick<PreparedRenewalPriceReplacement, "expected" | "quantity" | "providerSnapshot">;
|
|
5
|
+
export declare function validateReadMaterial(args: Omit<z.infer<typeof readInput>, "prepared">, prepared: RenewalPreparationMaterial, scheduleId?: string): {
|
|
6
|
+
prepared: RenewalPreparationMaterial;
|
|
7
|
+
subscription: {
|
|
8
|
+
[x: string]: unknown;
|
|
9
|
+
id: string;
|
|
10
|
+
object: "subscription";
|
|
11
|
+
customer_account: string;
|
|
12
|
+
status: "active";
|
|
13
|
+
currency: string;
|
|
14
|
+
livemode: boolean;
|
|
15
|
+
cancel_at: null;
|
|
16
|
+
cancel_at_period_end: false;
|
|
17
|
+
pause_collection: null;
|
|
18
|
+
pending_update: null;
|
|
19
|
+
default_source: null;
|
|
20
|
+
application_fee_percent: null;
|
|
21
|
+
payment_settings: {
|
|
22
|
+
payment_method_options: null;
|
|
23
|
+
payment_method_types: null;
|
|
24
|
+
save_default_payment_method: "off" | null;
|
|
25
|
+
} | null;
|
|
26
|
+
billing_schedules?: unknown[] | undefined;
|
|
27
|
+
items: {
|
|
28
|
+
[x: string]: unknown;
|
|
29
|
+
has_more: false;
|
|
30
|
+
data: [{
|
|
31
|
+
[x: string]: unknown;
|
|
32
|
+
id: string;
|
|
33
|
+
object: "subscription_item";
|
|
34
|
+
subscription: string;
|
|
35
|
+
current_period_start: number;
|
|
36
|
+
current_period_end: number;
|
|
37
|
+
quantity: number;
|
|
38
|
+
price: {
|
|
39
|
+
[x: string]: unknown;
|
|
40
|
+
id: string;
|
|
41
|
+
object: "price";
|
|
42
|
+
product: string | {
|
|
43
|
+
[x: string]: unknown;
|
|
44
|
+
id: string;
|
|
45
|
+
object: "product";
|
|
46
|
+
deleted?: false | undefined;
|
|
47
|
+
};
|
|
48
|
+
active: boolean;
|
|
49
|
+
livemode: boolean;
|
|
50
|
+
type: "recurring";
|
|
51
|
+
currency: string;
|
|
52
|
+
billing_scheme: "per_unit";
|
|
53
|
+
recurring: {
|
|
54
|
+
[x: string]: unknown;
|
|
55
|
+
interval: "day" | "month" | "week" | "year";
|
|
56
|
+
interval_count: number;
|
|
57
|
+
usage_type: "licensed";
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
}];
|
|
61
|
+
};
|
|
62
|
+
schedule: string | {
|
|
63
|
+
[x: string]: unknown;
|
|
64
|
+
id: string;
|
|
65
|
+
object: "subscription_schedule";
|
|
66
|
+
deleted?: false | undefined;
|
|
67
|
+
customer_account?: string | undefined;
|
|
68
|
+
livemode?: boolean | undefined;
|
|
69
|
+
} | null;
|
|
70
|
+
};
|
|
71
|
+
item: {
|
|
72
|
+
[x: string]: unknown;
|
|
73
|
+
id: string;
|
|
74
|
+
object: "subscription_item";
|
|
75
|
+
subscription: string;
|
|
76
|
+
current_period_start: number;
|
|
77
|
+
current_period_end: number;
|
|
78
|
+
quantity: number;
|
|
79
|
+
price: {
|
|
80
|
+
[x: string]: unknown;
|
|
81
|
+
id: string;
|
|
82
|
+
object: "price";
|
|
83
|
+
product: string | {
|
|
84
|
+
[x: string]: unknown;
|
|
85
|
+
id: string;
|
|
86
|
+
object: "product";
|
|
87
|
+
deleted?: false | undefined;
|
|
88
|
+
};
|
|
89
|
+
active: boolean;
|
|
90
|
+
livemode: boolean;
|
|
91
|
+
type: "recurring";
|
|
92
|
+
currency: string;
|
|
93
|
+
billing_scheme: "per_unit";
|
|
94
|
+
recurring: {
|
|
95
|
+
[x: string]: unknown;
|
|
96
|
+
interval: "day" | "month" | "week" | "year";
|
|
97
|
+
interval_count: number;
|
|
98
|
+
usage_type: "licensed";
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
customer: {
|
|
103
|
+
[x: string]: unknown;
|
|
104
|
+
id: string;
|
|
105
|
+
object: "customer";
|
|
106
|
+
customer_account: string;
|
|
107
|
+
livemode: boolean;
|
|
108
|
+
deleted?: false | undefined;
|
|
109
|
+
discount: {
|
|
110
|
+
[x: string]: unknown;
|
|
111
|
+
id: string;
|
|
112
|
+
object: "discount";
|
|
113
|
+
deleted?: false | undefined;
|
|
114
|
+
} | null;
|
|
115
|
+
};
|
|
116
|
+
targetPrice: {
|
|
117
|
+
[x: string]: unknown;
|
|
118
|
+
id: string;
|
|
119
|
+
object: "price";
|
|
120
|
+
product: string | {
|
|
121
|
+
[x: string]: unknown;
|
|
122
|
+
id: string;
|
|
123
|
+
object: "product";
|
|
124
|
+
deleted?: false | undefined;
|
|
125
|
+
};
|
|
126
|
+
active: boolean;
|
|
127
|
+
livemode: boolean;
|
|
128
|
+
type: "recurring";
|
|
129
|
+
currency: string;
|
|
130
|
+
billing_scheme: "per_unit";
|
|
131
|
+
recurring: {
|
|
132
|
+
[x: string]: unknown;
|
|
133
|
+
interval: "day" | "month" | "week" | "year";
|
|
134
|
+
interval_count: number;
|
|
135
|
+
usage_type: "licensed";
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
profile: import("./profile.js").RenewalProfile;
|
|
139
|
+
discounts: {
|
|
140
|
+
[x: string]: unknown;
|
|
141
|
+
id: string;
|
|
142
|
+
object: "discount";
|
|
143
|
+
deleted?: false | undefined;
|
|
144
|
+
customer_account: string;
|
|
145
|
+
customer?: string | {
|
|
146
|
+
[x: string]: unknown;
|
|
147
|
+
id: string;
|
|
148
|
+
object: "customer";
|
|
149
|
+
deleted?: false | undefined;
|
|
150
|
+
livemode?: boolean | undefined;
|
|
151
|
+
customer_account?: string | null | undefined;
|
|
152
|
+
} | null | undefined;
|
|
153
|
+
subscription: string | null;
|
|
154
|
+
subscription_item: string | null;
|
|
155
|
+
start: number;
|
|
156
|
+
end: null;
|
|
157
|
+
source: {
|
|
158
|
+
[x: string]: unknown;
|
|
159
|
+
type: "coupon";
|
|
160
|
+
coupon: {
|
|
161
|
+
[x: string]: unknown;
|
|
162
|
+
id: string;
|
|
163
|
+
object: "coupon";
|
|
164
|
+
deleted?: false | undefined;
|
|
165
|
+
livemode?: boolean | undefined;
|
|
166
|
+
duration: "forever";
|
|
167
|
+
applies_to?: {
|
|
168
|
+
products: string[];
|
|
169
|
+
} | undefined;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
}[];
|
|
173
|
+
itemDiscounts: {
|
|
174
|
+
[x: string]: unknown;
|
|
175
|
+
id: string;
|
|
176
|
+
object: "discount";
|
|
177
|
+
deleted?: false | undefined;
|
|
178
|
+
customer_account: string;
|
|
179
|
+
customer?: string | {
|
|
180
|
+
[x: string]: unknown;
|
|
181
|
+
id: string;
|
|
182
|
+
object: "customer";
|
|
183
|
+
deleted?: false | undefined;
|
|
184
|
+
livemode?: boolean | undefined;
|
|
185
|
+
customer_account?: string | null | undefined;
|
|
186
|
+
} | null | undefined;
|
|
187
|
+
subscription: string | null;
|
|
188
|
+
subscription_item: string | null;
|
|
189
|
+
start: number;
|
|
190
|
+
end: null;
|
|
191
|
+
source: {
|
|
192
|
+
[x: string]: unknown;
|
|
193
|
+
type: "coupon";
|
|
194
|
+
coupon: {
|
|
195
|
+
[x: string]: unknown;
|
|
196
|
+
id: string;
|
|
197
|
+
object: "coupon";
|
|
198
|
+
deleted?: false | undefined;
|
|
199
|
+
livemode?: boolean | undefined;
|
|
200
|
+
duration: "forever";
|
|
201
|
+
applies_to?: {
|
|
202
|
+
products: string[];
|
|
203
|
+
} | undefined;
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
}[];
|
|
207
|
+
originalSettings: {
|
|
208
|
+
context: {
|
|
209
|
+
customerAccountId: string;
|
|
210
|
+
customerId: string;
|
|
211
|
+
livemode: boolean;
|
|
212
|
+
effectiveCollectionMethod: "charge_automatically" | "send_invoice";
|
|
213
|
+
effectiveAutomaticTax: boolean;
|
|
214
|
+
effectiveInvoiceIssuer: {
|
|
215
|
+
type: "self";
|
|
216
|
+
account?: null | undefined;
|
|
217
|
+
} | {
|
|
218
|
+
type: "account";
|
|
219
|
+
account: string | {
|
|
220
|
+
[x: string]: unknown;
|
|
221
|
+
id: string;
|
|
222
|
+
object: string;
|
|
223
|
+
deleted?: false | undefined;
|
|
224
|
+
livemode?: boolean | undefined;
|
|
225
|
+
customer?: string | {
|
|
226
|
+
[x: string]: unknown;
|
|
227
|
+
id: string;
|
|
228
|
+
object: "customer";
|
|
229
|
+
deleted?: false | undefined;
|
|
230
|
+
livemode?: boolean | undefined;
|
|
231
|
+
customer_account?: string | null | undefined;
|
|
232
|
+
} | null | undefined;
|
|
233
|
+
customer_account?: string | null | undefined;
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
invoice: {
|
|
238
|
+
account_tax_ids: (string | {
|
|
239
|
+
[x: string]: unknown;
|
|
240
|
+
id: string;
|
|
241
|
+
object: "tax_id";
|
|
242
|
+
deleted?: false | undefined;
|
|
243
|
+
livemode: boolean;
|
|
244
|
+
customer?: null | undefined;
|
|
245
|
+
customer_account?: null | undefined;
|
|
246
|
+
owner: {
|
|
247
|
+
type: "self";
|
|
248
|
+
customer_account: null;
|
|
249
|
+
account?: null | undefined;
|
|
250
|
+
customer?: null | undefined;
|
|
251
|
+
} | {
|
|
252
|
+
type: "account";
|
|
253
|
+
account: string | {
|
|
254
|
+
[x: string]: unknown;
|
|
255
|
+
id: string;
|
|
256
|
+
object: string;
|
|
257
|
+
deleted?: false | undefined;
|
|
258
|
+
livemode?: boolean | undefined;
|
|
259
|
+
customer?: string | {
|
|
260
|
+
[x: string]: unknown;
|
|
261
|
+
id: string;
|
|
262
|
+
object: "customer";
|
|
263
|
+
deleted?: false | undefined;
|
|
264
|
+
livemode?: boolean | undefined;
|
|
265
|
+
customer_account?: string | null | undefined;
|
|
266
|
+
} | null | undefined;
|
|
267
|
+
customer_account?: string | null | undefined;
|
|
268
|
+
};
|
|
269
|
+
customer_account: null;
|
|
270
|
+
customer?: null | undefined;
|
|
271
|
+
};
|
|
272
|
+
})[] | null;
|
|
273
|
+
custom_fields: {
|
|
274
|
+
name: string;
|
|
275
|
+
value: string;
|
|
276
|
+
}[] | null;
|
|
277
|
+
description: string | null;
|
|
278
|
+
footer: string | null;
|
|
279
|
+
issuer: {
|
|
280
|
+
type: "self";
|
|
281
|
+
account?: null | undefined;
|
|
282
|
+
} | {
|
|
283
|
+
type: "account";
|
|
284
|
+
account: string | {
|
|
285
|
+
[x: string]: unknown;
|
|
286
|
+
id: string;
|
|
287
|
+
object: string;
|
|
288
|
+
deleted?: false | undefined;
|
|
289
|
+
livemode?: boolean | undefined;
|
|
290
|
+
customer?: string | {
|
|
291
|
+
[x: string]: unknown;
|
|
292
|
+
id: string;
|
|
293
|
+
object: "customer";
|
|
294
|
+
deleted?: false | undefined;
|
|
295
|
+
livemode?: boolean | undefined;
|
|
296
|
+
customer_account?: string | null | undefined;
|
|
297
|
+
} | null | undefined;
|
|
298
|
+
customer_account?: string | null | undefined;
|
|
299
|
+
};
|
|
300
|
+
};
|
|
301
|
+
};
|
|
302
|
+
automaticTax: {
|
|
303
|
+
enabled: boolean;
|
|
304
|
+
liability?: {
|
|
305
|
+
type: "self";
|
|
306
|
+
account?: null | undefined;
|
|
307
|
+
} | {
|
|
308
|
+
type: "account";
|
|
309
|
+
account: string | {
|
|
310
|
+
[x: string]: unknown;
|
|
311
|
+
id: string;
|
|
312
|
+
object: string;
|
|
313
|
+
deleted?: false | undefined;
|
|
314
|
+
livemode?: boolean | undefined;
|
|
315
|
+
customer?: string | {
|
|
316
|
+
[x: string]: unknown;
|
|
317
|
+
id: string;
|
|
318
|
+
object: "customer";
|
|
319
|
+
deleted?: false | undefined;
|
|
320
|
+
livemode?: boolean | undefined;
|
|
321
|
+
customer_account?: string | null | undefined;
|
|
322
|
+
} | null | undefined;
|
|
323
|
+
customer_account?: string | null | undefined;
|
|
324
|
+
};
|
|
325
|
+
} | null | undefined;
|
|
326
|
+
disabled_reason?: null | undefined;
|
|
327
|
+
};
|
|
328
|
+
taxLevels: {
|
|
329
|
+
subscription: string[];
|
|
330
|
+
item: string[];
|
|
331
|
+
};
|
|
332
|
+
};
|
|
333
|
+
};
|
|
334
|
+
export type RenewalReadMaterial = ReturnType<typeof validateReadMaterial>;
|
|
335
|
+
//# sourceMappingURL=readMaterial.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readMaterial.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalAggregate/readMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAMrF,OAAO,EACL,SAAS,EASV,MAAM,aAAa,CAAC;AAKrB,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAC3C,+BAA+B,EAC/B,UAAU,GAAG,UAAU,GAAG,kBAAkB,CAC7C,CAAC;AAcF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,EAAE,UAAU,CAAC,EACjD,QAAQ,EAAE,0BAA0B,EACpC,UAAU,CAAC,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgIpB;AAED,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { renewalSubscription, renewalPrice, renewalBillingCustomer, } from "../renewalReplacementSchema.js";
|
|
3
|
+
import { referenceId, equal, conflict, unsupported, supportedVersion, timestamp, resourceId, productId, } from "./shared.js";
|
|
4
|
+
import { profileOf } from "./profile.js";
|
|
5
|
+
import { qualifySourceDiscounts } from "./sourceDiscounts.js";
|
|
6
|
+
import { qualifyOriginalSettings } from "./sourceSettings.js";
|
|
7
|
+
const attachedReference = z.union([
|
|
8
|
+
resourceId("sub_sched"),
|
|
9
|
+
z
|
|
10
|
+
.object({
|
|
11
|
+
id: resourceId("sub_sched"),
|
|
12
|
+
object: z.literal("subscription_schedule"),
|
|
13
|
+
deleted: z.literal(false).optional(),
|
|
14
|
+
customer_account: resourceId("acct").optional(),
|
|
15
|
+
livemode: z.boolean().optional(),
|
|
16
|
+
})
|
|
17
|
+
.passthrough(),
|
|
18
|
+
]);
|
|
19
|
+
export function validateReadMaterial(args, prepared, scheduleId) {
|
|
20
|
+
supportedVersion(args.apiVersion);
|
|
21
|
+
const subscription = renewalSubscription
|
|
22
|
+
.extend({ schedule: scheduleId ? attachedReference : z.null() })
|
|
23
|
+
.safeParse(args.freshSubscription);
|
|
24
|
+
if (!subscription.success)
|
|
25
|
+
unsupported("unsupported_original_subscription_state");
|
|
26
|
+
const source = subscription.data;
|
|
27
|
+
if (scheduleId) {
|
|
28
|
+
if (referenceId(source.schedule, "sub_sched", "subscription_schedule") !==
|
|
29
|
+
scheduleId)
|
|
30
|
+
conflict("schedule_association_mismatch");
|
|
31
|
+
if (typeof source.schedule === "object" &&
|
|
32
|
+
source.schedule !== null &&
|
|
33
|
+
((source.schedule.customer_account !== undefined &&
|
|
34
|
+
source.schedule.customer_account !==
|
|
35
|
+
prepared.expected.customerAccountId) ||
|
|
36
|
+
(source.schedule.livemode !== undefined &&
|
|
37
|
+
source.schedule.livemode !== prepared.expected.livemode)))
|
|
38
|
+
conflict("schedule_association_mismatch");
|
|
39
|
+
}
|
|
40
|
+
const { schedule: originalSchedule, ...original } = prepared.providerSnapshot.subscription;
|
|
41
|
+
const { schedule: freshSchedule, ...fresh } = source;
|
|
42
|
+
if (scheduleId ? originalSchedule !== null : freshSchedule !== null)
|
|
43
|
+
conflict("schedule_association_mismatch");
|
|
44
|
+
if (!equal(original, fresh))
|
|
45
|
+
conflict("original_source_drift");
|
|
46
|
+
const target = renewalPrice.safeParse(args.targetPrice);
|
|
47
|
+
if (!target.success || !target.data.active)
|
|
48
|
+
unsupported("unsupported_target_price");
|
|
49
|
+
if (!equal(target.data, prepared.providerSnapshot.targetPrice))
|
|
50
|
+
conflict("target_price_drift");
|
|
51
|
+
if (prepared.providerSnapshot.billingCustomer === undefined ||
|
|
52
|
+
args.billingCustomer === undefined)
|
|
53
|
+
unsupported("missing_retained_billing_customer");
|
|
54
|
+
const customer = renewalBillingCustomer.safeParse(args.billingCustomer);
|
|
55
|
+
if (!customer.success)
|
|
56
|
+
unsupported("unsupported_billing_customer");
|
|
57
|
+
if (!equal(customer.data, prepared.providerSnapshot.billingCustomer))
|
|
58
|
+
conflict("billing_customer_drift");
|
|
59
|
+
const referenceContext = {
|
|
60
|
+
customerAccountId: prepared.expected.customerAccountId,
|
|
61
|
+
livemode: prepared.expected.livemode,
|
|
62
|
+
};
|
|
63
|
+
if (referenceId(source.customer, "cus", "customer", referenceContext) !==
|
|
64
|
+
customer.data.id ||
|
|
65
|
+
customer.data.customer_account !== prepared.expected.customerAccountId ||
|
|
66
|
+
customer.data.livemode !== prepared.expected.livemode)
|
|
67
|
+
conflict("billing_customer_identity_mismatch");
|
|
68
|
+
const item = source.items.data[0];
|
|
69
|
+
if (productId(item.price.product, referenceContext) !==
|
|
70
|
+
prepared.expected.currentProductId ||
|
|
71
|
+
productId(target.data.product, referenceContext) !==
|
|
72
|
+
prepared.expected.targetProductId)
|
|
73
|
+
unsupported("product_identity_mismatch");
|
|
74
|
+
if (args.observedAt < prepared.expected.periodStart ||
|
|
75
|
+
args.observedAt >= prepared.expected.periodEnd)
|
|
76
|
+
unsupported("outside_original_paid_period");
|
|
77
|
+
for (const field of [
|
|
78
|
+
"billing_thresholds",
|
|
79
|
+
"managed_payments",
|
|
80
|
+
"next_pending_invoice_item_invoice",
|
|
81
|
+
"pending_invoice_item_interval",
|
|
82
|
+
"pending_setup_intent",
|
|
83
|
+
"canceled_at",
|
|
84
|
+
"ended_at",
|
|
85
|
+
"trial_settings",
|
|
86
|
+
])
|
|
87
|
+
if (source[field] !== null)
|
|
88
|
+
unsupported(`unsupported_original_${field}`);
|
|
89
|
+
if (item.billing_thresholds !== null)
|
|
90
|
+
unsupported("unsupported_item_billing_thresholds");
|
|
91
|
+
if (item.current_trial !== null)
|
|
92
|
+
unsupported("unsupported_or_missing_item_current_trial");
|
|
93
|
+
if (!Array.isArray(source.billing_schedules) ||
|
|
94
|
+
source.billing_schedules.length)
|
|
95
|
+
unsupported("unsupported_original_billing_schedules");
|
|
96
|
+
if (source.trial_end !== null &&
|
|
97
|
+
(!timestamp.safeParse(source.trial_end).success ||
|
|
98
|
+
Number(source.trial_end) > prepared.expected.periodStart))
|
|
99
|
+
unsupported("unsupported_original_trial");
|
|
100
|
+
if (source.status_details != null || source.presentment_details != null)
|
|
101
|
+
unsupported("unsupported_special_billing_state");
|
|
102
|
+
const originalSettings = qualifyOriginalSettings(source, item, customer.data);
|
|
103
|
+
const profile = profileOf(source, item.price, target.data, args.apiVersion);
|
|
104
|
+
const anchor = timestamp.parse(source.billing_cycle_anchor);
|
|
105
|
+
if (anchor > prepared.expected.periodStart)
|
|
106
|
+
unsupported("unqualified_anchor_after_paid_period_start");
|
|
107
|
+
const discounts = qualifySourceDiscounts(source.discounts, "subscription", prepared.expected, customer.data.id, args.observedAt);
|
|
108
|
+
const itemDiscounts = qualifySourceDiscounts(item.discounts, "item", prepared.expected, customer.data.id, args.observedAt);
|
|
109
|
+
return {
|
|
110
|
+
prepared,
|
|
111
|
+
subscription: source,
|
|
112
|
+
item,
|
|
113
|
+
customer: customer.data,
|
|
114
|
+
targetPrice: target.data,
|
|
115
|
+
profile,
|
|
116
|
+
discounts,
|
|
117
|
+
itemDiscounts,
|
|
118
|
+
originalSettings,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=readMaterial.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readMa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4BAA4B,CAAC,CAAC;IAC5C,IAAI,MAAM,CAAC,cAAc,IAAI,IAAI,IAAI,MAAM,CAAC,mBAAmB,IAAI,IAAI;QACrE,WAAW,CAAC,mCAAmC,CAAC,CAAC;IACnD,MAAM,gBAAgB,GAAG,uBAAuB,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC9E,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAC5E,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;IAC5D,IAAI,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,WAAW;QACxC,WAAW,CAAC,4CAA4C,CAAC,CAAC;IAC5D,MAAM,SAAS,GAAG,sBAAsB,CACtC,MAAM,CAAC,SAAS,EAChB,cAAc,EACd,QAAQ,CAAC,QAAQ,EACjB,QAAQ,CAAC,IAAI,CAAC,EAAE,EAChB,IAAI,CAAC,UAAU,CAChB,CAAC;IACF,MAAM,aAAa,GAAG,sBAAsB,CAC1C,IAAI,CAAC,SAAS,EACd,MAAM,EACN,QAAQ,CAAC,QAAQ,EACjB,QAAQ,CAAC,IAAI,CAAC,EAAE,EAChB,IAAI,CAAC,UAAU,CAChB,CAAC;IACF,OAAO;QACL,QAAQ;QACR,YAAY,EAAE,MAAM;QACpB,IAAI;QACJ,QAAQ,EAAE,QAAQ,CAAC,IAAI;QACvB,WAAW,EAAE,MAAM,CAAC,IAAI;QACxB,OAAO;QACP,SAAS;QACT,aAAa;QACb,gBAAgB;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** Internal fixed-family encoding. This is consistency, not authorization. */
|
|
2
|
-
export declare function renewalBindingV2(family: "renewal" | "renewal-attach", preimage: unknown): Promise<string>;
|
|
2
|
+
export declare function renewalBindingV2(family: "renewal" | "renewal-attach" | "renewal-attach-receipt" | "renewal-baseline" | "renewal-defaults" | "renewal-configure", preimage: unknown): Promise<string>;
|
|
3
3
|
//# sourceMappingURL=binding.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalV2/binding.ts"],"names":[],"mappings":"AAEA,8EAA8E;AAC9E,wBAAsB,gBAAgB,CACpC,MAAM,
|
|
1
|
+
{"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalV2/binding.ts"],"names":[],"mappings":"AAEA,8EAA8E;AAC9E,wBAAsB,gBAAgB,CACpC,MAAM,EACF,SAAS,GACT,gBAAgB,GAChB,wBAAwB,GACxB,kBAAkB,GAClB,kBAAkB,GAClB,mBAAmB,EACvB,QAAQ,EAAE,OAAO,GAChB,OAAO,CAAC,MAAM,CAAC,CAkBjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binding.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalV2/binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAEnE,8EAA8E;AAC9E,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,
|
|
1
|
+
{"version":3,"file":"binding.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalV2/binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAEnE,8EAA8E;AAC9E,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAMuB,EACvB,QAAiB;IAEjB,uEAAuE;IACvE,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CACzB,eAAe,CAAC,CAAC,8BAA8B,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CACvE,CAAC;IACF,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7C,IAAI,KAAK,CAAC,UAAU,GAAG,OAAO;QAC5B,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC;IACzC,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU;QAChD,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IACrD,IAAI,CAAC,CAAC,MAAM,YAAY,WAAW,CAAC,IAAI,MAAM,CAAC,UAAU,KAAK,EAAE;QAC9D,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CACtD,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CACnC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACX,OAAO,GAAG,MAAM,cAAc,GAAG,EAAE,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type ObjectData } from "../renewalAggregate/shared.js";
|
|
2
|
+
export declare function captureConfiguration(raw: unknown): {
|
|
3
|
+
preparation: {
|
|
4
|
+
subscription: unknown;
|
|
5
|
+
targetPrice: unknown;
|
|
6
|
+
expected: unknown;
|
|
7
|
+
key: string;
|
|
8
|
+
billingCustomer?: unknown;
|
|
9
|
+
};
|
|
10
|
+
freshSubscription: unknown;
|
|
11
|
+
targetPrice: unknown;
|
|
12
|
+
billingCustomer?: unknown;
|
|
13
|
+
schedule: unknown;
|
|
14
|
+
apiVersion: string;
|
|
15
|
+
observedAt: number;
|
|
16
|
+
firstDispatchedAt: number;
|
|
17
|
+
configureKey: string;
|
|
18
|
+
attachReceipt: {
|
|
19
|
+
attachRequest: {
|
|
20
|
+
preparation: {
|
|
21
|
+
subscription: unknown;
|
|
22
|
+
targetPrice: unknown;
|
|
23
|
+
billingCustomer?: unknown;
|
|
24
|
+
expected: unknown;
|
|
25
|
+
key: string;
|
|
26
|
+
};
|
|
27
|
+
apiVersion: string;
|
|
28
|
+
attachKey: string;
|
|
29
|
+
firstDispatchedAt: number;
|
|
30
|
+
};
|
|
31
|
+
actualDispatch: {
|
|
32
|
+
scope: "platform";
|
|
33
|
+
apiVersion: string;
|
|
34
|
+
method: "POST";
|
|
35
|
+
path: "/v1/subscription_schedules";
|
|
36
|
+
payload: {
|
|
37
|
+
from_subscription: string;
|
|
38
|
+
};
|
|
39
|
+
key: string;
|
|
40
|
+
firstDispatchedAt: number;
|
|
41
|
+
};
|
|
42
|
+
providerSnapshot: ObjectData;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=configureInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configureInput.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalV2/configureInput.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,KAAK,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAwE3E,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAShD"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { renewalSnapshot } from "../renewalReplacementSnapshot.js";
|
|
3
|
+
import { timestamp } from "../renewalAggregate/shared.js";
|
|
4
|
+
import { captureAttachmentReceipt, validateAttachmentReceiptFields, } from "./receipt.js";
|
|
5
|
+
function ownData(raw, required, optional = []) {
|
|
6
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
7
|
+
throw Error("Invalid raw renewal configuration.");
|
|
8
|
+
const keys = Reflect.ownKeys(raw);
|
|
9
|
+
if (keys.some((k) => typeof k !== "string" || ![...required, ...optional].includes(k)) ||
|
|
10
|
+
required.some((k) => !keys.includes(k)))
|
|
11
|
+
throw Error("Invalid raw renewal configuration fields.");
|
|
12
|
+
const fields = {};
|
|
13
|
+
for (const key of keys) {
|
|
14
|
+
const d = Object.getOwnPropertyDescriptor(raw, key);
|
|
15
|
+
if (!d || !d.enumerable || !("value" in d))
|
|
16
|
+
throw Error("Renewal configuration requires own JSON data.");
|
|
17
|
+
fields[key] = d.value;
|
|
18
|
+
}
|
|
19
|
+
return fields;
|
|
20
|
+
}
|
|
21
|
+
function closed(raw) {
|
|
22
|
+
const root = ownData(raw, [
|
|
23
|
+
"preparation",
|
|
24
|
+
"attachReceipt",
|
|
25
|
+
"freshSubscription",
|
|
26
|
+
"targetPrice",
|
|
27
|
+
"schedule",
|
|
28
|
+
"apiVersion",
|
|
29
|
+
"observedAt",
|
|
30
|
+
"firstDispatchedAt",
|
|
31
|
+
"configureKey",
|
|
32
|
+
], ["billingCustomer"]);
|
|
33
|
+
ownData(root.preparation, ["subscription", "targetPrice", "expected", "key"], ["billingCustomer"]);
|
|
34
|
+
validateAttachmentReceiptFields(root.attachReceipt);
|
|
35
|
+
}
|
|
36
|
+
const preparation = z
|
|
37
|
+
.object({
|
|
38
|
+
subscription: z.unknown(),
|
|
39
|
+
targetPrice: z.unknown(),
|
|
40
|
+
expected: z.unknown(),
|
|
41
|
+
key: z.string(),
|
|
42
|
+
billingCustomer: z.unknown().optional(),
|
|
43
|
+
})
|
|
44
|
+
.strict();
|
|
45
|
+
const input = z
|
|
46
|
+
.object({
|
|
47
|
+
preparation,
|
|
48
|
+
attachReceipt: z.unknown(),
|
|
49
|
+
freshSubscription: z.unknown(),
|
|
50
|
+
targetPrice: z.unknown(),
|
|
51
|
+
billingCustomer: z.unknown().optional(),
|
|
52
|
+
schedule: z.unknown(),
|
|
53
|
+
apiVersion: z.string(),
|
|
54
|
+
observedAt: timestamp,
|
|
55
|
+
firstDispatchedAt: timestamp,
|
|
56
|
+
configureKey: z.string(),
|
|
57
|
+
})
|
|
58
|
+
.strict();
|
|
59
|
+
export function captureConfiguration(raw) {
|
|
60
|
+
closed(raw);
|
|
61
|
+
const captured = renewalSnapshot(raw);
|
|
62
|
+
closed(captured);
|
|
63
|
+
const args = input.parse(captured);
|
|
64
|
+
return {
|
|
65
|
+
...args,
|
|
66
|
+
attachReceipt: captureAttachmentReceipt(args.attachReceipt),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=configureInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configureInput.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalV2/configureInput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAmB,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EACL,wBAAwB,EACxB,+BAA+B,GAChC,MAAM,cAAc,CAAC;AAEtB,SAAS,OAAO,CAAC,GAAY,EAAE,QAAkB,EAAE,QAAQ,GAAa,EAAE;IACxE,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QACvD,MAAM,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACpD,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAClC,IACE,IAAI,CAAC,IAAI,CACP,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,GAAG,QAAQ,EAAE,GAAG,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CACxE;QACD,QAAQ,CAAC,IAAI,CAA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,EAAE;CACxC,CAAC;KACD,MAAM,EAAE,CAAC;AACZ,MAAM,KAAK,GAAG,CAAC;KACZ,MAAM,CAAC;IACN,WAAW;IACX,aAAa,EAAE,CAAC,CAAC,OAAO,EAAE;IAC1B,iBAAiB,EAAE,CAAC,CAAC,OAAO,EAAE;IAC9B,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE;IACxB,eAAe,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACvC,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;IACrB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,UAAU,EAAE,SAAS;IACrB,iBAAiB,EAAE,SAAS;IAC5B,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;CACzB,CAAC;KACD,MAAM,EAAE,CAAC;AACZ,MAAM,UAAU,oBAAoB,CAAC,GAAY;IAC/C,MAAM,CAAC,GAAG,CAAC,CAAC;IACZ,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACjB,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACnC,OAAO;QACL,GAAG,IAAI;QACP,aAAa,EAAE,wBAAwB,CAAC,IAAI,CAAC,aAAa,CAAC;KAC5D,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type PrepareRenewalPriceReplacementOptions, type PreparedRenewalPriceReplacement } from "../renewalPriceReplacement.js";
|
|
2
|
+
import { type Failure } from "../renewalAggregate/shared.js";
|
|
3
|
+
import type { ProjectedRenewalConfiguration } from "../renewalAggregate/configure.js";
|
|
2
4
|
export type PrepareRenewalPriceReplacementV2Options = PrepareRenewalPriceReplacementOptions;
|
|
3
5
|
export type PreparedRenewalPriceReplacementV2 = Omit<PreparedRenewalPriceReplacement, "version" | "requestIdentity"> & {
|
|
4
6
|
version: 2;
|
|
@@ -35,4 +37,48 @@ export type PreparedRenewalScheduleAttachmentV2 = {
|
|
|
35
37
|
};
|
|
36
38
|
/** Pure C2 request. No dispatch, receipt, provider qualification or V1 migration. */
|
|
37
39
|
export declare function prepareRenewalScheduleAttachmentV2(options: PrepareRenewalScheduleAttachmentV2Options): Promise<PreparedRenewalScheduleAttachmentV2>;
|
|
40
|
+
export type ConstructRenewalScheduleAttachmentReceiptV2Options = {
|
|
41
|
+
attachRequest: {
|
|
42
|
+
preparation: PrepareRenewalPriceReplacementV2Options;
|
|
43
|
+
apiVersion: string;
|
|
44
|
+
attachKey: string;
|
|
45
|
+
firstDispatchedAt: number;
|
|
46
|
+
};
|
|
47
|
+
actualDispatch: Pick<PreparedRenewalScheduleAttachmentV2, "scope" | "apiVersion" | "method" | "path" | "payload" | "key" | "firstDispatchedAt">;
|
|
48
|
+
providerSnapshot: Record<string, unknown>;
|
|
49
|
+
};
|
|
50
|
+
export type RenewalScheduleAttachmentReceiptV2 = {
|
|
51
|
+
version: 2;
|
|
52
|
+
stage: "attached_unconfigured";
|
|
53
|
+
scope: "platform";
|
|
54
|
+
logicalBinding: string;
|
|
55
|
+
request: PreparedRenewalScheduleAttachmentV2;
|
|
56
|
+
scheduleId: string;
|
|
57
|
+
subscriptionId: string;
|
|
58
|
+
customerAccountId: string;
|
|
59
|
+
livemode: boolean;
|
|
60
|
+
providerSnapshot: Record<string, unknown>;
|
|
61
|
+
binding: string;
|
|
62
|
+
};
|
|
63
|
+
/** Pure unsigned consistency data. Does not authenticate or acknowledge a POST. */
|
|
64
|
+
export declare function constructRenewalScheduleAttachmentReceiptV2(options: ConstructRenewalScheduleAttachmentReceiptV2Options): Promise<RenewalScheduleAttachmentReceiptV2>;
|
|
65
|
+
export type ProjectRenewalConfigurationV2Options = {
|
|
66
|
+
preparation: PrepareRenewalPriceReplacementV2Options;
|
|
67
|
+
/** Raw attachment inputs, not a stored receipt or caller verification handle. */
|
|
68
|
+
attachReceipt: ConstructRenewalScheduleAttachmentReceiptV2Options;
|
|
69
|
+
freshSubscription: unknown;
|
|
70
|
+
targetPrice: unknown;
|
|
71
|
+
billingCustomer?: unknown;
|
|
72
|
+
schedule: unknown;
|
|
73
|
+
apiVersion: string;
|
|
74
|
+
observedAt: number;
|
|
75
|
+
firstDispatchedAt: number;
|
|
76
|
+
configureKey: string;
|
|
77
|
+
};
|
|
78
|
+
export type ProjectedRenewalConfigurationV2 = Omit<ProjectedRenewalConfiguration, "version"> & {
|
|
79
|
+
version: 2;
|
|
80
|
+
};
|
|
81
|
+
export type RenewalConfigurationProjectionFailure = Failure;
|
|
82
|
+
/** Pure raw-only configuration candidate; provider qualification remains required. */
|
|
83
|
+
export declare function projectRenewalConfigurationV2(options: ProjectRenewalConfigurationV2Options): Promise<ProjectedRenewalConfigurationV2 | RenewalConfigurationProjectionFailure>;
|
|
38
84
|
//# sourceMappingURL=index.d.ts.map
|