@fantastic.dev/better-stripe 0.86.0 → 0.87.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 +6 -0
- package/README.md +1 -1
- 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 +1 -0
- package/dist/client/billing/renewalV2/configureInput.d.ts.map +1 -1
- package/dist/client/billing/renewalV2/configureInput.js +3 -3
- package/dist/client/billing/renewalV2/configureInput.js.map +1 -1
- package/dist/client/billing/renewalV2/configureReceipt.d.ts +19 -0
- package/dist/client/billing/renewalV2/configureReceipt.d.ts.map +1 -0
- package/dist/client/billing/renewalV2/configureReceipt.js +91 -0
- package/dist/client/billing/renewalV2/configureReceipt.js.map +1 -0
- package/dist/client/billing/renewalV2/index.d.ts +34 -0
- package/dist/client/billing/renewalV2/index.d.ts.map +1 -1
- package/dist/client/billing/renewalV2/index.js +65 -0
- package/dist/client/billing/renewalV2/index.js.map +1 -1
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +32 -32
- package/dist/client/connect/payoutSyncTestHelpers.d.ts +16 -16
- 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/balanceFunding/mutations.d.ts +16 -16
- package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
- package/dist/component/balanceFunding/stateHandlers.d.ts +8 -8
- package/dist/component/balanceFunding/workflowValidators.d.ts +16 -16
- package/dist/component/earnings/triggers.d.ts +16 -16
- package/docs/renewal-context-reads.md +5 -1
- package/docs/renewal-phase-assembly.md +68 -0
- package/package.json +1 -1
- package/src/client/billing/renewalV2/binding.ts +4 -1
- package/src/client/billing/renewalV2/configureInput.ts +3 -3
- package/src/client/billing/renewalV2/configureReceipt.test.ts +558 -0
- package/src/client/billing/renewalV2/configureReceipt.ts +96 -0
- package/src/client/billing/renewalV2/index.ts +117 -0
- package/src/client/renewal.ts +3 -0
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
assertAttachmentIdentity,
|
|
28
28
|
} from "./receipt.js";
|
|
29
29
|
import { captureConfiguration } from "./configureInput.js";
|
|
30
|
+
import { captureConfigurationReceipt } from "./configureReceipt.js";
|
|
30
31
|
|
|
31
32
|
export type PrepareRenewalPriceReplacementV2Options =
|
|
32
33
|
PrepareRenewalPriceReplacementOptions;
|
|
@@ -336,3 +337,119 @@ export async function projectRenewalConfigurationV2(
|
|
|
336
337
|
return failure(error, ownedScheduleId);
|
|
337
338
|
}
|
|
338
339
|
}
|
|
340
|
+
|
|
341
|
+
export type ConstructRenewalConfigurationReceiptV2Options = {
|
|
342
|
+
configuration: ProjectRenewalConfigurationV2Options;
|
|
343
|
+
actualDispatch: Pick<
|
|
344
|
+
ProjectedRenewalConfigurationV2,
|
|
345
|
+
| "scope"
|
|
346
|
+
| "apiVersion"
|
|
347
|
+
| "method"
|
|
348
|
+
| "path"
|
|
349
|
+
| "payload"
|
|
350
|
+
| "key"
|
|
351
|
+
| "firstDispatchedAt"
|
|
352
|
+
>;
|
|
353
|
+
providerSnapshot: Record<string, unknown>;
|
|
354
|
+
transport: { status: number; requestId?: string };
|
|
355
|
+
};
|
|
356
|
+
export type RenewalConfigurationReceiptV2 = {
|
|
357
|
+
version: 2;
|
|
358
|
+
stage: "configure_acknowledged";
|
|
359
|
+
scope: "platform";
|
|
360
|
+
verification: "owned_response_only";
|
|
361
|
+
apiVersion: string;
|
|
362
|
+
logicalBinding: string;
|
|
363
|
+
request: ProjectedRenewalConfigurationV2;
|
|
364
|
+
attachReceiptBinding: string;
|
|
365
|
+
scheduleId: string;
|
|
366
|
+
subscriptionId: string;
|
|
367
|
+
customerAccountId: string;
|
|
368
|
+
billingCustomerId: string;
|
|
369
|
+
livemode: boolean;
|
|
370
|
+
providerSnapshot: Record<string, unknown>;
|
|
371
|
+
transport: { status: number; requestId?: string };
|
|
372
|
+
providerSnapshotBinding: string;
|
|
373
|
+
defaultSettingsBinding?: string;
|
|
374
|
+
binding: string;
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
/** Unsigned operation consistency only. Does not authenticate an acknowledgement. */
|
|
378
|
+
export async function constructRenewalConfigurationReceiptV2(
|
|
379
|
+
options: ConstructRenewalConfigurationReceiptV2Options,
|
|
380
|
+
): Promise<RenewalConfigurationReceiptV2> {
|
|
381
|
+
try {
|
|
382
|
+
const args = captureConfigurationReceipt(options);
|
|
383
|
+
const configuration =
|
|
384
|
+
args.configuration as ProjectRenewalConfigurationV2Options;
|
|
385
|
+
const request = await projectRenewalConfigurationV2(configuration);
|
|
386
|
+
if (request.status !== "projected_configure_request") throw Error();
|
|
387
|
+
const { scope, apiVersion, method, path, payload, key, firstDispatchedAt } =
|
|
388
|
+
request;
|
|
389
|
+
if (
|
|
390
|
+
!equal(args.actualDispatch, {
|
|
391
|
+
scope,
|
|
392
|
+
apiVersion,
|
|
393
|
+
method,
|
|
394
|
+
path,
|
|
395
|
+
payload,
|
|
396
|
+
key,
|
|
397
|
+
firstDispatchedAt,
|
|
398
|
+
})
|
|
399
|
+
)
|
|
400
|
+
throw Error();
|
|
401
|
+
// These raw selectors have just been revalidated through complete C1-C6.
|
|
402
|
+
const expected = configuration.preparation.expected;
|
|
403
|
+
const billingCustomerId = resourceId("cus").parse(
|
|
404
|
+
(configuration.billingCustomer as Record<string, unknown>).id,
|
|
405
|
+
);
|
|
406
|
+
assertAttachmentIdentity(args.providerSnapshot, {
|
|
407
|
+
scheduleId: request.scheduleId,
|
|
408
|
+
subscriptionId: expected.subscriptionId,
|
|
409
|
+
customerAccountId: expected.customerAccountId,
|
|
410
|
+
billingCustomerId,
|
|
411
|
+
livemode: expected.livemode,
|
|
412
|
+
});
|
|
413
|
+
const providerSnapshotBinding = await renewalBindingV2(
|
|
414
|
+
"renewal-configured-baseline",
|
|
415
|
+
args.providerSnapshot,
|
|
416
|
+
);
|
|
417
|
+
const defaultsPresent = Object.prototype.hasOwnProperty.call(
|
|
418
|
+
args.providerSnapshot,
|
|
419
|
+
"default_settings",
|
|
420
|
+
);
|
|
421
|
+
const defaults = defaultsPresent
|
|
422
|
+
? {
|
|
423
|
+
defaultSettingsBinding: await renewalBindingV2(
|
|
424
|
+
"renewal-configured-defaults",
|
|
425
|
+
args.providerSnapshot.default_settings,
|
|
426
|
+
),
|
|
427
|
+
}
|
|
428
|
+
: {};
|
|
429
|
+
const receipt = {
|
|
430
|
+
version: 2 as const,
|
|
431
|
+
stage: "configure_acknowledged" as const,
|
|
432
|
+
scope: "platform" as const,
|
|
433
|
+
verification: "owned_response_only" as const,
|
|
434
|
+
apiVersion: request.apiVersion,
|
|
435
|
+
logicalBinding: request.logicalBinding,
|
|
436
|
+
request,
|
|
437
|
+
attachReceiptBinding: request.attachReceiptBinding,
|
|
438
|
+
scheduleId: request.scheduleId,
|
|
439
|
+
subscriptionId: expected.subscriptionId,
|
|
440
|
+
customerAccountId: expected.customerAccountId,
|
|
441
|
+
billingCustomerId,
|
|
442
|
+
livemode: expected.livemode,
|
|
443
|
+
providerSnapshot: args.providerSnapshot,
|
|
444
|
+
transport: args.transport,
|
|
445
|
+
providerSnapshotBinding,
|
|
446
|
+
...defaults,
|
|
447
|
+
};
|
|
448
|
+
return renewalSnapshot({
|
|
449
|
+
...receipt,
|
|
450
|
+
binding: await renewalBindingV2("renewal-configure-receipt", receipt),
|
|
451
|
+
});
|
|
452
|
+
} catch {
|
|
453
|
+
throw Error("Invalid renewal configuration receipt input.");
|
|
454
|
+
}
|
|
455
|
+
}
|
package/src/client/renewal.ts
CHANGED
|
@@ -16,6 +16,7 @@ export {
|
|
|
16
16
|
prepareRenewalScheduleAttachmentV2,
|
|
17
17
|
constructRenewalScheduleAttachmentReceiptV2,
|
|
18
18
|
projectRenewalConfigurationV2,
|
|
19
|
+
constructRenewalConfigurationReceiptV2,
|
|
19
20
|
} from "./billing/renewalV2/index.js";
|
|
20
21
|
export type {
|
|
21
22
|
PrepareRenewalPriceReplacementV2Options,
|
|
@@ -27,4 +28,6 @@ export type {
|
|
|
27
28
|
ProjectRenewalConfigurationV2Options,
|
|
28
29
|
ProjectedRenewalConfigurationV2,
|
|
29
30
|
RenewalConfigurationProjectionFailure,
|
|
31
|
+
ConstructRenewalConfigurationReceiptV2Options,
|
|
32
|
+
RenewalConfigurationReceiptV2,
|
|
30
33
|
} from "./billing/renewalV2/index.js";
|