Integrations
Connect PagePay to Pera Wallet, GoPlausible facilitator, Circle USDC faucet, Groq AI, and the x402 protocol sandbox.
Pera Wallet
Package: @perawallet/connect
PagePay connects to Pera via the official browser SDK. There is no Pera Chrome extension — desktop users interact through Pera Web or mobile via WalletConnect QR codes.
Connection flow
PeraWalletConnect()instance created once per sessionconnect()→ modal / redirect to Pera Web- User approves Testnet account
connector.activeAccountprovides address for UI + signing
Signing flow
- Build atomic txn group from x402 payment requirements
- Map to
SignTransactionformat with explicitsignersarrays signTransaction([group])— do not pass address as second arg in v2 integration- Return signed bytes to
createPaymentPayload
Disconnect / reconnect
Call disconnect() on logout. Stale sessions can cause silent signing failures — always surface wallet.error in UI.
GoPlausible facilitator
URL: https://facilitator.goplausible.xyz
The hosted facilitator implements x402 verify and settle for exact-AVM Algorand payments. PagePay's server calls it — clients never talk to the facilitator directly.
| Endpoint | Purpose |
|---|---|
POST /verify | Validate signed payment before chain submission |
POST /settle | Co-sign and submit atomic group |
Fee sponsorship: the facilitator's feePayer address appears in payment requirement extra. It covers Algorand transaction fees so payers only need USDC + minimal ALGO.
Self-hosting: for production you may run your own facilitator. PagePay demo uses GoPlausible to reduce setup friction.
Circle USDC faucet
Testnet USDC is issued by Circle's faucet, not the Algorand dispenser.
- Go to faucet.circle.com
- Select Algorand blockchain
- Select Testnet network
- Paste your Pera address
- Submit — USDC (ASA 10458941) arrives in ~4 seconds
Rate limits: the faucet may limit requests per address per day. Use a fresh Testnet address if depleted.
Verification: in Pera, open Assets → confirm USDC balance. In explorer, check /asset/10458941 transfers to your address.
Groq AI
Post-settlement, PagePay calls Groq for text generation when GROQ_API_KEY is configured server-side.
| Model | Use case |
|---|---|
openai/gpt-oss-20b | Fast responses, protocol demo default |
qwen/qwen3.6-27b | Higher quality summaries |
Independence: payment and AI are decoupled. Settlement must succeed before any Groq call. If Groq fails after payment, the tx is still on-chain — handle this as a fulfillment error in production (retry, refund policy, support).
Output format: Groq returns Markdown (**bold**, ## headings, bullet lists). Render with react-markdown — do not display raw Markdown strings.
@x402-avm packages
| Package | Import | Purpose |
|---|---|---|
@x402-avm/core | decodePaymentRequiredHeader, createPaymentPayload, encodePaymentSignatureHeader | Header codec + payload lifecycle |
@x402-avm/avm | Algorand transaction builders | Exact scheme txn groups |
Version alignment: PagePay pins x402 v2 compatible releases. Mismatch between server and client package versions can cause header decode failures.
Environment variables (reference)
These are configured server-side for the demo deployment. Documented here for integrators — do not commit secrets.
| Variable | Purpose |
|---|---|
RESOURCE_PAY_TO | Merchant Algorand address receiving USDC |
GROQ_API_KEY | Groq API authentication |
LOVABLE_API_KEY | Fallback AI gateway when Groq unset |
Frontend env: wallet and network config are compile-time constants in src/lib/x402/client.ts and src/lib/wallet/pera.ts for Testnet.
Protocol sandbox integration
Embed or link the /x402-demo page in your onboarding:
- Test Mode — zero wallet setup, instant happy-path walkthrough
- Live flow — real 402 against
/api/x402-demowith Groq unlock - Raw HTTP panel — copy/paste headers for your own client implementation
- Log console — timestamped protocol events for debugging
Simulation modes (failed, timeout, invalid_token) help QA error UI without spending testnet USDC.
Browser compatibility
| Browser | Pera signing | Notes |
|---|---|---|
| Chrome | ✅ | Recommended |
| Edge | ✅ | Recommended |
| Firefox | ⚠️ | Pera Web works; test thoroughly |
| Safari | ⚠️ | Popup / tab focus issues possible |
| Cursor embedded | ❌ | Cannot open Pera Web properly |
Always test payments in a standalone browser window, not IDE previews.