Test Payments End-to-End
Walk through a full payment in the sandbox using testnet USDC.
Test Payments End-to-End
Before going live, run through a complete payment in the sandbox. No real money moves — you'll use testnet USDC on test networks.
What you need
- A test API key (
bag_test_sk_*) — get one here - A crypto wallet (MetaMask, Coinbase Wallet, or Phantom for Solana)
- Testnet USDC in that wallet
- A webhook endpoint (optional but recommended)
Get testnet tokens
You need two things: testnet USDC to pay with, and native tokens for gas.
USDC faucets
| Network | Faucet |
|---|---|
| Base Sepolia / Eth Sepolia | Circle USDC Faucet |
| Solana Devnet | Use the devnet USDC mint 4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU |
Gas faucets
| Network | Faucet |
|---|---|
| Base Sepolia | Base Faucet |
| Ethereum Sepolia | Sepolia Faucet |
| Solana Devnet | Solana Faucet |
Step 1: Create a test payment link
import { Bag } from "@getbagsapp/sdk";
const bag = new Bag({ apiKey: process.env.BAG_API_KEY! });
const link = await bag.paymentLinks.create({
name: "Test Product",
amount: 1.00,
network: "base_sepolia",
});
console.log(`Checkout: https://justusebag.xyz/pay/${link._id}`);Use a small amount like 1.00 so you don't need much testnet USDC.
Step 2: Open the checkout page
Visit https://justusebag.xyz/pay/{paymentLinkId} in your browser. You'll see the Bag checkout page with:
- Product name and amount
- Network selector (if multi-chain)
- Wallet connect button
Step 3: Connect your wallet and pay
- Click Connect Wallet and select your test wallet.
- Make sure your wallet is on the correct testnet (Base Sepolia, Eth Sepolia, or Solana Devnet).
- Approve the USDC transfer.
- Wait for on-chain confirmation.
The checkout page updates in real-time as the transaction progresses.
Step 4: Verify the webhook
If you have a webhook endpoint registered, you should receive a payment.completed event within seconds of on-chain confirmation. All sandbox webhook payloads include "livemode": false:
{
"event": "payment.completed",
"livemode": false,
"data": {
"sessionId": "...",
"txHash": "0x...",
"amount": "1.00",
"network": "base_sepolia",
"livemode": false
},
"timestamp": "2026-03-01T12:05:00.000Z"
}No webhook endpoint yet? See Handle Webhooks Securely.
Step 5: Check the dashboard
Go to the Bag dashboard and enable Test mode using the toggle in the sidebar. You should see:
- The transaction with status completed
- The tx hash linking to the block explorer
- The amount and network
- An orange "TEST MODE" banner confirming you're viewing sandbox data
Verification checklist
- Payment link created with test key
- Checkout page loads correctly
- Wallet connects on the right testnet
- USDC transfer completes on-chain
- Webhook received with valid signature
- Transaction visible in dashboard
- Session status shows
complete
Troubleshooting
| Problem | Fix |
|---|---|
| "Test API keys can only be used with testnet networks" | You're using a test key (bag_test_sk_*) with a mainnet network like base. Use base_sepolia, eth_sepolia, or solana_devnet instead. |
| "Live API keys cannot be used with testnet networks" | You're using a live key (bag_live_sk_*) with a testnet network. Switch to a test key for sandbox testing. |
| Checkout page shows wrong network | Make sure the payment link uses a testnet network (base_sepolia, eth_sepolia, solana_devnet) |
| Wallet won't connect | Switch your wallet to the matching testnet |
| Transaction stuck | Check the block explorer — testnet can be slow. Wait a few minutes. |
| No webhook received | Verify your endpoint is reachable (use ngrok for localhost) and registered in the dashboard |
| "Insufficient funds" | Get more testnet USDC from the faucet |
| Dashboard shows no test data | Make sure the Test mode toggle in the sidebar is enabled |