import { AlertTriangleIcon, CopyIcon, ExternalLinkIcon } from "lucide-react"; import React from "react"; import { toast } from "sonner"; import { AppDetailConnectedApps } from "src/components/connections/AppDetailConnectedApps"; import { AppStoreDetailHeader } from "src/components/connections/AppStoreDetailHeader"; import { appStoreApps } from "src/components/connections/SuggestedAppData"; import Loading from "src/components/Loading"; import QRCode from "src/components/QRCode"; import { Alert, AlertDescription, AlertTitle } from "src/components/ui/alert"; import { Button } from "src/components/ui/button"; import { LoadingButton } from "src/components/ui/custom/loading-button"; import { Input } from "src/components/ui/input"; import { Label } from "src/components/ui/label"; import { useApps } from "src/hooks/useApps"; import { copyToClipboard } from "src/lib/clipboard"; import { createApp } from "src/requests/createApp"; import { handleRequestError } from "src/utils/handleRequestError"; import { openLink } from "src/utils/openLink"; export function BuzzPay() { const [name, setName] = React.useState(""); const [isLoading, setLoading] = React.useState(false); const { data: appsData, mutate: reloadApps } = useApps(undefined, undefined, { appStoreAppId: "buzzpay", }); const [posUrl, setPosUrl] = React.useState(""); const appStoreApp = appStoreApps.find((app) => app.id === "buzzpay"); if (!appStoreApp) { return null; } if (!appsData) { return ; } const handleSubmit = async (event: React.FormEvent) => { event.preventDefault(); setLoading(true); (async () => { try { const createAppResponse = await createApp({ name, scopes: ["get_info", "lookup_invoice", "make_invoice"], isolated: true, metadata: { app_store_app_id: "buzzpay", }, }); setPosUrl( `https://pos.albylabs.com/#/?nwc=${btoa(createAppResponse.pairingUri)}&label=${encodeURIComponent(name)}` ); await reloadApps(); toast("BuzzPay PoS connection created"); } catch (error) { handleRequestError("Failed to create PoS connection", error); } setLoading(false); })(); }; return (
{posUrl && (

Open the PoS link below and share it with your employees and devices you want to use the PoS with.

Save this link and add it to your home screen This link will only be shown once and can't be retrieved afterwards. Please make sure to keep it somewhere safe.
)} {!posUrl && ( <>

BuzzPay works by creating read-only connections to your Alby Hub.

  • 🔒 Allow employees to collect but never spend your funds
  • 🔗 Sharable link that can be used on any device
  • âš¡ Lightning fast transactions directly to your Alby Hub
setName(e.target.value)} required autoComplete="off" />
Next
)}
); }