# Payment Success Dialog URL: /docs/components/payment-success-dialog A confirmation dialog that celebrates a successful payment with the paid amount and product name, plus actions to proceed or go back. *** title: Payment Success Dialog description: A confirmation dialog that celebrates a successful payment with the paid amount and product name, plus actions to proceed or go back. -------------------------------------------------------------------------------------------------------------------------------------------------- ```tsx title="src/components/payment-success-dialog-demo.tsx" "use client"; import { useState } from "react"; import { PaymentSuccessDialog } from "@/components/billingsdk/payment-success-dialog"; import { Card, CardContent } from "@/components/ui/card"; export function PaymentSuccessDialogDemo() { const [, setLastAction] = useState(""); const [open, setOpen] = useState(false); return (
Click the button to preview the success dialog.
setLastAction("proceed")} onBack={() => setLastAction("back")} />
); } ```
## Installation ```bash npx shadcn@latest add @billingsdk/payment-success-dialog ``` ```bash pnpm dlx shadcn@latest add @billingsdk/payment-success-dialog ``` ```bash yarn dlx shadcn@latest add @billingsdk/payment-success-dialog ``` ```bash bunx shadcn@latest add @billingsdk/payment-success-dialog ``` ```bash npx @billingsdk/cli add payment-success-dialog ``` ```bash pnpm dlx @billingsdk/cli add payment-success-dialog ``` ```bash yarn dlx @billingsdk/cli add payment-success-dialog ``` ```bash bunx @billingsdk/cli add payment-success-dialog ``` ## Usage ```tsx import { PaymentSuccessDialog, type PaymentSuccessDialogRef } from "@/components/billingsdk/payment-success-dialog"; ``` ```tsx // Controlled usage (recommended) const [open, setOpen] = useState(false); // Show on demand, e.g. after successful payment setOpen(true); ``` ```tsx // Imperative ref (optional) const ref = useRef(null); ref.current?.open(); ``` ## Props | Prop | Type | Required | Description | | ------------------- | ------------------------- | -------- | ---------------------------------------------------------- | | `title` | `string` | ❌ | Optional heading (default: "Congratulations!") | | `subtitle` | `string` | ❌ | Optional subtext (default: "Your payment was successful.") | | `currencySymbol` | `string` | ❌ | Currency symbol prefix (default: `$`) | | `price` | `string` | ✅ | Amount paid | | `productName` | `string` | ✅ | Product Name | | `proceedButtonText` | `string` | ❌ | Primary action label | | `backButtonText` | `string` | ❌ | Secondary action label | | `onProceed` | `() => void` | ❌ | Callback for proceed action | | `onBack` | `() => void` | ❌ | Callback for back action | | `className` | `string` | ❌ | Additional class names | | `open` | `boolean` | ❌ | Controlled open state | | `onOpenChange` | `(open: boolean) => void` | ❌ | Controlled state handler | ## Theming This dialog inherits BillingSDK theme tokens via `getThemeStyles`, remaining consistent with other components. Colors adapt to light/dark modes and active theme. ## Example ```tsx title="src/components/payment-success-dialog-demo.tsx" "use client"; import { useState } from "react"; import { PaymentSuccessDialog } from "@/components/billingsdk/payment-success-dialog"; import { Card, CardContent } from "@/components/ui/card"; export function PaymentSuccessDialogDemo() { const [, setLastAction] = useState(""); const [open, setOpen] = useState(false); return (
Click the button to preview the success dialog.
setLastAction("proceed")} onBack={() => setLastAction("back")} />
); } ``` ### Credits * Created by [@ritiksahni22](https://github.com/ritiksahni)