@fantastic.dev/better-stripe 0.112.0 → 0.119.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +94 -0
- package/MIGRATION.md +50 -4
- package/README.md +69 -2
- package/dist/client/billing/renewalAggregate/phases.d.ts.map +1 -1
- package/dist/client/billing/renewalAggregate/phases.js +27 -13
- package/dist/client/billing/renewalAggregate/phases.js.map +1 -1
- package/dist/client/billing/renewalAggregate/preflight.d.ts +1 -0
- package/dist/client/billing/renewalAggregate/preflight.d.ts.map +1 -1
- package/dist/client/billing/renewalAggregate/readMaterial.d.ts +2 -1
- package/dist/client/billing/renewalAggregate/readMaterial.d.ts.map +1 -1
- package/dist/client/billing/renewalAggregate/readMaterial.js +28 -5
- package/dist/client/billing/renewalAggregate/readMaterial.js.map +1 -1
- package/dist/client/billing/renewalAggregate/sourceDiscounts.d.ts +1 -1
- package/dist/client/billing/renewalAggregate/sourceDiscounts.d.ts.map +1 -1
- package/dist/client/billing/renewalAggregate/sourceDiscounts.js +2 -2
- package/dist/client/billing/renewalAggregate/sourceDiscounts.js.map +1 -1
- package/dist/client/billing/renewalAttach/attachmentProfile.d.ts +13 -0
- package/dist/client/billing/renewalAttach/attachmentProfile.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/attachmentProfile.js +15 -0
- package/dist/client/billing/renewalAttach/attachmentProfile.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/c10/eventCapture.js +1 -1
- package/dist/client/billing/renewalAttach/internal/c10/eventCapture.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/material/classifiers.d.ts +1 -1
- package/dist/client/billing/renewalAttach/internal/material/classifiers.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/material/classifiers.js +11 -10
- package/dist/client/billing/renewalAttach/internal/material/classifiers.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/material/readMaterial.d.ts +1 -1
- package/dist/client/billing/renewalAttach/internal/material/readMaterial.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/material/readMaterial.js +20 -5
- package/dist/client/billing/renewalAttach/internal/material/readMaterial.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.js +7 -7
- package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js +5 -3
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/preflight/grammar.js +1 -1
- package/dist/client/billing/renewalAttach/internal/preflight/grammar.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/attachAcknowledgement.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/attachAcknowledgement.js +4 -4
- package/dist/client/billing/renewalAttach/internal/producer/attachAcknowledgement.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/configureWriteFactory.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/configureWriteFactory.js +7 -6
- package/dist/client/billing/renewalAttach/internal/producer/configureWriteFactory.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.d.ts +3 -0
- package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.js +16 -1
- package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/nodeAttachmentProfile.d.ts +9 -0
- package/dist/client/billing/renewalAttach/internal/producer/nodeAttachmentProfile.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/nodeAttachmentProfile.js +83 -0
- package/dist/client/billing/renewalAttach/internal/producer/nodeAttachmentProfile.js.map +1 -0
- package/dist/client/billing/renewalAttach/liveAttachment.d.ts +12 -0
- package/dist/client/billing/renewalAttach/liveAttachment.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/liveAttachment.js +23 -0
- package/dist/client/billing/renewalAttach/liveAttachment.js.map +1 -0
- package/dist/client/billing/renewalAttach/nodeAttachment.d.ts +4 -0
- package/dist/client/billing/renewalAttach/nodeAttachment.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/nodeAttachment.js +154 -0
- package/dist/client/billing/renewalAttach/nodeAttachment.js.map +1 -0
- package/dist/client/billing/renewalAttach/nodeConfiguration.d.ts +3 -0
- package/dist/client/billing/renewalAttach/nodeConfiguration.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/nodeConfiguration.js +126 -0
- package/dist/client/billing/renewalAttach/nodeConfiguration.js.map +1 -0
- 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 +2 -1
- package/dist/client/billing/renewalV2/configureInput.js.map +1 -1
- package/dist/client/billing/renewalV2/index.d.ts +3 -0
- package/dist/client/billing/renewalV2/index.d.ts.map +1 -1
- package/dist/client/billing/renewalV2/index.js +1 -1
- package/dist/client/billing/renewalV2/index.js.map +1 -1
- package/dist/client/billing/renewalV2/observationInput.d.ts +1 -0
- package/dist/client/billing/renewalV2/observationInput.d.ts.map +1 -1
- package/dist/client/index.d.ts +7 -14
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +10 -2
- package/dist/client/index.js.map +1 -1
- package/dist/client/node.d.ts +2 -0
- package/dist/client/node.d.ts.map +1 -0
- package/dist/client/node.js +9 -0
- package/dist/client/node.js.map +1 -0
- package/dist/client/renewal.d.ts +4 -0
- package/dist/client/renewal.d.ts.map +1 -1
- package/dist/client/renewal.js +2 -1
- package/dist/client/renewal.js.map +1 -1
- package/dist/client/renewalAttachmentPreparation.d.ts +23 -0
- package/dist/client/renewalAttachmentPreparation.d.ts.map +1 -0
- package/dist/client/renewalAttachmentPreparation.js +89 -0
- package/dist/client/renewalAttachmentPreparation.js.map +1 -0
- package/dist/client/renewalAttachmentRuntime.d.ts +6 -0
- package/dist/client/renewalAttachmentRuntime.d.ts.map +1 -0
- package/dist/client/renewalAttachmentRuntime.js +13 -0
- package/dist/client/renewalAttachmentRuntime.js.map +1 -0
- package/dist/client/renewalAttachmentTypes.d.ts +45 -0
- package/dist/client/renewalAttachmentTypes.d.ts.map +1 -0
- package/dist/client/renewalAttachmentTypes.js +2 -0
- package/dist/client/renewalAttachmentTypes.js.map +1 -0
- package/dist/client/renewalConfigurationPreparation.d.ts +27 -0
- package/dist/client/renewalConfigurationPreparation.d.ts.map +1 -0
- package/dist/client/renewalConfigurationPreparation.js +78 -0
- package/dist/client/renewalConfigurationPreparation.js.map +1 -0
- package/dist/client/renewalConfigurationRuntime.d.ts +6 -0
- package/dist/client/renewalConfigurationRuntime.d.ts.map +1 -0
- package/dist/client/renewalConfigurationRuntime.js +12 -0
- package/dist/client/renewalConfigurationRuntime.js.map +1 -0
- package/dist/client/renewalConfigurationTypes.d.ts +19 -0
- package/dist/client/renewalConfigurationTypes.d.ts.map +1 -0
- package/dist/client/renewalConfigurationTypes.js +2 -0
- package/dist/client/renewalConfigurationTypes.js.map +1 -0
- package/dist/client/renewalContextClient.d.ts +5 -0
- package/dist/client/renewalContextClient.d.ts.map +1 -1
- package/dist/client/renewalContextClient.js +9 -0
- package/dist/client/renewalContextClient.js.map +1 -1
- package/dist/client/types/documents.d.ts +2 -0
- package/dist/client/types/documents.d.ts.map +1 -1
- package/dist/client/webhooks/helpers.d.ts.map +1 -1
- package/dist/client/webhooks/helpers.js +1 -0
- package/dist/client/webhooks/helpers.js.map +1 -1
- package/dist/client/webhooks/ledger.d.ts +31 -0
- package/dist/client/webhooks/ledger.d.ts.map +1 -0
- package/dist/client/webhooks/ledger.js +13 -0
- package/dist/client/webhooks/ledger.js.map +1 -0
- package/dist/client/webhooks/processors.d.ts.map +1 -1
- package/dist/client/webhooks/processors.js +6 -3
- package/dist/client/webhooks/processors.js.map +1 -1
- package/dist/client/webhooks/subscriptionDeleted.d.ts.map +1 -1
- package/dist/client/webhooks/subscriptionDeleted.js +3 -2
- package/dist/client/webhooks/subscriptionDeleted.js.map +1 -1
- package/dist/component/_generated/api.d.ts +2 -0
- package/dist/component/_generated/api.d.ts.map +1 -1
- package/dist/component/_generated/api.js.map +1 -1
- package/dist/component/_generated/component.d.ts +18 -1
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
- package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
- package/dist/component/billing/mutations.d.ts +2 -1
- package/dist/component/billing/mutations.d.ts.map +1 -1
- package/dist/component/billing/mutations.js +28 -3
- package/dist/component/billing/mutations.js.map +1 -1
- package/dist/component/billing/queries.d.ts +8 -0
- package/dist/component/billing/queries.d.ts.map +1 -1
- package/dist/component/billing/schema.d.ts +3 -1
- package/dist/component/billing/schema.d.ts.map +1 -1
- package/dist/component/billing/validators.d.ts +16 -1
- package/dist/component/billing/validators.d.ts.map +1 -1
- package/dist/component/billing/validators.js +8 -0
- package/dist/component/billing/validators.js.map +1 -1
- package/dist/component/billingHistory/queries.d.ts +1 -0
- package/dist/component/billingHistory/queries.d.ts.map +1 -1
- package/dist/component/core/mutations.d.ts +4 -0
- package/dist/component/core/mutations.d.ts.map +1 -1
- package/dist/component/core/mutations.js +6 -0
- package/dist/component/core/mutations.js.map +1 -1
- package/dist/component/core/stripeMode.d.ts +8 -0
- package/dist/component/core/stripeMode.d.ts.map +1 -0
- package/dist/component/core/stripeMode.js +23 -0
- package/dist/component/core/stripeMode.js.map +1 -0
- package/dist/component/earnings/triggers.d.ts +6 -4
- package/dist/component/earnings/triggers.d.ts.map +1 -1
- package/dist/component/financialObservations/settlementHelpers.d.ts +3 -3
- 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/dist/component/schema.d.ts +4 -2
- package/dist/component/webhooks/mutations.d.ts +19 -0
- package/dist/component/webhooks/mutations.d.ts.map +1 -1
- package/dist/component/webhooks/mutations.js +56 -0
- package/dist/component/webhooks/mutations.js.map +1 -1
- package/dist/component/webhooks/schema.d.ts +1 -1
- package/dist/component/webhooks/schema.d.ts.map +1 -1
- package/dist/component/webhooks/schema.js +2 -1
- package/dist/component/webhooks/schema.js.map +1 -1
- package/docs/README.md +43 -8
- package/docs/billing-history.md +1 -1
- package/docs/client-api.md +63 -10
- package/docs/evidence/native-metering/mixed-settlement-2026-10-20.json +1 -1
- package/docs/evidence/native-metering/product-flows-2026-10-19.json +1 -1
- package/docs/example-routing.md +93 -0
- package/docs/pull-request-standard.md +142 -0
- package/docs/react-workflows-audit.md +1 -2
- package/docs/read-contracts.md +6 -5
- package/docs/releasing.md +27 -2
- package/docs/renewal-attachment.md +176 -0
- package/docs/renewal-configuration.md +127 -0
- package/docs/renewal-context-reads.md +9 -5
- package/docs/renewal-example-authorization.md +74 -0
- package/docs/settlement.md +2 -1
- package/docs/stripe-sandbox-worktrees.md +245 -0
- package/docs/webhooks.md +110 -1
- package/docs/worktrees.md +134 -0
- package/package.json +14 -2
- package/src/client/billing/renewalAggregate/phases.ts +31 -13
- package/src/client/billing/renewalAggregate/readMaterial.ts +36 -2
- package/src/client/billing/renewalAggregate/sourceDiscounts.ts +3 -1
- package/src/client/billing/renewalAttach/attachmentProfile.ts +22 -0
- package/src/client/billing/renewalAttach/internal/c10/eventCapture.ts +1 -1
- package/src/client/billing/renewalAttach/internal/material/classifiers.ts +26 -7
- package/src/client/billing/renewalAttach/internal/material/readMaterial.ts +26 -2
- package/src/client/billing/renewalAttach/internal/operations/configureReadTransport.ts +10 -9
- package/src/client/billing/renewalAttach/internal/operations/initialAttach.ts +5 -3
- package/src/client/billing/renewalAttach/internal/preflight/grammar.ts +1 -1
- package/src/client/billing/renewalAttach/internal/producer/attachAcknowledgement.ts +4 -6
- package/src/client/billing/renewalAttach/internal/producer/configureWriteFactory.ts +10 -8
- package/src/client/billing/renewalAttach/internal/producer/invocationProducer.ts +28 -1
- package/src/client/billing/renewalAttach/internal/producer/nodeAttachmentProfile.ts +108 -0
- package/src/client/billing/renewalAttach/liveAttachment.ts +43 -0
- package/src/client/billing/renewalAttach/nodeAttachment.ts +181 -0
- package/src/client/billing/renewalAttach/nodeConfiguration.ts +147 -0
- package/src/client/billing/renewalV2/configureInput.ts +2 -1
- package/src/client/billing/renewalV2/index.ts +7 -1
- package/src/client/index.ts +13 -15
- package/src/client/node.ts +8 -0
- package/src/client/renewal.ts +17 -0
- package/src/client/renewalAttachmentPreparation.ts +118 -0
- package/src/client/renewalAttachmentRuntime.ts +25 -0
- package/src/client/renewalAttachmentTypes.ts +51 -0
- package/src/client/renewalConfigurationPreparation.ts +92 -0
- package/src/client/renewalConfigurationRuntime.ts +24 -0
- package/src/client/renewalConfigurationTypes.ts +30 -0
- package/src/client/renewalContextClient.ts +22 -0
- package/src/client/types/documents.ts +2 -0
- package/src/client/webhooks/helpers.ts +1 -0
- package/src/client/webhooks/ledger.ts +48 -0
- package/src/client/webhooks/processors.ts +5 -0
- package/src/client/webhooks/subscriptionDeleted.ts +3 -2
- package/src/component/_generated/api.ts +2 -0
- package/src/component/_generated/component.ts +18 -1
- package/src/component/billing/mutations.ts +35 -2
- package/src/component/billing/validators.ts +12 -0
- package/src/component/core/mutations.ts +6 -0
- package/src/component/core/stripeMode.ts +30 -0
- package/src/component/webhooks/mutations.ts +66 -0
- package/src/component/webhooks/schema.ts +2 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/array-order.test.d.ts +0 -2
- package/dist/client/billing/renewalAttach/internal/acquisition/array-order.test.d.ts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/array-order.test.js +0 -61
- package/dist/client/billing/renewalAttach/internal/acquisition/array-order.test.js.map +0 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/coupon-stop-order.test.d.ts +0 -2
- package/dist/client/billing/renewalAttach/internal/acquisition/coupon-stop-order.test.d.ts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/coupon-stop-order.test.js +0 -18
- package/dist/client/billing/renewalAttach/internal/acquisition/coupon-stop-order.test.js.map +0 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/fetch-metadata.test.d.ts +0 -2
- package/dist/client/billing/renewalAttach/internal/acquisition/fetch-metadata.test.d.ts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/fetch-metadata.test.js +0 -67
- package/dist/client/billing/renewalAttach/internal/acquisition/fetch-metadata.test.js.map +0 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/raw-acquisition.test.d.ts +0 -2
- package/dist/client/billing/renewalAttach/internal/acquisition/raw-acquisition.test.d.ts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/raw-acquisition.test.js +0 -372
- package/dist/client/billing/renewalAttach/internal/acquisition/raw-acquisition.test.js.map +0 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/sourceBinding.test.d.ts +0 -2
- package/dist/client/billing/renewalAttach/internal/acquisition/sourceBinding.test.d.ts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/sourceBinding.test.js +0 -126
- package/dist/client/billing/renewalAttach/internal/acquisition/sourceBinding.test.js.map +0 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/fixture.d.mts +0 -627
- package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/fixture.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/fixture.mjs +0 -488
- package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/fixture.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/raw-retention-fixture.d.mts +0 -214
- package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/raw-retention-fixture.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/raw-retention-fixture.mjs +0 -63
- package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/raw-retention-fixture.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/scenario.d.mts +0 -75
- package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/scenario.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/scenario.mjs +0 -145
- package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/scenario.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/sourcePort.d.mts +0 -7
- package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/sourcePort.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/sourcePort.mjs +0 -26
- package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/sourcePort.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/compilerIndex.d.mts +0 -3
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/compilerIndex.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/compilerIndex.mjs +0 -4
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/compilerIndex.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/fixture.d.mts +0 -26
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/fixture.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/fixture.mjs +0 -42
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/fixture.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f00.d.mts +0 -7
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f00.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f00.mjs +0 -60
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f00.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f01.d.mts +0 -335
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f01.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f01.mjs +0 -122
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f01.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f02.d.mts +0 -46
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f02.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f02.mjs +0 -87
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f02.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f03.d.mts +0 -35
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f03.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f03.mjs +0 -90
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f03.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f04.d.mts +0 -132
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f04.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f04.mjs +0 -82
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f04.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f05.d.mts +0 -4
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f05.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f05.mjs +0 -23
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f05.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f06.d.mts +0 -16
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f06.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f06.mjs +0 -41
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f06.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f07.d.mts +0 -43
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f07.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f07.mjs +0 -132
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f07.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f08.d.mts +0 -200
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f08.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f08.mjs +0 -150
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f08.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f09.d.mts +0 -124
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f09.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f09.mjs +0 -127
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f09.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f10.d.mts +0 -3
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f10.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f10.mjs +0 -69
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f10.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f11.d.mts +0 -2
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f11.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f11.mjs +0 -152
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f11.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f12.d.mts +0 -2
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f12.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f12.mjs +0 -2
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f12.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f13.d.mts +0 -5
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f13.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f13.mjs +0 -243
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f13.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f14.d.mts +0 -17
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f14.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f14.mjs +0 -75
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f14.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f15.d.mts +0 -2
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f15.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f15.mjs +0 -173
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f15.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f16.d.mts +0 -4
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f16.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f16.mjs +0 -4
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f16.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f17.d.mts +0 -7
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f17.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f17.mjs +0 -30
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f17.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f18.d.mts +0 -29
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f18.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f18.mjs +0 -33
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f18.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f19.json +0 -452
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f20.d.mts +0 -2
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f20.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f20.mjs +0 -173
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f20.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f21.d.mts +0 -2
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f21.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f21.mjs +0 -449
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f21.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f22.d.mts +0 -9
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f22.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f22.mjs +0 -27
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f22.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f23.d.mts +0 -7
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f23.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f23.mjs +0 -150
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f23.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f24.d.mts +0 -3
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f24.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f24.mjs +0 -503
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f24.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f25.d.mts +0 -2
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f25.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f25.mjs +0 -91
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f25.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f26.d.mts +0 -14
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f26.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f26.mjs +0 -41
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f26.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f27.d.mts +0 -103
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f27.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f27.mjs +0 -46
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f27.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f28.d.mts +0 -73
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f28.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f28.mjs +0 -294
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f28.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f29.d.mts +0 -2
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f29.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f29.mjs +0 -60
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f29.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/publishedRawkeyHelper.d.mts +0 -58
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/publishedRawkeyHelper.d.mts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/publishedRawkeyHelper.mjs +0 -96
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/publishedRawkeyHelper.mjs.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/semanticSetup.d.ts +0 -2
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/semanticSetup.d.ts.map +0 -1
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/semanticSetup.js +0 -40
- package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/semanticSetup.js.map +0 -1
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +0 -10349
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +0 -1
- package/dist/client/connect/payoutAdoptionTestHelpers.js +0 -242
- package/dist/client/connect/payoutAdoptionTestHelpers.js.map +0 -1
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +0 -5166
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +0 -1
- package/dist/client/connect/payoutExecutionTestHelpers.js +0 -208
- package/dist/client/connect/payoutExecutionTestHelpers.js.map +0 -1
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +0 -10341
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +0 -1
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.js +0 -55
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.js.map +0 -1
- package/dist/client/connect/payoutSyncTestHelpers.d.ts +0 -5098
- package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +0 -1
- package/dist/client/connect/payoutSyncTestHelpers.js +0 -62
- package/dist/client/connect/payoutSyncTestHelpers.js.map +0 -1
- package/dist/client/paymentSource/resolver.fixtures.d.ts +0 -220
- package/dist/client/paymentSource/resolver.fixtures.d.ts.map +0 -1
- package/dist/client/paymentSource/resolver.fixtures.js +0 -189
- package/dist/client/paymentSource/resolver.fixtures.js.map +0 -1
- package/dist/client/recoveryWorkflow/provider.fixture.d.ts +0 -21
- package/dist/client/recoveryWorkflow/provider.fixture.d.ts.map +0 -1
- package/dist/client/recoveryWorkflow/provider.fixture.js +0 -125
- package/dist/client/recoveryWorkflow/provider.fixture.js.map +0 -1
- package/dist/client/settlement/authorization.fixture.d.ts +0 -148
- package/dist/client/settlement/authorization.fixture.d.ts.map +0 -1
- package/dist/client/settlement/authorization.fixture.js +0 -178
- package/dist/client/settlement/authorization.fixture.js.map +0 -1
- package/dist/client/setup.test.d.ts +0 -18
- package/dist/client/setup.test.d.ts.map +0 -1
- package/dist/client/setup.test.js +0 -33
- package/dist/client/setup.test.js.map +0 -1
- package/dist/client/usage/correctionTransport.fixtures.d.ts +0 -37
- package/dist/client/usage/correctionTransport.fixtures.d.ts.map +0 -1
- package/dist/client/usage/correctionTransport.fixtures.js +0 -322
- package/dist/client/usage/correctionTransport.fixtures.js.map +0 -1
- package/dist/client/usage/creditSettlement.fixtures.d.ts +0 -216
- package/dist/client/usage/creditSettlement.fixtures.d.ts.map +0 -1
- package/dist/client/usage/creditSettlement.fixtures.js +0 -59
- package/dist/client/usage/creditSettlement.fixtures.js.map +0 -1
- package/dist/client/usage/creditTransport.fixtures.d.ts +0 -108
- package/dist/client/usage/creditTransport.fixtures.d.ts.map +0 -1
- package/dist/client/usage/creditTransport.fixtures.js +0 -293
- package/dist/client/usage/creditTransport.fixtures.js.map +0 -1
- package/dist/client/usage/invoiceSale.fixtures.d.ts +0 -285
- package/dist/client/usage/invoiceSale.fixtures.d.ts.map +0 -1
- package/dist/client/usage/invoiceSale.fixtures.js +0 -104
- package/dist/client/usage/invoiceSale.fixtures.js.map +0 -1
- package/dist/client/usage/mixedInvoice.fixtures.d.ts +0 -315
- package/dist/client/usage/mixedInvoice.fixtures.d.ts.map +0 -1
- package/dist/client/usage/mixedInvoice.fixtures.js +0 -55
- package/dist/client/usage/mixedInvoice.fixtures.js.map +0 -1
- package/dist/client/usage/subscription.fixtures.d.ts +0 -118
- package/dist/client/usage/subscription.fixtures.d.ts.map +0 -1
- package/dist/client/usage/subscription.fixtures.js +0 -84
- package/dist/client/usage/subscription.fixtures.js.map +0 -1
- package/dist/client/usage/subscriptionTransport.fixtures.d.ts +0 -25
- package/dist/client/usage/subscriptionTransport.fixtures.d.ts.map +0 -1
- package/dist/client/usage/subscriptionTransport.fixtures.js +0 -206
- package/dist/client/usage/subscriptionTransport.fixtures.js.map +0 -1
- package/dist/client/webhooks/payoutReconciliationTestHelpers.d.ts +0 -117
- package/dist/client/webhooks/payoutReconciliationTestHelpers.d.ts.map +0 -1
- package/dist/client/webhooks/payoutReconciliationTestHelpers.js +0 -105
- package/dist/client/webhooks/payoutReconciliationTestHelpers.js.map +0 -1
- package/dist/component/usage/allowance.fixtures.d.ts +0 -5088
- package/dist/component/usage/allowance.fixtures.d.ts.map +0 -1
- package/dist/component/usage/allowance.fixtures.js +0 -67
- package/dist/component/usage/allowance.fixtures.js.map +0 -1
- package/dist/component/usageCredits/accounting.fixtures.d.ts +0 -5111
- package/dist/component/usageCredits/accounting.fixtures.d.ts.map +0 -1
- package/dist/component/usageCredits/accounting.fixtures.js +0 -89
- package/dist/component/usageCredits/accounting.fixtures.js.map +0 -1
- package/dist/react/workflows/Usage.fixtures.d.ts +0 -17
- package/dist/react/workflows/Usage.fixtures.d.ts.map +0 -1
- package/dist/react/workflows/Usage.fixtures.js +0 -79
- package/dist/react/workflows/Usage.fixtures.js.map +0 -1
- package/dist/test.d.ts +0 -6
- package/dist/test.d.ts.map +0 -1
- package/dist/test.js +0 -15
- package/dist/test.js.map +0 -1
- package/dist/testing/component-db.d.ts +0 -3
- package/dist/testing/component-db.d.ts.map +0 -1
- package/dist/testing/component-db.js +0 -26
- package/dist/testing/component-db.js.map +0 -1
- package/src/client/balanceFundingWorkflow/capture.test.ts +0 -144
- package/src/client/billing/balanceFunding.test.ts +0 -257
- package/src/client/billing/balanceFundingTransport.test.ts +0 -89
- package/src/client/billing/captured-checkout-payment.test.ts +0 -272
- package/src/client/billing/checkout-idempotency.test.ts +0 -82
- package/src/client/billing/checkout-ui-modes.test.ts +0 -49
- package/src/client/billing/checkout.test.ts +0 -1282
- package/src/client/billing/checkoutPages.test.ts +0 -270
- package/src/client/billing/historyPages.test.ts +0 -58
- package/src/client/billing/intents.test.ts +0 -216
- package/src/client/billing/intentsTransport.test.ts +0 -94
- package/src/client/billing/invoicePages.test.ts +0 -174
- package/src/client/billing/invoicePaymentPages.test.ts +0 -354
- package/src/client/billing/invoicePaymentRead.test.ts +0 -233
- package/src/client/billing/invoicePaymentReadTransport.test.ts +0 -101
- package/src/client/billing/invoicePreview.test.ts +0 -123
- package/src/client/billing/invoicePreviewTransport.test.ts +0 -70
- package/src/client/billing/invoices.test.ts +0 -243
- package/src/client/billing/prepared-checkout.test.ts +0 -430
- package/src/client/billing/providerReads.test.ts +0 -60
- package/src/client/billing/renewal-discount-projection.test.ts +0 -207
- package/src/client/billing/renewal-item-settings-projection.test.ts +0 -79
- package/src/client/billing/renewal-price-replacement.test.ts +0 -503
- package/src/client/billing/renewal-settings-projection.test.ts +0 -300
- package/src/client/billing/renewalAggregate/configure.test.ts +0 -372
- package/src/client/billing/renewalAggregate/preflight.test.ts +0 -233
- package/src/client/billing/renewalAggregate/sourceAndTaxRetention.test.ts +0 -247
- package/src/client/billing/renewalAttach/couponEvidence.test.ts +0 -103
- package/src/client/billing/renewalAttach/internal/acquisition/array-order.test.js +0 -70
- package/src/client/billing/renewalAttach/internal/acquisition/coupon-stop-order.test.js +0 -23
- package/src/client/billing/renewalAttach/internal/acquisition/fetch-metadata.test.js +0 -77
- package/src/client/billing/renewalAttach/internal/acquisition/raw-acquisition.test.js +0 -418
- package/src/client/billing/renewalAttach/internal/acquisition/sourceBinding.test.js +0 -138
- package/src/client/billing/renewalAttach/internal/acquisition/test-fixtures/fixture.mjs +0 -510
- package/src/client/billing/renewalAttach/internal/acquisition/test-fixtures/raw-retention-fixture.mjs +0 -64
- package/src/client/billing/renewalAttach/internal/acquisition/test-fixtures/scenario.mjs +0 -159
- package/src/client/billing/renewalAttach/internal/acquisition/test-fixtures/sourcePort.mjs +0 -25
- package/src/client/billing/renewalAttach/internal/c10/appendAck.first.test.ts +0 -86
- package/src/client/billing/renewalAttach/internal/c10/appendCodec.test.ts +0 -186
- package/src/client/billing/renewalAttach/internal/c10/arrayOrder.test.ts +0 -47
- package/src/client/billing/renewalAttach/internal/c10/compiler.test.ts +0 -443
- package/src/client/billing/renewalAttach/internal/c10/hardening.test.ts +0 -175
- package/src/client/billing/renewalAttach/internal/c10/historicalClassifier.test.ts +0 -114
- package/src/client/billing/renewalAttach/internal/c10/ownerContinuations.test.ts +0 -283
- package/src/client/billing/renewalAttach/internal/c10/reflectionPrivacy.test.ts +0 -87
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/compilerIndex.mjs +0 -3
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/fixture.mjs +0 -49
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f00.mjs +0 -63
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f01.mjs +0 -160
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f02.mjs +0 -88
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f03.mjs +0 -102
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f04.mjs +0 -82
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f05.mjs +0 -20
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f06.mjs +0 -41
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f07.mjs +0 -137
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f08.mjs +0 -153
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f09.mjs +0 -127
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f10.mjs +0 -85
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f11.mjs +0 -170
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f12.mjs +0 -6
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f13.mjs +0 -295
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f14.mjs +0 -78
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f15.mjs +0 -177
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f16.mjs +0 -8
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f17.mjs +0 -34
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f18.mjs +0 -32
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f19.json +0 -452
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f20.mjs +0 -177
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f21.mjs +0 -466
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f22.mjs +0 -29
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f23.mjs +0 -165
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f24.mjs +0 -507
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f25.mjs +0 -89
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f26.mjs +0 -38
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f27.mjs +0 -45
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f28.mjs +0 -309
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f29.mjs +0 -58
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/publishedRawkeyHelper.mjs +0 -104
- package/src/client/billing/renewalAttach/internal/c10/test-fixtures/semanticSetup.ts +0 -43
- package/src/client/billing/renewalAttach/internal/configure/dispatch.integration.test.ts +0 -32
- package/src/client/billing/renewalAttach/internal/configure/limits.test.ts +0 -510
- package/src/client/billing/renewalAttach/internal/configure/order.integration.test.ts +0 -207
- package/src/client/billing/renewalAttach/internal/configure/ownership.integration.test.ts +0 -148
- package/src/client/billing/renewalAttach/internal/configure/replay.integration.test.ts +0 -173
- package/src/client/billing/renewalAttach/internal/configure/transport.integration.test.ts +0 -507
- package/src/client/billing/renewalAttach/internal/material/classifiers.test.ts +0 -510
- package/src/client/billing/renewalAttach/internal/observation/freshActor.integration.test.ts +0 -360
- package/src/client/billing/renewalAttach/internal/observation/freshActorControls.integration.test.ts +0 -442
- package/src/client/billing/renewalAttach/internal/observation/history.integration.test.ts +0 -79
- package/src/client/billing/renewalAttach/internal/observation/historyControls.integration.test.ts +0 -238
- package/src/client/billing/renewalAttach/internal/observation/invoiceActor.integration.test.ts +0 -142
- package/src/client/billing/renewalAttach/internal/observation/invoiceActorControls.integration.test.ts +0 -495
- package/src/client/billing/renewalAttach/internal/observation/observation.integration.test.ts +0 -220
- package/src/client/billing/renewalAttach/internal/observation/observationConfigureACK.integration.test.ts +0 -36
- package/src/client/billing/renewalAttach/internal/observation/observationConfigureACKControls.integration.test.ts +0 -48
- package/src/client/billing/renewalAttach/internal/observation/observationConfigureACKLifecycle.integration.test.ts +0 -44
- package/src/client/billing/renewalAttach/internal/observation/observationConfiguredHistory.integration.test.ts +0 -34
- package/src/client/billing/renewalAttach/internal/observation/observationRetirement.integration.test.ts +0 -60
- package/src/client/billing/renewalAttach/internal/observation/reader.integration.test.ts +0 -93
- package/src/client/billing/renewalAttach/internal/observation/readerControls.integration.test.ts +0 -553
- package/src/client/billing/renewalAttach/internal/observation/witnessAcquisition.integration.test.ts +0 -348
- package/src/client/billing/renewalAttach/internal/observation/witnessActor.integration.test.ts +0 -204
- package/src/client/billing/renewalAttach/internal/observation/witnessCapabilities.integration.test.ts +0 -231
- package/src/client/billing/renewalAttach/internal/observation/witnessHistorical.integration.test.ts +0 -98
- package/src/client/billing/renewalAttach/internal/observation/witnessImmutable.integration.test.ts +0 -78
- package/src/client/billing/renewalAttach/internal/observation/witnessInvoice.integration.test.ts +0 -85
- package/src/client/billing/renewalAttach/internal/observation/witnessLifecycle.integration.test.ts +0 -264
- package/src/client/billing/renewalAttach/internal/observation/witnessProfile.integration.test.ts +0 -93
- package/src/client/billing/renewalAttach/internal/observation/witnessRPCControls.integration.test.ts +0 -256
- package/src/client/billing/renewalAttach/internal/operationJournal.acknowledgement.integration.test.ts +0 -500
- package/src/client/billing/renewalAttach/internal/operationJournal.c10.integration.test.ts +0 -560
- package/src/client/billing/renewalAttach/internal/operationJournal.controls.integration.test.ts +0 -356
- package/src/client/billing/renewalAttach/internal/operationJournal.integration.test.ts +0 -560
- package/src/client/billing/renewalAttach/internal/operationJournal.methods.integration.test.ts +0 -534
- package/src/client/billing/renewalAttach/internal/operations/defaultBindings.test.ts +0 -69
- package/src/client/billing/renewalAttach/internal/operations/initialAttach.integration.test.ts +0 -34
- package/src/client/billing/renewalAttach/internal/operations/providerFailure.integration.test.ts +0 -61
- package/src/client/billing/renewalAttach/internal/operations/transport.integration.test.ts +0 -116
- package/src/client/billing/renewalAttach/internal/originalOwner.test.ts +0 -258
- package/src/client/billing/renewalAttach/internal/preflight/configurePreflight.integration.test.ts +0 -285
- package/src/client/billing/renewalAttach/internal/preflight/configureReads.integration.test.ts +0 -139
- package/src/client/billing/renewalAttach/internal/preflight/owner.integration.test.ts +0 -82
- package/src/client/billing/renewalAttach/internal/preflight/preflight.integration.test.ts +0 -354
- package/src/client/billing/renewalAttach/internal/producer/producerAcknowledgement.integration.test.ts +0 -320
- package/src/client/billing/renewalAttach/internal/producer/producerAcknowledgementControls.integration.test.ts +0 -411
- package/src/client/billing/renewalAttach/internal/producer/producerAcquisition.integration.test.ts +0 -240
- package/src/client/billing/renewalAttach/internal/producer/producerActor.integration.test.ts +0 -526
- package/src/client/billing/renewalAttach/internal/producer/producerChannels.integration.test.ts +0 -350
- package/src/client/billing/renewalAttach/internal/producer/producerClock.integration.test.ts +0 -175
- package/src/client/billing/renewalAttach/internal/producer/producerConfigureAdmission.integration.test.ts +0 -203
- package/src/client/billing/renewalAttach/internal/producer/producerConfigureChannelControls.integration.test.ts +0 -542
- package/src/client/billing/renewalAttach/internal/producer/producerConfigureChannels.integration.test.ts +0 -321
- package/src/client/billing/renewalAttach/internal/producer/producerConfigureControls.integration.test.ts +0 -566
- package/src/client/billing/renewalAttach/internal/producer/producerConfigurePreflight.integration.test.ts +0 -67
- package/src/client/billing/renewalAttach/internal/producer/producerConfigurePreflightControls.integration.test.ts +0 -475
- package/src/client/billing/renewalAttach/internal/producer/producerConfigureRecovery.integration.test.ts +0 -99
- package/src/client/billing/renewalAttach/internal/producer/producerConfigureRecoveryControls.integration.test.ts +0 -420
- package/src/client/billing/renewalAttach/internal/producer/producerConfigureWrite.integration.test.ts +0 -158
- package/src/client/billing/renewalAttach/internal/producer/producerConfigureWriteControls.integration.test.ts +0 -549
- package/src/client/billing/renewalAttach/internal/producer/producerGuards.integration.test.ts +0 -323
- package/src/client/billing/renewalAttach/internal/producer/producerInitial.integration.test.ts +0 -301
- package/src/client/billing/renewalAttach/internal/producer/producerIsolation.integration.test.ts +0 -531
- package/src/client/billing/renewalAttach/internal/producer/producerMaterial.integration.test.ts +0 -251
- package/src/client/billing/renewalAttach/internal/producer/producerOwner.integration.test.ts +0 -449
- package/src/client/billing/renewalAttach/internal/producer/producerRecovery.integration.test.ts +0 -394
- package/src/client/billing/renewalAttach/internal/producer/producerRecoveryControls.integration.test.ts +0 -437
- package/src/client/billing/renewalAttach/internal/producer/producerRecoveryIsolation.integration.test.ts +0 -332
- package/src/client/billing/renewalAttach/internal/producer/producerTransport.integration.test.ts +0 -440
- package/src/client/billing/renewalAttach/internal/recovery/recovery.integration.test.ts +0 -463
- package/src/client/billing/renewalAttach/internal/sourceBindings.test.ts +0 -13
- package/src/client/billing/renewalAttach/internal/stockRawDelegate.test.ts +0 -156
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachEntries.ts +0 -217
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachObservations.ts +0 -226
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenario.ts +0 -556
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenarioAssertions.ts +0 -180
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenarioBarriers.ts +0 -144
- package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightAssertions.ts +0 -122
- package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightBarriers.ts +0 -330
- package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightControls.ts +0 -139
- package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightOperation.ts +0 -513
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadNativeBaseline.ts +0 -344
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadOperation.ts +0 -278
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadPort.ts +0 -17
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteAssertions.ts +0 -537
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteBarriers.ts +0 -125
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDeclarations.ts +0 -325
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDelegate.ts +0 -38
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteHistory.ts +0 -471
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteObservations.ts +0 -515
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteOperation.ts +0 -587
- package/src/client/billing/renewalAttach/internal/test-fixtures/freshObservation.ts +0 -94
- package/src/client/billing/renewalAttach/internal/test-fixtures/historySnapshot.ts +0 -51
- package/src/client/billing/renewalAttach/internal/test-fixtures/invoiceObservation.ts +0 -160
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationAssertions.ts +0 -211
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKAssertions.ts +0 -115
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKDeclarations.ts +0 -141
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleAssertions.ts +0 -74
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleDeclarations.ts +0 -79
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleInstrumentation.ts +0 -207
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleOperation.ts +0 -494
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKOperation.ts +0 -452
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryAssertions.ts +0 -88
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryDeclarations.ts +0 -170
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryNative.ts +0 -99
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryOperation.ts +0 -411
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationDeclarations.ts +0 -192
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationHTTP.ts +0 -197
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationObservations.ts +0 -269
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationOperation.ts +0 -262
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationProbe.ts +0 -319
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationReader.ts +0 -101
- package/src/client/billing/renewalAttach/internal/test-fixtures/ownedOperations.ts +0 -94
- package/src/client/billing/renewalAttach/internal/test-fixtures/producerConfigureAdmission.ts +0 -538
- package/src/client/billing/renewalAttach/internal/test-fixtures/producerInitialDeclarations.ts +0 -5
- package/src/client/billing/renewalAttach/internal/test-fixtures/producerInitialOperation.ts +0 -329
- package/src/client/billing/renewalAttach/internal/test-fixtures/sourceOperationPort.ts +0 -16
- package/src/client/billing/renewalAttach/internal/test-fixtures/stockHttp.ts +0 -21
- package/src/client/billing/renewalAttach/internal/test-fixtures/witnessHistory.ts +0 -70
- package/src/client/billing/renewalAttach/internal/test-fixtures/witnessObservation.ts +0 -353
- package/src/client/billing/renewalAttach/reader.test.ts +0 -409
- package/src/client/billing/renewalAttach/wireJson.test.ts +0 -265
- package/src/client/billing/renewalObservation/evidence-admission.test.ts +0 -219
- package/src/client/billing/renewalObservation/evidence-history.test.ts +0 -187
- package/src/client/billing/renewalObservation/evidence-invoice-controls.test.ts +0 -293
- package/src/client/billing/renewalObservation/evidence-invoice-identity.test.ts +0 -61
- package/src/client/billing/renewalObservation/evidence-invoice.test.ts +0 -177
- package/src/client/billing/renewalObservation/evidence-material.test.ts +0 -289
- package/src/client/billing/renewalObservation/evidence-v1.test.ts +0 -371
- package/src/client/billing/renewalV2/configure.test.ts +0 -362
- package/src/client/billing/renewalV2/configureReceipt.test.ts +0 -558
- package/src/client/billing/renewalV2/index.test.ts +0 -414
- package/src/client/billing/renewalV2/observation.boundary-review.test.ts +0 -49
- package/src/client/billing/renewalV2/observation.test.ts +0 -334
- package/src/client/billing/renewalV2/rawRetention.test.ts +0 -293
- package/src/client/billing/renewalV2/receipt.test.ts +0 -289
- package/src/client/billing/setup-intent-read.test.ts +0 -324
- package/src/client/billing/subscription-payment-method.test.ts +0 -460
- package/src/client/billing/subscriptionCancellation.test.ts +0 -68
- package/src/client/billing/subscriptions.test.ts +0 -1049
- package/src/client/charge-currency.test.ts +0 -113
- package/src/client/component-api-types.test.ts +0 -137
- package/src/client/connect/commissionReceipts.test.ts +0 -157
- package/src/client/connect/dispute-upload.test.ts +0 -208
- package/src/client/connect/disputes.test.ts +0 -502
- package/src/client/connect/paymentMethodUtils.test.ts +0 -83
- package/src/client/connect/paymentMethods.test.ts +0 -68
- package/src/client/connect/payoutAdoption.test.ts +0 -186
- package/src/client/connect/payoutAdoptionAge.test.ts +0 -89
- package/src/client/connect/payoutAdoptionAllocation.test.ts +0 -132
- package/src/client/connect/payoutAdoptionConcurrency.test.ts +0 -266
- package/src/client/connect/payoutAdoptionTestHelpers.ts +0 -269
- package/src/client/connect/payoutAllocation.test.ts +0 -325
- package/src/client/connect/payoutCacheIdentity.test.ts +0 -93
- package/src/client/connect/payoutCollection.test.ts +0 -74
- package/src/client/connect/payoutDeadline.test.ts +0 -238
- package/src/client/connect/payoutExecution.test.ts +0 -294
- package/src/client/connect/payoutExecutionTestHelpers.ts +0 -244
- package/src/client/connect/payoutHistory.test.ts +0 -145
- package/src/client/connect/payoutLargeAdoption.test.ts +0 -541
- package/src/client/connect/payoutLargeAdoptionTestHelpers.ts +0 -74
- package/src/client/connect/payoutLargeHistory.test.ts +0 -222
- package/src/client/connect/payoutLiabilityVersion.test.ts +0 -221
- package/src/client/connect/payoutOutcomeBatches.test.ts +0 -40
- package/src/client/connect/payoutPreview.test.ts +0 -414
- package/src/client/connect/payoutQualificationFreshness.test.ts +0 -192
- package/src/client/connect/payoutReceipt.test.ts +0 -312
- package/src/client/connect/payoutReconciliation.test.ts +0 -414
- package/src/client/connect/payoutReturnedAdoption.test.ts +0 -157
- package/src/client/connect/payoutSnapshot.test.ts +0 -118
- package/src/client/connect/payoutSync.test.ts +0 -313
- package/src/client/connect/payoutSyncTestHelpers.ts +0 -82
- package/src/client/connect/payoutWorker.test.ts +0 -201
- package/src/client/connect/payouts.test.ts +0 -132
- package/src/client/connect/refundActor.test.ts +0 -121
- package/src/client/connect/refundPrincipal.test.ts +0 -46
- package/src/client/connect/refundSync.test.ts +0 -239
- package/src/client/connect/refundSync.transport.test.ts +0 -396
- package/src/client/connect/refunds.test.ts +0 -438
- package/src/client/connect/transferReceipt.pagination.test.ts +0 -209
- package/src/client/connect/transferReceipt.test.ts +0 -520
- package/src/client/connect/transferReceiptBaseline.test.ts +0 -55
- package/src/client/connect/transfers.test.ts +0 -557
- package/src/client/core/account-close-guard.test.ts +0 -349
- package/src/client/core/account-close-orchestration.test.ts +0 -131
- package/src/client/core/account-closure-preview.test.ts +0 -219
- package/src/client/core/account-closure.test.ts +0 -317
- package/src/client/core/account-idempotency.test.ts +0 -78
- package/src/client/core/account-session-client.test.ts +0 -74
- package/src/client/core/accountConfigurations.test.ts +0 -183
- package/src/client/core/accountLinks.test.ts +0 -389
- package/src/client/core/accountStatus.test.ts +0 -169
- package/src/client/core/accounts.test.ts +0 -1385
- package/src/client/core/billingPortal.test.ts +0 -249
- package/src/client/core/billingPortalFlow.test.ts +0 -349
- package/src/client/core/billingPortalIdentity.test.ts +0 -418
- package/src/client/core/config.test.ts +0 -69
- package/src/client/core/descriptors.test.ts +0 -70
- package/src/client/core/fees.test.ts +0 -369
- package/src/client/core/idempotency.test.ts +0 -10
- package/src/client/core/personal-account-mapping.test.ts +0 -71
- package/src/client/costRecovery-import.test.ts +0 -174
- package/src/client/costRecovery-invoiceReceipt.test.ts +0 -140
- package/src/client/costRecovery-invoices.test.ts +0 -470
- package/src/client/costRecovery-invoices.transport.test.ts +0 -107
- package/src/client/costRecovery.test.ts +0 -110
- package/src/client/customer-preview-thin.test.ts +0 -41
- package/src/client/customer-preview-webhooks.test.ts +0 -150
- package/src/client/customer-preview.test.ts +0 -366
- package/src/client/errors.test.ts +0 -66
- package/src/client/financialObservations.test.ts +0 -109
- package/src/client/financialOutcomes/outcomes.test.ts +0 -254
- package/src/client/financialOwnership.test.ts +0 -80
- package/src/client/helpers.test.ts +0 -74
- package/src/client/index.test.ts +0 -1784
- package/src/client/operationEvidence.test.ts +0 -110
- package/src/client/originalIdReadOptions.test.ts +0 -63
- package/src/client/paymentSource/resolver.fixtures.ts +0 -216
- package/src/client/paymentSource/resolver.test.ts +0 -386
- package/src/client/payoutPolicy.test.ts +0 -579
- package/src/client/payoutRevisionMigration.test.ts +0 -40
- package/src/client/processingCostDeficit/calculator.test.ts +0 -176
- package/src/client/processingCostReconciliation/invoiceProvider.test.ts +0 -353
- package/src/client/processingCostReconciliation/provider.test.ts +0 -324
- package/src/client/products/catalog-idempotency.test.ts +0 -116
- package/src/client/products/catalog.test.ts +0 -389
- package/src/client/products/fixedPrice.test.ts +0 -57
- package/src/client/products/identity.test.ts +0 -91
- package/src/client/products/prices.test.ts +0 -375
- package/src/client/products/product-descriptor-inheritance.test.ts +0 -245
- package/src/client/products/product-descriptors.test.ts +0 -260
- package/src/client/products/product-set-idempotency.test.ts +0 -188
- package/src/client/products/products.test.ts +0 -517
- package/src/client/readPagination.test.ts +0 -83
- package/src/client/recoveryWorkflow/client.test.ts +0 -37
- package/src/client/recoveryWorkflow/provider.fixture.ts +0 -143
- package/src/client/recoveryWorkflow/provider.test.ts +0 -509
- package/src/client/refund-command-evidence.test.ts +0 -68
- package/src/client/refund-command-normalization.test.ts +0 -61
- package/src/client/refund-context-shapes.test.ts +0 -127
- package/src/client/refund-context.test.ts +0 -404
- package/src/client/refund-history.test.ts +0 -67
- package/src/client/reversalObservations.test.ts +0 -69
- package/src/client/settlement/allocation.test.ts +0 -98
- package/src/client/settlement/authorization.fixture.ts +0 -199
- package/src/client/settlement/authorization.test.ts +0 -160
- package/src/client/settlement/commissions.test.ts +0 -103
- package/src/client/settlement/execution.test.ts +0 -191
- package/src/client/settlement/policy-context.test.ts +0 -277
- package/src/client/settlement/processingCosts.test.ts +0 -349
- package/src/client/settlement/processingCostsTransport.test.ts +0 -135
- package/src/client/settlement/verifiedSale.test.ts +0 -139
- package/src/client/setup.test.ts +0 -47
- package/src/client/singleAttemptHttpClient.test.ts +0 -70
- package/src/client/strictStripeTransport.test.ts +0 -73
- package/src/client/stripe-version.test.ts +0 -53
- package/src/client/transferContinuation.test.ts +0 -90
- package/src/client/transferObservations.test.ts +0 -98
- package/src/client/usage/allowanceClient.test.ts +0 -93
- package/src/client/usage/allowanceTerms.test.ts +0 -131
- package/src/client/usage/boundaries.test.ts +0 -136
- package/src/client/usage/catalog.test.ts +0 -464
- package/src/client/usage/catalogMath.test.ts +0 -13
- package/src/client/usage/contracts.test.ts +0 -145
- package/src/client/usage/correctionClient.test.ts +0 -153
- package/src/client/usage/correctionCredits.test.ts +0 -156
- package/src/client/usage/correctionInvoice.test.ts +0 -127
- package/src/client/usage/correctionRecovery.test.ts +0 -113
- package/src/client/usage/correctionTransport.fixtures.ts +0 -372
- package/src/client/usage/creditBackingIsolation.test.ts +0 -110
- package/src/client/usage/creditCapacity.test.ts +0 -162
- package/src/client/usage/creditClient.test.ts +0 -221
- package/src/client/usage/creditInvoice.test.ts +0 -149
- package/src/client/usage/creditObservation.test.ts +0 -150
- package/src/client/usage/creditProofBounds.test.ts +0 -187
- package/src/client/usage/creditProvider.test.ts +0 -276
- package/src/client/usage/creditRevenue.test.ts +0 -105
- package/src/client/usage/creditSettlement.fixtures.ts +0 -70
- package/src/client/usage/creditSettlement.test.ts +0 -66
- package/src/client/usage/creditSettlementRecovery.test.ts +0 -173
- package/src/client/usage/creditTerms.test.ts +0 -48
- package/src/client/usage/creditTransport.fixtures.ts +0 -308
- package/src/client/usage/deliveryProvider.test.ts +0 -316
- package/src/client/usage/invoiceObservation.test.ts +0 -195
- package/src/client/usage/invoiceSale.fixtures.ts +0 -103
- package/src/client/usage/invoiceSale.test.ts +0 -252
- package/src/client/usage/ledger-client.test.ts +0 -74
- package/src/client/usage/mixedInvoice.fixtures.ts +0 -54
- package/src/client/usage/mixedInvoiceSale.test.ts +0 -92
- package/src/client/usage/mixedSettlement.test.ts +0 -187
- package/src/client/usage/providerObservation.test.ts +0 -207
- package/src/client/usage/reconciliation.test.ts +0 -117
- package/src/client/usage/record-composition.test.ts +0 -195
- package/src/client/usage/settlement.test.ts +0 -179
- package/src/client/usage/subscription.fixtures.ts +0 -84
- package/src/client/usage/subscriptionAbandonment.test.ts +0 -124
- package/src/client/usage/subscriptionCheckout.test.ts +0 -44
- package/src/client/usage/subscriptionClient.test.ts +0 -375
- package/src/client/usage/subscriptionProvider.test.ts +0 -48
- package/src/client/usage/subscriptionTerms.test.ts +0 -158
- package/src/client/usage/subscriptionTransport.fixtures.ts +0 -247
- package/src/client/usage/summary.test.ts +0 -222
- package/src/client/utils/data.test.ts +0 -61
- package/src/client/utils/owner.test.ts +0 -38
- package/src/client/utils/stripeDashboardUrl.test.ts +0 -71
- package/src/client/utils/webhookEndpoints.test.ts +0 -459
- package/src/client/webhook-handlers.test.ts +0 -569
- package/src/client/webhooks/handler.test.ts +0 -601
- package/src/client/webhooks/helpers.test.ts +0 -343
- package/src/client/webhooks/hooks.test.ts +0 -119
- package/src/client/webhooks/meterErrors.test.ts +0 -164
- package/src/client/webhooks/payout-canceled.integration.test.ts +0 -230
- package/src/client/webhooks/payout-reconciliation.integration.test.ts +0 -168
- package/src/client/webhooks/payoutReconciliationTestHelpers.ts +0 -135
- package/src/client/webhooks/processors.test.ts +0 -2553
- package/src/client/webhooks/refund-delivery.test.ts +0 -512
- package/src/client/webhooks/refund-reconciliation.test.ts +0 -320
- package/src/client/webhooks/retry.integration.test.ts +0 -196
- package/src/client/webhooks/subscription-deleted-dispatch.test.ts +0 -61
- package/src/client/webhooks/subscription-deleted.integration.test.ts +0 -313
- package/src/client/webhooks/usageSubscriptions.test.ts +0 -162
- package/src/client/webhooks/v2.test.ts +0 -432
- package/src/client/webhooks.test.ts +0 -1681
- package/src/component/accountClosure/blockers.test.ts +0 -114
- package/src/component/affiliatePayouts/affiliate-direct-payout.test.ts +0 -159
- package/src/component/affiliateRecovery/affiliate-component-pagination.test.ts +0 -56
- package/src/component/affiliateRecovery/affiliate-recovery-lifecycle.test.ts +0 -586
- package/src/component/balanceFunding/failure.test.ts +0 -116
- package/src/component/balanceFunding/import.test.ts +0 -221
- package/src/component/balanceFunding/lookup.test.ts +0 -113
- package/src/component/balanceFunding/preparation.test.ts +0 -146
- package/src/component/balanceFunding/requestLookup.test.ts +0 -160
- package/src/component/balanceFunding/scopeLookup.test.ts +0 -94
- package/src/component/balanceFunding/state.test.ts +0 -352
- package/src/component/balanceFunding/validation.test.ts +0 -100
- package/src/component/balanceFunding/workflow.fixtures.ts +0 -366
- package/src/component/balanceFunding/workflow.test.ts +0 -552
- package/src/component/billing/checkout.test.ts +0 -89
- package/src/component/billing/invoices.test.ts +0 -294
- package/src/component/billing/store-subscriptions.test.ts +0 -31
- package/src/component/billing/subscription-scoping.test.ts +0 -120
- package/src/component/billing/subscriptions.test.ts +0 -477
- package/src/component/billingHistory/guards.test.ts +0 -235
- package/src/component/billingHistory/options.test.ts +0 -35
- package/src/component/billingHistory/pages.test.ts +0 -74
- package/src/component/connect/connect.test.ts +0 -715
- package/src/component/connect/fee-routing.test.ts +0 -122
- package/src/component/connect/payment-unique.test.ts +0 -195
- package/src/component/connect/payments.test.ts +0 -88
- package/src/component/connect/payouts.test.ts +0 -173
- package/src/component/connect/reversal-races.test.ts +0 -958
- package/src/component/connect/seller-case-ownership.test.ts +0 -60
- package/src/component/connect/transfers.test.ts +0 -517
- package/src/component/core/accounts.test.ts +0 -266
- package/src/component/core/config-queries.test.ts +0 -49
- package/src/component/core/original-id-unique.test.ts +0 -209
- package/src/component/core/payout-reset-safety.test.ts +0 -175
- package/src/component/core/personal-account-mapping.test.ts +0 -173
- package/src/component/core/reset.test.ts +0 -131
- package/src/component/costRecovery/cost-recovery.test.ts +0 -343
- package/src/component/costRecovery/preparation.test.ts +0 -355
- package/src/component/durableExecution/composition.test.ts +0 -568
- package/src/component/durableExecution/crossDomain.test.ts +0 -241
- package/src/component/durableExecution/crossDomainBoundaries.test.ts +0 -233
- package/src/component/durableExecution/crossDomainDisputes.test.ts +0 -108
- package/src/component/durableExecution/crossDomainMigration.test.ts +0 -192
- package/src/component/durableExecution/crossDomainWebhooks.test.ts +0 -122
- package/src/component/earnings/currency-migration.test.ts +0 -118
- package/src/component/earnings/currency-totals.test.ts +0 -94
- package/src/component/earnings/earnings-totals.test.ts +0 -237
- package/src/component/earnings/paired-adjustment.test.ts +0 -258
- package/src/component/earnings/summary-arithmetic.test.ts +0 -250
- package/src/component/financialObservations/continuation.test.ts +0 -445
- package/src/component/financialObservations/observation-boundaries.test.ts +0 -466
- package/src/component/financialObservations/settlement-observations.test.ts +0 -86
- package/src/component/financialObservations/transfer-batches.test.ts +0 -61
- package/src/component/financialObservations/transfer-boundaries.test.ts +0 -116
- package/src/component/financialObservations/transfer-continuation-guards.test.ts +0 -428
- package/src/component/financialObservations/transfer-continuation.test.ts +0 -154
- package/src/component/financialObservations/transfer-observations.test.ts +0 -212
- package/src/component/financialObservations/transfer-overflow.test.ts +0 -181
- package/src/component/financialObservations/transfer-writers.test.ts +0 -162
- package/src/component/financialOwnership/financial-ownership.test.ts +0 -102
- package/src/component/financialOwnership/ownership-boundaries.test.ts +0 -308
- package/src/component/lib/idempotency.test.ts +0 -37
- package/src/component/operationEvidence/integrity.test.ts +0 -257
- package/src/component/operationEvidence/maintenance.test.ts +0 -152
- package/src/component/operationEvidence/reads.test.ts +0 -140
- package/src/component/payoutPolicy/payout-policy-adoption.test.ts +0 -130
- package/src/component/payoutPolicy/payout-policy.test.ts +0 -247
- package/src/component/payoutRelease/payout-adoption.test.ts +0 -268
- package/src/component/payoutRelease/payout-fees.test.ts +0 -223
- package/src/component/payoutRelease/payout-recovery-integration.test.ts +0 -171
- package/src/component/payoutRelease/payout-release-snapshot.test.ts +0 -56
- package/src/component/payoutRelease/payout-release.test.ts +0 -587
- package/src/component/payoutRelease/progress.test.ts +0 -63
- package/src/component/payoutSnapshots/legacy-revisions.test.ts +0 -246
- package/src/component/payoutSnapshots/payout-revisions.test.ts +0 -124
- package/src/component/payoutSnapshots/payout-snapshots.test.ts +0 -438
- package/src/component/payoutSnapshots/revision-journal-callbacks.test.ts +0 -160
- package/src/component/payoutSnapshots/revision-journal-held.test.ts +0 -94
- package/src/component/payoutSnapshots/revision-journal.test.ts +0 -310
- package/src/component/payoutSnapshots/revision-migration.test.ts +0 -128
- package/src/component/payoutSync/payout-sync.test.ts +0 -116
- package/src/component/payoutWorker/payout-component-pagination.test.ts +0 -211
- package/src/component/payoutWorker/payout-worker.test.ts +0 -164
- package/src/component/processingCostReconciliation/adoption.test.ts +0 -206
- package/src/component/processingCostReconciliation/invoice.test.ts +0 -152
- package/src/component/processingCostReconciliation/state.test.ts +0 -407
- package/src/component/processingCostReconciliation/workflow.test.ts +0 -329
- package/src/component/products/identity.test.ts +0 -217
- package/src/component/products/products.test.ts +0 -239
- package/src/component/products/provider-price-pagination.test.ts +0 -174
- package/src/component/products/read-pagination.test.ts +0 -192
- package/src/component/recoveryWorkflow/bridge.test.ts +0 -481
- package/src/component/recoveryWorkflow/journal.test.ts +0 -104
- package/src/component/recoveryWorkflow/state.test.ts +0 -191
- package/src/component/refundHistory/command-evidence.test.ts +0 -288
- package/src/component/refundHistory/command-normalization-resource.test.ts +0 -77
- package/src/component/refundHistory/command-normalization.test.ts +0 -229
- package/src/component/refundHistory/command-provenance.test.ts +0 -59
- package/src/component/refundHistory/original-seller-boundaries.test.ts +0 -138
- package/src/component/refundHistory/original-seller.test.ts +0 -175
- package/src/component/refundHistory/refund-history.test.ts +0 -197
- package/src/component/refundSync/refund-sync.test.ts +0 -255
- package/src/component/renewalOperations/acknowledgement.fixtures.ts +0 -552
- package/src/component/renewalOperations/acknowledgement.test.ts +0 -573
- package/src/component/renewalOperations/acknowledgementReads.test.ts +0 -442
- package/src/component/renewalOperations/acknowledgementV2.test.ts +0 -493
- package/src/component/renewalOperations/acknowledgementV2Publication.test.ts +0 -373
- package/src/component/renewalOperations/basisBinding.test.ts +0 -567
- package/src/component/renewalOperations/basisLifecycle.test.ts +0 -569
- package/src/component/renewalOperations/boundHistory.test.ts +0 -474
- package/src/component/renewalOperations/configureAcknowledgement.test.ts +0 -30
- package/src/component/renewalOperations/configureAcknowledgementControls.test.ts +0 -96
- package/src/component/renewalOperations/configureBasis.test.ts +0 -77
- package/src/component/renewalOperations/configureCreation.test.ts +0 -75
- package/src/component/renewalOperations/configureJournal.fixtures.ts +0 -407
- package/src/component/renewalOperations/configurePolicy.test.ts +0 -105
- package/src/component/renewalOperations/configurePublication.test.ts +0 -85
- package/src/component/renewalOperations/configureReceiptBounds.test.ts +0 -39
- package/src/component/renewalOperations/configureSourceControls.test.ts +0 -65
- package/src/component/renewalOperations/historyReads.test.ts +0 -595
- package/src/component/renewalOperations/initialBasis.test.ts +0 -578
- package/src/component/renewalOperations/journal.test.ts +0 -567
- package/src/component/renewalOperations/payload.test.ts +0 -589
- package/src/component/renewalOperations/payloadEncoding.test.ts +0 -592
- package/src/component/renewalOperations/timingPolicy.fixtures.ts +0 -193
- package/src/component/renewalOperations/timingPolicy.test.ts +0 -523
- package/src/component/renewalWitnesses/bounds.test.ts +0 -204
- package/src/component/renewalWitnesses/codec.test.ts +0 -84
- package/src/component/renewalWitnesses/controls.test.ts +0 -250
- package/src/component/renewalWitnesses/protocol.test.ts +0 -63
- package/src/component/renewalWitnesses/routes.test.ts +0 -154
- package/src/component/reversalObservations/boundaries.test.ts +0 -62
- package/src/component/reversalObservations/capture-integrity.test.ts +0 -119
- package/src/component/reversalObservations/continuation.test.ts +0 -131
- package/src/component/reversalObservations/lifecycle.test.ts +0 -81
- package/src/component/reversalObservations/provenance.test.ts +0 -167
- package/src/component/settlement/affiliate-clawbacks.test.ts +0 -369
- package/src/component/settlement/settlement-claims.test.ts +0 -130
- package/src/component/usage/allowance.fixtures.ts +0 -77
- package/src/component/usage/allowance.test.ts +0 -372
- package/src/component/usage/allowanceBounds.test.ts +0 -79
- package/src/component/usage/historyIsolation.test.ts +0 -124
- package/src/component/usage/ledger.test.ts +0 -303
- package/src/component/usageCorrections/corrections.test.ts +0 -389
- package/src/component/usageCredits/accounting.fixtures.ts +0 -96
- package/src/component/usageCredits/accounting.test.ts +0 -483
- package/src/component/usageCredits/freshness.test.ts +0 -33
- package/src/component/usageCredits/quotas.test.ts +0 -63
- package/src/component/usageDelivery/concurrency.test.ts +0 -62
- package/src/component/usageDelivery/workflow.test.ts +0 -402
- package/src/component/usageObservations/history.test.ts +0 -87
- package/src/component/usageObservations/queries.test.ts +0 -162
- package/src/component/usageSubscriptions/acceptance.test.ts +0 -122
- package/src/component/usageSubscriptions/history.test.ts +0 -126
- package/src/component/usageSubscriptions/mutations.test.ts +0 -205
- package/src/component/webhooks/events.test.ts +0 -121
- package/src/component/webhooks/triggers.test.ts +0 -360
- package/src/react/components/AccountOnboardingCard.test.ts +0 -27
- package/src/react/components/BuyerBillingView.render.test.tsx +0 -212
- package/src/react/components/ConnectProvider.live.test.tsx +0 -61
- package/src/react/components/DisputeDetail.render.test.tsx +0 -147
- package/src/react/components/DisputesList.render.test.tsx +0 -265
- package/src/react/components/EarningsSummary.render.test.tsx +0 -149
- package/src/react/components/EmbeddedCheckout.render.test.tsx +0 -57
- package/src/react/components/EmbeddedCheckout.test.ts +0 -25
- package/src/react/components/EmbeddedDisputes.render.test.tsx +0 -144
- package/src/react/components/EvidenceForm.render.test.tsx +0 -208
- package/src/react/components/PayoutSchedule.render.test.tsx +0 -193
- package/src/react/components/PriceBadge.render.test.tsx +0 -134
- package/src/react/components/PriceCard.render.test.tsx +0 -172
- package/src/react/components/SplitBreakdown.render.test.tsx +0 -191
- package/src/react/components/StripeProvider.test.ts +0 -45
- package/src/react/components/TrialAlert.render.test.tsx +0 -132
- package/src/react/hooks/skipSentinel.test.ts +0 -85
- package/src/react/hooks/useAccountOnboarding.test.ts +0 -75
- package/src/react/hooks/useCheckoutSession.promotions.test.tsx +0 -303
- package/src/react/hooks/useConfirmPayment.test.tsx +0 -47
- package/src/react/hooks/useCurrencyEarnings.test.ts +0 -59
- package/src/react/hooks/useDisputeWithCountdown.test.ts +0 -90
- package/src/react/hooks/useDisputes.test.ts +0 -75
- package/src/react/hooks/useEarnings.test.ts +0 -194
- package/src/react/hooks/useInvoices.test.ts +0 -79
- package/src/react/hooks/useProducts.test.ts +0 -75
- package/src/react/hooks/useSplitBreakdown.test.ts +0 -151
- package/src/react/hooks/useStripeMode.test.ts +0 -46
- package/src/react/hooks/useStripePublishableKey.test.ts +0 -35
- package/src/react/index.payment-element.test.ts +0 -26
- package/src/react/index.test.ts +0 -172
- package/src/react/lib/connect-requirement-keys.test.ts +0 -73
- package/src/react/lib/price-helpers.test.ts +0 -212
- package/src/react/lib/stripe-element-styles.test.ts +0 -94
- package/src/react/lib/subscription-helpers.test.ts +0 -127
- package/src/react/read-contracts.render.test.tsx +0 -20
- package/src/react/workflows/Account.test.tsx +0 -31
- package/src/react/workflows/AffiliatePayoutEditor.test.tsx +0 -90
- package/src/react/workflows/AffiliateRateEditor.test.tsx +0 -36
- package/src/react/workflows/AffiliateRecovery.test.tsx +0 -106
- package/src/react/workflows/Billing.test.tsx +0 -45
- package/src/react/workflows/BillingPlans.test.tsx +0 -31
- package/src/react/workflows/BillingPortal.test.tsx +0 -101
- package/src/react/workflows/Checkout.test.tsx +0 -148
- package/src/react/workflows/CheckoutChooser.test.tsx +0 -44
- package/src/react/workflows/CheckoutForm.test.tsx +0 -66
- package/src/react/workflows/CheckoutForms.test.tsx +0 -163
- package/src/react/workflows/ClipboardButton.test.tsx +0 -34
- package/src/react/workflows/Collections.test.tsx +0 -122
- package/src/react/workflows/Connect.test.tsx +0 -50
- package/src/react/workflows/Costs.test.tsx +0 -62
- package/src/react/workflows/Disputes.test.tsx +0 -64
- package/src/react/workflows/Earnings.test.ts +0 -19
- package/src/react/workflows/EvidenceUpload.test.tsx +0 -56
- package/src/react/workflows/Financials.test.tsx +0 -35
- package/src/react/workflows/IntegrationSwitch.test.tsx +0 -61
- package/src/react/workflows/Onboarding.test.tsx +0 -148
- package/src/react/workflows/Overview.test.tsx +0 -57
- package/src/react/workflows/Pagination.test.tsx +0 -53
- package/src/react/workflows/PaymentMethods.test.tsx +0 -60
- package/src/react/workflows/PaymentReceipt.test.tsx +0 -24
- package/src/react/workflows/PayoutProgress.test.tsx +0 -356
- package/src/react/workflows/PayoutSettings.test.tsx +0 -139
- package/src/react/workflows/Payouts.test.tsx +0 -145
- package/src/react/workflows/PlanPricingEditor.currency.test.tsx +0 -164
- package/src/react/workflows/PlanPricingEditor.test.tsx +0 -79
- package/src/react/workflows/PlanPricingEditor.zero.test.tsx +0 -100
- package/src/react/workflows/Products.test.tsx +0 -282
- package/src/react/workflows/ReferralLinks.test.tsx +0 -39
- package/src/react/workflows/Refunds.currency.test.tsx +0 -290
- package/src/react/workflows/Refunds.test.tsx +0 -75
- package/src/react/workflows/SaveCard.test.tsx +0 -127
- package/src/react/workflows/Setup.test.tsx +0 -25
- package/src/react/workflows/Storefront.test.tsx +0 -82
- package/src/react/workflows/SubscriptionOverview.test.tsx +0 -27
- package/src/react/workflows/Subscriptions.test.tsx +0 -61
- package/src/react/workflows/Tasks.test.tsx +0 -23
- package/src/react/workflows/Usage.fixtures.ts +0 -88
- package/src/react/workflows/Usage.test.tsx +0 -388
- package/src/react/workflows/UsageConfiguration.test.tsx +0 -393
- package/src/react/workflows/UsageHistory.test.tsx +0 -206
- package/src/react/workflows/UsagePriceRow.test.tsx +0 -140
- package/src/react/workflows/current-subscription.test.ts +0 -29
- package/src/react/workflows/filters.test.ts +0 -12
- package/src/react/workflows/native-interactions.test.tsx +0 -73
- package/src/react/workflows/public-workflows.test.tsx +0 -216
- package/src/react/workflows/refund-preview.test.ts +0 -65
- package/src/react/workflows/usage-configuration-validation.test.ts +0 -107
- package/src/react/workflows/useWorkflowAction.commit.test.tsx +0 -194
- package/src/react/workflows/useWorkflowAction.ssr.test.tsx +0 -20
- package/src/react/workflows/useWorkflowAction.test.tsx +0 -54
- package/src/react/workflows/useWorkflowResource.test.tsx +0 -41
- package/src/test.ts +0 -21
- package/src/testing/assert-test-env.test.ts +0 -33
- package/src/testing/component-db.ts +0 -24
- package/src/testing/crossDomain/fixture.ts +0 -96
- package/src/testing/crossDomain/host.ts +0 -288
- package/src/testing/crossDomain/transport.ts +0 -293
- package/src/testing/mock-webhooks.test.ts +0 -97
package/src/client/index.test.ts
DELETED
|
@@ -1,1784 +0,0 @@
|
|
|
1
|
-
import { ConvexError } from "convex/values";
|
|
2
|
-
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
-
|
|
4
|
-
import { isBetterStripeError } from "./errors.js";
|
|
5
|
-
import { components } from "./setup.test.js";
|
|
6
|
-
|
|
7
|
-
// ---------------------------------------------------------------------------
|
|
8
|
-
// Mock Stripe SDK
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
|
|
11
|
-
const mockStripeInstance = {
|
|
12
|
-
v2: {
|
|
13
|
-
core: {
|
|
14
|
-
accounts: {
|
|
15
|
-
create: vi.fn(),
|
|
16
|
-
update: vi.fn(),
|
|
17
|
-
retrieve: vi.fn(),
|
|
18
|
-
list: vi.fn(),
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
products: {
|
|
23
|
-
create: vi.fn(),
|
|
24
|
-
update: vi.fn(),
|
|
25
|
-
list: vi.fn(),
|
|
26
|
-
},
|
|
27
|
-
prices: {
|
|
28
|
-
create: vi.fn(),
|
|
29
|
-
update: vi.fn(),
|
|
30
|
-
list: vi.fn(),
|
|
31
|
-
},
|
|
32
|
-
checkout: {
|
|
33
|
-
sessions: {
|
|
34
|
-
create: vi.fn(),
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
subscriptions: {
|
|
38
|
-
update: vi.fn(),
|
|
39
|
-
cancel: vi.fn(),
|
|
40
|
-
retrieve: vi.fn(),
|
|
41
|
-
list: vi.fn(),
|
|
42
|
-
},
|
|
43
|
-
subscriptionItems: {
|
|
44
|
-
update: vi.fn(),
|
|
45
|
-
},
|
|
46
|
-
refunds: {
|
|
47
|
-
create: vi.fn(),
|
|
48
|
-
},
|
|
49
|
-
paymentIntents: {
|
|
50
|
-
retrieve: vi.fn(),
|
|
51
|
-
},
|
|
52
|
-
charges: {
|
|
53
|
-
retrieve: vi.fn(),
|
|
54
|
-
},
|
|
55
|
-
disputes: {
|
|
56
|
-
update: vi.fn(),
|
|
57
|
-
close: vi.fn(),
|
|
58
|
-
},
|
|
59
|
-
paymentMethods: {
|
|
60
|
-
list: vi.fn(),
|
|
61
|
-
attach: vi.fn(),
|
|
62
|
-
detach: vi.fn(),
|
|
63
|
-
},
|
|
64
|
-
invoices: {
|
|
65
|
-
retrieve: vi.fn(),
|
|
66
|
-
},
|
|
67
|
-
accountLinks: {
|
|
68
|
-
create: vi.fn(),
|
|
69
|
-
},
|
|
70
|
-
accounts: {
|
|
71
|
-
createLoginLink: vi.fn(),
|
|
72
|
-
},
|
|
73
|
-
payouts: {
|
|
74
|
-
create: vi.fn(),
|
|
75
|
-
},
|
|
76
|
-
transfers: {
|
|
77
|
-
createReversal: vi.fn(),
|
|
78
|
-
retrieve: vi.fn(),
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
vi.mock("stripe", () => ({
|
|
83
|
-
default: class StripeMock {
|
|
84
|
-
constructor() {
|
|
85
|
-
return mockStripeInstance;
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
}));
|
|
89
|
-
|
|
90
|
-
// ---------------------------------------------------------------------------
|
|
91
|
-
// Import BetterStripe after the mock is set up
|
|
92
|
-
// ---------------------------------------------------------------------------
|
|
93
|
-
|
|
94
|
-
const { BetterStripe } = await import("./index.js");
|
|
95
|
-
|
|
96
|
-
// ---------------------------------------------------------------------------
|
|
97
|
-
// Helpers
|
|
98
|
-
// ---------------------------------------------------------------------------
|
|
99
|
-
|
|
100
|
-
function createMockCtx() {
|
|
101
|
-
return {
|
|
102
|
-
runQuery: vi.fn(),
|
|
103
|
-
runMutation: vi.fn(),
|
|
104
|
-
runAction: vi.fn(),
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// ---------------------------------------------------------------------------
|
|
109
|
-
// Tests
|
|
110
|
-
// ---------------------------------------------------------------------------
|
|
111
|
-
|
|
112
|
-
describe("BetterStripe", () => {
|
|
113
|
-
let mockCtx: ReturnType<typeof createMockCtx>;
|
|
114
|
-
|
|
115
|
-
beforeEach(() => {
|
|
116
|
-
vi.clearAllMocks();
|
|
117
|
-
mockCtx = createMockCtx();
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
// =========================================================================
|
|
121
|
-
// Constructor & apiKey
|
|
122
|
-
// =========================================================================
|
|
123
|
-
|
|
124
|
-
describe("constructor & apiKey", () => {
|
|
125
|
-
it("accepts STRIPE_SECRET_KEY", () => {
|
|
126
|
-
expect(
|
|
127
|
-
() =>
|
|
128
|
-
new BetterStripe(components.betterStripe, {
|
|
129
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
130
|
-
}),
|
|
131
|
-
).not.toThrow();
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it("apiKey throws when not set", () => {
|
|
135
|
-
const bs = new BetterStripe(components.betterStripe);
|
|
136
|
-
expect(() => bs.apiKey).toThrow("STRIPE_SECRET_KEY is not set");
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it("validates platformFee at construction and exposes it", () => {
|
|
140
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
141
|
-
platformFee: { percent: 10, fixed: 30 },
|
|
142
|
-
});
|
|
143
|
-
expect(bs.platformFee).toEqual({ percent: 10, fixed: 30 });
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it("throws on an invalid platformFee config", () => {
|
|
147
|
-
expect(
|
|
148
|
-
() =>
|
|
149
|
-
new BetterStripe(components.betterStripe, {
|
|
150
|
-
platformFee: { percent: 150 },
|
|
151
|
-
}),
|
|
152
|
-
).toThrow(/platformFee/);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
it("validates statementDescriptorSuffix at construction and exposes the trimmed value", () => {
|
|
156
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
157
|
-
statementDescriptorSuffix: " ACME STORE ",
|
|
158
|
-
});
|
|
159
|
-
expect(bs.statementDescriptorSuffix).toBe("ACME STORE");
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it("throws on an invalid statementDescriptorSuffix", () => {
|
|
163
|
-
expect(
|
|
164
|
-
() =>
|
|
165
|
-
new BetterStripe(components.betterStripe, {
|
|
166
|
-
statementDescriptorSuffix: "BAD*SUFFIX",
|
|
167
|
-
}),
|
|
168
|
-
).toThrow(/statement descriptor/i);
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it("statementDescriptorSuffix is undefined when not configured", () => {
|
|
172
|
-
const bs = new BetterStripe(components.betterStripe);
|
|
173
|
-
expect(bs.statementDescriptorSuffix).toBeUndefined();
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it("platformFee is undefined when not configured", () => {
|
|
177
|
-
const bs = new BetterStripe(components.betterStripe);
|
|
178
|
-
expect(bs.platformFee).toBeUndefined();
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
it("does not retain or re-expose the caller's mutable fee object", () => {
|
|
182
|
-
const input = { percent: 10, tiers: [{ upTo: null, percent: 10 }] };
|
|
183
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
184
|
-
platformFee: input,
|
|
185
|
-
});
|
|
186
|
-
// Mutating the original input must not change stored config.
|
|
187
|
-
input.percent = 999;
|
|
188
|
-
input.tiers[0].percent = 999;
|
|
189
|
-
expect(bs.platformFee).toEqual({
|
|
190
|
-
percent: 10,
|
|
191
|
-
tiers: [{ upTo: null, percent: 10 }],
|
|
192
|
-
});
|
|
193
|
-
// Mutating a returned copy must not change internal state either.
|
|
194
|
-
const returned = bs.platformFee!;
|
|
195
|
-
returned.percent = 42;
|
|
196
|
-
expect(bs.platformFee!.percent).toBe(10);
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
// =========================================================================
|
|
201
|
-
// Account methods
|
|
202
|
-
// =========================================================================
|
|
203
|
-
|
|
204
|
-
describe("createAccount", () => {
|
|
205
|
-
it("calls Stripe V2 API + upsertAccount mutation", async () => {
|
|
206
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
207
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
const fakeAccount = { id: "acct_123" };
|
|
211
|
-
mockStripeInstance.v2.core.accounts.create.mockResolvedValue(fakeAccount);
|
|
212
|
-
mockCtx.runQuery.mockResolvedValue({ _id: "internal_id_1" });
|
|
213
|
-
|
|
214
|
-
const result = await bs.createAccount(mockCtx, {
|
|
215
|
-
userId: "user_1",
|
|
216
|
-
email: "test@example.com",
|
|
217
|
-
name: "Test User",
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
expect(mockStripeInstance.v2.core.accounts.create).toHaveBeenCalledWith(
|
|
221
|
-
expect.objectContaining({
|
|
222
|
-
contact_email: "test@example.com",
|
|
223
|
-
metadata: expect.objectContaining({ userId: "user_1" }),
|
|
224
|
-
}),
|
|
225
|
-
);
|
|
226
|
-
expect(mockCtx.runMutation).toHaveBeenCalledWith(
|
|
227
|
-
components.betterStripe.core.mutations.upsertAccount,
|
|
228
|
-
expect.objectContaining({
|
|
229
|
-
stripeAccountId: "acct_123",
|
|
230
|
-
userId: "user_1",
|
|
231
|
-
email: "test@example.com",
|
|
232
|
-
name: "Test User",
|
|
233
|
-
onboardingStatus: "pending",
|
|
234
|
-
}),
|
|
235
|
-
);
|
|
236
|
-
expect(result).toEqual({
|
|
237
|
-
accountId: "internal_id_1",
|
|
238
|
-
stripeAccountId: "acct_123",
|
|
239
|
-
});
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
describe("listTransfersByCharge", () => {
|
|
244
|
-
it("reads a sale's split legs via the component query (passthrough)", async () => {
|
|
245
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
246
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
247
|
-
});
|
|
248
|
-
const rows = [
|
|
249
|
-
{ stripeTransferId: "tr_store", role: "store", amount: 8000 },
|
|
250
|
-
{ stripeTransferId: "tr_aff", role: "affiliate", amount: 2000 },
|
|
251
|
-
];
|
|
252
|
-
mockCtx.runQuery.mockResolvedValue(rows);
|
|
253
|
-
|
|
254
|
-
const result = await bs.listTransfersByCharge(mockCtx, {
|
|
255
|
-
sourceChargeId: "ch_split",
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
expect(mockCtx.runQuery).toHaveBeenCalledTimes(1);
|
|
259
|
-
expect(mockCtx.runQuery.mock.calls[0][1]).toEqual({
|
|
260
|
-
sourceChargeId: "ch_split",
|
|
261
|
-
});
|
|
262
|
-
expect(result).toBe(rows);
|
|
263
|
-
});
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
describe("listTransfersByAccount", () => {
|
|
267
|
-
it("reads a recipient's transfer ledger via the component query (passthrough)", async () => {
|
|
268
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
269
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
270
|
-
});
|
|
271
|
-
const rows = [{ stripeTransferId: "tr_aff", amount: 2000 }];
|
|
272
|
-
mockCtx.runQuery.mockResolvedValue(rows);
|
|
273
|
-
|
|
274
|
-
const result = await bs.listTransfersByAccount(mockCtx, {
|
|
275
|
-
destinationAccountId: "acct_avery",
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
expect(mockCtx.runQuery).toHaveBeenCalledTimes(1);
|
|
279
|
-
expect(mockCtx.runQuery.mock.calls[0][1]).toEqual({
|
|
280
|
-
destinationAccountId: "acct_avery",
|
|
281
|
-
});
|
|
282
|
-
expect(result).toBe(rows);
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
describe("reverseTransfers", () => {
|
|
287
|
-
it("takes the atomic claimReversalSlices path when operationId is provided", async () => {
|
|
288
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
289
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
mockCtx.runMutation.mockImplementation(
|
|
293
|
-
async (ref: Record<symbol, string>) => {
|
|
294
|
-
const TO_REF = Symbol.for("toReferencePath");
|
|
295
|
-
const claimRef = components.betterStripe.connect.mutations
|
|
296
|
-
.claimReversalSlices as unknown as Record<symbol, string>;
|
|
297
|
-
if (ref[TO_REF] === claimRef[TO_REF]) {
|
|
298
|
-
return {
|
|
299
|
-
replay: false,
|
|
300
|
-
slices: [
|
|
301
|
-
{
|
|
302
|
-
stripeTransferId: "tr_store",
|
|
303
|
-
from: 0,
|
|
304
|
-
to: 8000,
|
|
305
|
-
confirmed: 0,
|
|
306
|
-
},
|
|
307
|
-
],
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
return undefined;
|
|
311
|
-
},
|
|
312
|
-
);
|
|
313
|
-
mockStripeInstance.transfers.createReversal.mockResolvedValue({
|
|
314
|
-
id: "trr_1",
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
const result = await bs.reverseTransfers(mockCtx, {
|
|
318
|
-
sourceChargeId: "ch_1",
|
|
319
|
-
operationId: "dp_1",
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
expect(mockCtx.runMutation).toHaveBeenCalledWith(
|
|
323
|
-
components.betterStripe.connect.mutations.claimReversalSlices,
|
|
324
|
-
expect.objectContaining({
|
|
325
|
-
operationId: "dp_1",
|
|
326
|
-
sourceChargeId: "ch_1",
|
|
327
|
-
mode: { kind: "full" },
|
|
328
|
-
}),
|
|
329
|
-
);
|
|
330
|
-
expect(mockStripeInstance.transfers.createReversal).toHaveBeenCalledWith(
|
|
331
|
-
"tr_store",
|
|
332
|
-
{ amount: 8000 },
|
|
333
|
-
{ idempotencyKey: "bs_rev_dp_1_tr_store" },
|
|
334
|
-
);
|
|
335
|
-
expect(result).toEqual({
|
|
336
|
-
reversals: [{ stripeTransferId: "tr_store", amount: 8000 }],
|
|
337
|
-
});
|
|
338
|
-
});
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
describe("addCustomerConfiguration", () => {
|
|
342
|
-
it("applies the customer configuration and records applied configs", async () => {
|
|
343
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
344
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
mockCtx.runQuery.mockResolvedValue({ userId: "user_1" });
|
|
348
|
-
mockStripeInstance.v2.core.accounts.update.mockResolvedValue({});
|
|
349
|
-
mockStripeInstance.v2.core.accounts.retrieve.mockResolvedValue({
|
|
350
|
-
applied_configurations: ["customer"],
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
const result = await bs.addCustomerConfiguration(mockCtx, {
|
|
354
|
-
stripeAccountId: "acct_123",
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
expect(mockStripeInstance.v2.core.accounts.update).toHaveBeenCalledWith(
|
|
358
|
-
"acct_123",
|
|
359
|
-
{ configuration: { customer: {} } },
|
|
360
|
-
);
|
|
361
|
-
expect(mockCtx.runMutation).toHaveBeenCalledWith(
|
|
362
|
-
components.betterStripe.core.mutations.upsertAccount,
|
|
363
|
-
expect.objectContaining({
|
|
364
|
-
stripeAccountId: "acct_123",
|
|
365
|
-
userId: "user_1",
|
|
366
|
-
appliedConfigurations: ["customer"],
|
|
367
|
-
}),
|
|
368
|
-
);
|
|
369
|
-
expect(result).toEqual({
|
|
370
|
-
success: true,
|
|
371
|
-
appliedConfigurations: ["customer"],
|
|
372
|
-
});
|
|
373
|
-
});
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
// =========================================================================
|
|
377
|
-
// Product methods
|
|
378
|
-
// =========================================================================
|
|
379
|
-
|
|
380
|
-
describe("createProduct", () => {
|
|
381
|
-
it("calls Stripe API + upsertProduct mutation", async () => {
|
|
382
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
383
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
384
|
-
});
|
|
385
|
-
|
|
386
|
-
const fakeProduct = {
|
|
387
|
-
id: "prod_123",
|
|
388
|
-
name: "My Product",
|
|
389
|
-
description: "A product",
|
|
390
|
-
active: true,
|
|
391
|
-
metadata: {},
|
|
392
|
-
};
|
|
393
|
-
mockStripeInstance.products.create.mockResolvedValue(fakeProduct);
|
|
394
|
-
mockCtx.runQuery.mockResolvedValue({ _id: "internal_prod_1" });
|
|
395
|
-
|
|
396
|
-
const result = await bs.createProduct(mockCtx, {
|
|
397
|
-
name: "My Product",
|
|
398
|
-
description: "A product",
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
expect(mockStripeInstance.products.create).toHaveBeenCalledWith(
|
|
402
|
-
expect.objectContaining({
|
|
403
|
-
name: "My Product",
|
|
404
|
-
description: "A product",
|
|
405
|
-
active: true,
|
|
406
|
-
}),
|
|
407
|
-
);
|
|
408
|
-
expect(mockCtx.runMutation).toHaveBeenCalledWith(
|
|
409
|
-
components.betterStripe.products.mutations.upsertProduct,
|
|
410
|
-
expect.objectContaining({
|
|
411
|
-
stripeProductId: "prod_123",
|
|
412
|
-
name: "My Product",
|
|
413
|
-
active: true,
|
|
414
|
-
}),
|
|
415
|
-
);
|
|
416
|
-
expect(result).toEqual({
|
|
417
|
-
productId: "internal_prod_1",
|
|
418
|
-
stripeProductId: "prod_123",
|
|
419
|
-
});
|
|
420
|
-
});
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
// =========================================================================
|
|
424
|
-
// Price methods
|
|
425
|
-
// =========================================================================
|
|
426
|
-
|
|
427
|
-
describe("createPrice", () => {
|
|
428
|
-
it("calls Stripe API + upsertPrice mutation", async () => {
|
|
429
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
430
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
431
|
-
});
|
|
432
|
-
|
|
433
|
-
const fakePrice = {
|
|
434
|
-
id: "price_123",
|
|
435
|
-
nickname: "Monthly",
|
|
436
|
-
unit_amount: 1999,
|
|
437
|
-
currency: "usd",
|
|
438
|
-
active: true,
|
|
439
|
-
metadata: {},
|
|
440
|
-
};
|
|
441
|
-
mockStripeInstance.prices.create.mockResolvedValue(fakePrice);
|
|
442
|
-
mockCtx.runQuery.mockResolvedValue({ _id: "internal_prod_1" });
|
|
443
|
-
|
|
444
|
-
const result = await bs.createPrice(mockCtx, {
|
|
445
|
-
stripeProductId: "prod_123",
|
|
446
|
-
unitAmount: 1999,
|
|
447
|
-
currency: "usd",
|
|
448
|
-
type: "recurring",
|
|
449
|
-
interval: "month",
|
|
450
|
-
});
|
|
451
|
-
|
|
452
|
-
expect(mockStripeInstance.prices.create).toHaveBeenCalledWith(
|
|
453
|
-
expect.objectContaining({
|
|
454
|
-
product: "prod_123",
|
|
455
|
-
unit_amount: 1999,
|
|
456
|
-
currency: "usd",
|
|
457
|
-
recurring: { interval: "month", interval_count: 1 },
|
|
458
|
-
}),
|
|
459
|
-
);
|
|
460
|
-
expect(mockCtx.runMutation).toHaveBeenCalledWith(
|
|
461
|
-
components.betterStripe.products.mutations.upsertPrice,
|
|
462
|
-
expect.objectContaining({
|
|
463
|
-
stripePriceId: "price_123",
|
|
464
|
-
productId: "internal_prod_1",
|
|
465
|
-
stripeProductId: "prod_123",
|
|
466
|
-
unitAmount: 1999,
|
|
467
|
-
type: "recurring",
|
|
468
|
-
interval: "month",
|
|
469
|
-
}),
|
|
470
|
-
);
|
|
471
|
-
expect(result).toEqual({ stripePriceId: "price_123" });
|
|
472
|
-
});
|
|
473
|
-
});
|
|
474
|
-
|
|
475
|
-
// =========================================================================
|
|
476
|
-
// Checkout methods
|
|
477
|
-
// =========================================================================
|
|
478
|
-
|
|
479
|
-
describe("createCheckoutSession", () => {
|
|
480
|
-
it("returns clientSecret for embedded ui_mode", async () => {
|
|
481
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
482
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
483
|
-
});
|
|
484
|
-
|
|
485
|
-
mockStripeInstance.checkout.sessions.create.mockResolvedValue({
|
|
486
|
-
id: "cs_123",
|
|
487
|
-
client_secret: "cs_secret_xxx",
|
|
488
|
-
status: "open",
|
|
489
|
-
url: null,
|
|
490
|
-
});
|
|
491
|
-
|
|
492
|
-
const result = await bs.createCheckoutSession(mockCtx, {
|
|
493
|
-
userId: "user_1",
|
|
494
|
-
stripePriceId: "price_123",
|
|
495
|
-
mode: "subscription",
|
|
496
|
-
uiMode: "embedded",
|
|
497
|
-
returnUrl: "https://example.com/return",
|
|
498
|
-
});
|
|
499
|
-
|
|
500
|
-
expect(mockStripeInstance.checkout.sessions.create).toHaveBeenCalledWith(
|
|
501
|
-
expect.objectContaining({
|
|
502
|
-
ui_mode: "embedded_page",
|
|
503
|
-
return_url: "https://example.com/return",
|
|
504
|
-
}),
|
|
505
|
-
);
|
|
506
|
-
expect(result.clientSecret).toBe("cs_secret_xxx");
|
|
507
|
-
expect(result.stripeSessionId).toBe("cs_123");
|
|
508
|
-
});
|
|
509
|
-
|
|
510
|
-
it("returns url for redirect ui_mode", async () => {
|
|
511
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
512
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
513
|
-
});
|
|
514
|
-
|
|
515
|
-
mockStripeInstance.checkout.sessions.create.mockResolvedValue({
|
|
516
|
-
id: "cs_456",
|
|
517
|
-
client_secret: null,
|
|
518
|
-
status: "open",
|
|
519
|
-
url: "https://checkout.stripe.com/pay/cs_456",
|
|
520
|
-
});
|
|
521
|
-
|
|
522
|
-
const result = await bs.createCheckoutSession(mockCtx, {
|
|
523
|
-
userId: "user_1",
|
|
524
|
-
stripePriceId: "price_123",
|
|
525
|
-
mode: "subscription",
|
|
526
|
-
uiMode: "redirect",
|
|
527
|
-
returnUrl: "https://example.com/return",
|
|
528
|
-
});
|
|
529
|
-
|
|
530
|
-
expect(mockStripeInstance.checkout.sessions.create).toHaveBeenCalledWith(
|
|
531
|
-
expect.objectContaining({
|
|
532
|
-
success_url:
|
|
533
|
-
"https://example.com/return?session_id={CHECKOUT_SESSION_ID}",
|
|
534
|
-
cancel_url: "https://example.com/return",
|
|
535
|
-
}),
|
|
536
|
-
);
|
|
537
|
-
expect(result.url).toBe("https://checkout.stripe.com/pay/cs_456");
|
|
538
|
-
expect(result.stripeSessionId).toBe("cs_456");
|
|
539
|
-
});
|
|
540
|
-
|
|
541
|
-
it("passes the configured default statement-descriptor suffix through to destination charges (BTS-32)", async () => {
|
|
542
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
543
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
544
|
-
statementDescriptorSuffix: "PLATFORM DEF",
|
|
545
|
-
});
|
|
546
|
-
// No component account record for the store → falls back to the default.
|
|
547
|
-
mockCtx.runQuery.mockResolvedValue(null);
|
|
548
|
-
mockStripeInstance.checkout.sessions.create.mockResolvedValue({
|
|
549
|
-
id: "cs_sd",
|
|
550
|
-
client_secret: "cs_secret_sd",
|
|
551
|
-
status: "open",
|
|
552
|
-
url: null,
|
|
553
|
-
});
|
|
554
|
-
|
|
555
|
-
await bs.createCheckoutSession(mockCtx, {
|
|
556
|
-
userId: "user_1",
|
|
557
|
-
stripePriceId: "price_123",
|
|
558
|
-
mode: "payment",
|
|
559
|
-
returnUrl: "https://example.com/return",
|
|
560
|
-
destinationAccountId: "acct_store",
|
|
561
|
-
});
|
|
562
|
-
|
|
563
|
-
expect(mockStripeInstance.checkout.sessions.create).toHaveBeenCalledWith(
|
|
564
|
-
expect.objectContaining({
|
|
565
|
-
payment_intent_data: expect.objectContaining({
|
|
566
|
-
statement_descriptor_suffix: "PLATFORM DEF",
|
|
567
|
-
}),
|
|
568
|
-
}),
|
|
569
|
-
);
|
|
570
|
-
});
|
|
571
|
-
});
|
|
572
|
-
|
|
573
|
-
// =========================================================================
|
|
574
|
-
// Subscription methods
|
|
575
|
-
// =========================================================================
|
|
576
|
-
|
|
577
|
-
describe("cancelSubscription", () => {
|
|
578
|
-
it("uses update with cancel_at_period_end when atPeriodEnd", async () => {
|
|
579
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
580
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
581
|
-
});
|
|
582
|
-
|
|
583
|
-
mockStripeInstance.subscriptions.update.mockResolvedValue({});
|
|
584
|
-
|
|
585
|
-
await bs.cancelSubscription(mockCtx, {
|
|
586
|
-
stripeSubscriptionId: "sub_123",
|
|
587
|
-
cancelAtPeriodEnd: true,
|
|
588
|
-
});
|
|
589
|
-
|
|
590
|
-
expect(mockStripeInstance.subscriptions.update).toHaveBeenCalledWith(
|
|
591
|
-
"sub_123",
|
|
592
|
-
{ cancel_at_period_end: true },
|
|
593
|
-
);
|
|
594
|
-
expect(mockStripeInstance.subscriptions.cancel).not.toHaveBeenCalled();
|
|
595
|
-
});
|
|
596
|
-
|
|
597
|
-
it("uses cancel for immediate cancellation", async () => {
|
|
598
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
599
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
600
|
-
});
|
|
601
|
-
|
|
602
|
-
mockStripeInstance.subscriptions.cancel.mockResolvedValue({});
|
|
603
|
-
|
|
604
|
-
await bs.cancelSubscription(mockCtx, {
|
|
605
|
-
stripeSubscriptionId: "sub_123",
|
|
606
|
-
cancelAtPeriodEnd: false,
|
|
607
|
-
});
|
|
608
|
-
|
|
609
|
-
expect(mockStripeInstance.subscriptions.cancel).toHaveBeenCalledWith(
|
|
610
|
-
"sub_123",
|
|
611
|
-
);
|
|
612
|
-
expect(mockStripeInstance.subscriptions.update).not.toHaveBeenCalled();
|
|
613
|
-
});
|
|
614
|
-
});
|
|
615
|
-
|
|
616
|
-
describe("reactivateSubscription", () => {
|
|
617
|
-
it("sets cancel_at_period_end to false", async () => {
|
|
618
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
619
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
620
|
-
});
|
|
621
|
-
|
|
622
|
-
mockStripeInstance.subscriptions.update.mockResolvedValue({});
|
|
623
|
-
|
|
624
|
-
await bs.reactivateSubscription(mockCtx, {
|
|
625
|
-
stripeSubscriptionId: "sub_123",
|
|
626
|
-
});
|
|
627
|
-
|
|
628
|
-
expect(mockStripeInstance.subscriptions.update).toHaveBeenCalledWith(
|
|
629
|
-
"sub_123",
|
|
630
|
-
{ cancel_at_period_end: false },
|
|
631
|
-
);
|
|
632
|
-
});
|
|
633
|
-
});
|
|
634
|
-
|
|
635
|
-
describe("updateSubscriptionQuantity", () => {
|
|
636
|
-
it("retrieves the subscription and updates the first item quantity", async () => {
|
|
637
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
638
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
639
|
-
});
|
|
640
|
-
|
|
641
|
-
mockStripeInstance.subscriptions.retrieve.mockResolvedValue({
|
|
642
|
-
items: { data: [{ id: "si_1" }] },
|
|
643
|
-
});
|
|
644
|
-
mockStripeInstance.subscriptionItems.update.mockResolvedValue({});
|
|
645
|
-
|
|
646
|
-
const result = await bs.updateSubscriptionQuantity(mockCtx, {
|
|
647
|
-
stripeSubscriptionId: "sub_123",
|
|
648
|
-
quantity: 3,
|
|
649
|
-
});
|
|
650
|
-
|
|
651
|
-
expect(mockStripeInstance.subscriptions.retrieve).toHaveBeenCalledWith(
|
|
652
|
-
"sub_123",
|
|
653
|
-
);
|
|
654
|
-
expect(mockStripeInstance.subscriptionItems.update).toHaveBeenCalledWith(
|
|
655
|
-
"si_1",
|
|
656
|
-
{ quantity: 3 },
|
|
657
|
-
);
|
|
658
|
-
expect(result).toEqual({ success: true });
|
|
659
|
-
});
|
|
660
|
-
|
|
661
|
-
it("rejects when the subscription has no items and does not call update", async () => {
|
|
662
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
663
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
664
|
-
});
|
|
665
|
-
|
|
666
|
-
mockStripeInstance.subscriptions.retrieve.mockResolvedValue({
|
|
667
|
-
items: { data: [] },
|
|
668
|
-
});
|
|
669
|
-
|
|
670
|
-
await expect(
|
|
671
|
-
bs.updateSubscriptionQuantity(mockCtx, {
|
|
672
|
-
stripeSubscriptionId: "sub_123",
|
|
673
|
-
quantity: 3,
|
|
674
|
-
}),
|
|
675
|
-
).rejects.toThrow("Subscription has no items");
|
|
676
|
-
|
|
677
|
-
expect(
|
|
678
|
-
mockStripeInstance.subscriptionItems.update,
|
|
679
|
-
).not.toHaveBeenCalled();
|
|
680
|
-
});
|
|
681
|
-
|
|
682
|
-
it("surfaces a STRIPE_API_ERROR when the retrieve call throws", async () => {
|
|
683
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
684
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
685
|
-
});
|
|
686
|
-
|
|
687
|
-
mockStripeInstance.subscriptions.retrieve.mockRejectedValue(
|
|
688
|
-
new Error("boom"),
|
|
689
|
-
);
|
|
690
|
-
|
|
691
|
-
await expect(
|
|
692
|
-
bs.updateSubscriptionQuantity(mockCtx, {
|
|
693
|
-
stripeSubscriptionId: "sub_123",
|
|
694
|
-
quantity: 3,
|
|
695
|
-
}),
|
|
696
|
-
).rejects.toMatchObject({ data: { code: "STRIPE_API_ERROR" } });
|
|
697
|
-
});
|
|
698
|
-
});
|
|
699
|
-
|
|
700
|
-
describe("cancelSubscription error handling", () => {
|
|
701
|
-
it("surfaces a STRIPE_API_ERROR when the Stripe call throws", async () => {
|
|
702
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
703
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
704
|
-
});
|
|
705
|
-
|
|
706
|
-
mockStripeInstance.subscriptions.update.mockRejectedValue(
|
|
707
|
-
new Error("boom"),
|
|
708
|
-
);
|
|
709
|
-
|
|
710
|
-
await expect(
|
|
711
|
-
bs.cancelSubscription(mockCtx, {
|
|
712
|
-
stripeSubscriptionId: "sub_123",
|
|
713
|
-
cancelAtPeriodEnd: true,
|
|
714
|
-
}),
|
|
715
|
-
).rejects.toMatchObject({ data: { code: "STRIPE_API_ERROR" } });
|
|
716
|
-
});
|
|
717
|
-
});
|
|
718
|
-
|
|
719
|
-
describe("pauseSubscription", () => {
|
|
720
|
-
it("defaults behavior to keep_as_draft when omitted", async () => {
|
|
721
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
722
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
723
|
-
});
|
|
724
|
-
|
|
725
|
-
mockStripeInstance.subscriptions.update.mockResolvedValue({});
|
|
726
|
-
|
|
727
|
-
const result = await bs.pauseSubscription(mockCtx, {
|
|
728
|
-
stripeSubscriptionId: "sub_123",
|
|
729
|
-
});
|
|
730
|
-
|
|
731
|
-
expect(mockStripeInstance.subscriptions.update).toHaveBeenCalledWith(
|
|
732
|
-
"sub_123",
|
|
733
|
-
{ pause_collection: { behavior: "keep_as_draft" } },
|
|
734
|
-
);
|
|
735
|
-
expect(result).toEqual({ success: true });
|
|
736
|
-
});
|
|
737
|
-
|
|
738
|
-
it("passes resumes_at and behavior when provided", async () => {
|
|
739
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
740
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
741
|
-
});
|
|
742
|
-
|
|
743
|
-
mockStripeInstance.subscriptions.update.mockResolvedValue({});
|
|
744
|
-
|
|
745
|
-
await bs.pauseSubscription(mockCtx, {
|
|
746
|
-
stripeSubscriptionId: "sub_123",
|
|
747
|
-
behavior: "void",
|
|
748
|
-
resumesAt: 1893456000,
|
|
749
|
-
});
|
|
750
|
-
|
|
751
|
-
expect(mockStripeInstance.subscriptions.update).toHaveBeenCalledWith(
|
|
752
|
-
"sub_123",
|
|
753
|
-
{ pause_collection: { behavior: "void", resumes_at: 1893456000 } },
|
|
754
|
-
);
|
|
755
|
-
});
|
|
756
|
-
|
|
757
|
-
it("surfaces a STRIPE_API_ERROR when the Stripe call throws", async () => {
|
|
758
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
759
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
760
|
-
});
|
|
761
|
-
|
|
762
|
-
mockStripeInstance.subscriptions.update.mockRejectedValue(
|
|
763
|
-
new Error("boom"),
|
|
764
|
-
);
|
|
765
|
-
|
|
766
|
-
await expect(
|
|
767
|
-
bs.pauseSubscription(mockCtx, { stripeSubscriptionId: "sub_123" }),
|
|
768
|
-
).rejects.toMatchObject({ data: { code: "STRIPE_API_ERROR" } });
|
|
769
|
-
});
|
|
770
|
-
});
|
|
771
|
-
|
|
772
|
-
describe("resumeSubscription", () => {
|
|
773
|
-
it("clears pause_collection with the empty-string sentinel", async () => {
|
|
774
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
775
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
776
|
-
});
|
|
777
|
-
|
|
778
|
-
mockStripeInstance.subscriptions.update.mockResolvedValue({});
|
|
779
|
-
|
|
780
|
-
const result = await bs.resumeSubscription(mockCtx, {
|
|
781
|
-
stripeSubscriptionId: "sub_123",
|
|
782
|
-
});
|
|
783
|
-
|
|
784
|
-
expect(mockStripeInstance.subscriptions.update).toHaveBeenCalledWith(
|
|
785
|
-
"sub_123",
|
|
786
|
-
{ pause_collection: "" },
|
|
787
|
-
);
|
|
788
|
-
expect(result).toEqual({ success: true });
|
|
789
|
-
});
|
|
790
|
-
});
|
|
791
|
-
|
|
792
|
-
describe("updateSubscriptionPrice", () => {
|
|
793
|
-
it("retrieves the item id and defaults proration_behavior to none", async () => {
|
|
794
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
795
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
796
|
-
});
|
|
797
|
-
|
|
798
|
-
mockStripeInstance.subscriptions.retrieve.mockResolvedValue({
|
|
799
|
-
items: { data: [{ id: "si_1" }] },
|
|
800
|
-
});
|
|
801
|
-
mockStripeInstance.subscriptions.update.mockResolvedValue({});
|
|
802
|
-
|
|
803
|
-
const result = await bs.updateSubscriptionPrice(mockCtx, {
|
|
804
|
-
stripeSubscriptionId: "sub_123",
|
|
805
|
-
stripePriceId: "price_new",
|
|
806
|
-
});
|
|
807
|
-
|
|
808
|
-
expect(mockStripeInstance.subscriptions.retrieve).toHaveBeenCalledWith(
|
|
809
|
-
"sub_123",
|
|
810
|
-
);
|
|
811
|
-
expect(mockStripeInstance.subscriptions.update).toHaveBeenCalledWith(
|
|
812
|
-
"sub_123",
|
|
813
|
-
{
|
|
814
|
-
items: [{ id: "si_1", price: "price_new" }],
|
|
815
|
-
proration_behavior: "none",
|
|
816
|
-
},
|
|
817
|
-
);
|
|
818
|
-
expect(result).toEqual({ success: true });
|
|
819
|
-
});
|
|
820
|
-
|
|
821
|
-
it("passes through a caller-provided prorationBehavior", async () => {
|
|
822
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
823
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
824
|
-
});
|
|
825
|
-
|
|
826
|
-
mockStripeInstance.subscriptions.retrieve.mockResolvedValue({
|
|
827
|
-
items: { data: [{ id: "si_1" }] },
|
|
828
|
-
});
|
|
829
|
-
mockStripeInstance.subscriptions.update.mockResolvedValue({});
|
|
830
|
-
|
|
831
|
-
await bs.updateSubscriptionPrice(mockCtx, {
|
|
832
|
-
stripeSubscriptionId: "sub_123",
|
|
833
|
-
stripePriceId: "price_new",
|
|
834
|
-
prorationBehavior: "always_invoice",
|
|
835
|
-
});
|
|
836
|
-
|
|
837
|
-
expect(mockStripeInstance.subscriptions.update).toHaveBeenCalledWith(
|
|
838
|
-
"sub_123",
|
|
839
|
-
{
|
|
840
|
-
items: [{ id: "si_1", price: "price_new" }],
|
|
841
|
-
proration_behavior: "always_invoice",
|
|
842
|
-
},
|
|
843
|
-
);
|
|
844
|
-
});
|
|
845
|
-
|
|
846
|
-
it("rejects when the subscription has no items and does not call update", async () => {
|
|
847
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
848
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
849
|
-
});
|
|
850
|
-
|
|
851
|
-
mockStripeInstance.subscriptions.retrieve.mockResolvedValue({
|
|
852
|
-
items: { data: [] },
|
|
853
|
-
});
|
|
854
|
-
|
|
855
|
-
await expect(
|
|
856
|
-
bs.updateSubscriptionPrice(mockCtx, {
|
|
857
|
-
stripeSubscriptionId: "sub_123",
|
|
858
|
-
stripePriceId: "price_new",
|
|
859
|
-
}),
|
|
860
|
-
).rejects.toThrow("Subscription has no items");
|
|
861
|
-
|
|
862
|
-
expect(mockStripeInstance.subscriptions.update).not.toHaveBeenCalled();
|
|
863
|
-
});
|
|
864
|
-
|
|
865
|
-
it("surfaces a STRIPE_API_ERROR when the update call throws after a successful retrieve", async () => {
|
|
866
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
867
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
868
|
-
});
|
|
869
|
-
|
|
870
|
-
mockStripeInstance.subscriptions.retrieve.mockResolvedValue({
|
|
871
|
-
items: { data: [{ id: "si_1" }] },
|
|
872
|
-
});
|
|
873
|
-
mockStripeInstance.subscriptions.update.mockRejectedValue(
|
|
874
|
-
new Error("boom"),
|
|
875
|
-
);
|
|
876
|
-
|
|
877
|
-
await expect(
|
|
878
|
-
bs.updateSubscriptionPrice(mockCtx, {
|
|
879
|
-
stripeSubscriptionId: "sub_123",
|
|
880
|
-
stripePriceId: "price_new",
|
|
881
|
-
}),
|
|
882
|
-
).rejects.toMatchObject({ data: { code: "STRIPE_API_ERROR" } });
|
|
883
|
-
});
|
|
884
|
-
});
|
|
885
|
-
|
|
886
|
-
describe("updateSubscriptionMetadata", () => {
|
|
887
|
-
it("calls update with the provided metadata", async () => {
|
|
888
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
889
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
890
|
-
});
|
|
891
|
-
|
|
892
|
-
mockStripeInstance.subscriptions.update.mockResolvedValue({});
|
|
893
|
-
|
|
894
|
-
const result = await bs.updateSubscriptionMetadata(mockCtx, {
|
|
895
|
-
stripeSubscriptionId: "sub_123",
|
|
896
|
-
metadata: { plan: "pro" },
|
|
897
|
-
});
|
|
898
|
-
|
|
899
|
-
expect(mockStripeInstance.subscriptions.update).toHaveBeenCalledWith(
|
|
900
|
-
"sub_123",
|
|
901
|
-
{ metadata: { plan: "pro" } },
|
|
902
|
-
);
|
|
903
|
-
expect(result).toEqual({ success: true });
|
|
904
|
-
});
|
|
905
|
-
});
|
|
906
|
-
|
|
907
|
-
describe("updateSubscriptionTrialEnd", () => {
|
|
908
|
-
it("ends the trial immediately with 'now'", async () => {
|
|
909
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
910
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
911
|
-
});
|
|
912
|
-
|
|
913
|
-
mockStripeInstance.subscriptions.update.mockResolvedValue({});
|
|
914
|
-
|
|
915
|
-
const result = await bs.updateSubscriptionTrialEnd(mockCtx, {
|
|
916
|
-
stripeSubscriptionId: "sub_123",
|
|
917
|
-
trialEnd: "now",
|
|
918
|
-
});
|
|
919
|
-
|
|
920
|
-
expect(mockStripeInstance.subscriptions.update).toHaveBeenCalledWith(
|
|
921
|
-
"sub_123",
|
|
922
|
-
{ trial_end: "now" },
|
|
923
|
-
);
|
|
924
|
-
expect(result).toEqual({ success: true });
|
|
925
|
-
});
|
|
926
|
-
|
|
927
|
-
it("passes a numeric timestamp through unchanged", async () => {
|
|
928
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
929
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
930
|
-
});
|
|
931
|
-
|
|
932
|
-
mockStripeInstance.subscriptions.update.mockResolvedValue({});
|
|
933
|
-
|
|
934
|
-
await bs.updateSubscriptionTrialEnd(mockCtx, {
|
|
935
|
-
stripeSubscriptionId: "sub_123",
|
|
936
|
-
trialEnd: 1893456000,
|
|
937
|
-
});
|
|
938
|
-
|
|
939
|
-
expect(mockStripeInstance.subscriptions.update).toHaveBeenCalledWith(
|
|
940
|
-
"sub_123",
|
|
941
|
-
{ trial_end: 1893456000 },
|
|
942
|
-
);
|
|
943
|
-
});
|
|
944
|
-
});
|
|
945
|
-
|
|
946
|
-
// =========================================================================
|
|
947
|
-
// Invoice methods
|
|
948
|
-
// =========================================================================
|
|
949
|
-
|
|
950
|
-
describe("getInvoice", () => {
|
|
951
|
-
it("runs the getInvoiceByStripeId component query with the invoice id", async () => {
|
|
952
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
953
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
954
|
-
});
|
|
955
|
-
|
|
956
|
-
const fakeInvoice = {
|
|
957
|
-
stripeInvoiceId: "in_123",
|
|
958
|
-
status: "paid",
|
|
959
|
-
amountDue: 1000,
|
|
960
|
-
};
|
|
961
|
-
mockCtx.runQuery.mockResolvedValue(fakeInvoice);
|
|
962
|
-
|
|
963
|
-
const result = await bs.getInvoice(mockCtx, {
|
|
964
|
-
stripeInvoiceId: "in_123",
|
|
965
|
-
});
|
|
966
|
-
|
|
967
|
-
expect(mockCtx.runQuery).toHaveBeenCalledWith(
|
|
968
|
-
components.betterStripe.billing.queries.getInvoiceByStripeId,
|
|
969
|
-
{ stripeInvoiceId: "in_123" },
|
|
970
|
-
);
|
|
971
|
-
expect(result).toEqual(fakeInvoice);
|
|
972
|
-
});
|
|
973
|
-
|
|
974
|
-
it("returns null when the invoice is not found", async () => {
|
|
975
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
976
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
977
|
-
});
|
|
978
|
-
|
|
979
|
-
mockCtx.runQuery.mockResolvedValue(null);
|
|
980
|
-
|
|
981
|
-
const result = await bs.getInvoice(mockCtx, {
|
|
982
|
-
stripeInvoiceId: "in_missing",
|
|
983
|
-
});
|
|
984
|
-
|
|
985
|
-
expect(result).toBeNull();
|
|
986
|
-
});
|
|
987
|
-
});
|
|
988
|
-
|
|
989
|
-
describe("getInvoiceByStripeId", () => {
|
|
990
|
-
it("is an alias that runs the same component query", async () => {
|
|
991
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
992
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
993
|
-
});
|
|
994
|
-
|
|
995
|
-
const fakeInvoice = { stripeInvoiceId: "in_456", status: "open" };
|
|
996
|
-
mockCtx.runQuery.mockResolvedValue(fakeInvoice);
|
|
997
|
-
|
|
998
|
-
const result = await bs.getInvoiceByStripeId(mockCtx, {
|
|
999
|
-
stripeInvoiceId: "in_456",
|
|
1000
|
-
});
|
|
1001
|
-
|
|
1002
|
-
expect(mockCtx.runQuery).toHaveBeenCalledWith(
|
|
1003
|
-
components.betterStripe.billing.queries.getInvoiceByStripeId,
|
|
1004
|
-
{ stripeInvoiceId: "in_456" },
|
|
1005
|
-
);
|
|
1006
|
-
expect(result).toEqual(fakeInvoice);
|
|
1007
|
-
});
|
|
1008
|
-
});
|
|
1009
|
-
|
|
1010
|
-
describe("listInvoices", () => {
|
|
1011
|
-
it("maps stripeAccountId to the component accountId arg", async () => {
|
|
1012
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1013
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1014
|
-
});
|
|
1015
|
-
|
|
1016
|
-
mockCtx.runQuery.mockResolvedValue([]);
|
|
1017
|
-
|
|
1018
|
-
await bs.listInvoices(mockCtx, {
|
|
1019
|
-
stripeAccountId: "acct_map_001",
|
|
1020
|
-
status: "paid",
|
|
1021
|
-
});
|
|
1022
|
-
|
|
1023
|
-
expect(mockCtx.runQuery).toHaveBeenCalledWith(
|
|
1024
|
-
components.betterStripe.billing.queries.listInvoices,
|
|
1025
|
-
{ accountId: "acct_map_001", status: "paid" },
|
|
1026
|
-
);
|
|
1027
|
-
});
|
|
1028
|
-
|
|
1029
|
-
it("passes no accountId when stripeAccountId is omitted", async () => {
|
|
1030
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1031
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1032
|
-
});
|
|
1033
|
-
|
|
1034
|
-
mockCtx.runQuery.mockResolvedValue([]);
|
|
1035
|
-
|
|
1036
|
-
await bs.listInvoices(mockCtx, { userId: "user_map_001" });
|
|
1037
|
-
|
|
1038
|
-
expect(mockCtx.runQuery).toHaveBeenCalledWith(
|
|
1039
|
-
components.betterStripe.billing.queries.listInvoices,
|
|
1040
|
-
{ userId: "user_map_001" },
|
|
1041
|
-
);
|
|
1042
|
-
});
|
|
1043
|
-
});
|
|
1044
|
-
|
|
1045
|
-
describe("listSubscriptions", () => {
|
|
1046
|
-
it("maps stripeAccountId to the component accountId arg", async () => {
|
|
1047
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1048
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1049
|
-
});
|
|
1050
|
-
|
|
1051
|
-
mockCtx.runQuery.mockResolvedValue([]);
|
|
1052
|
-
|
|
1053
|
-
await bs.listSubscriptions(mockCtx, {
|
|
1054
|
-
stripeAccountId: "acct_map_sub_001",
|
|
1055
|
-
status: "active",
|
|
1056
|
-
});
|
|
1057
|
-
|
|
1058
|
-
expect(mockCtx.runQuery).toHaveBeenCalledWith(
|
|
1059
|
-
components.betterStripe.billing.queries.listSubscriptions,
|
|
1060
|
-
{ accountId: "acct_map_sub_001", status: "active" },
|
|
1061
|
-
);
|
|
1062
|
-
});
|
|
1063
|
-
|
|
1064
|
-
it("passes no accountId when stripeAccountId is omitted", async () => {
|
|
1065
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1066
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1067
|
-
});
|
|
1068
|
-
|
|
1069
|
-
mockCtx.runQuery.mockResolvedValue([]);
|
|
1070
|
-
|
|
1071
|
-
await bs.listSubscriptions(mockCtx, { status: "canceled" });
|
|
1072
|
-
|
|
1073
|
-
expect(mockCtx.runQuery).toHaveBeenCalledWith(
|
|
1074
|
-
components.betterStripe.billing.queries.listSubscriptions,
|
|
1075
|
-
{ status: "canceled" },
|
|
1076
|
-
);
|
|
1077
|
-
});
|
|
1078
|
-
});
|
|
1079
|
-
|
|
1080
|
-
describe("listPayouts", () => {
|
|
1081
|
-
it("maps stripeAccountId to the component accountId arg", async () => {
|
|
1082
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1083
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1084
|
-
});
|
|
1085
|
-
|
|
1086
|
-
mockCtx.runQuery.mockResolvedValue([]);
|
|
1087
|
-
|
|
1088
|
-
await bs.listPayouts(mockCtx, {
|
|
1089
|
-
stripeAccountId: "acct_map_po_001",
|
|
1090
|
-
status: "paid",
|
|
1091
|
-
});
|
|
1092
|
-
|
|
1093
|
-
expect(mockCtx.runQuery).toHaveBeenCalledWith(
|
|
1094
|
-
components.betterStripe.connect.queries.listPayouts,
|
|
1095
|
-
{ accountId: "acct_map_po_001", status: "paid" },
|
|
1096
|
-
);
|
|
1097
|
-
});
|
|
1098
|
-
|
|
1099
|
-
it("passes no accountId when stripeAccountId is omitted", async () => {
|
|
1100
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1101
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1102
|
-
});
|
|
1103
|
-
|
|
1104
|
-
mockCtx.runQuery.mockResolvedValue([]);
|
|
1105
|
-
|
|
1106
|
-
await bs.listPayouts(mockCtx, { status: "pending", limit: 10 });
|
|
1107
|
-
|
|
1108
|
-
expect(mockCtx.runQuery).toHaveBeenCalledWith(
|
|
1109
|
-
components.betterStripe.connect.queries.listPayouts,
|
|
1110
|
-
{ status: "pending", limit: 10 },
|
|
1111
|
-
);
|
|
1112
|
-
});
|
|
1113
|
-
});
|
|
1114
|
-
|
|
1115
|
-
// =========================================================================
|
|
1116
|
-
// Payout: createPayout
|
|
1117
|
-
// =========================================================================
|
|
1118
|
-
|
|
1119
|
-
describe("createPayout", () => {
|
|
1120
|
-
it("calls payouts.create with the stripeAccount routing header and default currency", async () => {
|
|
1121
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1122
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1123
|
-
});
|
|
1124
|
-
|
|
1125
|
-
mockStripeInstance.payouts.create.mockResolvedValue({ id: "po_1" });
|
|
1126
|
-
|
|
1127
|
-
const result = await bs.createPayout(mockCtx, {
|
|
1128
|
-
stripeAccountId: "acct_1",
|
|
1129
|
-
amount: 5000,
|
|
1130
|
-
});
|
|
1131
|
-
|
|
1132
|
-
expect(mockStripeInstance.payouts.create).toHaveBeenCalledWith(
|
|
1133
|
-
{ amount: 5000, currency: "usd", metadata: undefined },
|
|
1134
|
-
{ stripeAccount: "acct_1" },
|
|
1135
|
-
);
|
|
1136
|
-
expect(result).toEqual({ stripePayoutId: "po_1" });
|
|
1137
|
-
});
|
|
1138
|
-
|
|
1139
|
-
it("passes through a currency override and returns stripePayoutId", async () => {
|
|
1140
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1141
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1142
|
-
});
|
|
1143
|
-
|
|
1144
|
-
mockStripeInstance.payouts.create.mockResolvedValue({ id: "po_2" });
|
|
1145
|
-
|
|
1146
|
-
const result = await bs.createPayout(mockCtx, {
|
|
1147
|
-
stripeAccountId: "acct_1",
|
|
1148
|
-
amount: 10000,
|
|
1149
|
-
currency: "gbp",
|
|
1150
|
-
});
|
|
1151
|
-
|
|
1152
|
-
expect(mockStripeInstance.payouts.create).toHaveBeenCalledWith(
|
|
1153
|
-
{ amount: 10000, currency: "gbp", metadata: undefined },
|
|
1154
|
-
{ stripeAccount: "acct_1" },
|
|
1155
|
-
);
|
|
1156
|
-
expect(result).toEqual({ stripePayoutId: "po_2" });
|
|
1157
|
-
});
|
|
1158
|
-
});
|
|
1159
|
-
|
|
1160
|
-
// =========================================================================
|
|
1161
|
-
// Refund methods
|
|
1162
|
-
// =========================================================================
|
|
1163
|
-
|
|
1164
|
-
describe("createRefund", () => {
|
|
1165
|
-
it("creates a refund for a payment intent and returns the refund id", async () => {
|
|
1166
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1167
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1168
|
-
});
|
|
1169
|
-
|
|
1170
|
-
mockStripeInstance.refunds.create.mockResolvedValue({ id: "re_1" });
|
|
1171
|
-
// Plain (non-marketplace) charge: no fee/transfer → no flags sent.
|
|
1172
|
-
mockStripeInstance.paymentIntents.retrieve.mockResolvedValue({
|
|
1173
|
-
id: "pi_1",
|
|
1174
|
-
latest_charge: "ch_1",
|
|
1175
|
-
});
|
|
1176
|
-
mockStripeInstance.charges.retrieve.mockResolvedValue({
|
|
1177
|
-
id: "ch_1",
|
|
1178
|
-
transfer: null,
|
|
1179
|
-
application_fee: null,
|
|
1180
|
-
});
|
|
1181
|
-
|
|
1182
|
-
const result = await bs.createRefund(mockCtx, {
|
|
1183
|
-
stripePaymentIntentId: "pi_1",
|
|
1184
|
-
amount: 250,
|
|
1185
|
-
reason: "requested_by_customer",
|
|
1186
|
-
});
|
|
1187
|
-
|
|
1188
|
-
expect(mockStripeInstance.refunds.create).toHaveBeenCalledWith(
|
|
1189
|
-
{
|
|
1190
|
-
payment_intent: "pi_1",
|
|
1191
|
-
amount: 250,
|
|
1192
|
-
reason: "requested_by_customer",
|
|
1193
|
-
},
|
|
1194
|
-
undefined,
|
|
1195
|
-
);
|
|
1196
|
-
expect(result).toEqual({ stripeRefundId: "re_1" });
|
|
1197
|
-
});
|
|
1198
|
-
|
|
1199
|
-
it("routes to a connected account when stripeAccountId is given", async () => {
|
|
1200
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1201
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1202
|
-
});
|
|
1203
|
-
|
|
1204
|
-
mockStripeInstance.refunds.create.mockResolvedValue({ id: "re_2" });
|
|
1205
|
-
mockStripeInstance.charges.retrieve.mockResolvedValue({
|
|
1206
|
-
id: "ch_1",
|
|
1207
|
-
transfer: null,
|
|
1208
|
-
application_fee: null,
|
|
1209
|
-
});
|
|
1210
|
-
|
|
1211
|
-
await bs.createRefund(mockCtx, {
|
|
1212
|
-
stripeChargeId: "ch_1",
|
|
1213
|
-
stripeAccountId: "acct_1",
|
|
1214
|
-
});
|
|
1215
|
-
|
|
1216
|
-
expect(mockStripeInstance.refunds.create).toHaveBeenCalledWith(
|
|
1217
|
-
{ charge: "ch_1" },
|
|
1218
|
-
{ stripeAccount: "acct_1" },
|
|
1219
|
-
);
|
|
1220
|
-
});
|
|
1221
|
-
|
|
1222
|
-
it("rejects with REFUND_CREATE_FAILED when neither PI nor charge is given", async () => {
|
|
1223
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1224
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1225
|
-
});
|
|
1226
|
-
|
|
1227
|
-
await expect(bs.createRefund(mockCtx, {})).rejects.toMatchObject({
|
|
1228
|
-
data: { code: "REFUND_CREATE_FAILED" },
|
|
1229
|
-
});
|
|
1230
|
-
expect(mockStripeInstance.refunds.create).not.toHaveBeenCalled();
|
|
1231
|
-
});
|
|
1232
|
-
|
|
1233
|
-
it("rejects with REFUND_CREATE_FAILED when both PI and charge are given", async () => {
|
|
1234
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1235
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1236
|
-
});
|
|
1237
|
-
|
|
1238
|
-
await expect(
|
|
1239
|
-
bs.createRefund(mockCtx, {
|
|
1240
|
-
stripePaymentIntentId: "pi_1",
|
|
1241
|
-
stripeChargeId: "ch_1",
|
|
1242
|
-
}),
|
|
1243
|
-
).rejects.toMatchObject({ data: { code: "REFUND_CREATE_FAILED" } });
|
|
1244
|
-
expect(mockStripeInstance.refunds.create).not.toHaveBeenCalled();
|
|
1245
|
-
});
|
|
1246
|
-
|
|
1247
|
-
it("surfaces a STRIPE API failure as REFUND_CREATE_FAILED", async () => {
|
|
1248
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1249
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1250
|
-
});
|
|
1251
|
-
|
|
1252
|
-
mockStripeInstance.refunds.create.mockRejectedValue(new Error("boom"));
|
|
1253
|
-
|
|
1254
|
-
await expect(
|
|
1255
|
-
bs.createRefund(mockCtx, { stripePaymentIntentId: "pi_1" }),
|
|
1256
|
-
).rejects.toMatchObject({ data: { code: "REFUND_CREATE_FAILED" } });
|
|
1257
|
-
});
|
|
1258
|
-
});
|
|
1259
|
-
|
|
1260
|
-
describe("listRefunds / getRefundByStripeId", () => {
|
|
1261
|
-
it("forwards reads to the component, mapping stripeAccountId to accountId", async () => {
|
|
1262
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1263
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1264
|
-
});
|
|
1265
|
-
|
|
1266
|
-
mockCtx.runQuery.mockResolvedValue([]);
|
|
1267
|
-
|
|
1268
|
-
await bs.listRefunds(mockCtx, {
|
|
1269
|
-
stripeAccountId: "acct_1",
|
|
1270
|
-
status: "succeeded",
|
|
1271
|
-
});
|
|
1272
|
-
|
|
1273
|
-
expect(mockCtx.runQuery).toHaveBeenCalledWith(expect.anything(), {
|
|
1274
|
-
accountId: "acct_1",
|
|
1275
|
-
status: "succeeded",
|
|
1276
|
-
});
|
|
1277
|
-
});
|
|
1278
|
-
});
|
|
1279
|
-
|
|
1280
|
-
// =========================================================================
|
|
1281
|
-
// Dispute methods
|
|
1282
|
-
// =========================================================================
|
|
1283
|
-
|
|
1284
|
-
describe("updateDispute", () => {
|
|
1285
|
-
it("submits evidence with the submit flag", async () => {
|
|
1286
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1287
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1288
|
-
});
|
|
1289
|
-
|
|
1290
|
-
mockStripeInstance.disputes.update.mockResolvedValue({});
|
|
1291
|
-
|
|
1292
|
-
const result = await bs.updateDispute(mockCtx, {
|
|
1293
|
-
stripeDisputeId: "dp_1",
|
|
1294
|
-
evidence: { product_description: "A widget" },
|
|
1295
|
-
submit: true,
|
|
1296
|
-
});
|
|
1297
|
-
|
|
1298
|
-
expect(mockStripeInstance.disputes.update).toHaveBeenCalledWith(
|
|
1299
|
-
"dp_1",
|
|
1300
|
-
{ evidence: { product_description: "A widget" }, submit: true },
|
|
1301
|
-
undefined,
|
|
1302
|
-
);
|
|
1303
|
-
expect(result).toEqual({ success: true });
|
|
1304
|
-
});
|
|
1305
|
-
|
|
1306
|
-
it("surfaces a STRIPE API failure as DISPUTE_UPDATE_FAILED", async () => {
|
|
1307
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1308
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1309
|
-
});
|
|
1310
|
-
|
|
1311
|
-
mockStripeInstance.disputes.update.mockRejectedValue(new Error("boom"));
|
|
1312
|
-
|
|
1313
|
-
await expect(
|
|
1314
|
-
bs.updateDispute(mockCtx, { stripeDisputeId: "dp_1", submit: true }),
|
|
1315
|
-
).rejects.toMatchObject({ data: { code: "DISPUTE_UPDATE_FAILED" } });
|
|
1316
|
-
});
|
|
1317
|
-
});
|
|
1318
|
-
|
|
1319
|
-
describe("closeDispute", () => {
|
|
1320
|
-
it("closes the dispute, passing routing options in the third arg", async () => {
|
|
1321
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1322
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1323
|
-
});
|
|
1324
|
-
|
|
1325
|
-
mockStripeInstance.disputes.close.mockResolvedValue({});
|
|
1326
|
-
|
|
1327
|
-
const result = await bs.closeDispute(mockCtx, {
|
|
1328
|
-
stripeDisputeId: "dp_1",
|
|
1329
|
-
stripeAccountId: "acct_1",
|
|
1330
|
-
});
|
|
1331
|
-
|
|
1332
|
-
expect(mockStripeInstance.disputes.close).toHaveBeenCalledWith(
|
|
1333
|
-
"dp_1",
|
|
1334
|
-
{},
|
|
1335
|
-
{ stripeAccount: "acct_1" },
|
|
1336
|
-
);
|
|
1337
|
-
expect(result).toEqual({ success: true });
|
|
1338
|
-
});
|
|
1339
|
-
});
|
|
1340
|
-
|
|
1341
|
-
// =========================================================================
|
|
1342
|
-
// Payment method: listPaymentMethods
|
|
1343
|
-
// =========================================================================
|
|
1344
|
-
|
|
1345
|
-
describe("listPaymentMethods", () => {
|
|
1346
|
-
it("defaults to card type and uses the V2 customer_account param", async () => {
|
|
1347
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1348
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1349
|
-
});
|
|
1350
|
-
|
|
1351
|
-
mockStripeInstance.paymentMethods.list.mockResolvedValue({ data: [] });
|
|
1352
|
-
|
|
1353
|
-
await bs.listPaymentMethods(mockCtx, { stripeCustomerId: "acct_1" });
|
|
1354
|
-
|
|
1355
|
-
expect(mockStripeInstance.paymentMethods.list).toHaveBeenCalledWith({
|
|
1356
|
-
customer_account: "acct_1",
|
|
1357
|
-
type: "card",
|
|
1358
|
-
});
|
|
1359
|
-
});
|
|
1360
|
-
|
|
1361
|
-
it("passes through an explicit type", async () => {
|
|
1362
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1363
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1364
|
-
});
|
|
1365
|
-
|
|
1366
|
-
mockStripeInstance.paymentMethods.list.mockResolvedValue({ data: [] });
|
|
1367
|
-
|
|
1368
|
-
await bs.listPaymentMethods(mockCtx, {
|
|
1369
|
-
stripeCustomerId: "acct_1",
|
|
1370
|
-
type: "us_bank_account",
|
|
1371
|
-
});
|
|
1372
|
-
|
|
1373
|
-
expect(mockStripeInstance.paymentMethods.list).toHaveBeenCalledWith({
|
|
1374
|
-
customer_account: "acct_1",
|
|
1375
|
-
type: "us_bank_account",
|
|
1376
|
-
});
|
|
1377
|
-
});
|
|
1378
|
-
});
|
|
1379
|
-
|
|
1380
|
-
// =========================================================================
|
|
1381
|
-
// Payment method: attachPaymentMethod
|
|
1382
|
-
// =========================================================================
|
|
1383
|
-
|
|
1384
|
-
describe("attachPaymentMethod", () => {
|
|
1385
|
-
it("attaches with the V2 customer_account param and returns success", async () => {
|
|
1386
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1387
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1388
|
-
});
|
|
1389
|
-
|
|
1390
|
-
mockStripeInstance.paymentMethods.attach.mockResolvedValue({});
|
|
1391
|
-
|
|
1392
|
-
const result = await bs.attachPaymentMethod(mockCtx, {
|
|
1393
|
-
paymentMethodId: "pm_1",
|
|
1394
|
-
stripeCustomerId: "acct_1",
|
|
1395
|
-
});
|
|
1396
|
-
|
|
1397
|
-
expect(mockStripeInstance.paymentMethods.attach).toHaveBeenCalledWith(
|
|
1398
|
-
"pm_1",
|
|
1399
|
-
{ customer_account: "acct_1" },
|
|
1400
|
-
);
|
|
1401
|
-
expect(result).toEqual({ success: true });
|
|
1402
|
-
});
|
|
1403
|
-
});
|
|
1404
|
-
|
|
1405
|
-
// =========================================================================
|
|
1406
|
-
// Payment method: detachPaymentMethod
|
|
1407
|
-
// =========================================================================
|
|
1408
|
-
|
|
1409
|
-
describe("detachPaymentMethod", () => {
|
|
1410
|
-
it("calls paymentMethods.detach with the payment method id", async () => {
|
|
1411
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1412
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1413
|
-
});
|
|
1414
|
-
|
|
1415
|
-
mockStripeInstance.paymentMethods.detach.mockResolvedValue({});
|
|
1416
|
-
|
|
1417
|
-
await bs.detachPaymentMethod(mockCtx, { paymentMethodId: "pm_1" });
|
|
1418
|
-
|
|
1419
|
-
expect(mockStripeInstance.paymentMethods.detach).toHaveBeenCalledWith(
|
|
1420
|
-
"pm_1",
|
|
1421
|
-
);
|
|
1422
|
-
});
|
|
1423
|
-
});
|
|
1424
|
-
|
|
1425
|
-
// =========================================================================
|
|
1426
|
-
// Payment method: setDefaultPaymentMethod
|
|
1427
|
-
// =========================================================================
|
|
1428
|
-
|
|
1429
|
-
describe("setDefaultPaymentMethod", () => {
|
|
1430
|
-
it("throws not-yet-implemented error", async () => {
|
|
1431
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1432
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1433
|
-
});
|
|
1434
|
-
|
|
1435
|
-
await expect(
|
|
1436
|
-
bs.setDefaultPaymentMethod(mockCtx, {
|
|
1437
|
-
stripeAccountId: "acct_123",
|
|
1438
|
-
paymentMethodId: "pm_123",
|
|
1439
|
-
}),
|
|
1440
|
-
).rejects.toThrow("not yet implemented for V2 Accounts");
|
|
1441
|
-
});
|
|
1442
|
-
});
|
|
1443
|
-
|
|
1444
|
-
// =========================================================================
|
|
1445
|
-
// syncAllProducts
|
|
1446
|
-
// =========================================================================
|
|
1447
|
-
|
|
1448
|
-
describe("syncAllProducts", () => {
|
|
1449
|
-
/** Helper: returns an async iterable from an array (matches Stripe's auto-pagination API). */
|
|
1450
|
-
async function* asyncIter<T>(items: T[]): AsyncIterable<T> {
|
|
1451
|
-
for (const item of items) {
|
|
1452
|
-
yield item;
|
|
1453
|
-
}
|
|
1454
|
-
}
|
|
1455
|
-
|
|
1456
|
-
it("calls getProductByStripeId exactly once per distinct product even with multiple prices", async () => {
|
|
1457
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1458
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1459
|
-
});
|
|
1460
|
-
|
|
1461
|
-
mockStripeInstance.products.list.mockReturnValue(
|
|
1462
|
-
asyncIter([
|
|
1463
|
-
{
|
|
1464
|
-
id: "prod_1",
|
|
1465
|
-
name: "Product 1",
|
|
1466
|
-
active: true,
|
|
1467
|
-
description: null,
|
|
1468
|
-
metadata: {},
|
|
1469
|
-
},
|
|
1470
|
-
]),
|
|
1471
|
-
);
|
|
1472
|
-
|
|
1473
|
-
// Three prices all belonging to the same product
|
|
1474
|
-
mockStripeInstance.prices.list.mockReturnValue(
|
|
1475
|
-
asyncIter([
|
|
1476
|
-
{
|
|
1477
|
-
id: "price_1",
|
|
1478
|
-
product: "prod_1",
|
|
1479
|
-
active: true,
|
|
1480
|
-
currency: "usd",
|
|
1481
|
-
unit_amount: 1000,
|
|
1482
|
-
type: "one_time",
|
|
1483
|
-
recurring: null,
|
|
1484
|
-
nickname: null,
|
|
1485
|
-
metadata: {},
|
|
1486
|
-
},
|
|
1487
|
-
{
|
|
1488
|
-
id: "price_2",
|
|
1489
|
-
product: "prod_1",
|
|
1490
|
-
active: true,
|
|
1491
|
-
currency: "usd",
|
|
1492
|
-
unit_amount: 2000,
|
|
1493
|
-
type: "one_time",
|
|
1494
|
-
recurring: null,
|
|
1495
|
-
nickname: null,
|
|
1496
|
-
metadata: {},
|
|
1497
|
-
},
|
|
1498
|
-
{
|
|
1499
|
-
id: "price_3",
|
|
1500
|
-
product: "prod_1",
|
|
1501
|
-
active: true,
|
|
1502
|
-
currency: "usd",
|
|
1503
|
-
unit_amount: 3000,
|
|
1504
|
-
type: "one_time",
|
|
1505
|
-
recurring: null,
|
|
1506
|
-
nickname: null,
|
|
1507
|
-
metadata: {},
|
|
1508
|
-
},
|
|
1509
|
-
]),
|
|
1510
|
-
);
|
|
1511
|
-
|
|
1512
|
-
// Resolve query for prod_1 → an internal product
|
|
1513
|
-
mockCtx.runQuery.mockResolvedValue({ _id: "internal_prod_1" });
|
|
1514
|
-
// runMutation succeeds silently
|
|
1515
|
-
mockCtx.runMutation.mockResolvedValue(undefined);
|
|
1516
|
-
|
|
1517
|
-
const result = await bs.syncAllProducts(mockCtx);
|
|
1518
|
-
|
|
1519
|
-
// 1 product upserted + 3 prices upserted
|
|
1520
|
-
expect(result.productsSynced).toBe(1);
|
|
1521
|
-
expect(result.pricesSynced).toBe(3);
|
|
1522
|
-
|
|
1523
|
-
// getProductByStripeId must have been queried exactly once (cache hit on 2nd/3rd price)
|
|
1524
|
-
const queryCallsForGetProduct = mockCtx.runQuery.mock.calls.filter(
|
|
1525
|
-
(call) =>
|
|
1526
|
-
(call[1] as { stripeProductId?: string } | undefined)
|
|
1527
|
-
?.stripeProductId === "prod_1",
|
|
1528
|
-
);
|
|
1529
|
-
expect(queryCallsForGetProduct).toHaveLength(1);
|
|
1530
|
-
});
|
|
1531
|
-
});
|
|
1532
|
-
|
|
1533
|
-
// =========================================================================
|
|
1534
|
-
// syncAllAccounts
|
|
1535
|
-
// =========================================================================
|
|
1536
|
-
|
|
1537
|
-
describe("syncAllAccounts", () => {
|
|
1538
|
-
/** Helper: returns an async iterable from an array (matches Stripe's V2 auto-pagination API). */
|
|
1539
|
-
async function* asyncIter<T>(items: T[]): AsyncIterable<T> {
|
|
1540
|
-
for (const item of items) {
|
|
1541
|
-
yield item;
|
|
1542
|
-
}
|
|
1543
|
-
}
|
|
1544
|
-
|
|
1545
|
-
it("drains every V2 account the SDK's auto-pagination iterator yields", async () => {
|
|
1546
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1547
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1548
|
-
});
|
|
1549
|
-
|
|
1550
|
-
mockStripeInstance.v2.core.accounts.list.mockReturnValue(
|
|
1551
|
-
asyncIter([
|
|
1552
|
-
{
|
|
1553
|
-
id: "acct_1",
|
|
1554
|
-
metadata: { userId: "u1" },
|
|
1555
|
-
configuration: { customer: { applied: true } },
|
|
1556
|
-
},
|
|
1557
|
-
{
|
|
1558
|
-
id: "acct_2",
|
|
1559
|
-
metadata: { userId: "u2" },
|
|
1560
|
-
configuration: { customer: { applied: true } },
|
|
1561
|
-
},
|
|
1562
|
-
{
|
|
1563
|
-
id: "acct_3",
|
|
1564
|
-
metadata: { userId: "u3" },
|
|
1565
|
-
configuration: { customer: { applied: true } },
|
|
1566
|
-
},
|
|
1567
|
-
]),
|
|
1568
|
-
);
|
|
1569
|
-
|
|
1570
|
-
const result = await bs.syncAllAccounts(mockCtx);
|
|
1571
|
-
|
|
1572
|
-
expect(result.synced).toBe(3);
|
|
1573
|
-
expect(result.errorCount).toBe(0);
|
|
1574
|
-
|
|
1575
|
-
expect(mockStripeInstance.v2.core.accounts.list).toHaveBeenCalledTimes(1);
|
|
1576
|
-
expect(mockStripeInstance.v2.core.accounts.list).toHaveBeenCalledWith({
|
|
1577
|
-
limit: 20,
|
|
1578
|
-
});
|
|
1579
|
-
|
|
1580
|
-
// Verify upsertAccount was called 3 times
|
|
1581
|
-
expect(mockCtx.runMutation).toHaveBeenCalledTimes(3);
|
|
1582
|
-
});
|
|
1583
|
-
|
|
1584
|
-
it("derives onboarding status from account requirements", async () => {
|
|
1585
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1586
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1587
|
-
});
|
|
1588
|
-
|
|
1589
|
-
mockStripeInstance.v2.core.accounts.list.mockReturnValue(
|
|
1590
|
-
asyncIter([
|
|
1591
|
-
{
|
|
1592
|
-
id: "acct_restricted",
|
|
1593
|
-
metadata: { userId: "u_restricted" },
|
|
1594
|
-
requirements: {
|
|
1595
|
-
entries: [
|
|
1596
|
-
{
|
|
1597
|
-
description: "business_type",
|
|
1598
|
-
awaiting_action_from: "user",
|
|
1599
|
-
errors: [],
|
|
1600
|
-
impact: { restricts_capabilities: [] },
|
|
1601
|
-
minimum_deadline: { status: "currently_due" },
|
|
1602
|
-
requested_reasons: [],
|
|
1603
|
-
},
|
|
1604
|
-
{
|
|
1605
|
-
description: "tos_acceptance",
|
|
1606
|
-
awaiting_action_from: "user",
|
|
1607
|
-
errors: [],
|
|
1608
|
-
impact: { restricts_capabilities: [] },
|
|
1609
|
-
minimum_deadline: { status: "currently_due" },
|
|
1610
|
-
requested_reasons: [],
|
|
1611
|
-
},
|
|
1612
|
-
],
|
|
1613
|
-
summary: {
|
|
1614
|
-
minimum_deadline: { status: "past_due" },
|
|
1615
|
-
},
|
|
1616
|
-
},
|
|
1617
|
-
configuration: {},
|
|
1618
|
-
},
|
|
1619
|
-
]),
|
|
1620
|
-
);
|
|
1621
|
-
|
|
1622
|
-
const result = await bs.syncAllAccounts(mockCtx);
|
|
1623
|
-
|
|
1624
|
-
expect(result.synced).toBe(1);
|
|
1625
|
-
expect(mockCtx.runMutation).toHaveBeenCalledWith(
|
|
1626
|
-
components.betterStripe.core.mutations.upsertAccount,
|
|
1627
|
-
expect.objectContaining({
|
|
1628
|
-
stripeAccountId: "acct_restricted",
|
|
1629
|
-
onboardingStatus: "restricted",
|
|
1630
|
-
missingRequirements: expect.arrayContaining([
|
|
1631
|
-
"business_type",
|
|
1632
|
-
"tos_acceptance",
|
|
1633
|
-
]),
|
|
1634
|
-
}),
|
|
1635
|
-
);
|
|
1636
|
-
});
|
|
1637
|
-
});
|
|
1638
|
-
|
|
1639
|
-
// =========================================================================
|
|
1640
|
-
// Structured error alignment — one test per converted raw-throw site
|
|
1641
|
-
// =========================================================================
|
|
1642
|
-
|
|
1643
|
-
describe("structured error alignment", () => {
|
|
1644
|
-
it("createAccountWithOnboarding throws BetterStripeError ACCOUNT_CREATE_FAILED on config error", async () => {
|
|
1645
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1646
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1647
|
-
});
|
|
1648
|
-
|
|
1649
|
-
const fakeAccount = {
|
|
1650
|
-
id: "acct_err",
|
|
1651
|
-
applied_configurations: [],
|
|
1652
|
-
configuration: {},
|
|
1653
|
-
metadata: {},
|
|
1654
|
-
requirements: {
|
|
1655
|
-
entries: [],
|
|
1656
|
-
summary: { minimum_deadline: { status: "no_requirements" } },
|
|
1657
|
-
},
|
|
1658
|
-
};
|
|
1659
|
-
mockStripeInstance.v2.core.accounts.create.mockResolvedValue(fakeAccount);
|
|
1660
|
-
mockStripeInstance.v2.core.accounts.update.mockRejectedValue({
|
|
1661
|
-
type: "api_error",
|
|
1662
|
-
code: "resource_missing",
|
|
1663
|
-
message: "config failed",
|
|
1664
|
-
});
|
|
1665
|
-
mockCtx.runMutation.mockResolvedValue(undefined);
|
|
1666
|
-
|
|
1667
|
-
let caught: unknown;
|
|
1668
|
-
try {
|
|
1669
|
-
await bs.createAccountWithOnboarding(mockCtx, {
|
|
1670
|
-
userId: "user_123",
|
|
1671
|
-
country: "US",
|
|
1672
|
-
refreshUrl: "https://example.com/refresh",
|
|
1673
|
-
returnUrl: "https://example.com/return",
|
|
1674
|
-
});
|
|
1675
|
-
expect.unreachable("should have thrown");
|
|
1676
|
-
} catch (e) {
|
|
1677
|
-
caught = e;
|
|
1678
|
-
}
|
|
1679
|
-
|
|
1680
|
-
expect(isBetterStripeError(caught)).toBe(true);
|
|
1681
|
-
const data = (caught as ConvexError<{ code: string; message: string }>)
|
|
1682
|
-
.data;
|
|
1683
|
-
expect(data.code).toBe("ACCOUNT_CREATE_FAILED");
|
|
1684
|
-
expect(data.message).toContain(
|
|
1685
|
-
"Failed to apply account configuration after create",
|
|
1686
|
-
);
|
|
1687
|
-
});
|
|
1688
|
-
|
|
1689
|
-
it("updateSubscriptionQuantity throws BetterStripeError SUBSCRIPTION_UPDATE_FAILED when sub has no items", async () => {
|
|
1690
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1691
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1692
|
-
});
|
|
1693
|
-
|
|
1694
|
-
mockStripeInstance.subscriptions.retrieve.mockResolvedValue({
|
|
1695
|
-
id: "sub_no_items",
|
|
1696
|
-
items: { data: [] },
|
|
1697
|
-
});
|
|
1698
|
-
|
|
1699
|
-
let caught: unknown;
|
|
1700
|
-
try {
|
|
1701
|
-
await bs.updateSubscriptionQuantity(mockCtx, {
|
|
1702
|
-
stripeSubscriptionId: "sub_no_items",
|
|
1703
|
-
quantity: 2,
|
|
1704
|
-
});
|
|
1705
|
-
expect.unreachable("should have thrown");
|
|
1706
|
-
} catch (e) {
|
|
1707
|
-
caught = e;
|
|
1708
|
-
}
|
|
1709
|
-
|
|
1710
|
-
expect(isBetterStripeError(caught)).toBe(true);
|
|
1711
|
-
const data = (caught as ConvexError<{ code: string; message: string }>)
|
|
1712
|
-
.data;
|
|
1713
|
-
expect(data.code).toBe("SUBSCRIPTION_UPDATE_FAILED");
|
|
1714
|
-
expect(data.message).toBe("Subscription has no items");
|
|
1715
|
-
});
|
|
1716
|
-
|
|
1717
|
-
it("createPrice throws BetterStripeError PRODUCT_NOT_FOUND when product missing from DB", async () => {
|
|
1718
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1719
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1720
|
-
});
|
|
1721
|
-
|
|
1722
|
-
mockStripeInstance.prices.create.mockResolvedValue({
|
|
1723
|
-
id: "price_new",
|
|
1724
|
-
nickname: null,
|
|
1725
|
-
unit_amount: 500,
|
|
1726
|
-
currency: "usd",
|
|
1727
|
-
active: true,
|
|
1728
|
-
metadata: {},
|
|
1729
|
-
});
|
|
1730
|
-
// runQuery returns null — product not found in component DB
|
|
1731
|
-
mockCtx.runQuery.mockResolvedValue(null);
|
|
1732
|
-
|
|
1733
|
-
let caught: unknown;
|
|
1734
|
-
try {
|
|
1735
|
-
await bs.createPrice(mockCtx, {
|
|
1736
|
-
stripeProductId: "prod_missing",
|
|
1737
|
-
unitAmount: 500,
|
|
1738
|
-
currency: "usd",
|
|
1739
|
-
type: "one_time",
|
|
1740
|
-
});
|
|
1741
|
-
expect.unreachable("should have thrown");
|
|
1742
|
-
} catch (e) {
|
|
1743
|
-
caught = e;
|
|
1744
|
-
}
|
|
1745
|
-
|
|
1746
|
-
expect(isBetterStripeError(caught)).toBe(true);
|
|
1747
|
-
const data = (caught as ConvexError<{ code: string; message: string }>)
|
|
1748
|
-
.data;
|
|
1749
|
-
expect(data.code).toBe("PRODUCT_NOT_FOUND");
|
|
1750
|
-
expect(data.message).toContain("prod_missing");
|
|
1751
|
-
|
|
1752
|
-
// Validate-first: the product is missing, so we must throw BEFORE any
|
|
1753
|
-
// Stripe write. Calling prices.create here would orphan a price in
|
|
1754
|
-
// Stripe with no corresponding component record (BTS-2).
|
|
1755
|
-
expect(mockStripeInstance.prices.create).not.toHaveBeenCalled();
|
|
1756
|
-
expect(mockCtx.runMutation).not.toHaveBeenCalled();
|
|
1757
|
-
});
|
|
1758
|
-
|
|
1759
|
-
it("setDefaultPaymentMethod throws BetterStripeError PAYMENT_METHOD_FAILED", async () => {
|
|
1760
|
-
const bs = new BetterStripe(components.betterStripe, {
|
|
1761
|
-
STRIPE_SECRET_KEY: "sk_test_xxx",
|
|
1762
|
-
});
|
|
1763
|
-
|
|
1764
|
-
let caught: unknown;
|
|
1765
|
-
try {
|
|
1766
|
-
await bs.setDefaultPaymentMethod(mockCtx, {
|
|
1767
|
-
stripeAccountId: "acct_123",
|
|
1768
|
-
paymentMethodId: "pm_123",
|
|
1769
|
-
});
|
|
1770
|
-
expect.unreachable("should have thrown");
|
|
1771
|
-
} catch (e) {
|
|
1772
|
-
caught = e;
|
|
1773
|
-
}
|
|
1774
|
-
|
|
1775
|
-
expect(isBetterStripeError(caught)).toBe(true);
|
|
1776
|
-
const data = (caught as ConvexError<{ code: string; message: string }>)
|
|
1777
|
-
.data;
|
|
1778
|
-
expect(data.code).toBe("PAYMENT_METHOD_FAILED");
|
|
1779
|
-
expect(data.message).toContain(
|
|
1780
|
-
"setDefaultPaymentMethod is not yet implemented",
|
|
1781
|
-
);
|
|
1782
|
-
});
|
|
1783
|
-
});
|
|
1784
|
-
});
|