@fantastic.dev/better-stripe 0.4.0-bootstrap.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +318 -0
- package/README.md +1117 -0
- package/dist/client/billing/checkout.d.ts +75 -0
- package/dist/client/billing/checkout.d.ts.map +1 -0
- package/dist/client/billing/checkout.js +260 -0
- package/dist/client/billing/checkout.js.map +1 -0
- package/dist/client/billing/invoices.d.ts +37 -0
- package/dist/client/billing/invoices.d.ts.map +1 -0
- package/dist/client/billing/invoices.js +29 -0
- package/dist/client/billing/invoices.js.map +1 -0
- package/dist/client/billing/subscriptions.d.ts +179 -0
- package/dist/client/billing/subscriptions.d.ts.map +1 -0
- package/dist/client/billing/subscriptions.js +346 -0
- package/dist/client/billing/subscriptions.js.map +1 -0
- package/dist/client/connect/disputes.d.ts +112 -0
- package/dist/client/connect/disputes.d.ts.map +1 -0
- package/dist/client/connect/disputes.js +186 -0
- package/dist/client/connect/disputes.js.map +1 -0
- package/dist/client/connect/paymentMethodUtils.d.ts +17 -0
- package/dist/client/connect/paymentMethodUtils.d.ts.map +1 -0
- package/dist/client/connect/paymentMethodUtils.js +24 -0
- package/dist/client/connect/paymentMethodUtils.js.map +1 -0
- package/dist/client/connect/paymentMethods.d.ts +23 -0
- package/dist/client/connect/paymentMethods.d.ts.map +1 -0
- package/dist/client/connect/paymentMethods.js +27 -0
- package/dist/client/connect/paymentMethods.js.map +1 -0
- package/dist/client/connect/payouts.d.ts +47 -0
- package/dist/client/connect/payouts.d.ts.map +1 -0
- package/dist/client/connect/payouts.js +52 -0
- package/dist/client/connect/payouts.js.map +1 -0
- package/dist/client/connect/refundActor.d.ts +50 -0
- package/dist/client/connect/refundActor.d.ts.map +1 -0
- package/dist/client/connect/refundActor.js +17 -0
- package/dist/client/connect/refundActor.js.map +1 -0
- package/dist/client/connect/refunds.d.ts +75 -0
- package/dist/client/connect/refunds.d.ts.map +1 -0
- package/dist/client/connect/refunds.js +141 -0
- package/dist/client/connect/refunds.js.map +1 -0
- package/dist/client/connect/transfers.d.ts +189 -0
- package/dist/client/connect/transfers.d.ts.map +1 -0
- package/dist/client/connect/transfers.js +347 -0
- package/dist/client/connect/transfers.js.map +1 -0
- package/dist/client/constants.d.ts +15 -0
- package/dist/client/constants.d.ts.map +1 -0
- package/dist/client/constants.js +14 -0
- package/dist/client/constants.js.map +1 -0
- package/dist/client/core/accountLinks.d.ts +68 -0
- package/dist/client/core/accountLinks.d.ts.map +1 -0
- package/dist/client/core/accountLinks.js +131 -0
- package/dist/client/core/accountLinks.js.map +1 -0
- package/dist/client/core/accountStatus.d.ts +12 -0
- package/dist/client/core/accountStatus.d.ts.map +1 -0
- package/dist/client/core/accountStatus.js +56 -0
- package/dist/client/core/accountStatus.js.map +1 -0
- package/dist/client/core/accounts.d.ts +181 -0
- package/dist/client/core/accounts.d.ts.map +1 -0
- package/dist/client/core/accounts.js +359 -0
- package/dist/client/core/accounts.js.map +1 -0
- package/dist/client/core/config.d.ts +5 -0
- package/dist/client/core/config.d.ts.map +1 -0
- package/dist/client/core/config.js +11 -0
- package/dist/client/core/config.js.map +1 -0
- package/dist/client/core/descriptors.d.ts +24 -0
- package/dist/client/core/descriptors.d.ts.map +1 -0
- package/dist/client/core/descriptors.js +43 -0
- package/dist/client/core/descriptors.js.map +1 -0
- package/dist/client/core/fees.d.ts +83 -0
- package/dist/client/core/fees.d.ts.map +1 -0
- package/dist/client/core/fees.js +178 -0
- package/dist/client/core/fees.js.map +1 -0
- package/dist/client/errors.d.ts +20 -0
- package/dist/client/errors.d.ts.map +1 -0
- package/dist/client/errors.js +31 -0
- package/dist/client/errors.js.map +1 -0
- package/dist/client/helpers.d.ts +20 -0
- package/dist/client/helpers.d.ts.map +1 -0
- package/dist/client/helpers.js +46 -0
- package/dist/client/helpers.js.map +1 -0
- package/dist/client/index.d.ts +880 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +791 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/products/prices.d.ts +61 -0
- package/dist/client/products/prices.d.ts.map +1 -0
- package/dist/client/products/prices.js +92 -0
- package/dist/client/products/prices.js.map +1 -0
- package/dist/client/products/products.d.ts +65 -0
- package/dist/client/products/products.d.ts.map +1 -0
- package/dist/client/products/products.js +186 -0
- package/dist/client/products/products.js.map +1 -0
- package/dist/client/stripe-types.d.ts +44 -0
- package/dist/client/stripe-types.d.ts.map +1 -0
- package/dist/client/stripe-types.js +2 -0
- package/dist/client/stripe-types.js.map +1 -0
- package/dist/client/types/documents.d.ts +195 -0
- package/dist/client/types/documents.d.ts.map +1 -0
- package/dist/client/types/documents.js +2 -0
- package/dist/client/types/documents.js.map +1 -0
- package/dist/client/types/events.d.ts +43 -0
- package/dist/client/types/events.d.ts.map +1 -0
- package/dist/client/types/events.js +2 -0
- package/dist/client/types/events.js.map +1 -0
- package/dist/client/types/index.d.ts +5 -0
- package/dist/client/types/index.d.ts.map +1 -0
- package/dist/client/types/index.js +2 -0
- package/dist/client/types/index.js.map +1 -0
- package/dist/client/types/options.d.ts +79 -0
- package/dist/client/types/options.d.ts.map +1 -0
- package/dist/client/types/options.js +2 -0
- package/dist/client/types/options.js.map +1 -0
- package/dist/client/types/triggers.d.ts +101 -0
- package/dist/client/types/triggers.d.ts.map +1 -0
- package/dist/client/types/triggers.js +2 -0
- package/dist/client/types/triggers.js.map +1 -0
- package/dist/client/types.d.ts +2 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +2 -0
- package/dist/client/types.js.map +1 -0
- package/dist/client/utils/data.d.ts +10 -0
- package/dist/client/utils/data.d.ts.map +1 -0
- package/dist/client/utils/data.js +13 -0
- package/dist/client/utils/data.js.map +1 -0
- package/dist/client/utils/owner.d.ts +22 -0
- package/dist/client/utils/owner.d.ts.map +1 -0
- package/dist/client/utils/owner.js +20 -0
- package/dist/client/utils/owner.js.map +1 -0
- package/dist/client/utils/stripeDashboardUrl.d.ts +12 -0
- package/dist/client/utils/stripeDashboardUrl.d.ts.map +1 -0
- package/dist/client/utils/stripeDashboardUrl.js +39 -0
- package/dist/client/utils/stripeDashboardUrl.js.map +1 -0
- package/dist/client/utils/webhookEndpoints.d.ts +83 -0
- package/dist/client/utils/webhookEndpoints.d.ts.map +1 -0
- package/dist/client/utils/webhookEndpoints.js +185 -0
- package/dist/client/utils/webhookEndpoints.js.map +1 -0
- package/dist/client/webhooks/handler.d.ts +4 -0
- package/dist/client/webhooks/handler.d.ts.map +1 -0
- package/dist/client/webhooks/handler.js +170 -0
- package/dist/client/webhooks/handler.js.map +1 -0
- package/dist/client/webhooks/helpers.d.ts +56 -0
- package/dist/client/webhooks/helpers.d.ts.map +1 -0
- package/dist/client/webhooks/helpers.js +229 -0
- package/dist/client/webhooks/helpers.js.map +1 -0
- package/dist/client/webhooks/hooks.d.ts +11 -0
- package/dist/client/webhooks/hooks.d.ts.map +1 -0
- package/dist/client/webhooks/hooks.js +134 -0
- package/dist/client/webhooks/hooks.js.map +1 -0
- package/dist/client/webhooks/index.d.ts +23 -0
- package/dist/client/webhooks/index.d.ts.map +1 -0
- package/dist/client/webhooks/index.js +35 -0
- package/dist/client/webhooks/index.js.map +1 -0
- package/dist/client/webhooks/processors.d.ts +4 -0
- package/dist/client/webhooks/processors.d.ts.map +1 -0
- package/dist/client/webhooks/processors.js +932 -0
- package/dist/client/webhooks/processors.js.map +1 -0
- package/dist/client/webhooks/v2.d.ts +11 -0
- package/dist/client/webhooks/v2.d.ts.map +1 -0
- package/dist/client/webhooks/v2.js +94 -0
- package/dist/client/webhooks/v2.js.map +1 -0
- package/dist/client/webhooks.d.ts +2 -0
- package/dist/client/webhooks.d.ts.map +1 -0
- package/dist/client/webhooks.js +4 -0
- package/dist/client/webhooks.js.map +1 -0
- package/dist/component/_generated/component.d.ts +1262 -0
- package/dist/component/_generated/component.d.ts.map +1 -0
- package/dist/component/_generated/component.js +11 -0
- package/dist/component/_generated/component.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +46 -0
- package/dist/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/component/_generated/dataModel.js +11 -0
- package/dist/component/_generated/dataModel.js.map +1 -0
- package/dist/component/_generated/server.d.ts +129 -0
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/component/_generated/server.js +79 -0
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/billing/mutations.d.ts +86 -0
- package/dist/component/billing/mutations.d.ts.map +1 -0
- package/dist/component/billing/mutations.js +131 -0
- package/dist/component/billing/mutations.js.map +1 -0
- package/dist/component/billing/queries.d.ts +425 -0
- package/dist/component/billing/queries.d.ts.map +1 -0
- package/dist/component/billing/queries.js +304 -0
- package/dist/component/billing/queries.js.map +1 -0
- package/dist/component/billing/schema.d.ts +228 -0
- package/dist/component/billing/schema.d.ts.map +1 -0
- package/dist/component/billing/schema.js +33 -0
- package/dist/component/billing/schema.js.map +1 -0
- package/dist/component/billing/validators.d.ts +364 -0
- package/dist/component/billing/validators.d.ts.map +1 -0
- package/dist/component/billing/validators.js +98 -0
- package/dist/component/billing/validators.js.map +1 -0
- package/dist/component/connect/mutations.d.ts +182 -0
- package/dist/component/connect/mutations.d.ts.map +1 -0
- package/dist/component/connect/mutations.js +480 -0
- package/dist/component/connect/mutations.js.map +1 -0
- package/dist/component/connect/queries.d.ts +347 -0
- package/dist/component/connect/queries.d.ts.map +1 -0
- package/dist/component/connect/queries.js +449 -0
- package/dist/component/connect/queries.js.map +1 -0
- package/dist/component/connect/schema.d.ts +258 -0
- package/dist/component/connect/schema.d.ts.map +1 -0
- package/dist/component/connect/schema.js +70 -0
- package/dist/component/connect/schema.js.map +1 -0
- package/dist/component/connect/validators.d.ts +468 -0
- package/dist/component/connect/validators.d.ts.map +1 -0
- package/dist/component/connect/validators.js +250 -0
- package/dist/component/connect/validators.js.map +1 -0
- package/dist/component/convex.config.d.ts +5 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js +17 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/core/mutations.d.ts +52 -0
- package/dist/component/core/mutations.d.ts.map +1 -0
- package/dist/component/core/mutations.js +153 -0
- package/dist/component/core/mutations.js.map +1 -0
- package/dist/component/core/queries.d.ts +95 -0
- package/dist/component/core/queries.d.ts.map +1 -0
- package/dist/component/core/queries.js +86 -0
- package/dist/component/core/queries.js.map +1 -0
- package/dist/component/core/schema.d.ts +41 -0
- package/dist/component/core/schema.d.ts.map +1 -0
- package/dist/component/core/schema.js +12 -0
- package/dist/component/core/schema.js.map +1 -0
- package/dist/component/core/validators.d.ts +65 -0
- package/dist/component/core/validators.d.ts.map +1 -0
- package/dist/component/core/validators.js +35 -0
- package/dist/component/core/validators.js.map +1 -0
- package/dist/component/lib/fees.d.ts +74 -0
- package/dist/component/lib/fees.d.ts.map +1 -0
- package/dist/component/lib/fees.js +51 -0
- package/dist/component/lib/fees.js.map +1 -0
- package/dist/component/lib/idempotency.d.ts +9 -0
- package/dist/component/lib/idempotency.d.ts.map +1 -0
- package/dist/component/lib/idempotency.js +18 -0
- package/dist/component/lib/idempotency.js.map +1 -0
- package/dist/component/lib/reversals.d.ts +48 -0
- package/dist/component/lib/reversals.d.ts.map +1 -0
- package/dist/component/lib/reversals.js +79 -0
- package/dist/component/lib/reversals.js.map +1 -0
- package/dist/component/lib/stripeFactory.d.ts +7 -0
- package/dist/component/lib/stripeFactory.d.ts.map +1 -0
- package/dist/component/lib/stripeFactory.js +28 -0
- package/dist/component/lib/stripeFactory.js.map +1 -0
- package/dist/component/products/mutations.d.ts +22 -0
- package/dist/component/products/mutations.d.ts.map +1 -0
- package/dist/component/products/mutations.js +63 -0
- package/dist/component/products/mutations.js.map +1 -0
- package/dist/component/products/queries.d.ts +109 -0
- package/dist/component/products/queries.d.ts.map +1 -0
- package/dist/component/products/queries.js +122 -0
- package/dist/component/products/queries.js.map +1 -0
- package/dist/component/products/schema.d.ts +58 -0
- package/dist/component/products/schema.d.ts.map +1 -0
- package/dist/component/products/schema.js +20 -0
- package/dist/component/products/schema.js.map +1 -0
- package/dist/component/products/validators.d.ts +86 -0
- package/dist/component/products/validators.d.ts.map +1 -0
- package/dist/component/products/validators.js +47 -0
- package/dist/component/products/validators.js.map +1 -0
- package/dist/component/schema.d.ts +555 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +28 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/component/webhooks/mutations.d.ts +30 -0
- package/dist/component/webhooks/mutations.d.ts.map +1 -0
- package/dist/component/webhooks/mutations.js +124 -0
- package/dist/component/webhooks/mutations.js.map +1 -0
- package/dist/component/webhooks/queries.d.ts +35 -0
- package/dist/component/webhooks/queries.d.ts.map +1 -0
- package/dist/component/webhooks/queries.js +41 -0
- package/dist/component/webhooks/queries.js.map +1 -0
- package/dist/component/webhooks/schema.d.ts +22 -0
- package/dist/component/webhooks/schema.d.ts.map +1 -0
- package/dist/component/webhooks/schema.js +9 -0
- package/dist/component/webhooks/schema.js.map +1 -0
- package/dist/component/webhooks/validators.d.ts +37 -0
- package/dist/component/webhooks/validators.d.ts.map +1 -0
- package/dist/component/webhooks/validators.js +22 -0
- package/dist/component/webhooks/validators.js.map +1 -0
- package/dist/react/components/AccountCloseButton.d.ts +42 -0
- package/dist/react/components/AccountCloseButton.d.ts.map +1 -0
- package/dist/react/components/AccountCloseButton.js +33 -0
- package/dist/react/components/AccountCloseButton.js.map +1 -0
- package/dist/react/components/AccountCloseCard.d.ts +31 -0
- package/dist/react/components/AccountCloseCard.d.ts.map +1 -0
- package/dist/react/components/AccountCloseCard.js +22 -0
- package/dist/react/components/AccountCloseCard.js.map +1 -0
- package/dist/react/components/AccountCreateButton.d.ts +37 -0
- package/dist/react/components/AccountCreateButton.d.ts.map +1 -0
- package/dist/react/components/AccountCreateButton.js +30 -0
- package/dist/react/components/AccountCreateButton.js.map +1 -0
- package/dist/react/components/AccountCreateCard.d.ts +48 -0
- package/dist/react/components/AccountCreateCard.d.ts.map +1 -0
- package/dist/react/components/AccountCreateCard.js +29 -0
- package/dist/react/components/AccountCreateCard.js.map +1 -0
- package/dist/react/components/AccountLoginButton.d.ts +31 -0
- package/dist/react/components/AccountLoginButton.d.ts.map +1 -0
- package/dist/react/components/AccountLoginButton.js +31 -0
- package/dist/react/components/AccountLoginButton.js.map +1 -0
- package/dist/react/components/AccountLoginCard.d.ts +33 -0
- package/dist/react/components/AccountLoginCard.d.ts.map +1 -0
- package/dist/react/components/AccountLoginCard.js +19 -0
- package/dist/react/components/AccountLoginCard.js.map +1 -0
- package/dist/react/components/AccountOnboardingButton.d.ts +37 -0
- package/dist/react/components/AccountOnboardingButton.d.ts.map +1 -0
- package/dist/react/components/AccountOnboardingButton.js +30 -0
- package/dist/react/components/AccountOnboardingButton.js.map +1 -0
- package/dist/react/components/AccountOnboardingCard.d.ts +56 -0
- package/dist/react/components/AccountOnboardingCard.d.ts.map +1 -0
- package/dist/react/components/AccountOnboardingCard.js +36 -0
- package/dist/react/components/AccountOnboardingCard.js.map +1 -0
- package/dist/react/components/AddCardForm.d.ts +18 -0
- package/dist/react/components/AddCardForm.d.ts.map +1 -0
- package/dist/react/components/AddCardForm.js +49 -0
- package/dist/react/components/AddCardForm.js.map +1 -0
- package/dist/react/components/BillingPortalLink.d.ts +23 -0
- package/dist/react/components/BillingPortalLink.d.ts.map +1 -0
- package/dist/react/components/BillingPortalLink.js +55 -0
- package/dist/react/components/BillingPortalLink.js.map +1 -0
- package/dist/react/components/BuyerBillingView.d.ts +80 -0
- package/dist/react/components/BuyerBillingView.d.ts.map +1 -0
- package/dist/react/components/BuyerBillingView.js +44 -0
- package/dist/react/components/BuyerBillingView.js.map +1 -0
- package/dist/react/components/CheckoutSessionProvider.d.ts +34 -0
- package/dist/react/components/CheckoutSessionProvider.d.ts.map +1 -0
- package/dist/react/components/CheckoutSessionProvider.js +38 -0
- package/dist/react/components/CheckoutSessionProvider.js.map +1 -0
- package/dist/react/components/CheckoutSessionProviderWithKey.d.ts +36 -0
- package/dist/react/components/CheckoutSessionProviderWithKey.d.ts.map +1 -0
- package/dist/react/components/CheckoutSessionProviderWithKey.js +36 -0
- package/dist/react/components/CheckoutSessionProviderWithKey.js.map +1 -0
- package/dist/react/components/CheckoutStatus.d.ts +25 -0
- package/dist/react/components/CheckoutStatus.d.ts.map +1 -0
- package/dist/react/components/CheckoutStatus.js +22 -0
- package/dist/react/components/CheckoutStatus.js.map +1 -0
- package/dist/react/components/ConnectProvider.d.ts +29 -0
- package/dist/react/components/ConnectProvider.d.ts.map +1 -0
- package/dist/react/components/ConnectProvider.js +25 -0
- package/dist/react/components/ConnectProvider.js.map +1 -0
- package/dist/react/components/ConnectRequirements.d.ts +55 -0
- package/dist/react/components/ConnectRequirements.d.ts.map +1 -0
- package/dist/react/components/ConnectRequirements.js +58 -0
- package/dist/react/components/ConnectRequirements.js.map +1 -0
- package/dist/react/components/ConnectStatusBadge.d.ts +26 -0
- package/dist/react/components/ConnectStatusBadge.d.ts.map +1 -0
- package/dist/react/components/ConnectStatusBadge.js +20 -0
- package/dist/react/components/ConnectStatusBadge.js.map +1 -0
- package/dist/react/components/DeletePaymentMethodDialog.d.ts +25 -0
- package/dist/react/components/DeletePaymentMethodDialog.d.ts.map +1 -0
- package/dist/react/components/DeletePaymentMethodDialog.js +16 -0
- package/dist/react/components/DeletePaymentMethodDialog.js.map +1 -0
- package/dist/react/components/DisputeDetail.d.ts +42 -0
- package/dist/react/components/DisputeDetail.d.ts.map +1 -0
- package/dist/react/components/DisputeDetail.js +34 -0
- package/dist/react/components/DisputeDetail.js.map +1 -0
- package/dist/react/components/DisputesList.d.ts +42 -0
- package/dist/react/components/DisputesList.d.ts.map +1 -0
- package/dist/react/components/DisputesList.js +47 -0
- package/dist/react/components/DisputesList.js.map +1 -0
- package/dist/react/components/EarningsSummary.d.ts +53 -0
- package/dist/react/components/EarningsSummary.d.ts.map +1 -0
- package/dist/react/components/EarningsSummary.js +37 -0
- package/dist/react/components/EarningsSummary.js.map +1 -0
- package/dist/react/components/EmbeddedCheckout.d.ts +18 -0
- package/dist/react/components/EmbeddedCheckout.d.ts.map +1 -0
- package/dist/react/components/EmbeddedCheckout.js +17 -0
- package/dist/react/components/EmbeddedCheckout.js.map +1 -0
- package/dist/react/components/EmbeddedDisputes.d.ts +21 -0
- package/dist/react/components/EmbeddedDisputes.d.ts.map +1 -0
- package/dist/react/components/EmbeddedDisputes.js +17 -0
- package/dist/react/components/EmbeddedDisputes.js.map +1 -0
- package/dist/react/components/EvidenceForm.d.ts +63 -0
- package/dist/react/components/EvidenceForm.d.ts.map +1 -0
- package/dist/react/components/EvidenceForm.js +79 -0
- package/dist/react/components/EvidenceForm.js.map +1 -0
- package/dist/react/components/IntervalSelector.d.ts +20 -0
- package/dist/react/components/IntervalSelector.d.ts.map +1 -0
- package/dist/react/components/IntervalSelector.js +15 -0
- package/dist/react/components/IntervalSelector.js.map +1 -0
- package/dist/react/components/PaymentMethodActions.d.ts +27 -0
- package/dist/react/components/PaymentMethodActions.d.ts.map +1 -0
- package/dist/react/components/PaymentMethodActions.js +23 -0
- package/dist/react/components/PaymentMethodActions.js.map +1 -0
- package/dist/react/components/PaymentMethodsList.d.ts +32 -0
- package/dist/react/components/PaymentMethodsList.d.ts.map +1 -0
- package/dist/react/components/PaymentMethodsList.js +18 -0
- package/dist/react/components/PaymentMethodsList.js.map +1 -0
- package/dist/react/components/PayoutSchedule.d.ts +55 -0
- package/dist/react/components/PayoutSchedule.d.ts.map +1 -0
- package/dist/react/components/PayoutSchedule.js +51 -0
- package/dist/react/components/PayoutSchedule.js.map +1 -0
- package/dist/react/components/PriceBadge.d.ts +19 -0
- package/dist/react/components/PriceBadge.d.ts.map +1 -0
- package/dist/react/components/PriceBadge.js +25 -0
- package/dist/react/components/PriceBadge.js.map +1 -0
- package/dist/react/components/PriceCard.d.ts +34 -0
- package/dist/react/components/PriceCard.d.ts.map +1 -0
- package/dist/react/components/PriceCard.js +20 -0
- package/dist/react/components/PriceCard.js.map +1 -0
- package/dist/react/components/PricePicker.d.ts +28 -0
- package/dist/react/components/PricePicker.d.ts.map +1 -0
- package/dist/react/components/PricePicker.js +32 -0
- package/dist/react/components/PricePicker.js.map +1 -0
- package/dist/react/components/SplitBreakdown.d.ts +45 -0
- package/dist/react/components/SplitBreakdown.d.ts.map +1 -0
- package/dist/react/components/SplitBreakdown.js +48 -0
- package/dist/react/components/SplitBreakdown.js.map +1 -0
- package/dist/react/components/StripeProvider.d.ts +30 -0
- package/dist/react/components/StripeProvider.d.ts.map +1 -0
- package/dist/react/components/StripeProvider.js +38 -0
- package/dist/react/components/StripeProvider.js.map +1 -0
- package/dist/react/components/StripeProviderWithKey.d.ts +33 -0
- package/dist/react/components/StripeProviderWithKey.d.ts.map +1 -0
- package/dist/react/components/StripeProviderWithKey.js +44 -0
- package/dist/react/components/StripeProviderWithKey.js.map +1 -0
- package/dist/react/components/SubscriptionActions.d.ts +31 -0
- package/dist/react/components/SubscriptionActions.d.ts.map +1 -0
- package/dist/react/components/SubscriptionActions.js +30 -0
- package/dist/react/components/SubscriptionActions.js.map +1 -0
- package/dist/react/components/SubscriptionCard.d.ts +41 -0
- package/dist/react/components/SubscriptionCard.d.ts.map +1 -0
- package/dist/react/components/SubscriptionCard.js +18 -0
- package/dist/react/components/SubscriptionCard.js.map +1 -0
- package/dist/react/components/SubscriptionLineItems.d.ts +23 -0
- package/dist/react/components/SubscriptionLineItems.d.ts.map +1 -0
- package/dist/react/components/SubscriptionLineItems.js +20 -0
- package/dist/react/components/SubscriptionLineItems.js.map +1 -0
- package/dist/react/components/TrialAlert.d.ts +19 -0
- package/dist/react/components/TrialAlert.d.ts.map +1 -0
- package/dist/react/components/TrialAlert.js +16 -0
- package/dist/react/components/TrialAlert.js.map +1 -0
- package/dist/react/hooks/useAccount.d.ts +14 -0
- package/dist/react/hooks/useAccount.d.ts.map +1 -0
- package/dist/react/hooks/useAccount.js +18 -0
- package/dist/react/hooks/useAccount.js.map +1 -0
- package/dist/react/hooks/useAccountOnboarding.d.ts +15 -0
- package/dist/react/hooks/useAccountOnboarding.d.ts.map +1 -0
- package/dist/react/hooks/useAccountOnboarding.js +19 -0
- package/dist/react/hooks/useAccountOnboarding.js.map +1 -0
- package/dist/react/hooks/useCheckout.d.ts +14 -0
- package/dist/react/hooks/useCheckout.d.ts.map +1 -0
- package/dist/react/hooks/useCheckout.js +18 -0
- package/dist/react/hooks/useCheckout.js.map +1 -0
- package/dist/react/hooks/useCheckoutSession.d.ts +62 -0
- package/dist/react/hooks/useCheckoutSession.d.ts.map +1 -0
- package/dist/react/hooks/useCheckoutSession.js +68 -0
- package/dist/react/hooks/useCheckoutSession.js.map +1 -0
- package/dist/react/hooks/useConfirmPayment.d.ts +38 -0
- package/dist/react/hooks/useConfirmPayment.d.ts.map +1 -0
- package/dist/react/hooks/useConfirmPayment.js +91 -0
- package/dist/react/hooks/useConfirmPayment.js.map +1 -0
- package/dist/react/hooks/useDisputeWithCountdown.d.ts +25 -0
- package/dist/react/hooks/useDisputeWithCountdown.d.ts.map +1 -0
- package/dist/react/hooks/useDisputeWithCountdown.js +19 -0
- package/dist/react/hooks/useDisputeWithCountdown.js.map +1 -0
- package/dist/react/hooks/useDisputes.d.ts +14 -0
- package/dist/react/hooks/useDisputes.d.ts.map +1 -0
- package/dist/react/hooks/useDisputes.js +15 -0
- package/dist/react/hooks/useDisputes.js.map +1 -0
- package/dist/react/hooks/useEarnings.d.ts +92 -0
- package/dist/react/hooks/useEarnings.d.ts.map +1 -0
- package/dist/react/hooks/useEarnings.js +35 -0
- package/dist/react/hooks/useEarnings.js.map +1 -0
- package/dist/react/hooks/useInvoices.d.ts +11 -0
- package/dist/react/hooks/useInvoices.d.ts.map +1 -0
- package/dist/react/hooks/useInvoices.js +11 -0
- package/dist/react/hooks/useInvoices.js.map +1 -0
- package/dist/react/hooks/usePaymentMethodActions.d.ts +74 -0
- package/dist/react/hooks/usePaymentMethodActions.d.ts.map +1 -0
- package/dist/react/hooks/usePaymentMethodActions.js +156 -0
- package/dist/react/hooks/usePaymentMethodActions.js.map +1 -0
- package/dist/react/hooks/usePaymentMethods.d.ts +23 -0
- package/dist/react/hooks/usePaymentMethods.d.ts.map +1 -0
- package/dist/react/hooks/usePaymentMethods.js +18 -0
- package/dist/react/hooks/usePaymentMethods.js.map +1 -0
- package/dist/react/hooks/usePrices.d.ts +12 -0
- package/dist/react/hooks/usePrices.d.ts.map +1 -0
- package/dist/react/hooks/usePrices.js +16 -0
- package/dist/react/hooks/usePrices.js.map +1 -0
- package/dist/react/hooks/useProducts.d.ts +10 -0
- package/dist/react/hooks/useProducts.d.ts.map +1 -0
- package/dist/react/hooks/useProducts.js +11 -0
- package/dist/react/hooks/useProducts.js.map +1 -0
- package/dist/react/hooks/useSplitBreakdown.d.ts +58 -0
- package/dist/react/hooks/useSplitBreakdown.d.ts.map +1 -0
- package/dist/react/hooks/useSplitBreakdown.js +59 -0
- package/dist/react/hooks/useSplitBreakdown.js.map +1 -0
- package/dist/react/hooks/useStripeConfig.d.ts +14 -0
- package/dist/react/hooks/useStripeConfig.d.ts.map +1 -0
- package/dist/react/hooks/useStripeConfig.js +21 -0
- package/dist/react/hooks/useStripeConfig.js.map +1 -0
- package/dist/react/hooks/useStripeMode.d.ts +3 -0
- package/dist/react/hooks/useStripeMode.d.ts.map +1 -0
- package/dist/react/hooks/useStripeMode.js +6 -0
- package/dist/react/hooks/useStripeMode.js.map +1 -0
- package/dist/react/hooks/useStripePublishableKey.d.ts +2 -0
- package/dist/react/hooks/useStripePublishableKey.d.ts.map +1 -0
- package/dist/react/hooks/useStripePublishableKey.js +6 -0
- package/dist/react/hooks/useStripePublishableKey.js.map +1 -0
- package/dist/react/hooks/useSubscription.d.ts +17 -0
- package/dist/react/hooks/useSubscription.d.ts.map +1 -0
- package/dist/react/hooks/useSubscription.js +30 -0
- package/dist/react/hooks/useSubscription.js.map +1 -0
- package/dist/react/hooks/useSubscriptions.d.ts +11 -0
- package/dist/react/hooks/useSubscriptions.d.ts.map +1 -0
- package/dist/react/hooks/useSubscriptions.js +13 -0
- package/dist/react/hooks/useSubscriptions.js.map +1 -0
- package/dist/react/index.d.ts +108 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +87 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/lib/connect-requirement-keys.d.ts +14 -0
- package/dist/react/lib/connect-requirement-keys.d.ts.map +1 -0
- package/dist/react/lib/connect-requirement-keys.js +57 -0
- package/dist/react/lib/connect-requirement-keys.js.map +1 -0
- package/dist/react/lib/price-helpers.d.ts +31 -0
- package/dist/react/lib/price-helpers.d.ts.map +1 -0
- package/dist/react/lib/price-helpers.js +46 -0
- package/dist/react/lib/price-helpers.js.map +1 -0
- package/dist/react/lib/stripe-element-styles.d.ts +91 -0
- package/dist/react/lib/stripe-element-styles.d.ts.map +1 -0
- package/dist/react/lib/stripe-element-styles.js +131 -0
- package/dist/react/lib/stripe-element-styles.js.map +1 -0
- package/dist/react/lib/subscription-helpers.d.ts +33 -0
- package/dist/react/lib/subscription-helpers.d.ts.map +1 -0
- package/dist/react/lib/subscription-helpers.js +47 -0
- package/dist/react/lib/subscription-helpers.js.map +1 -0
- package/dist/react/types.d.ts +20 -0
- package/dist/react/types.d.ts.map +1 -0
- package/dist/react/types.js +2 -0
- package/dist/react/types.js.map +1 -0
- package/dist/testing/assert-test-env.d.ts +6 -0
- package/dist/testing/assert-test-env.d.ts.map +1 -0
- package/dist/testing/assert-test-env.js +15 -0
- package/dist/testing/assert-test-env.js.map +1 -0
- package/dist/testing/fixtures.d.ts +38 -0
- package/dist/testing/fixtures.d.ts.map +1 -0
- package/dist/testing/fixtures.js +54 -0
- package/dist/testing/fixtures.js.map +1 -0
- package/dist/testing/index.d.ts +4 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +4 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/mock-webhooks.d.ts +19 -0
- package/dist/testing/mock-webhooks.d.ts.map +1 -0
- package/dist/testing/mock-webhooks.js +81 -0
- package/dist/testing/mock-webhooks.js.map +1 -0
- package/package.json +131 -0
- package/src/client/billing/checkout.test.ts +1234 -0
- package/src/client/billing/checkout.ts +416 -0
- package/src/client/billing/invoices.test.ts +237 -0
- package/src/client/billing/invoices.ts +93 -0
- package/src/client/billing/subscriptions.test.ts +987 -0
- package/src/client/billing/subscriptions.ts +604 -0
- package/src/client/component-api-types.test.ts +137 -0
- package/src/client/connect/disputes.test.ts +487 -0
- package/src/client/connect/disputes.ts +302 -0
- package/src/client/connect/paymentMethodUtils.test.ts +83 -0
- package/src/client/connect/paymentMethodUtils.ts +28 -0
- package/src/client/connect/paymentMethods.test.ts +66 -0
- package/src/client/connect/paymentMethods.ts +55 -0
- package/src/client/connect/payouts.test.ts +132 -0
- package/src/client/connect/payouts.ts +105 -0
- package/src/client/connect/refundActor.test.ts +121 -0
- package/src/client/connect/refundActor.ts +60 -0
- package/src/client/connect/refunds.test.ts +341 -0
- package/src/client/connect/refunds.ts +256 -0
- package/src/client/connect/transfers.test.ts +492 -0
- package/src/client/connect/transfers.ts +572 -0
- package/src/client/constants.ts +15 -0
- package/src/client/core/accountLinks.test.ts +378 -0
- package/src/client/core/accountLinks.ts +211 -0
- package/src/client/core/accountStatus.test.ts +102 -0
- package/src/client/core/accountStatus.ts +91 -0
- package/src/client/core/accounts.test.ts +1496 -0
- package/src/client/core/accounts.ts +667 -0
- package/src/client/core/config.test.ts +68 -0
- package/src/client/core/config.ts +27 -0
- package/src/client/core/descriptors.test.ts +68 -0
- package/src/client/core/descriptors.ts +46 -0
- package/src/client/core/fees.test.ts +377 -0
- package/src/client/core/fees.ts +268 -0
- package/src/client/errors.test.ts +66 -0
- package/src/client/errors.ts +70 -0
- package/src/client/helpers.test.ts +74 -0
- package/src/client/helpers.ts +94 -0
- package/src/client/index.test.ts +1848 -0
- package/src/client/index.ts +1872 -0
- package/src/client/products/prices.test.ts +345 -0
- package/src/client/products/prices.ts +194 -0
- package/src/client/products/products.test.ts +476 -0
- package/src/client/products/products.ts +335 -0
- package/src/client/setup.test.ts +47 -0
- package/src/client/stripe-types.ts +108 -0
- package/src/client/types/documents.ts +245 -0
- package/src/client/types/events.ts +72 -0
- package/src/client/types/index.ts +43 -0
- package/src/client/types/options.ts +103 -0
- package/src/client/types/triggers.ts +293 -0
- package/src/client/types.ts +35 -0
- package/src/client/utils/data.test.ts +59 -0
- package/src/client/utils/data.ts +22 -0
- package/src/client/utils/owner.test.ts +35 -0
- package/src/client/utils/owner.ts +27 -0
- package/src/client/utils/stripeDashboardUrl.test.ts +71 -0
- package/src/client/utils/stripeDashboardUrl.ts +71 -0
- package/src/client/utils/webhookEndpoints.test.ts +454 -0
- package/src/client/utils/webhookEndpoints.ts +271 -0
- package/src/client/webhook-handlers.test.ts +603 -0
- package/src/client/webhooks/handler.test.ts +604 -0
- package/src/client/webhooks/handler.ts +256 -0
- package/src/client/webhooks/helpers.test.ts +330 -0
- package/src/client/webhooks/helpers.ts +277 -0
- package/src/client/webhooks/hooks.test.ts +111 -0
- package/src/client/webhooks/hooks.ts +177 -0
- package/src/client/webhooks/index.ts +51 -0
- package/src/client/webhooks/processors.test.ts +2392 -0
- package/src/client/webhooks/processors.ts +1166 -0
- package/src/client/webhooks/v2.test.ts +396 -0
- package/src/client/webhooks/v2.ts +124 -0
- package/src/client/webhooks.test.ts +1689 -0
- package/src/client/webhooks.ts +3 -0
- package/src/component/_generated/api.ts +86 -0
- package/src/component/_generated/component.ts +1758 -0
- package/src/component/_generated/dataModel.ts +60 -0
- package/src/component/_generated/server.ts +164 -0
- package/src/component/billing/mutations.ts +155 -0
- package/src/component/billing/queries.ts +378 -0
- package/src/component/billing/schema.ts +40 -0
- package/src/component/billing/validators.ts +137 -0
- package/src/component/config-queries.test.ts +47 -0
- package/src/component/connect/mutations.ts +624 -0
- package/src/component/connect/queries.ts +537 -0
- package/src/component/connect/schema.ts +90 -0
- package/src/component/connect/validators.ts +333 -0
- package/src/component/connect.test.ts +721 -0
- package/src/component/convex.config.ts +17 -0
- package/src/component/core/mutations.ts +182 -0
- package/src/component/core/queries.ts +100 -0
- package/src/component/core/schema.ts +13 -0
- package/src/component/core/validators.ts +55 -0
- package/src/component/earnings-totals.test.ts +196 -0
- package/src/component/fee-routing.test.ts +124 -0
- package/src/component/lib/fees.ts +64 -0
- package/src/component/lib/idempotency.test.ts +37 -0
- package/src/component/lib/idempotency.ts +20 -0
- package/src/component/lib/reversals.ts +113 -0
- package/src/component/lib/stripeFactory.ts +30 -0
- package/src/component/products/mutations.ts +73 -0
- package/src/component/products/queries.ts +149 -0
- package/src/component/products/schema.ts +22 -0
- package/src/component/products/validators.ts +63 -0
- package/src/component/public.test.ts +1858 -0
- package/src/component/reversal-races.test.ts +920 -0
- package/src/component/schema.ts +45 -0
- package/src/component/subscription-scoping.test.ts +118 -0
- package/src/component/transfers.test.ts +402 -0
- package/src/component/triggers.test.ts +359 -0
- package/src/component/webhooks/mutations.ts +151 -0
- package/src/component/webhooks/queries.ts +44 -0
- package/src/component/webhooks/schema.ts +10 -0
- package/src/component/webhooks/validators.ts +30 -0
- package/src/react/components/AccountCloseButton.tsx +91 -0
- package/src/react/components/AccountCloseCard.tsx +84 -0
- package/src/react/components/AccountCreateButton.tsx +83 -0
- package/src/react/components/AccountCreateCard.tsx +123 -0
- package/src/react/components/AccountLoginButton.tsx +69 -0
- package/src/react/components/AccountLoginCard.tsx +99 -0
- package/src/react/components/AccountOnboardingButton.tsx +83 -0
- package/src/react/components/AccountOnboardingCard.test.ts +27 -0
- package/src/react/components/AccountOnboardingCard.tsx +152 -0
- package/src/react/components/AddCardForm.tsx +80 -0
- package/src/react/components/BillingPortalLink.tsx +93 -0
- package/src/react/components/BuyerBillingView.render.test.tsx +207 -0
- package/src/react/components/BuyerBillingView.tsx +193 -0
- package/src/react/components/CheckoutSessionProvider.tsx +70 -0
- package/src/react/components/CheckoutSessionProviderWithKey.tsx +99 -0
- package/src/react/components/CheckoutStatus.tsx +71 -0
- package/src/react/components/ConnectProvider.tsx +58 -0
- package/src/react/components/ConnectRequirements.tsx +159 -0
- package/src/react/components/ConnectStatusBadge.tsx +60 -0
- package/src/react/components/DeletePaymentMethodDialog.tsx +61 -0
- package/src/react/components/DisputeDetail.render.test.tsx +143 -0
- package/src/react/components/DisputeDetail.tsx +111 -0
- package/src/react/components/DisputesList.render.test.tsx +244 -0
- package/src/react/components/DisputesList.tsx +120 -0
- package/src/react/components/EarningsSummary.render.test.tsx +153 -0
- package/src/react/components/EarningsSummary.tsx +131 -0
- package/src/react/components/EmbeddedCheckout.test.ts +25 -0
- package/src/react/components/EmbeddedCheckout.tsx +54 -0
- package/src/react/components/EmbeddedDisputes.render.test.tsx +142 -0
- package/src/react/components/EmbeddedDisputes.tsx +38 -0
- package/src/react/components/EvidenceForm.render.test.tsx +215 -0
- package/src/react/components/EvidenceForm.tsx +176 -0
- package/src/react/components/IntervalSelector.tsx +58 -0
- package/src/react/components/PaymentMethodActions.tsx +68 -0
- package/src/react/components/PaymentMethodsList.tsx +81 -0
- package/src/react/components/PayoutSchedule.render.test.tsx +178 -0
- package/src/react/components/PayoutSchedule.tsx +148 -0
- package/src/react/components/PriceBadge.render.test.tsx +134 -0
- package/src/react/components/PriceBadge.tsx +49 -0
- package/src/react/components/PriceCard.render.test.tsx +135 -0
- package/src/react/components/PriceCard.tsx +83 -0
- package/src/react/components/PricePicker.tsx +95 -0
- package/src/react/components/SplitBreakdown.render.test.tsx +168 -0
- package/src/react/components/SplitBreakdown.tsx +121 -0
- package/src/react/components/StripeProvider.test.ts +45 -0
- package/src/react/components/StripeProvider.tsx +80 -0
- package/src/react/components/StripeProviderWithKey.tsx +95 -0
- package/src/react/components/SubscriptionActions.tsx +79 -0
- package/src/react/components/SubscriptionCard.tsx +92 -0
- package/src/react/components/SubscriptionLineItems.tsx +62 -0
- package/src/react/components/TrialAlert.render.test.tsx +132 -0
- package/src/react/components/TrialAlert.tsx +44 -0
- package/src/react/hooks/skipSentinel.test.ts +85 -0
- package/src/react/hooks/useAccount.ts +28 -0
- package/src/react/hooks/useAccountOnboarding.test.ts +75 -0
- package/src/react/hooks/useAccountOnboarding.ts +35 -0
- package/src/react/hooks/useCheckout.ts +33 -0
- package/src/react/hooks/useCheckoutSession.ts +110 -0
- package/src/react/hooks/useConfirmPayment.ts +117 -0
- package/src/react/hooks/useDisputeWithCountdown.test.ts +90 -0
- package/src/react/hooks/useDisputeWithCountdown.ts +48 -0
- package/src/react/hooks/useDisputes.test.ts +75 -0
- package/src/react/hooks/useDisputes.ts +28 -0
- package/src/react/hooks/useEarnings.test.ts +159 -0
- package/src/react/hooks/useEarnings.ts +132 -0
- package/src/react/hooks/useInvoices.test.ts +79 -0
- package/src/react/hooks/useInvoices.ts +25 -0
- package/src/react/hooks/usePaymentMethodActions.ts +206 -0
- package/src/react/hooks/usePaymentMethods.ts +44 -0
- package/src/react/hooks/usePrices.ts +26 -0
- package/src/react/hooks/useProducts.test.ts +75 -0
- package/src/react/hooks/useProducts.ts +24 -0
- package/src/react/hooks/useSplitBreakdown.test.ts +151 -0
- package/src/react/hooks/useSplitBreakdown.ts +118 -0
- package/src/react/hooks/useStripeConfig.ts +31 -0
- package/src/react/hooks/useStripeMode.test.ts +49 -0
- package/src/react/hooks/useStripeMode.ts +9 -0
- package/src/react/hooks/useStripePublishableKey.test.ts +35 -0
- package/src/react/hooks/useStripePublishableKey.ts +9 -0
- package/src/react/hooks/useSubscription.ts +52 -0
- package/src/react/hooks/useSubscriptions.ts +33 -0
- package/src/react/index.payment-element.test.ts +41 -0
- package/src/react/index.test.ts +167 -0
- package/src/react/index.ts +279 -0
- package/src/react/lib/connect-requirement-keys.test.ts +73 -0
- package/src/react/lib/connect-requirement-keys.ts +66 -0
- package/src/react/lib/price-helpers.test.ts +199 -0
- package/src/react/lib/price-helpers.ts +68 -0
- package/src/react/lib/stripe-element-styles.test.ts +94 -0
- package/src/react/lib/stripe-element-styles.ts +178 -0
- package/src/react/lib/subscription-helpers.test.ts +127 -0
- package/src/react/lib/subscription-helpers.ts +64 -0
- package/src/react/types.ts +32 -0
- package/src/test.ts +5 -0
- package/src/testing/assert-test-env.test.ts +33 -0
- package/src/testing/assert-test-env.ts +20 -0
- package/src/testing/fixtures.ts +95 -0
- package/src/testing/index.ts +13 -0
- package/src/testing/mock-webhooks.test.ts +97 -0
- package/src/testing/mock-webhooks.ts +101 -0
- package/src/vite-env.d.ts +4 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export const STRIPE_DASHBOARD_BASE_URL = "https://dashboard.stripe.com";
|
|
2
|
+
export const StripeDashboardResourcePath = {
|
|
3
|
+
Product: "products",
|
|
4
|
+
Price: "prices",
|
|
5
|
+
Customer: "customers",
|
|
6
|
+
Subscription: "subscriptions",
|
|
7
|
+
};
|
|
8
|
+
function normalizeStripeMode(stripeMode) {
|
|
9
|
+
if (stripeMode === "test" || stripeMode === "live") {
|
|
10
|
+
return stripeMode;
|
|
11
|
+
}
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
function inferStripeModeFromKey(key) {
|
|
15
|
+
if (key?.startsWith("pk_test_") || key?.startsWith("sk_test_")) {
|
|
16
|
+
return "test";
|
|
17
|
+
}
|
|
18
|
+
if (key?.startsWith("pk_live_") || key?.startsWith("sk_live_")) {
|
|
19
|
+
return "live";
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
export function isStripeTestMode(stripeMode) {
|
|
24
|
+
const explicitMode = normalizeStripeMode(stripeMode);
|
|
25
|
+
if (explicitMode) {
|
|
26
|
+
return explicitMode === "test";
|
|
27
|
+
}
|
|
28
|
+
const inferredMode = inferStripeModeFromKey(process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY) ??
|
|
29
|
+
inferStripeModeFromKey(process.env.STRIPE_PUBLISHABLE_KEY) ??
|
|
30
|
+
inferStripeModeFromKey(process.env.STRIPE_SECRET_KEY);
|
|
31
|
+
return inferredMode === "test";
|
|
32
|
+
}
|
|
33
|
+
export function getStripeDashboardUrl(resourceType, resourceId, stripeMode) {
|
|
34
|
+
const modePath = isStripeTestMode(stripeMode) ? "/test" : "";
|
|
35
|
+
const resourcePath = StripeDashboardResourcePath[(resourceType.charAt(0).toUpperCase() +
|
|
36
|
+
resourceType.slice(1))];
|
|
37
|
+
return `${STRIPE_DASHBOARD_BASE_URL}${modePath}/${resourcePath}/${resourceId}`;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=stripeDashboardUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripeDashboardUrl.js","sourceRoot":"","sources":["../../../src/client/utils/stripeDashboardUrl.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GAAG,8BAA8B,CAAC;AAExE,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,OAAO,EAAE,UAAU;IACnB,KAAK,EAAE,QAAQ;IACf,QAAQ,EAAE,WAAW;IACrB,YAAY,EAAE,eAAe;CACrB,CAAC;AAUX,SAAS,mBAAmB,CAC1B,UAAqC;IAErC,IAAI,UAAU,KAAK,MAAM,IAAI,UAAU,KAAK,MAAM,EAAE,CAAC;QACnD,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,sBAAsB,CAC7B,GAA8B;IAE9B,IAAI,GAAG,EAAE,UAAU,CAAC,UAAU,CAAC,IAAI,GAAG,EAAE,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/D,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,GAAG,EAAE,UAAU,CAAC,UAAU,CAAC,IAAI,GAAG,EAAE,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/D,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,UAA0B;IACzD,MAAM,YAAY,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAErD,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,YAAY,KAAK,MAAM,CAAC;IACjC,CAAC;IAED,MAAM,YAAY,GAChB,sBAAsB,CAAC,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC;QACtE,sBAAsB,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC;QAC1D,sBAAsB,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAExD,OAAO,YAAY,KAAK,MAAM,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,YAAyC,EACzC,UAAkB,EAClB,UAA0B;IAE1B,MAAM,QAAQ,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IAE7D,MAAM,YAAY,GAChB,2BAA2B,CACzB,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE;QACnC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAA6C,CACrE,CAAC;IAEJ,OAAO,GAAG,yBAAyB,GAAG,QAAQ,IAAI,YAAY,IAAI,UAAU,EAAE,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type Stripe from "stripe";
|
|
2
|
+
import type { RunCtx } from "../helpers.js";
|
|
3
|
+
/**
|
|
4
|
+
* V1 Stripe event types the better-stripe webhook handler processes.
|
|
5
|
+
* Use this when creating webhook endpoints to ensure all needed events are enabled.
|
|
6
|
+
*/
|
|
7
|
+
export declare const BETTER_STRIPE_WEBHOOK_EVENTS: readonly ["product.created", "product.updated", "price.created", "price.updated", "customer.subscription.created", "customer.subscription.updated", "customer.subscription.deleted", "customer.subscription.trial_will_end", "checkout.session.completed", "invoice.created", "invoice.finalized", "invoice.paid", "invoice.payment_failed", "payment_intent.succeeded", "payment_intent.payment_failed", "payment_intent.canceled", "payout.created", "payout.updated", "payout.paid", "payout.failed", "refund.created", "refund.updated", "refund.failed", "application_fee.refunded", "charge.dispute.created", "charge.dispute.updated", "charge.dispute.closed", "charge.dispute.funds_withdrawn", "charge.dispute.funds_reinstated"];
|
|
8
|
+
export type BetterStripeWebhookEvent = (typeof BETTER_STRIPE_WEBHOOK_EVENTS)[number];
|
|
9
|
+
/**
|
|
10
|
+
* V2 Stripe event types for Connect account lifecycle.
|
|
11
|
+
* These are thin events — the webhook handler fetches full data from the API.
|
|
12
|
+
*/
|
|
13
|
+
export declare const BETTER_STRIPE_V2_WEBHOOK_EVENTS: readonly ["v2.core.account.updated", "v2.core.account.created", "v2.core.account[requirements].updated", "v2.core.account[identity].updated", "v2.core.account[configuration.merchant].updated", "v2.core.account[configuration.merchant].capability_status_updated", "v2.core.account[configuration.customer].updated", "v2.core.account[configuration.recipient].updated", "v2.core.account[defaults].updated", "v2.core.account_person.created", "v2.core.account_person.updated", "v2.core.account_link.returned"];
|
|
14
|
+
export type BetterStripeV2WebhookEvent = (typeof BETTER_STRIPE_V2_WEBHOOK_EVENTS)[number];
|
|
15
|
+
/**
|
|
16
|
+
* All events (V1 + V2) that better-stripe processes.
|
|
17
|
+
* Use with setupEventDestination() for complete webhook coverage.
|
|
18
|
+
*/
|
|
19
|
+
export declare const ALL_BETTER_STRIPE_EVENTS: readonly string[];
|
|
20
|
+
export declare function listWebhookEndpoints(stripe: Stripe, _ctx: RunCtx, opts?: {
|
|
21
|
+
limit?: number;
|
|
22
|
+
}): Promise<{
|
|
23
|
+
id: string;
|
|
24
|
+
url: string;
|
|
25
|
+
status: string;
|
|
26
|
+
enabledEvents: string[];
|
|
27
|
+
description: string | undefined;
|
|
28
|
+
livemode: boolean;
|
|
29
|
+
}[]>;
|
|
30
|
+
export declare function createWebhookEndpoint(stripe: Stripe, _ctx: RunCtx, opts: {
|
|
31
|
+
url: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
enabledEvents?: string[];
|
|
34
|
+
}): Promise<{
|
|
35
|
+
id: string;
|
|
36
|
+
secret: string;
|
|
37
|
+
url: string;
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Summary of a Stripe V2 event destination returned by
|
|
41
|
+
* {@link listEventDestinations}.
|
|
42
|
+
*
|
|
43
|
+
* The field types are annotated explicitly (via the public `Stripe`
|
|
44
|
+
* namespace) so the emitted declarations stay portable and don't reference
|
|
45
|
+
* Stripe's internal V2 module path (TS2742).
|
|
46
|
+
*/
|
|
47
|
+
export interface EventDestinationSummary {
|
|
48
|
+
id: string;
|
|
49
|
+
url: string;
|
|
50
|
+
status: Stripe.V2.Core.EventDestination["status"];
|
|
51
|
+
enabledEvents: Stripe.V2.Core.EventDestination["enabled_events"];
|
|
52
|
+
eventPayload: Stripe.V2.Core.EventDestination["event_payload"];
|
|
53
|
+
name: Stripe.V2.Core.EventDestination["name"];
|
|
54
|
+
description: Stripe.V2.Core.EventDestination["description"];
|
|
55
|
+
}
|
|
56
|
+
export declare function listEventDestinations(stripe: Stripe, _ctx: RunCtx, opts?: {
|
|
57
|
+
limit?: number;
|
|
58
|
+
}): Promise<EventDestinationSummary[]>;
|
|
59
|
+
/**
|
|
60
|
+
* Create or update a Stripe V2 event destination.
|
|
61
|
+
*
|
|
62
|
+
* Stripe requires separate destinations for snapshot (V1) and thin (V2) events
|
|
63
|
+
* because V2 events are inherently thin. This function finds an existing
|
|
64
|
+
* destination matching the URL and payload type, updates it if found, or
|
|
65
|
+
* creates a new one.
|
|
66
|
+
*
|
|
67
|
+
* Defaults to a thin destination with V2 account events if no overrides given.
|
|
68
|
+
*/
|
|
69
|
+
export declare function setupEventDestination(stripe: Stripe, _ctx: RunCtx, opts: {
|
|
70
|
+
url: string;
|
|
71
|
+
name?: string;
|
|
72
|
+
description?: string;
|
|
73
|
+
enabledEvents?: string[];
|
|
74
|
+
/** 'snapshot' for V1 events, 'thin' for V2 events. Defaults to 'thin'. */
|
|
75
|
+
eventPayload?: "snapshot" | "thin";
|
|
76
|
+
}): Promise<{
|
|
77
|
+
id: string;
|
|
78
|
+
secret: string;
|
|
79
|
+
url: string;
|
|
80
|
+
enabledEvents: string[];
|
|
81
|
+
created: boolean;
|
|
82
|
+
}>;
|
|
83
|
+
//# sourceMappingURL=webhookEndpoints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhookEndpoints.d.ts","sourceRoot":"","sources":["../../../src/client/utils/webhookEndpoints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAM5C;;;GAGG;AACH,eAAO,MAAM,4BAA4B,6sBAuC/B,CAAC;AAEX,MAAM,MAAM,wBAAwB,GAClC,CAAC,OAAO,4BAA4B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,+BAA+B,wfAalC,CAAC;AAEX,MAAM,MAAM,0BAA0B,GACpC,CAAC,OAAO,+BAA+B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnD;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EAGrD,CAAC;AAEF,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;;KAa1B;AAED,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE;IACJ,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B,GACA,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAqBtD;AAMD;;;;;;;GAOG;AACH,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAC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endpoint management
|
|
3
|
+
// =============================================================================
|
|
4
|
+
/**
|
|
5
|
+
* V1 Stripe event types the better-stripe webhook handler processes.
|
|
6
|
+
* Use this when creating webhook endpoints to ensure all needed events are enabled.
|
|
7
|
+
*/
|
|
8
|
+
export const BETTER_STRIPE_WEBHOOK_EVENTS = [
|
|
9
|
+
// Products & Prices
|
|
10
|
+
"product.created",
|
|
11
|
+
"product.updated",
|
|
12
|
+
"price.created",
|
|
13
|
+
"price.updated",
|
|
14
|
+
// Subscriptions
|
|
15
|
+
"customer.subscription.created",
|
|
16
|
+
"customer.subscription.updated",
|
|
17
|
+
"customer.subscription.deleted",
|
|
18
|
+
"customer.subscription.trial_will_end",
|
|
19
|
+
// Checkout
|
|
20
|
+
"checkout.session.completed",
|
|
21
|
+
// Invoices
|
|
22
|
+
"invoice.created",
|
|
23
|
+
"invoice.finalized",
|
|
24
|
+
"invoice.paid",
|
|
25
|
+
"invoice.payment_failed",
|
|
26
|
+
// Payments
|
|
27
|
+
"payment_intent.succeeded",
|
|
28
|
+
"payment_intent.payment_failed",
|
|
29
|
+
"payment_intent.canceled",
|
|
30
|
+
// Payouts
|
|
31
|
+
"payout.created",
|
|
32
|
+
"payout.updated",
|
|
33
|
+
"payout.paid",
|
|
34
|
+
"payout.failed",
|
|
35
|
+
// Refunds
|
|
36
|
+
"refund.created",
|
|
37
|
+
"refund.updated",
|
|
38
|
+
"refund.failed",
|
|
39
|
+
// Keeps feeCollectedAmount/feeRefundedAmount accurate on payments (BTS-34).
|
|
40
|
+
"application_fee.refunded",
|
|
41
|
+
// Disputes
|
|
42
|
+
"charge.dispute.created",
|
|
43
|
+
"charge.dispute.updated",
|
|
44
|
+
"charge.dispute.closed",
|
|
45
|
+
"charge.dispute.funds_withdrawn",
|
|
46
|
+
"charge.dispute.funds_reinstated",
|
|
47
|
+
];
|
|
48
|
+
/**
|
|
49
|
+
* V2 Stripe event types for Connect account lifecycle.
|
|
50
|
+
* These are thin events — the webhook handler fetches full data from the API.
|
|
51
|
+
*/
|
|
52
|
+
export const BETTER_STRIPE_V2_WEBHOOK_EVENTS = [
|
|
53
|
+
"v2.core.account.updated",
|
|
54
|
+
"v2.core.account.created",
|
|
55
|
+
"v2.core.account[requirements].updated",
|
|
56
|
+
"v2.core.account[identity].updated",
|
|
57
|
+
"v2.core.account[configuration.merchant].updated",
|
|
58
|
+
"v2.core.account[configuration.merchant].capability_status_updated",
|
|
59
|
+
"v2.core.account[configuration.customer].updated",
|
|
60
|
+
"v2.core.account[configuration.recipient].updated",
|
|
61
|
+
"v2.core.account[defaults].updated",
|
|
62
|
+
"v2.core.account_person.created",
|
|
63
|
+
"v2.core.account_person.updated",
|
|
64
|
+
"v2.core.account_link.returned",
|
|
65
|
+
];
|
|
66
|
+
/**
|
|
67
|
+
* All events (V1 + V2) that better-stripe processes.
|
|
68
|
+
* Use with setupEventDestination() for complete webhook coverage.
|
|
69
|
+
*/
|
|
70
|
+
export const ALL_BETTER_STRIPE_EVENTS = [
|
|
71
|
+
...BETTER_STRIPE_WEBHOOK_EVENTS,
|
|
72
|
+
...BETTER_STRIPE_V2_WEBHOOK_EVENTS,
|
|
73
|
+
];
|
|
74
|
+
export async function listWebhookEndpoints(stripe, _ctx, opts) {
|
|
75
|
+
const endpoints = await stripe.webhookEndpoints.list({
|
|
76
|
+
limit: opts?.limit ?? 100,
|
|
77
|
+
});
|
|
78
|
+
return endpoints.data.map((ep) => ({
|
|
79
|
+
id: ep.id,
|
|
80
|
+
url: ep.url,
|
|
81
|
+
status: ep.status,
|
|
82
|
+
enabledEvents: ep.enabled_events,
|
|
83
|
+
description: ep.description ?? undefined,
|
|
84
|
+
livemode: ep.livemode,
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
export async function createWebhookEndpoint(stripe, _ctx, opts) {
|
|
88
|
+
// Remove existing endpoint with same URL (secret is only available on create)
|
|
89
|
+
const existing = await stripe.webhookEndpoints.list({ limit: 100 });
|
|
90
|
+
const match = existing.data.find((ep) => ep.url === opts.url);
|
|
91
|
+
if (match) {
|
|
92
|
+
await stripe.webhookEndpoints.del(match.id);
|
|
93
|
+
}
|
|
94
|
+
const endpoint = await stripe.webhookEndpoints.create({
|
|
95
|
+
url: opts.url,
|
|
96
|
+
enabled_events: (opts.enabledEvents ??
|
|
97
|
+
BETTER_STRIPE_WEBHOOK_EVENTS),
|
|
98
|
+
description: opts.description ?? "Created by better-stripe createWebhookEndpoint",
|
|
99
|
+
});
|
|
100
|
+
return {
|
|
101
|
+
id: endpoint.id,
|
|
102
|
+
secret: endpoint.secret,
|
|
103
|
+
url: endpoint.url,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
export async function listEventDestinations(stripe, _ctx, opts) {
|
|
107
|
+
const destinations = await stripe.v2.core.eventDestinations.list({
|
|
108
|
+
limit: opts?.limit ?? 100,
|
|
109
|
+
include: ["webhook_endpoint.url"],
|
|
110
|
+
});
|
|
111
|
+
return destinations.data.map((d) => ({
|
|
112
|
+
id: d.id,
|
|
113
|
+
url: d.webhook_endpoint?.url ?? "",
|
|
114
|
+
status: d.status,
|
|
115
|
+
enabledEvents: d.enabled_events,
|
|
116
|
+
eventPayload: d.event_payload,
|
|
117
|
+
name: d.name,
|
|
118
|
+
description: d.description,
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Create or update a Stripe V2 event destination.
|
|
123
|
+
*
|
|
124
|
+
* Stripe requires separate destinations for snapshot (V1) and thin (V2) events
|
|
125
|
+
* because V2 events are inherently thin. This function finds an existing
|
|
126
|
+
* destination matching the URL and payload type, updates it if found, or
|
|
127
|
+
* creates a new one.
|
|
128
|
+
*
|
|
129
|
+
* Defaults to a thin destination with V2 account events if no overrides given.
|
|
130
|
+
*/
|
|
131
|
+
export async function setupEventDestination(stripe, _ctx, opts) {
|
|
132
|
+
const payloadType = opts.eventPayload ?? "thin";
|
|
133
|
+
const events = opts.enabledEvents ??
|
|
134
|
+
(payloadType === "thin"
|
|
135
|
+
? [...BETTER_STRIPE_V2_WEBHOOK_EVENTS]
|
|
136
|
+
: [...BETTER_STRIPE_WEBHOOK_EVENTS]);
|
|
137
|
+
const name = opts.name ??
|
|
138
|
+
(payloadType === "thin" ? "better-stripe-v2" : "better-stripe");
|
|
139
|
+
const description = opts.description ??
|
|
140
|
+
(payloadType === "thin"
|
|
141
|
+
? "better-stripe V2 Connect account events"
|
|
142
|
+
: "better-stripe V1 payment events");
|
|
143
|
+
// Check for an existing destination at the same URL with matching payload type
|
|
144
|
+
const existing = await stripe.v2.core.eventDestinations.list({
|
|
145
|
+
include: ["webhook_endpoint.url"],
|
|
146
|
+
});
|
|
147
|
+
const match = existing.data.find((d) => d.webhook_endpoint?.url === opts.url && d.event_payload === payloadType);
|
|
148
|
+
if (match) {
|
|
149
|
+
const updated = await stripe.v2.core.eventDestinations.update(match.id, {
|
|
150
|
+
name,
|
|
151
|
+
description,
|
|
152
|
+
enabled_events: events,
|
|
153
|
+
include: ["webhook_endpoint.url"],
|
|
154
|
+
});
|
|
155
|
+
if (updated.status === "disabled") {
|
|
156
|
+
await stripe.v2.core.eventDestinations.enable(match.id);
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
id: updated.id,
|
|
160
|
+
secret: match.webhook_endpoint?.signing_secret ?? "",
|
|
161
|
+
url: opts.url,
|
|
162
|
+
enabledEvents: updated.enabled_events,
|
|
163
|
+
created: false,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
// Create new event destination
|
|
167
|
+
const destination = await stripe.v2.core.eventDestinations.create({
|
|
168
|
+
name,
|
|
169
|
+
description,
|
|
170
|
+
type: "webhook_endpoint",
|
|
171
|
+
event_payload: payloadType,
|
|
172
|
+
enabled_events: events,
|
|
173
|
+
events_from: payloadType === "thin" ? ["self", "other_accounts"] : ["self"],
|
|
174
|
+
webhook_endpoint: { url: opts.url },
|
|
175
|
+
include: ["webhook_endpoint.signing_secret", "webhook_endpoint.url"],
|
|
176
|
+
});
|
|
177
|
+
return {
|
|
178
|
+
id: destination.id,
|
|
179
|
+
secret: destination.webhook_endpoint?.signing_secret ?? "",
|
|
180
|
+
url: opts.url,
|
|
181
|
+
enabledEvents: destination.enabled_events,
|
|
182
|
+
created: true,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=webhookEndpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhookEndpoints.js","sourceRoot":"","sources":["../../../src/client/utils/webhookEndpoints.ts"],"names":[],"mappings":"AAIA,gFAAgF;AAChF,8BAA8B;AAC9B,gFAAgF;AAEhF;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,oBAAoB;IACpB,iBAAiB;IACjB,iBAAiB;IACjB,eAAe;IACf,eAAe;IACf,gBAAgB;IAChB,+BAA+B;IAC/B,+BAA+B;IAC/B,+BAA+B;IAC/B,sCAAsC;IACtC,WAAW;IACX,4BAA4B;IAC5B,WAAW;IACX,iBAAiB;IACjB,mBAAmB;IACnB,cAAc;IACd,wBAAwB;IACxB,WAAW;IACX,0BAA0B;IAC1B,+BAA+B;IAC/B,yBAAyB;IACzB,UAAU;IACV,gBAAgB;IAChB,gBAAgB;IAChB,aAAa;IACb,eAAe;IACf,UAAU;IACV,gBAAgB;IAChB,gBAAgB;IAChB,eAAe;IACf,4EAA4E;IAC5E,0BAA0B;IAC1B,WAAW;IACX,wBAAwB;IACxB,wBAAwB;IACxB,uBAAuB;IACvB,gCAAgC;IAChC,iCAAiC;CACzB,CAAC;AAKX;;;GAGG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC7C,yBAAyB;IACzB,yBAAyB;IACzB,uCAAuC;IACvC,mCAAmC;IACnC,iDAAiD;IACjD,mEAAmE;IACnE,iDAAiD;IACjD,kDAAkD;IAClD,mCAAmC;IACnC,gCAAgC;IAChC,gCAAgC;IAChC,+BAA+B;CACvB,CAAC;AAKX;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAA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C,cAAc;YACrC,OAAO,EAAE,KAAK;SACf,CAAC;IACJ,CAAC;IAED,+BAA+B;IAC/B,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC;QAChE,IAAI;QACJ,WAAW;QACX,IAAI,EAAE,kBAAkB;QACxB,aAAa,EAAE,WAAW;QAC1B,cAAc,EAAE,MAAM;QACtB,WAAW,EAAE,WAAW,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAC3E,gBAAgB,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE;QACnC,OAAO,EAAE,CAAC,iCAAiC,EAAE,sBAAsB,CAAC;KACrE,CAAC,CAAC;IAEH,OAAO;QACL,EAAE,EAAE,WAAW,CAAC,EAAE;QAClB,MAAM,EAAE,WAAW,CAAC,gBAAgB,EAAE,cAAc,IAAI,EAAE;QAC1D,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,aAAa,EAAE,WAAW,CAAC,cAAc;QACzC,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Component } from "../helpers.js";
|
|
2
|
+
import type { RegisterRoutesConfig, WebhookActionCtx } from "../types.js";
|
|
3
|
+
export declare function handleWebhookRequest(ctx: WebhookActionCtx, request: Request, component: Component, config?: RegisterRoutesConfig): Promise<Response>;
|
|
4
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/client/webhooks/handler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EACV,oBAAoB,EAEpB,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAerB,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,gBAAgB,EACrB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,EACpB,MAAM,CAAC,EAAE,oBAAoB,GAC5B,OAAO,CAAC,QAAQ,CAAC,CAoOnB"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { componentRef, getStripeClient, jsonResponse, } from "./helpers.js";
|
|
2
|
+
import { runHooks, scheduleAsyncHook } from "./hooks.js";
|
|
3
|
+
import { processEvent } from "./processors.js";
|
|
4
|
+
import { handleV2Event, verifyV2Event } from "./v2.js";
|
|
5
|
+
// =============================================================================
|
|
6
|
+
// CORE WEBHOOK HANDLER
|
|
7
|
+
// =============================================================================
|
|
8
|
+
export async function handleWebhookRequest(ctx, request, component, config) {
|
|
9
|
+
const signature = request.headers.get("stripe-signature");
|
|
10
|
+
if (!signature) {
|
|
11
|
+
return jsonResponse({ error: "Missing stripe-signature header" }, 400);
|
|
12
|
+
}
|
|
13
|
+
const body = await request.text();
|
|
14
|
+
let parsedBody;
|
|
15
|
+
try {
|
|
16
|
+
parsedBody = JSON.parse(body);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return jsonResponse({ error: "Invalid JSON body" }, 400);
|
|
20
|
+
}
|
|
21
|
+
const eventType = parsedBody.type ?? "";
|
|
22
|
+
const isV2Event = eventType.startsWith("v2.");
|
|
23
|
+
const stripeSecretKey = config?.stripeSecretKey;
|
|
24
|
+
const stripeApiVersion = config?.stripeApiVersion;
|
|
25
|
+
if (!stripeSecretKey) {
|
|
26
|
+
console.error("[better-stripe] Missing stripeSecretKey in registerRoutes config");
|
|
27
|
+
return jsonResponse({ error: "Stripe component not configured: missing stripeSecretKey" }, 500);
|
|
28
|
+
}
|
|
29
|
+
const webhookSecret = config?.webhookSecret;
|
|
30
|
+
if (!webhookSecret) {
|
|
31
|
+
console.error("[better-stripe] Missing webhookSecret in registerRoutes config");
|
|
32
|
+
return jsonResponse({ error: "Stripe component not configured: missing webhookSecret" }, 500);
|
|
33
|
+
}
|
|
34
|
+
const stripe = getStripeClient(stripeSecretKey, stripeApiVersion);
|
|
35
|
+
const whCtx = {
|
|
36
|
+
ctx,
|
|
37
|
+
component,
|
|
38
|
+
config,
|
|
39
|
+
stripe,
|
|
40
|
+
webhookSecret,
|
|
41
|
+
};
|
|
42
|
+
if (isV2Event) {
|
|
43
|
+
const v2Secret = config?.webhookSecretV2 ?? webhookSecret;
|
|
44
|
+
let thinEvent;
|
|
45
|
+
try {
|
|
46
|
+
thinEvent = await verifyV2Event(stripe, body, signature, v2Secret);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.error("[better-stripe] V2 signature verification failed:", error);
|
|
50
|
+
return jsonResponse({ error: "V2 signature verification failed" }, 400);
|
|
51
|
+
}
|
|
52
|
+
const eventId = thinEvent.id;
|
|
53
|
+
console.info(`[better-stripe] ← V2 event received: ${thinEvent.type} (${eventId})`);
|
|
54
|
+
try {
|
|
55
|
+
const dedupStatus = await ctx.runMutation(componentRef(component, "webhooks/mutations/insertWebhookEvent"), {
|
|
56
|
+
stripeEventId: eventId,
|
|
57
|
+
eventType: thinEvent.type,
|
|
58
|
+
livemode: thinEvent.livemode,
|
|
59
|
+
});
|
|
60
|
+
if (dedupStatus !== "inserted") {
|
|
61
|
+
console.info(`[better-stripe] ↳ deduplicated (already processed)`);
|
|
62
|
+
return jsonResponse({ success: true, deduplicated: true }, 200);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
console.warn(`[better-stripe] Webhook ledger insert failed for ${eventId}:`, error);
|
|
67
|
+
}
|
|
68
|
+
let accountId = null;
|
|
69
|
+
try {
|
|
70
|
+
accountId = await handleV2Event(whCtx, thinEvent);
|
|
71
|
+
console.info(`[better-stripe] ↳ processed ${thinEvent.type}`);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
console.error(`[better-stripe] ✗ sync failed for ${thinEvent.type}:`, error);
|
|
75
|
+
try {
|
|
76
|
+
await ctx.runMutation(componentRef(component, "webhooks/mutations/markWebhookEventFailed"), {
|
|
77
|
+
stripeEventId: eventId,
|
|
78
|
+
error: error instanceof Error ? error.message : String(error),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// Ledger updates are best-effort only.
|
|
83
|
+
}
|
|
84
|
+
return jsonResponse({ error: "V2 account sync failed" }, 500);
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
await ctx.runMutation(componentRef(component, "webhooks/mutations/markWebhookEventProcessed"), {
|
|
88
|
+
stripeEventId: eventId,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
// Ledger updates are best-effort only.
|
|
93
|
+
}
|
|
94
|
+
// Schedule the async hook with the committed doc (never throws).
|
|
95
|
+
await scheduleAsyncHook(whCtx, thinEvent.type, accountId);
|
|
96
|
+
try {
|
|
97
|
+
await runHooks(ctx, config, thinEvent);
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
console.error(`[better-stripe] Hook runner error for ${thinEvent.type}:`, error);
|
|
101
|
+
}
|
|
102
|
+
return jsonResponse({ success: true }, 200);
|
|
103
|
+
}
|
|
104
|
+
let event;
|
|
105
|
+
try {
|
|
106
|
+
event = await stripe.webhooks.constructEventAsync(body, signature, webhookSecret);
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
110
|
+
console.error(`[better-stripe] Webhook signature verification failed: ${msg}`);
|
|
111
|
+
return jsonResponse({ error: "Webhook signature verification failed" }, 400);
|
|
112
|
+
}
|
|
113
|
+
// --- Atomic webhook dedup via event ledger ---
|
|
114
|
+
const eventId = event.id;
|
|
115
|
+
console.info(`[better-stripe] ← V1 event received: ${event.type} (${eventId})`);
|
|
116
|
+
try {
|
|
117
|
+
const dedupStatus = await ctx.runMutation(componentRef(component, "webhooks/mutations/insertWebhookEvent"), {
|
|
118
|
+
stripeEventId: eventId,
|
|
119
|
+
eventType: event.type,
|
|
120
|
+
livemode: event.livemode,
|
|
121
|
+
});
|
|
122
|
+
if (dedupStatus !== "inserted") {
|
|
123
|
+
console.info(`[better-stripe] ↳ deduplicated (already processed)`);
|
|
124
|
+
return jsonResponse({ success: true, deduplicated: true }, 200);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
// Ledger write failed — log but continue processing
|
|
129
|
+
console.warn(`[better-stripe] Webhook ledger insert failed for ${eventId}:`, error);
|
|
130
|
+
}
|
|
131
|
+
// --- Process event (sync) ---
|
|
132
|
+
try {
|
|
133
|
+
await processEvent(whCtx, event);
|
|
134
|
+
console.info(`[better-stripe] ↳ processed ${event.type}`);
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
console.error(`[better-stripe] ✗ sync failed for ${event.type}:`, error);
|
|
138
|
+
try {
|
|
139
|
+
await ctx.runMutation(componentRef(component, "webhooks/mutations/markWebhookEventFailed"), {
|
|
140
|
+
stripeEventId: eventId,
|
|
141
|
+
error: error instanceof Error ? error.message : String(error),
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
/* ledger update best-effort */
|
|
146
|
+
}
|
|
147
|
+
return jsonResponse({ error: "Sync processing failed" }, 500);
|
|
148
|
+
}
|
|
149
|
+
// --- Mark processed ---
|
|
150
|
+
try {
|
|
151
|
+
await ctx.runMutation(componentRef(component, "webhooks/mutations/markWebhookEventProcessed"), {
|
|
152
|
+
stripeEventId: eventId,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
/* ledger update best-effort */
|
|
157
|
+
}
|
|
158
|
+
// --- Schedule the async hook with the committed doc (never throws) ---
|
|
159
|
+
const objectId = event.data.object.id ?? null;
|
|
160
|
+
await scheduleAsyncHook(whCtx, event.type, objectId);
|
|
161
|
+
// --- Run async hooks (errors must not crash the handler) ---
|
|
162
|
+
try {
|
|
163
|
+
await runHooks(ctx, config, event);
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
console.error(`[better-stripe] Hook runner error for ${event.type}:`, error);
|
|
167
|
+
}
|
|
168
|
+
return jsonResponse({ success: true }, 200);
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/client/webhooks/handler.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,YAAY,EACZ,eAAe,EACf,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEvD,gFAAgF;AAChF,uBAAuB;AACvB,gFAAgF;AAEhF,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,GAAqB,EACrB,OAAgB,EAChB,SAAoB,EACpB,MAA6B;IAE7B,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAC1D,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,YAAY,CAAC,EAAE,KAAK,EAAE,iCAAiC,EAAE,EAAE,GAAG,CAAC,CAAC;IACzE,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;IAElC,IAAI,UAAmC,CAAC;IACxC,IAAI,CAAC;QACH,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAA4B,CAAC;IAC3D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,YAAY,CAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,EAAE,GAAG,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,SAAS,GAAI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CAAC;aAC9D,CACF,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,+BAA+B;QACjC,CAAC;QACD,OAAO,YAAY,CAAC,EAAE,KAAK,EAAE,wBAAwB,EAAE,EAAE,GAAG,CAAC,CAAC;IAChE,CAAC;IAED,yBAAyB;IACzB,IAAI,CAAC;QACH,MAAM,GAAG,CAAC,WAAW,CACnB,YAAY,CAAC,SAAS,EAAE,8CAA8C,CAAC,EACvE;YACE,aAAa,EAAE,OAAO;SACvB,CACF,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,+BAA+B;IACjC,CAAC;IAED,wEAAwE;IACxE,MAAM,QAAQ,GAAI,KAAK,CAAC,IAAI,CAAC,MAA0B,CAAC,EAAE,IAAI,IAAI,CAAC;IACnE,MAAM,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAErD,8DAA8D;IAC9D,IAAI,CAAC;QACH,MAAM,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CACX,yCAAyC,KAAK,CAAC,IAAI,GAAG,EACtD,KAAK,CACN,CAAC;IACJ,CAAC;IAED,OAAO,YAAY,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type Stripe from "stripe";
|
|
2
|
+
import type { Component } from "../helpers.js";
|
|
3
|
+
export { getStripeClient } from "../helpers.js";
|
|
4
|
+
import type { WebhookActionCtx } from "../types.js";
|
|
5
|
+
import type { TriggerDispatcherName } from "../types/triggers.js";
|
|
6
|
+
export declare function epochToIso(epoch: number | null | undefined): string | undefined;
|
|
7
|
+
export declare function deriveTrialFields(subscription: Stripe.Subscription): {
|
|
8
|
+
isTrialing: boolean;
|
|
9
|
+
trialStart: string | undefined;
|
|
10
|
+
trialEnd: string | undefined;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Extracts userId and orgId from Stripe object metadata.
|
|
14
|
+
*
|
|
15
|
+
* Returns userId `""` when the Stripe object has no userId metadata
|
|
16
|
+
* (e.g. created in the Stripe Dashboard). `""` rows are stored but
|
|
17
|
+
* never matched by user-scoped queries.
|
|
18
|
+
*/
|
|
19
|
+
export declare function extractIdentifiers(metadata: Record<string, string> | null | undefined): {
|
|
20
|
+
userId: string;
|
|
21
|
+
orgId: string | undefined;
|
|
22
|
+
};
|
|
23
|
+
export declare function jsonResponse(data: Record<string, unknown>, status: number): Response;
|
|
24
|
+
/**
|
|
25
|
+
* Resolve a component function reference by export name.
|
|
26
|
+
*
|
|
27
|
+
* Uses an anchor ref from the component to derive the base path prefix,
|
|
28
|
+
* then looks up the function's new domain path from COMPONENT_FUNCTION_MAP.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getComponentRef(component: Component, _moduleName: string, exportName: string): any;
|
|
31
|
+
/**
|
|
32
|
+
* Generic helper to resolve a component function by its full domain path.
|
|
33
|
+
* Example: componentRef(component, 'core/queries/getAccount')
|
|
34
|
+
*/
|
|
35
|
+
export declare function componentRef(component: Component, path: string): any;
|
|
36
|
+
/**
|
|
37
|
+
* Component upsert mutation path for each trigger dispatcher. Single source
|
|
38
|
+
* of truth shared by `dispatchUpsert` (direct-mutation fallback) and
|
|
39
|
+
* `webhookHandlers()`'s dispatcher specs — keeps the pairing in sync by
|
|
40
|
+
* construction.
|
|
41
|
+
*/
|
|
42
|
+
export declare const DISPATCHER_UPSERT_PATHS: Record<TriggerDispatcherName, string>;
|
|
43
|
+
/**
|
|
44
|
+
* Run a domain upsert. When the app registered the `webhooks` handler pair,
|
|
45
|
+
* route through `syncWebhook` so the sync trigger runs in the same transaction
|
|
46
|
+
* as the component write. Otherwise call the component mutation directly.
|
|
47
|
+
*/
|
|
48
|
+
export declare function dispatchUpsert(whCtx: WebhookContext, dispatcherName: TriggerDispatcherName, data: Record<string, unknown>): Promise<void>;
|
|
49
|
+
export type WebhookContext = {
|
|
50
|
+
ctx: WebhookActionCtx;
|
|
51
|
+
component: Component;
|
|
52
|
+
config?: import("../types.js").RegisterRoutesConfig;
|
|
53
|
+
stripe: Stripe;
|
|
54
|
+
webhookSecret: string;
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/client/webhooks/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAwElE,wBAAgB,UAAU,CACxB,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC/B,MAAM,GAAG,SAAS,CAGpB;AAED,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,CAAC,YAAY,GAAG;IACpE,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B,CAMA;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,GAClD;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAK/C;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,MAAM,EAAE,MAA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