What is the Prava SDK?
The Prava SDK provides a simple, secure interface for AI agents and applications to handle payments on behalf of users. It abstracts the complexity of card tokenization, intent management, passkey authentication, and checkout execution.Concepts
There are four primitives you need to understand:| Primitive | What it is | One-liner |
|---|---|---|
| Card | A tokenized card enrolled via PCI-compliant iframe | Your servers never see the raw PAN. Ever. |
| Intent | A mandate that describes what the AI can buy | Merchant, price, category, frequency — scoped and user-approved. |
| Payment Token | The transactable output (virtual PAN + expiry + CVV) | What your AI App actually uses to make a purchase. |
| Passkey | WebAuthn-based user approval | No passwords. Biometric/device confirmation for intents. |
The Flow
registerAndInvokeIntent().
Key Features
- Zero PCI Scope: Card data never touches your servers
- Intent-Based Permissions: Users authorize specific purchases via Passkey
- Network-Level Security: Merchant-specific, amount-scoped credentials
- Browser Automation Ready: Built-in checkout execution helpers
Installation
Quick Start
Create a session and enroll a card
Create a session server-side, then collect card data client-side:
SDK Architecture
Authentication
The SDK uses a dual-key system:| Key Type | Usage | Location |
|---|---|---|
Publishable Key (pk_live_* / pk_test_*) | Initialize SDK, client-side operations | Frontend |
Secret Key (sk_*) | Create sessions, server operations | Backend only |
Cleanup
When you’re done with the SDK (e.g., component unmount), calldestroy() to clean up:
Security Model
| Layer | Protection |
|---|---|
| Card Collection | PCI DSS compliant iframe. Raw PAN never touches your DOM, JS, or servers. |
| Iframe Sandbox | allow-scripts allow-same-origin allow-forms allow-popups. Minimal permissions. |
| Session Tokens | Short-lived, single-use. Created server-side with your secret key. |
| Passkeys (WebAuthn) | All intent mutations (register, update, delete) require biometric/device confirmation. No passwords. |
| Payment Tokens | Virtual card numbers scoped to mandate constraints. Single-use, time-limited, merchant-locked. |
| Origin Validation | PostMessage communication is origin-locked. The iframe resolves its backend from its own hostname — merchants cannot inject a fake backend URL. |
Requirements
- Browser: Chrome 80+, Firefox 80+, Safari 14+, Edge 80+
- WebAuthn: Device must support passkeys (Touch ID, Face ID, Windows Hello, or security key)
- Backend: Your server must implement the Prava session API (create sessions with your secret key)
- Keys: Obtain
publishableKeyandsecretKeyfrom the Prava Dashboard
Error Codes
| Code | When | What to do |
|---|---|---|
SDK_ALREADY_ACTIVE | collectPAN called while another session is active | Call destroy() first |
INVALID_CONFIG | Missing iframeUrl or publishableKey | Check your config |
IFRAME_LOAD_ERROR | Iframe failed to load | Check network, verify iframeUrl |
SDK_INIT_ERROR | SDK initialization failed | Check browser compatibility |
PASSKEY_REJECTED | User declined the passkey prompt | Prompt user to retry |
PASSKEY_UNAVAILABLE | Device doesn’t support WebAuthn | Fallback or inform user |
INTENT_EXPIRED | Intent past its expiresAt date | Register a new intent |
INTENT_LIMIT_REACHED | useLimit exhausted | Register a new intent |
MANDATE_VIOLATION | Amount/merchant doesn’t match mandate | Check intent constraints |
CARD_NOT_FOUND | Card ID doesn’t exist or was removed | Re-enroll or use a different card |
Types
Next Steps
Card Management
Learn how to collect and manage user cards
Intent Management
Create and manage payment intents
Register & Invoke
One-shot instant purchases
Browser Automation
Execute payments at merchant checkouts
Support
- Documentation: docs.prava.space
- Email: developers@prava.space