UI Components
SetupSubscriptionModal

SetupSubscriptionModal

The SetupSubscriptionModal is a fully-featured UI component that guides a user through:

  1. Creating a PayStreamer account (if they don't have one).
  2. Depositing an initial PUSD buffer to cover future billing cycles.
  3. Subscribing to your platform's specific tier.

Usage

import { SetupSubscriptionModal } from "@paystreamer/sdk/ui";
 
<SetupSubscriptionModal
  isOpen={isOpen}
  onClose={() => setIsOpen(false)}
  platformId="0x1240aa8e48d2df02ff25a359b3b83bc04c749aa6234a923419f5c0d9903d746"
  tierIndex={0}
  onSuccess={(digest) => alert("Success! Tx: " + digest)}
  theme={{
    primary: "#6c63ff",
    radius: "12px",
  }}
/>

Props

PropTypeDescription
isOpenbooleanWhether the modal is currently visible.
onClose() => voidCallback fired when the user dismisses the modal.
platformIdstringThe object ID of your deployed platform.
tierIndexnumberThe array index of the tier the user is subscribing to (used to fetch tier details from on-chain).
onSuccess?(txDigest: string) => voidCallback fired after a successful transaction.
formatUsd?(amount: bigint | number | string) => numberOptional custom formatter for displaying USD/PUSD values.
theme?PayStreamerThemeOptional. Local theme variables to customize colors and radius.

Theme Customization

You can pass a custom theme object to override color variables and border-radius. Theme parameters can also be configured globally using PayStreamerThemeProvider.

export interface PayStreamerTheme {
  primary?: string;            // Primary button and accent color
  primaryForeground?: string;  // Text color on primary buttons
  background?: string;         // Modal root background
  card?: string;               // Inner card background
  cardForeground?: string;     // Inner card text color
  muted?: string;              // Muted status and inputs background
  mutedForeground?: string;    // Muted text color
  border?: string;             // Borders color
  radius?: string;             // Base border-radius (e.g., '12px')
}

Styling Requirements

This component leverages standard class names compatible with TailwindCSS. If you are importing this component, ensure your application either compiles Tailwind utilities or includes standard shadcn-ui styles.