@stashgg/stash-pay
v1.0.3
Published
React component for Stash pay checkout
Readme
@stashgg/stash-pay
React component for Stash payment checkout integration.
Installation
npm install @stashgg/stash-payUsage
The component includes its own CSS styles. Depending on your bundler setup, you may need to import the styles separately:
With CSS Import (Recommended)
import { StashPay } from '@stashgg/stash-pay';
import '@stashgg/stash-pay/styles';
function App() {
const [isOpen, setIsOpen] = useState(false);
const [checkoutUrl, setCheckoutUrl] = useState<string | null>(null);
return (
<StashPay
isOpen={isOpen}
checkoutUrl={checkoutUrl}
onClose={() => setIsOpen(false)}
onPurchaseSuccess={(data) => console.log('Success:', data)}
onPurchaseFailed={(data) => console.log('Failed:', data)}
/>
);
}Without Separate Import
If your bundler handles CSS imports automatically (e.g., Next.js, Vite with CSS plugin), you can use the component directly:
import { StashPay } from '@stashgg/stash-pay';
function App() {
// ... same as above
}Note: The component includes CSS classes that are required for proper styling. If styles don't appear, make sure to import @stashgg/stash-pay/styles in your application.
Props
isOpen: boolean- Controls the visibility of the payment modalcheckoutUrl: string | null- The checkout URL to display in the iframeonClose: () => void- Callback when the modal is closedonPurchaseSuccess?: (data?: Record<string, unknown>) => void- Callback when payment succeedsonPurchaseFailed?: (data?: Record<string, unknown>) => void- Callback when payment fails
Types
StashWindowEvent- Enum of available window eventsStashEventMessage- Type for event messages
