@fantastic.dev/better-stripe 0.7.0 → 0.8.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 +29 -18
- package/README.md +123 -91
- package/dist/client/billing/checkout.d.ts +1 -1
- package/dist/client/billing/checkout.d.ts.map +1 -1
- package/dist/client/billing/checkout.js +7 -2
- package/dist/client/billing/checkout.js.map +1 -1
- package/dist/client/connect/disputes.d.ts +1 -1
- package/dist/client/connect/disputes.d.ts.map +1 -1
- package/dist/client/connect/disputes.js +12 -6
- package/dist/client/connect/disputes.js.map +1 -1
- package/dist/client/connect/paymentMethods.d.ts.map +1 -1
- package/dist/client/connect/paymentMethods.js.map +1 -1
- package/dist/client/connect/refundActor.d.ts.map +1 -1
- package/dist/client/connect/refundActor.js.map +1 -1
- package/dist/client/connect/refunds.d.ts.map +1 -1
- package/dist/client/connect/refunds.js.map +1 -1
- package/dist/client/connect/transfers.d.ts.map +1 -1
- package/dist/client/connect/transfers.js +15 -4
- package/dist/client/connect/transfers.js.map +1 -1
- package/dist/client/core/accountDefaults.d.ts +6 -0
- package/dist/client/core/accountDefaults.d.ts.map +1 -0
- package/dist/client/core/accountDefaults.js +15 -0
- package/dist/client/core/accountDefaults.js.map +1 -0
- package/dist/client/core/accounts.d.ts +1 -5
- package/dist/client/core/accounts.d.ts.map +1 -1
- package/dist/client/core/accounts.js +2 -14
- package/dist/client/core/accounts.js.map +1 -1
- package/dist/client/core/fees.d.ts.map +1 -1
- package/dist/client/core/fees.js +7 -2
- package/dist/client/core/fees.js.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/products/prices.d.ts.map +1 -1
- package/dist/client/products/prices.js.map +1 -1
- package/dist/client/products/products.d.ts.map +1 -1
- package/dist/client/products/products.js +3 -1
- package/dist/client/products/products.js.map +1 -1
- package/dist/client/utils/owner.d.ts.map +1 -1
- package/dist/client/utils/owner.js +3 -1
- package/dist/client/utils/owner.js.map +1 -1
- package/dist/client/utils/stripeDashboardUrl.d.ts.map +1 -1
- package/dist/client/utils/stripeDashboardUrl.js.map +1 -1
- package/dist/client/webhooks/helpers.d.ts +10 -0
- package/dist/client/webhooks/helpers.d.ts.map +1 -1
- package/dist/client/webhooks/helpers.js +18 -0
- package/dist/client/webhooks/helpers.js.map +1 -1
- package/dist/client/webhooks/processors.d.ts.map +1 -1
- package/dist/client/webhooks/processors.js +1 -19
- package/dist/client/webhooks/processors.js.map +1 -1
- package/dist/component/connect/mutations.d.ts.map +1 -1
- package/dist/component/connect/mutations.js +4 -33
- package/dist/component/connect/mutations.js.map +1 -1
- package/dist/component/connect/schema.d.ts.map +1 -1
- package/dist/component/connect/schema.js.map +1 -1
- package/dist/component/lib/paymentSeller.d.ts +3 -0
- package/dist/component/lib/paymentSeller.d.ts.map +1 -0
- package/dist/component/lib/paymentSeller.js +10 -0
- package/dist/component/lib/paymentSeller.js.map +1 -0
- package/dist/component/lib/reversals.d.ts +10 -0
- package/dist/component/lib/reversals.d.ts.map +1 -1
- package/dist/component/lib/reversals.js +17 -0
- package/dist/component/lib/reversals.js.map +1 -1
- package/dist/react/components/ConnectProvider.d.ts +1 -1
- package/dist/react/components/ConnectProvider.d.ts.map +1 -1
- package/dist/react/components/ConnectProvider.js +18 -4
- package/dist/react/components/ConnectProvider.js.map +1 -1
- package/dist/react/components/ConnectStatusBadge.d.ts.map +1 -1
- package/dist/react/components/ConnectStatusBadge.js.map +1 -1
- package/dist/react/components/DisputeDetail.d.ts +4 -1
- package/dist/react/components/DisputeDetail.d.ts.map +1 -1
- package/dist/react/components/DisputeDetail.js +12 -6
- package/dist/react/components/DisputeDetail.js.map +1 -1
- package/dist/react/components/DisputesList.d.ts.map +1 -1
- package/dist/react/components/DisputesList.js +2 -1
- package/dist/react/components/DisputesList.js.map +1 -1
- package/dist/react/components/EmbeddedDisputes.d.ts +1 -1
- package/dist/react/components/EmbeddedDisputes.d.ts.map +1 -1
- package/dist/react/components/EmbeddedDisputes.js +1 -1
- package/dist/react/components/EmbeddedDisputes.js.map +1 -1
- package/dist/react/components/SplitBreakdown.d.ts.map +1 -1
- package/dist/react/components/SplitBreakdown.js +12 -2
- package/dist/react/components/SplitBreakdown.js.map +1 -1
- package/dist/react/hooks/useCheckoutSession.d.ts.map +1 -1
- package/dist/react/hooks/useCheckoutSession.js.map +1 -1
- package/dist/react/hooks/useConfirmPayment.d.ts.map +1 -1
- package/dist/react/hooks/useConfirmPayment.js.map +1 -1
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +3 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/workflows/Account.d.ts +67 -0
- package/dist/react/workflows/Account.d.ts.map +1 -0
- package/dist/react/workflows/Account.js +74 -0
- package/dist/react/workflows/Account.js.map +1 -0
- package/dist/react/workflows/Billing.d.ts +60 -0
- package/dist/react/workflows/Billing.d.ts.map +1 -0
- package/dist/react/workflows/Billing.js +84 -0
- package/dist/react/workflows/Billing.js.map +1 -0
- package/dist/react/workflows/BillingPlans.d.ts +45 -0
- package/dist/react/workflows/BillingPlans.d.ts.map +1 -0
- package/dist/react/workflows/BillingPlans.js +51 -0
- package/dist/react/workflows/BillingPlans.js.map +1 -0
- package/dist/react/workflows/Checkout.d.ts +46 -0
- package/dist/react/workflows/Checkout.d.ts.map +1 -0
- package/dist/react/workflows/Checkout.js +61 -0
- package/dist/react/workflows/Checkout.js.map +1 -0
- package/dist/react/workflows/CheckoutChooser.d.ts +20 -0
- package/dist/react/workflows/CheckoutChooser.d.ts.map +1 -0
- package/dist/react/workflows/CheckoutChooser.js +24 -0
- package/dist/react/workflows/CheckoutChooser.js.map +1 -0
- package/dist/react/workflows/CheckoutForms.d.ts +26 -0
- package/dist/react/workflows/CheckoutForms.d.ts.map +1 -0
- package/dist/react/workflows/CheckoutForms.js +126 -0
- package/dist/react/workflows/CheckoutForms.js.map +1 -0
- package/dist/react/workflows/ClipboardButton.d.ts +17 -0
- package/dist/react/workflows/ClipboardButton.d.ts.map +1 -0
- package/dist/react/workflows/ClipboardButton.js +35 -0
- package/dist/react/workflows/ClipboardButton.js.map +1 -0
- package/dist/react/workflows/Collection.d.ts +30 -0
- package/dist/react/workflows/Collection.d.ts.map +1 -0
- package/dist/react/workflows/Collection.js +25 -0
- package/dist/react/workflows/Collection.js.map +1 -0
- package/dist/react/workflows/Collections.d.ts +56 -0
- package/dist/react/workflows/Collections.d.ts.map +1 -0
- package/dist/react/workflows/Collections.js +111 -0
- package/dist/react/workflows/Collections.js.map +1 -0
- package/dist/react/workflows/Connect.d.ts +19 -0
- package/dist/react/workflows/Connect.d.ts.map +1 -0
- package/dist/react/workflows/Connect.js +43 -0
- package/dist/react/workflows/Connect.js.map +1 -0
- package/dist/react/workflows/Costs.d.ts +48 -0
- package/dist/react/workflows/Costs.d.ts.map +1 -0
- package/dist/react/workflows/Costs.js +66 -0
- package/dist/react/workflows/Costs.js.map +1 -0
- package/dist/react/workflows/Disputes.d.ts +36 -0
- package/dist/react/workflows/Disputes.d.ts.map +1 -0
- package/dist/react/workflows/Disputes.js +74 -0
- package/dist/react/workflows/Disputes.js.map +1 -0
- package/dist/react/workflows/Earnings.d.ts +42 -0
- package/dist/react/workflows/Earnings.d.ts.map +1 -0
- package/dist/react/workflows/Earnings.js +38 -0
- package/dist/react/workflows/Earnings.js.map +1 -0
- package/dist/react/workflows/Financials.d.ts +43 -0
- package/dist/react/workflows/Financials.d.ts.map +1 -0
- package/dist/react/workflows/Financials.js +57 -0
- package/dist/react/workflows/Financials.js.map +1 -0
- package/dist/react/workflows/IntegrationSwitch.d.ts +23 -0
- package/dist/react/workflows/IntegrationSwitch.d.ts.map +1 -0
- package/dist/react/workflows/IntegrationSwitch.js +31 -0
- package/dist/react/workflows/IntegrationSwitch.js.map +1 -0
- package/dist/react/workflows/Onboarding.d.ts +56 -0
- package/dist/react/workflows/Onboarding.d.ts.map +1 -0
- package/dist/react/workflows/Onboarding.js +86 -0
- package/dist/react/workflows/Onboarding.js.map +1 -0
- package/dist/react/workflows/Overview.d.ts +51 -0
- package/dist/react/workflows/Overview.d.ts.map +1 -0
- package/dist/react/workflows/Overview.js +63 -0
- package/dist/react/workflows/Overview.js.map +1 -0
- package/dist/react/workflows/PaymentMethods.d.ts +35 -0
- package/dist/react/workflows/PaymentMethods.d.ts.map +1 -0
- package/dist/react/workflows/PaymentMethods.js +63 -0
- package/dist/react/workflows/PaymentMethods.js.map +1 -0
- package/dist/react/workflows/PaymentReceipt.d.ts +20 -0
- package/dist/react/workflows/PaymentReceipt.d.ts.map +1 -0
- package/dist/react/workflows/PaymentReceipt.js +24 -0
- package/dist/react/workflows/PaymentReceipt.js.map +1 -0
- package/dist/react/workflows/Payouts.d.ts +48 -0
- package/dist/react/workflows/Payouts.d.ts.map +1 -0
- package/dist/react/workflows/Payouts.js +88 -0
- package/dist/react/workflows/Payouts.js.map +1 -0
- package/dist/react/workflows/Products.d.ts +92 -0
- package/dist/react/workflows/Products.d.ts.map +1 -0
- package/dist/react/workflows/Products.js +179 -0
- package/dist/react/workflows/Products.js.map +1 -0
- package/dist/react/workflows/ReferralLinks.d.ts +26 -0
- package/dist/react/workflows/ReferralLinks.d.ts.map +1 -0
- package/dist/react/workflows/ReferralLinks.js +30 -0
- package/dist/react/workflows/ReferralLinks.js.map +1 -0
- package/dist/react/workflows/Refunds.d.ts +72 -0
- package/dist/react/workflows/Refunds.d.ts.map +1 -0
- package/dist/react/workflows/Refunds.js +95 -0
- package/dist/react/workflows/Refunds.js.map +1 -0
- package/dist/react/workflows/Setup.d.ts +50 -0
- package/dist/react/workflows/Setup.d.ts.map +1 -0
- package/dist/react/workflows/Setup.js +59 -0
- package/dist/react/workflows/Setup.js.map +1 -0
- package/dist/react/workflows/Storefront.d.ts +53 -0
- package/dist/react/workflows/Storefront.d.ts.map +1 -0
- package/dist/react/workflows/Storefront.js +44 -0
- package/dist/react/workflows/Storefront.js.map +1 -0
- package/dist/react/workflows/SubscriptionOverview.d.ts +13 -0
- package/dist/react/workflows/SubscriptionOverview.d.ts.map +1 -0
- package/dist/react/workflows/SubscriptionOverview.js +26 -0
- package/dist/react/workflows/SubscriptionOverview.js.map +1 -0
- package/dist/react/workflows/Subscriptions.d.ts +92 -0
- package/dist/react/workflows/Subscriptions.d.ts.map +1 -0
- package/dist/react/workflows/Subscriptions.js +149 -0
- package/dist/react/workflows/Subscriptions.js.map +1 -0
- package/dist/react/workflows/Tasks.d.ts +40 -0
- package/dist/react/workflows/Tasks.d.ts.map +1 -0
- package/dist/react/workflows/Tasks.js +113 -0
- package/dist/react/workflows/Tasks.js.map +1 -0
- package/dist/react/workflows/checkout-options.d.ts +37 -0
- package/dist/react/workflows/checkout-options.d.ts.map +1 -0
- package/dist/react/workflows/checkout-options.js +43 -0
- package/dist/react/workflows/checkout-options.js.map +1 -0
- package/dist/react/workflows/current-subscription.d.ts +11 -0
- package/dist/react/workflows/current-subscription.d.ts.map +1 -0
- package/dist/react/workflows/current-subscription.js +14 -0
- package/dist/react/workflows/current-subscription.js.map +1 -0
- package/dist/react/workflows/filters.d.ts +17 -0
- package/dist/react/workflows/filters.d.ts.map +1 -0
- package/dist/react/workflows/filters.js +23 -0
- package/dist/react/workflows/filters.js.map +1 -0
- package/dist/react/workflows/index.d.ts +70 -0
- package/dist/react/workflows/index.d.ts.map +1 -0
- package/dist/react/workflows/index.js +38 -0
- package/dist/react/workflows/index.js.map +1 -0
- package/dist/react/workflows/useWorkflowAction.d.ts +11 -0
- package/dist/react/workflows/useWorkflowAction.d.ts.map +1 -0
- package/dist/react/workflows/useWorkflowAction.js +68 -0
- package/dist/react/workflows/useWorkflowAction.js.map +1 -0
- package/dist/react/workflows/useWorkflowResource.d.ts +9 -0
- package/dist/react/workflows/useWorkflowResource.d.ts.map +1 -0
- package/dist/react/workflows/useWorkflowResource.js +67 -0
- package/dist/react/workflows/useWorkflowResource.js.map +1 -0
- package/docs/react-workflows-audit.md +88 -0
- package/docs/react-workflows.md +234 -0
- package/package.json +19 -3
- package/src/client/billing/checkout-ui-modes.test.ts +49 -0
- package/src/client/billing/checkout.ts +8 -3
- package/src/client/billing/invoices.test.ts +12 -6
- package/src/client/connect/disputes.test.ts +15 -0
- package/src/client/connect/disputes.ts +13 -7
- package/src/client/connect/paymentMethods.test.ts +3 -1
- package/src/client/connect/paymentMethods.ts +4 -1
- package/src/client/connect/refundActor.ts +1 -2
- package/src/client/connect/refunds.test.ts +35 -10
- package/src/client/connect/refunds.ts +4 -1
- package/src/client/connect/transfers.test.ts +66 -12
- package/src/client/connect/transfers.ts +32 -8
- package/src/client/core/accountDefaults.ts +15 -0
- package/src/client/core/accounts.ts +14 -17
- package/src/client/core/config.test.ts +2 -1
- package/src/client/core/descriptors.test.ts +6 -4
- package/src/client/core/fees.test.ts +20 -28
- package/src/client/core/fees.ts +9 -2
- package/src/client/index.test.ts +22 -22
- package/src/client/index.ts +1 -1
- package/src/client/products/prices.test.ts +8 -2
- package/src/client/products/prices.ts +4 -1
- package/src/client/products/products.test.ts +61 -20
- package/src/client/products/products.ts +3 -1
- package/src/client/utils/data.test.ts +3 -1
- package/src/client/utils/owner.test.ts +4 -1
- package/src/client/utils/owner.ts +5 -1
- package/src/client/utils/stripeDashboardUrl.ts +1 -4
- package/src/client/webhooks/handler.test.ts +16 -19
- package/src/client/webhooks/helpers.test.ts +26 -13
- package/src/client/webhooks/helpers.ts +23 -0
- package/src/client/webhooks/hooks.test.ts +1 -2
- package/src/client/webhooks/processors.test.ts +18 -34
- package/src/client/webhooks/processors.ts +1 -23
- package/src/client/webhooks.test.ts +1 -2
- package/src/component/_generated/api.ts +2 -0
- package/src/component/connect/mutations.ts +5 -46
- package/src/component/connect/schema.ts +4 -3
- package/src/component/connect.test.ts +1 -5
- package/src/component/lib/paymentSeller.ts +15 -0
- package/src/component/lib/reversals.ts +30 -2
- package/src/component/subscription-scoping.test.ts +5 -1
- package/src/component/triggers.test.ts +7 -4
- package/src/react/components/BuyerBillingView.render.test.tsx +7 -2
- package/src/react/components/ConnectProvider.live.test.tsx +61 -0
- package/src/react/components/ConnectProvider.tsx +18 -4
- package/src/react/components/ConnectStatusBadge.tsx +1 -4
- package/src/react/components/DisputeDetail.render.test.tsx +5 -1
- package/src/react/components/DisputeDetail.tsx +14 -5
- package/src/react/components/DisputesList.render.test.tsx +21 -0
- package/src/react/components/DisputesList.tsx +2 -1
- package/src/react/components/EarningsSummary.render.test.tsx +2 -6
- package/src/react/components/EmbeddedDisputes.render.test.tsx +7 -5
- package/src/react/components/EmbeddedDisputes.tsx +4 -1
- package/src/react/components/EvidenceForm.render.test.tsx +3 -10
- package/src/react/components/SplitBreakdown.render.test.tsx +28 -5
- package/src/react/components/SplitBreakdown.tsx +12 -2
- package/src/react/hooks/useCheckoutSession.ts +1 -2
- package/src/react/hooks/useConfirmPayment.ts +1 -2
- package/src/react/hooks/useEarnings.test.ts +43 -8
- package/src/react/hooks/useStripeMode.test.ts +5 -8
- package/src/react/index.ts +7 -1
- package/src/react/workflows/Account.test.tsx +31 -0
- package/src/react/workflows/Account.tsx +183 -0
- package/src/react/workflows/Billing.test.tsx +45 -0
- package/src/react/workflows/Billing.tsx +213 -0
- package/src/react/workflows/BillingPlans.test.tsx +31 -0
- package/src/react/workflows/BillingPlans.tsx +130 -0
- package/src/react/workflows/Checkout.test.tsx +118 -0
- package/src/react/workflows/Checkout.tsx +135 -0
- package/src/react/workflows/CheckoutChooser.test.tsx +44 -0
- package/src/react/workflows/CheckoutChooser.tsx +77 -0
- package/src/react/workflows/CheckoutForm.test.tsx +66 -0
- package/src/react/workflows/CheckoutForms.test.tsx +123 -0
- package/src/react/workflows/CheckoutForms.tsx +247 -0
- package/src/react/workflows/ClipboardButton.test.tsx +34 -0
- package/src/react/workflows/ClipboardButton.tsx +67 -0
- package/src/react/workflows/Collection.tsx +76 -0
- package/src/react/workflows/Collections.test.tsx +86 -0
- package/src/react/workflows/Collections.tsx +213 -0
- package/src/react/workflows/Connect.test.tsx +50 -0
- package/src/react/workflows/Connect.tsx +107 -0
- package/src/react/workflows/Costs.test.tsx +41 -0
- package/src/react/workflows/Costs.tsx +133 -0
- package/src/react/workflows/Disputes.test.tsx +64 -0
- package/src/react/workflows/Disputes.tsx +173 -0
- package/src/react/workflows/Earnings.test.ts +19 -0
- package/src/react/workflows/Earnings.tsx +84 -0
- package/src/react/workflows/Financials.test.tsx +35 -0
- package/src/react/workflows/Financials.tsx +117 -0
- package/src/react/workflows/IntegrationSwitch.test.tsx +36 -0
- package/src/react/workflows/IntegrationSwitch.tsx +63 -0
- package/src/react/workflows/Onboarding.test.tsx +75 -0
- package/src/react/workflows/Onboarding.tsx +171 -0
- package/src/react/workflows/Overview.test.tsx +57 -0
- package/src/react/workflows/Overview.tsx +123 -0
- package/src/react/workflows/PaymentMethods.test.tsx +60 -0
- package/src/react/workflows/PaymentMethods.tsx +117 -0
- package/src/react/workflows/PaymentReceipt.test.tsx +24 -0
- package/src/react/workflows/PaymentReceipt.tsx +46 -0
- package/src/react/workflows/Payouts.test.tsx +112 -0
- package/src/react/workflows/Payouts.tsx +215 -0
- package/src/react/workflows/Products.test.tsx +90 -0
- package/src/react/workflows/Products.tsx +377 -0
- package/src/react/workflows/ReferralLinks.test.tsx +39 -0
- package/src/react/workflows/ReferralLinks.tsx +75 -0
- package/src/react/workflows/Refunds.test.tsx +75 -0
- package/src/react/workflows/Refunds.tsx +223 -0
- package/src/react/workflows/Setup.test.tsx +25 -0
- package/src/react/workflows/Setup.tsx +166 -0
- package/src/react/workflows/Storefront.test.tsx +82 -0
- package/src/react/workflows/Storefront.tsx +138 -0
- package/src/react/workflows/SubscriptionOverview.test.tsx +27 -0
- package/src/react/workflows/SubscriptionOverview.tsx +48 -0
- package/src/react/workflows/Subscriptions.test.tsx +61 -0
- package/src/react/workflows/Subscriptions.tsx +282 -0
- package/src/react/workflows/Tasks.test.tsx +23 -0
- package/src/react/workflows/Tasks.tsx +199 -0
- package/src/react/workflows/checkout-options.ts +42 -0
- package/src/react/workflows/current-subscription.test.ts +29 -0
- package/src/react/workflows/current-subscription.ts +25 -0
- package/src/react/workflows/filters.test.ts +12 -0
- package/src/react/workflows/filters.ts +22 -0
- package/src/react/workflows/index.ts +238 -0
- package/src/react/workflows/native-interactions.test.tsx +73 -0
- package/src/react/workflows/public-workflows.test.tsx +216 -0
- package/src/react/workflows/useWorkflowAction.test.tsx +54 -0
- package/src/react/workflows/useWorkflowAction.ts +75 -0
- package/src/react/workflows/useWorkflowResource.test.tsx +41 -0
- package/src/react/workflows/useWorkflowResource.ts +78 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId, useState } from "react";
|
|
4
|
+
import { useWorkflowAction } from "./useWorkflowAction.js";
|
|
5
|
+
import { Connect } from "./Connect.js";
|
|
6
|
+
import { AccountOnboardingCard } from "../components/AccountOnboardingCard.js";
|
|
7
|
+
export const DEFAULT_CONNECT_COUNTRIES = [
|
|
8
|
+
{ code: "US", name: "United States" },
|
|
9
|
+
{ code: "GB", name: "United Kingdom" },
|
|
10
|
+
{ code: "AU", name: "Australia" },
|
|
11
|
+
{ code: "CA", name: "Canada" },
|
|
12
|
+
{ code: "DE", name: "Germany" },
|
|
13
|
+
{ code: "FR", name: "France" },
|
|
14
|
+
{ code: "JP", name: "Japan" },
|
|
15
|
+
{ code: "SG", name: "Singapore" },
|
|
16
|
+
];
|
|
17
|
+
export function useOnboarding(props) {
|
|
18
|
+
const [fields, setFields] = useState({
|
|
19
|
+
scope: props.scopeKey,
|
|
20
|
+
country: props.initialCountry ?? "US",
|
|
21
|
+
});
|
|
22
|
+
if (fields.scope !== props.scopeKey)
|
|
23
|
+
setFields({ scope: props.scopeKey, country: props.initialCountry ?? "US" });
|
|
24
|
+
const [operation, setOperation] = useState("create");
|
|
25
|
+
const action = useWorkflowAction(async (type) => {
|
|
26
|
+
setOperation(type);
|
|
27
|
+
if (type === "close") {
|
|
28
|
+
if (!props.closeAccount)
|
|
29
|
+
throw new Error("Account closing is not configured.");
|
|
30
|
+
await props.closeAccount();
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
const result = type === "create"
|
|
34
|
+
? await props.createAccount(fields.country)
|
|
35
|
+
: await props.continueOnboarding();
|
|
36
|
+
const url = "onboardingUrl" in result
|
|
37
|
+
? result.onboardingUrl
|
|
38
|
+
: "url" in result
|
|
39
|
+
? result.url
|
|
40
|
+
: undefined;
|
|
41
|
+
if (!url)
|
|
42
|
+
throw new Error("Stripe did not return an onboarding URL.");
|
|
43
|
+
(props.onNavigate ?? ((url) => window.location.assign(url)))(url);
|
|
44
|
+
return true;
|
|
45
|
+
}, props.scopeKey);
|
|
46
|
+
const run = action.run;
|
|
47
|
+
return {
|
|
48
|
+
selectedCountry: fields.country,
|
|
49
|
+
setSelectedCountry: (country) => setFields((previous) => ({ ...previous, country })),
|
|
50
|
+
isPending: action.isPending,
|
|
51
|
+
isCreating: action.isPending && operation === "create",
|
|
52
|
+
isLinking: action.isPending && operation === "link",
|
|
53
|
+
isRestarting: action.isPending && operation === "close",
|
|
54
|
+
error: action.error,
|
|
55
|
+
createError: operation === "create" ? action.error : null,
|
|
56
|
+
linkError: operation === "link" ? action.error : null,
|
|
57
|
+
restartError: operation === "close" ? action.error : null,
|
|
58
|
+
create: () => run("create"),
|
|
59
|
+
continue: () => run("link"),
|
|
60
|
+
close: () => run("close"),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export function Onboarding(props) {
|
|
64
|
+
return props.presentation === "embedded" ? (_jsx(Connect, { ...props, component: "onboarding" })) : (_jsx(OnboardingBody, { ...props }, props.scopeKey));
|
|
65
|
+
}
|
|
66
|
+
function OnboardingBody(props) {
|
|
67
|
+
const state = useOnboarding(props);
|
|
68
|
+
const id = useId();
|
|
69
|
+
if (props.children)
|
|
70
|
+
return _jsx(_Fragment, { children: props.children({ ...state, account: props.account }) });
|
|
71
|
+
if (props.account === undefined)
|
|
72
|
+
return _jsx("p", { role: "status", children: "Loading account\u2026" });
|
|
73
|
+
const status = props.account?.onboardingStatus;
|
|
74
|
+
const normalized = status === "complete" || status === "in_progress" || status === "restricted"
|
|
75
|
+
? status
|
|
76
|
+
: "pending";
|
|
77
|
+
return (_jsxs("section", { "data-better-stripe": "onboarding", "aria-busy": state.isPending, children: [_jsx("h2", { children: "Account setup" }), state.error && _jsx("p", { role: "alert", children: state.error }), !props.account ? (_jsxs("form", { onSubmit: (event) => {
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
void state.create();
|
|
80
|
+
}, children: [_jsx("label", { htmlFor: id, children: "Country" }), _jsx("select", { id: id, required: true, value: state.selectedCountry, onChange: (event) => state.setSelectedCountry(event.target.value), children: (props.countries ?? DEFAULT_CONNECT_COUNTRIES).map((country) => (_jsx("option", { value: country.code, children: country.name }, country.code))) }), _jsx("button", { type: "submit", disabled: state.isPending, children: state.isCreating ? "Creating account…" : "Create account" })] })) : (_jsxs(_Fragment, { children: [_jsx("p", { children: props.account.stripeAccountId }), _jsx(AccountOnboardingCard, { status: normalized, missingRequirements: props.account.missingRequirements, onContinue: () => {
|
|
81
|
+
void state.continue();
|
|
82
|
+
}, isLoading: state.isPending }), props.closeAccount && (_jsxs("details", { children: [_jsx("summary", { children: "Close account" }), _jsx("p", { children: "Closing a Stripe account is irreversible." }), _jsx("button", { type: "button", disabled: state.isPending, onClick: () => {
|
|
83
|
+
void state.close();
|
|
84
|
+
}, children: state.isRestarting ? "Closing…" : "Close account" })] }))] }))] }));
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=Onboarding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Onboarding.js","sourceRoot":"","sources":["../../../src/react/workflows/Onboarding.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AACxD,OAAO,EA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AAC,CAAC,CACF,8BACE,sBAAI,KAAK,CAAC,OAAO,CAAC,eAAe,GAAK,EACtC,KAAC,qBAAqB,IACpB,MAAM,EAAE,UAAU,EAClB,mBAAmB,EAAE,KAAK,CAAC,OAAO,CAAC,mBAAmB,EACtD,UAAU,EAAE,GAAG,EAAE;4BACf,KAAK,KAAK,CAAC,QAAQ,EAAE,CAAC;wBACxB,CAAC,EACD,SAAS,EAAE,KAAK,CAAC,SAAS,GAC1B,EACD,KAAK,CAAC,YAAY,IAAI,CACrB,8BACE,8CAAgC,EAChC,oEAAgD,EAChD,iBACE,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,OAAO,EAAE,GAAG,EAAE;oCACZ,KAAK,KAAK,CAAC,KAAK,EAAE,CAAC;gCACrB,CAAC,YAEA,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,eAAe,GAC3C,IACD,CACX,IACA,CACJ,IACO,CACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type OverviewState = {
|
|
3
|
+
isLoading: boolean;
|
|
4
|
+
totalProducts: number;
|
|
5
|
+
totalSubscriptions: number;
|
|
6
|
+
activeSubscriptions: number;
|
|
7
|
+
metrics: {
|
|
8
|
+
label: string;
|
|
9
|
+
value: number | string;
|
|
10
|
+
}[];
|
|
11
|
+
};
|
|
12
|
+
export type OverviewProps = {
|
|
13
|
+
products: unknown[] | undefined;
|
|
14
|
+
subscriptions: {
|
|
15
|
+
status: string;
|
|
16
|
+
}[] | undefined;
|
|
17
|
+
children?: (state: OverviewState) => ReactNode;
|
|
18
|
+
};
|
|
19
|
+
export declare function Overview({ products, subscriptions, children }: OverviewProps): import("react").JSX.Element;
|
|
20
|
+
/** Totals for one currency only. Upcoming payout amounts are not an account's available/pending Stripe balance. */
|
|
21
|
+
export declare function getPayoutTotals<T extends {
|
|
22
|
+
amount?: number;
|
|
23
|
+
status: string;
|
|
24
|
+
currency: string;
|
|
25
|
+
}>(payouts: T[] | undefined, currency: string): {
|
|
26
|
+
totalPayouts: number;
|
|
27
|
+
pendingBalance: number;
|
|
28
|
+
totalEarned: number;
|
|
29
|
+
recentPayouts: T[];
|
|
30
|
+
};
|
|
31
|
+
export type PayoutOverviewRow = {
|
|
32
|
+
stripePayoutId: string;
|
|
33
|
+
amount?: number;
|
|
34
|
+
currency: string;
|
|
35
|
+
status: string;
|
|
36
|
+
arrivalDate?: string | null;
|
|
37
|
+
};
|
|
38
|
+
export type PayoutOverviewProps<Row extends PayoutOverviewRow = PayoutOverviewRow> = {
|
|
39
|
+
payouts: Row[] | undefined;
|
|
40
|
+
currency: string;
|
|
41
|
+
children?: (state: ReturnType<typeof getPayoutTotals<Row>> & {
|
|
42
|
+
isLoading: boolean;
|
|
43
|
+
metrics: {
|
|
44
|
+
label: string;
|
|
45
|
+
value: string;
|
|
46
|
+
}[];
|
|
47
|
+
}) => ReactNode;
|
|
48
|
+
};
|
|
49
|
+
/** Payout activity totals. These amounts are not the available or pending account balance. */
|
|
50
|
+
export declare function PayoutOverview<Row extends PayoutOverviewRow>({ payouts, currency, children, }: PayoutOverviewProps<Row>): import("react").JSX.Element;
|
|
51
|
+
//# sourceMappingURL=Overview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Overview.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/Overview.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,MAA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,CAAC;AACF,8FAA8F;AAC9F,wBAAgB,cAAc,CAAC,GAAG,SAAS,iBAAiB,EAAE,EAC5D,OAAO,EACP,QAAQ,EACR,QAAQ,GACT,EAAE,mBAAmB,CAAC,GAAG,CAAC,+BA+B1B"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { formatPrice } from "../lib/price-helpers.js";
|
|
4
|
+
export function Overview({ products, subscriptions, children }) {
|
|
5
|
+
const isLoading = products === undefined || subscriptions === undefined;
|
|
6
|
+
const totalProducts = products?.length ?? 0;
|
|
7
|
+
const totalSubscriptions = subscriptions?.length ?? 0;
|
|
8
|
+
const activeSubscriptions = subscriptions?.filter((row) => row.status === "active").length ?? 0;
|
|
9
|
+
const state = {
|
|
10
|
+
isLoading,
|
|
11
|
+
totalProducts,
|
|
12
|
+
totalSubscriptions,
|
|
13
|
+
activeSubscriptions,
|
|
14
|
+
metrics: [
|
|
15
|
+
{ label: "Total Subscriptions", value: totalSubscriptions },
|
|
16
|
+
{ label: "Active Subscriptions", value: activeSubscriptions },
|
|
17
|
+
{ label: "Total Products", value: totalProducts },
|
|
18
|
+
{ label: "Data Status", value: isLoading ? "Loading…" : "Live" },
|
|
19
|
+
],
|
|
20
|
+
};
|
|
21
|
+
if (children)
|
|
22
|
+
return _jsx(_Fragment, { children: children(state) });
|
|
23
|
+
return (_jsxs("section", { "data-better-stripe": "overview", children: [_jsx("h2", { children: "Overview" }), _jsx("dl", { children: state.metrics.map((metric) => (_jsxs("div", { children: [_jsx("dt", { children: metric.label }), _jsx("dd", { children: isLoading ? "Loading…" : metric.value })] }, metric.label))) })] }));
|
|
24
|
+
}
|
|
25
|
+
/** Totals for one currency only. Upcoming payout amounts are not an account's available/pending Stripe balance. */
|
|
26
|
+
export function getPayoutTotals(payouts, currency) {
|
|
27
|
+
const rows = payouts?.filter((row) => row.currency === currency) ?? [];
|
|
28
|
+
const totalPayouts = rows
|
|
29
|
+
.filter((row) => row.status === "paid")
|
|
30
|
+
.reduce((sum, row) => sum + (row.amount ?? 0), 0);
|
|
31
|
+
const pendingBalance = rows
|
|
32
|
+
.filter((row) => row.status === "pending" || row.status === "in_transit")
|
|
33
|
+
.reduce((sum, row) => sum + (row.amount ?? 0), 0);
|
|
34
|
+
return {
|
|
35
|
+
totalPayouts,
|
|
36
|
+
pendingBalance,
|
|
37
|
+
totalEarned: totalPayouts + pendingBalance,
|
|
38
|
+
recentPayouts: rows.slice(0, 3),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** Payout activity totals. These amounts are not the available or pending account balance. */
|
|
42
|
+
export function PayoutOverview({ payouts, currency, children, }) {
|
|
43
|
+
const totals = getPayoutTotals(payouts, currency);
|
|
44
|
+
const state = {
|
|
45
|
+
...totals,
|
|
46
|
+
isLoading: payouts === undefined,
|
|
47
|
+
metrics: [
|
|
48
|
+
{
|
|
49
|
+
label: "Total payouts tracked",
|
|
50
|
+
value: formatPrice(totals.totalEarned, currency),
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
label: "Upcoming payouts",
|
|
54
|
+
value: formatPrice(totals.pendingBalance, currency),
|
|
55
|
+
},
|
|
56
|
+
{ label: "Paid out", value: formatPrice(totals.totalPayouts, currency) },
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
if (children)
|
|
60
|
+
return _jsx(_Fragment, { children: children(state) });
|
|
61
|
+
return (_jsxs("section", { "data-better-stripe": "payout-overview", children: [_jsx("h2", { children: "Payout activity" }), _jsx("dl", { children: state.metrics.map((metric) => (_jsxs("div", { children: [_jsx("dt", { children: metric.label }), _jsx("dd", { children: state.isLoading ? "Loading…" : metric.value })] }, metric.label))) })] }));
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=Overview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Overview.js","sourceRoot":"","sources":["../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E,OAAO,KAAK,SAAS;QAChC,OAAO,EAAE;YACP;gBACE,KAAK,EAAE,uBAAuB;gBAC9B,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC;aACjD;YACD;gBACE,KAAK,EAAE,kBAAkB;gBACzB,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,cAAc,EAAE,QAAQ,CAAC;aACpD;YACD,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE;SACzE;KACF,CAAC;IACF,IAAI,QAAQ;QAAE,OAAO,4BAAG,QAAQ,CAAC,KAAK,CAAC,GAAI,CAAC;IAC5C,OAAO,CACL,yCAA4B,iBAAiB,aAC3C,2CAAwB,EACxB,uBACG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAC7B,0BACE,uBAAK,MAAM,CAAC,KAAK,GAAM,EACvB,uBAAK,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,GAAM,KAF9C,MAAM,CAAC,KAAK,CAGhB,CACP,CAAC,GACC,IACG,CACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type PaymentMethodItem } from "../components/PaymentMethodsList.js";
|
|
3
|
+
export type PaymentMethodsActions = {
|
|
4
|
+
scopeKey: string;
|
|
5
|
+
load: () => Promise<PaymentMethodItem[]>;
|
|
6
|
+
attach: (paymentMethodId: string) => Promise<unknown>;
|
|
7
|
+
detach: (paymentMethodId: string) => Promise<unknown>;
|
|
8
|
+
};
|
|
9
|
+
export declare function usePaymentMethodsManager(props: PaymentMethodsActions): {
|
|
10
|
+
methods: PaymentMethodItem[];
|
|
11
|
+
isLoading: boolean;
|
|
12
|
+
isPending: boolean;
|
|
13
|
+
loadError: string | null;
|
|
14
|
+
attachError: string | null;
|
|
15
|
+
deleteError: string | null;
|
|
16
|
+
reload: () => void;
|
|
17
|
+
attach: (id: string) => Promise<void>;
|
|
18
|
+
detach: (id: string) => Promise<void>;
|
|
19
|
+
};
|
|
20
|
+
export declare function toPaymentMethodItem(method: {
|
|
21
|
+
id: string;
|
|
22
|
+
type: string;
|
|
23
|
+
card?: {
|
|
24
|
+
brand: string;
|
|
25
|
+
last4: string;
|
|
26
|
+
exp_month: number;
|
|
27
|
+
exp_year: number;
|
|
28
|
+
} | null;
|
|
29
|
+
}, defaultId?: string): PaymentMethodItem;
|
|
30
|
+
export type PaymentMethodsProps = PaymentMethodsActions & {
|
|
31
|
+
publishableKey: string;
|
|
32
|
+
children?: (state: ReturnType<typeof usePaymentMethodsManager>) => ReactNode;
|
|
33
|
+
};
|
|
34
|
+
export declare function PaymentMethods(props: PaymentMethodsProps): import("react").JSX.Element;
|
|
35
|
+
//# sourceMappingURL=PaymentMethods.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PaymentMethods.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/PaymentMethods.tsx"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,qCAAqC,CAAC;AAK7C,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACzC,MAAM,EAAE,CAAC,eAAe,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACtD,MAAM,EAAE,CAAC,eAAe,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACvD,CAAC;AACF,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,qBAAqB;IAgBjE,OAAO;IACP,SAAS;IACT,SAAS;IACT,SAAS;IACT,WAAW;IACX,WAAW;IACX,MAAM;IACN,MAAM,OAAO,MAAM;IACnB,MAAM,OAAO,MAAM;EAEtB;AACD,wBAAgB,mBAAmB,CACjC,MAAM,EAAE;IACN,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,IAAI,CAAC;CACV,EACD,SAAS,CAAC,EAAE,MAAM,GACjB,iBAAiB,CAcnB;AACD,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,GAAG;IACxD,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,KAAK,SAAS,CAAC;CAC9E,CAAC;AACF,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,+BAExD"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { PaymentMethodsList, } from "../components/PaymentMethodsList.js";
|
|
5
|
+
import { AddCardForm } from "../components/AddCardForm.js";
|
|
6
|
+
import { StripeProvider } from "../components/StripeProvider.js";
|
|
7
|
+
import { useWorkflowAction } from "./useWorkflowAction.js";
|
|
8
|
+
import { useWorkflowResource } from "./useWorkflowResource.js";
|
|
9
|
+
export function usePaymentMethodsManager(props) {
|
|
10
|
+
const resource = useWorkflowResource(props.load, props.scopeKey);
|
|
11
|
+
const [kind, setKind] = useState("attach");
|
|
12
|
+
const action = useWorkflowAction(async (kind, id) => {
|
|
13
|
+
setKind(kind);
|
|
14
|
+
if (!id.trim())
|
|
15
|
+
throw new Error("A payment method ID is required.");
|
|
16
|
+
await props[kind](id);
|
|
17
|
+
return true;
|
|
18
|
+
}, props.scopeKey);
|
|
19
|
+
const run = async (kind, id) => {
|
|
20
|
+
if (await action.run(kind, id))
|
|
21
|
+
resource.refresh();
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
methods: resource.data ?? [],
|
|
25
|
+
isLoading: resource.isLoading,
|
|
26
|
+
isPending: action.isPending,
|
|
27
|
+
loadError: resource.error,
|
|
28
|
+
attachError: kind === "attach" ? action.error : null,
|
|
29
|
+
deleteError: kind === "detach" ? action.error : null,
|
|
30
|
+
reload: resource.refresh,
|
|
31
|
+
attach: (id) => run("attach", id),
|
|
32
|
+
detach: (id) => run("detach", id),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export function toPaymentMethodItem(method, defaultId) {
|
|
36
|
+
return {
|
|
37
|
+
id: method.id,
|
|
38
|
+
type: method.type,
|
|
39
|
+
card: method.card
|
|
40
|
+
? {
|
|
41
|
+
brand: method.card.brand,
|
|
42
|
+
last4: method.card.last4,
|
|
43
|
+
expMonth: method.card.exp_month,
|
|
44
|
+
expYear: method.card.exp_year,
|
|
45
|
+
}
|
|
46
|
+
: undefined,
|
|
47
|
+
isDefault: method.id === defaultId,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export function PaymentMethods(props) {
|
|
51
|
+
return _jsx(PaymentMethodsBody, { ...props }, props.scopeKey);
|
|
52
|
+
}
|
|
53
|
+
function PaymentMethodsBody(props) {
|
|
54
|
+
const state = usePaymentMethodsManager(props);
|
|
55
|
+
if (props.children)
|
|
56
|
+
return _jsx(_Fragment, { children: props.children(state) });
|
|
57
|
+
return (_jsxs("section", { "data-better-stripe": "payment-methods", "aria-busy": state.isPending || state.isLoading, children: [_jsx("h2", { children: "Payment methods" }), _jsx(StripeProvider, { publishableKey: props.publishableKey, children: _jsxs("fieldset", { disabled: state.isPending, children: [_jsx("legend", { children: "Add a card" }), _jsx(AddCardForm, { onSuccess: (id) => {
|
|
58
|
+
void state.attach(id);
|
|
59
|
+
} })] }) }), (state.loadError || state.attachError || state.deleteError) && (_jsx("p", { role: "alert", children: state.loadError || state.attachError || state.deleteError })), _jsx("button", { type: "button", disabled: state.isLoading, onClick: state.reload, children: state.isLoading ? "Loading…" : "Refresh" }), state.isLoading ? (_jsx("p", { role: "status", children: "Loading payment methods\u2026" })) : (_jsx(PaymentMethodsList, { methods: state.methods, onDelete: (id) => {
|
|
60
|
+
void state.detach(id);
|
|
61
|
+
} }))] }));
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=PaymentMethods.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PaymentMethods.js","sourceRoot":"","sources":["../../../src/react/workflows/PaymentMethods.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AACjD,OAAO,EACL,kBAAkB,GAEnB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAO/D,MAAM,UAAU,wBAAwB,CAAC,KAA4B;IACnE,MAAM,QAAQ,GAAG,mBAAmB,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IACjE,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAsB,QAAQ,CAAC,CAAC;IAChE,MAAM,MAAM,GAAG,iBAAiB,CAC9B,KAAK,EAAE,IAAyB,EAAE,EAAU,EAAE,EAAE;QAC9C,OAAO,CAAC,IAAI,CAAC,CAAC;QACd,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,kCAA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C,SAAS,GAClC,EACR,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CACjB,YAAG,IAAI,EAAC,QAAQ,8CAA6B,CAC9C,CAAC,CAAC,CAAC,CACF,KAAC,kBAAkB,IACjB,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE;oBACf,KAAK,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;gBACxB,CAAC,GACD,CACH,IACO,CACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type ReceiptPayment = {
|
|
3
|
+
status: string;
|
|
4
|
+
amount: number;
|
|
5
|
+
currency: string;
|
|
6
|
+
};
|
|
7
|
+
export type PaymentReceiptState = {
|
|
8
|
+
payment: ReceiptPayment | null | undefined;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
isConfirmed: boolean;
|
|
11
|
+
title: string;
|
|
12
|
+
message: string;
|
|
13
|
+
amountLabel?: string;
|
|
14
|
+
};
|
|
15
|
+
export type PaymentReceiptProps = {
|
|
16
|
+
/** Supply authoritative server/webhook data, never a client-confirmation result. */ payment: ReceiptPayment | null | undefined;
|
|
17
|
+
children?: (state: PaymentReceiptState) => ReactNode;
|
|
18
|
+
};
|
|
19
|
+
export declare function PaymentReceipt({ payment, children }: PaymentReceiptProps): import("react").JSX.Element;
|
|
20
|
+
//# sourceMappingURL=PaymentReceipt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PaymentReceipt.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/PaymentReceipt.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,cAAc,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3C,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG;IAChC,oFAAoF,CAAC,OAAO,EAC1F,cAAc,GAAG,IAAI,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,SAAS,CAAC;CACtD,CAAC;AACF,wBAAgB,cAAc,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,mBAAmB,+BAwBxE"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { formatPrice } from "../lib/price-helpers.js";
|
|
4
|
+
export function PaymentReceipt({ payment, children }) {
|
|
5
|
+
const isConfirmed = payment?.status === "succeeded";
|
|
6
|
+
const state = {
|
|
7
|
+
payment,
|
|
8
|
+
isLoading: !payment,
|
|
9
|
+
isConfirmed,
|
|
10
|
+
title: isConfirmed ? "Payment successful!" : "Payment status",
|
|
11
|
+
message: !payment
|
|
12
|
+
? "Waiting for Stripe payment confirmation…"
|
|
13
|
+
: isConfirmed
|
|
14
|
+
? "Your purchase is confirmed by Stripe."
|
|
15
|
+
: `Stripe payment status: ${payment.status}`,
|
|
16
|
+
amountLabel: payment
|
|
17
|
+
? formatPrice(payment.amount, payment.currency)
|
|
18
|
+
: undefined,
|
|
19
|
+
};
|
|
20
|
+
if (children)
|
|
21
|
+
return _jsx(_Fragment, { children: children(state) });
|
|
22
|
+
return (_jsxs("section", { "data-better-stripe": "payment-receipt", children: [_jsx("h2", { children: state.title }), _jsx("p", { role: "status", children: state.message }), state.amountLabel && _jsx("p", { children: state.amountLabel })] }));
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=PaymentReceipt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PaymentReceipt.js","sourceRoot":"","sources":["../../../src/react/workflows/PaymentReceipt.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAmBtD,MAAM,UAAU,cAAc,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAuB;IACvE,MAAM,WAAW,GAAG,OAAO,EAAE,MAAM,KAAK,WAAW,CAAC;IACpD,MAAM,KAAK,GAAG;QACZ,OAAO;QACP,SAAS,EAAE,CAAC,OAAO;QACnB,WAAW;QACX,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,gBAAgB;QAC7D,OAAO,EAAE,CAAC,OAAO;YACf,CAAC,CAAC,0CAA0C;YAC5C,CAAC,CAAC,WAAW;gBACX,CAAC,CAAC,uCAAuC;gBACzC,CAAC,CAAC,0BAA0B,OAAO,CAAC,MAAM,EAAE;QAChD,WAAW,EAAE,OAAO;YAClB,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC;YAC/C,CAAC,CAAC,SAAS;KACd,CAAC;IACF,IAAI,QAAQ;QAAE,OAAO,4BAAG,QAAQ,CAAC,KAAK,CAAC,GAAI,CAAC;IAC5C,OAAO,CACL,yCAA4B,iBAAiB,aAC3C,uBAAK,KAAK,CAAC,KAAK,GAAM,EACtB,YAAG,IAAI,EAAC,QAAQ,YAAE,KAAK,CAAC,OAAO,GAAK,EACnC,KAAK,CAAC,WAAW,IAAI,sBAAI,KAAK,CAAC,WAAW,GAAK,IACxC,CACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type ConnectProps } from "./Connect.js";
|
|
3
|
+
import { type CollectionProps, type WorkflowColumn } from "./Collection.js";
|
|
4
|
+
export type PayoutRow = {
|
|
5
|
+
id: string;
|
|
6
|
+
amount: number;
|
|
7
|
+
currency: string;
|
|
8
|
+
status: string;
|
|
9
|
+
/** Unix milliseconds. */ arrivalDate: number | null;
|
|
10
|
+
created: number;
|
|
11
|
+
};
|
|
12
|
+
export type PayoutSnapshot = {
|
|
13
|
+
balances: {
|
|
14
|
+
currency: string;
|
|
15
|
+
available: number;
|
|
16
|
+
pending: number;
|
|
17
|
+
}[];
|
|
18
|
+
payouts: PayoutRow[];
|
|
19
|
+
upcoming: PayoutRow[];
|
|
20
|
+
nextCursor: string | null;
|
|
21
|
+
};
|
|
22
|
+
export type PayoutsRenderProps = {
|
|
23
|
+
data: PayoutSnapshot | undefined;
|
|
24
|
+
error: string | null;
|
|
25
|
+
isLoading: boolean;
|
|
26
|
+
isPending: boolean;
|
|
27
|
+
nextPayout: PayoutRow | undefined;
|
|
28
|
+
previousPayouts: PayoutRow[];
|
|
29
|
+
upcomingPayouts: PayoutRow[];
|
|
30
|
+
refresh: () => void;
|
|
31
|
+
loadMore: () => Promise<void>;
|
|
32
|
+
};
|
|
33
|
+
export type HeadlessPayoutsProps = {
|
|
34
|
+
presentation?: "headless";
|
|
35
|
+
scopeKey: string;
|
|
36
|
+
load: (cursor?: string) => Promise<PayoutSnapshot>;
|
|
37
|
+
children?: (state: PayoutsRenderProps) => ReactNode;
|
|
38
|
+
};
|
|
39
|
+
export type PayoutsProps = HeadlessPayoutsProps | (Omit<ConnectProps, "component"> & {
|
|
40
|
+
presentation: "embedded";
|
|
41
|
+
});
|
|
42
|
+
export declare function Payouts(props: PayoutsProps): import("react").JSX.Element;
|
|
43
|
+
export type PayoutHistoryRow = Pick<PayoutRow, "id" | "amount" | "currency" | "status" | "arrivalDate">;
|
|
44
|
+
export type PayoutHistoryProps<Row extends PayoutHistoryRow = PayoutHistoryRow> = Omit<CollectionProps<Row>, "columns" | "getKey"> & {
|
|
45
|
+
columns?: WorkflowColumn<Row>[];
|
|
46
|
+
};
|
|
47
|
+
export declare function PayoutHistory<Row extends PayoutHistoryRow>(props: PayoutHistoryProps<Row>): import("react").JSX.Element;
|
|
48
|
+
//# sourceMappingURL=Payouts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Payouts.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/Payouts.tsx"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAW,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAG1D,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,yBAAyB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACrD,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AACF,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACrE,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAAC;AACF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,cAAc,GAAG,SAAS,CAAC;IACjC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,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"react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { Connect } from "./Connect.js";
|
|
5
|
+
import { useWorkflowAction } from "./useWorkflowAction.js";
|
|
6
|
+
import { useWorkflowResource } from "./useWorkflowResource.js";
|
|
7
|
+
import { Collection, } from "./Collection.js";
|
|
8
|
+
import { formatPrice } from "../lib/price-helpers.js";
|
|
9
|
+
const upcoming = (row) => row.status === "pending" || row.status === "in_transit";
|
|
10
|
+
export function Payouts(props) {
|
|
11
|
+
return props.presentation === "embedded" ? (_jsx(Connect, { ...props, component: "payouts" })) : (_jsx(PayoutsBody, { ...props }, props.scopeKey));
|
|
12
|
+
}
|
|
13
|
+
function PayoutsBody({ load, scopeKey, children }) {
|
|
14
|
+
const resource = useWorkflowResource(() => load(), scopeKey);
|
|
15
|
+
const more = useWorkflowAction((cursor) => load(cursor), `${scopeKey}:${resource.revision}`);
|
|
16
|
+
const [pages, setPages] = useState({ base: undefined, rows: [], cursor: undefined });
|
|
17
|
+
if (pages.base !== resource.data)
|
|
18
|
+
setPages({ base: resource.data, rows: [], cursor: undefined });
|
|
19
|
+
const base = resource.data;
|
|
20
|
+
const nextCursor = pages.cursor === undefined ? (base?.nextCursor ?? null) : pages.cursor;
|
|
21
|
+
const data = base
|
|
22
|
+
? {
|
|
23
|
+
...base,
|
|
24
|
+
nextCursor,
|
|
25
|
+
payouts: [
|
|
26
|
+
...new Map([...base.payouts, ...pages.rows].map((row) => [row.id, row])).values(),
|
|
27
|
+
],
|
|
28
|
+
}
|
|
29
|
+
: undefined;
|
|
30
|
+
const loadMore = async () => {
|
|
31
|
+
if (!nextCursor || resource.isLoading)
|
|
32
|
+
return;
|
|
33
|
+
const next = await more.run(nextCursor);
|
|
34
|
+
if (next)
|
|
35
|
+
setPages((previous) => ({
|
|
36
|
+
...previous,
|
|
37
|
+
rows: [...previous.rows, ...next.payouts],
|
|
38
|
+
cursor: next.nextCursor,
|
|
39
|
+
}));
|
|
40
|
+
};
|
|
41
|
+
const sortedUpcoming = data?.upcoming
|
|
42
|
+
.filter(upcoming)
|
|
43
|
+
.slice()
|
|
44
|
+
.sort((a, b) => (a.arrivalDate ?? Infinity) - (b.arrivalDate ?? Infinity)) ?? [];
|
|
45
|
+
const state = {
|
|
46
|
+
data,
|
|
47
|
+
isLoading: resource.isLoading,
|
|
48
|
+
isPending: resource.isLoading || more.isPending,
|
|
49
|
+
error: resource.error ?? more.error,
|
|
50
|
+
nextPayout: sortedUpcoming[0],
|
|
51
|
+
upcomingPayouts: sortedUpcoming,
|
|
52
|
+
previousPayouts: data?.payouts.filter((row) => !upcoming(row)) ?? [],
|
|
53
|
+
refresh: resource.refresh,
|
|
54
|
+
loadMore,
|
|
55
|
+
};
|
|
56
|
+
return _jsx(_Fragment, { children: children ? children(state) : _jsx(NativePayouts, { ...state }) });
|
|
57
|
+
}
|
|
58
|
+
function date(value) {
|
|
59
|
+
return value === null
|
|
60
|
+
? "Not supplied by Stripe"
|
|
61
|
+
: new Date(value).toLocaleDateString(undefined, { timeZone: "UTC" });
|
|
62
|
+
}
|
|
63
|
+
export function PayoutHistory(props) {
|
|
64
|
+
const columns = [
|
|
65
|
+
{ id: "id", label: "Payout ID", cell: (row) => row.id },
|
|
66
|
+
{
|
|
67
|
+
id: "amount",
|
|
68
|
+
label: "Amount",
|
|
69
|
+
align: "end",
|
|
70
|
+
cell: (row) => formatPrice(row.amount, row.currency),
|
|
71
|
+
},
|
|
72
|
+
{ id: "status", label: "Status", cell: (row) => row.status },
|
|
73
|
+
{
|
|
74
|
+
id: "arrival",
|
|
75
|
+
label: "Arrival date",
|
|
76
|
+
cell: (row) => date(row.arrivalDate),
|
|
77
|
+
},
|
|
78
|
+
];
|
|
79
|
+
return (_jsx(Collection, { emptyLabel: "No payouts yet.", ...props, getKey: (row) => row.id, columns: props.columns ?? columns }));
|
|
80
|
+
}
|
|
81
|
+
function NativePayouts({ data, isLoading, isPending, error, nextPayout, previousPayouts, upcomingPayouts, refresh, loadMore, }) {
|
|
82
|
+
return (_jsxs("section", { "data-better-stripe": "payouts", "aria-busy": isPending, children: [_jsx("h2", { children: "Payouts" }), _jsx("button", { type: "button", disabled: isPending, onClick: refresh, children: isPending ? "Refreshing…" : "Refresh" }), error && _jsx("p", { role: "alert", children: error }), isLoading && !data && _jsx("p", { role: "status", children: "Loading payouts\u2026" }), data && (_jsxs(_Fragment, { children: [_jsxs("dl", { children: [data.balances.map((balance) => (_jsxs("div", { children: [_jsx("dt", { children: "Available" }), _jsx("dd", { children: formatPrice(balance.available, balance.currency) }), _jsx("dt", { children: "Pending" }), _jsx("dd", { children: formatPrice(balance.pending, balance.currency) })] }, balance.currency))), _jsx("dt", { children: "Next payout" }), _jsx("dd", { children: nextPayout
|
|
83
|
+
? `${formatPrice(nextPayout.amount, nextPayout.currency)} · ${date(nextPayout.arrivalDate)}`
|
|
84
|
+
: "Not scheduled" })] }), _jsx("h3", { children: "Upcoming payouts" }), _jsx(PayoutHistory, { rows: upcomingPayouts, emptyLabel: "No upcoming payouts scheduled." }), _jsx("h3", { children: "Previous payouts" }), _jsx(PayoutHistory, { rows: previousPayouts, emptyLabel: "No previous payouts yet." }), data.nextCursor && (_jsx("button", { type: "button", disabled: isPending, onClick: () => {
|
|
85
|
+
void loadMore();
|
|
86
|
+
}, children: isPending ? "Loading…" : "Load more payouts" }))] }))] }));
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=Payouts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Payouts.js","sourceRoot":"","sources":["../../../src/react/workflows/Payouts.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,OAAO,EAAqB,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACL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