Sell Digital Products from AI Chatbots Without Holding Funds
The Hidden Risk Nobody Talks About: Why Most AI Payment Systems Fail
You've built an incredible AI chatbot. It recommends products, answers questions, and customers actually want to buy from it. Then reality hits: you need to collect money.
Most developers reach for Stripe or PayPal, but here's the catch—you're now a money intermediary. Your chatbot holds customer funds, even if just for seconds. That means:
- Regulatory compliance headaches in Vietnam
- Payment processor disputes eating 2-3% per transaction
- Customer trust issues ("Why is my money in your account?")
- Complexity managing refunds and chargebacks
What if your AI chatbot could accept VietQR payments and never touch the money? The funds go straight to the merchant's bank account, confirmed by an automated bank feed. No escrow. No holding accounts. No regulatory grey zones.
That's exactly what AgentPay VN enables.
What AgentPay VN Actually Does (And Doesn't)
AgentPay VN is an open-source Python SDK + MCP server (MIT license) that strips payment collection down to three clean steps:
- create_payment_request — Your bot generates a unique VietQR code tied to a specific transaction
- send checkout_url — The bot sends a link; customers scan and pay directly to your merchant account
- await_settlement — The bot confirms payment when it hits your bank
The critical difference: AgentPay VN is not a payment processor. It's plumbing between your AI and Vietnam's banking infrastructure. Your bot initiates the payment flow, but the merchant bank handles the actual money transfer. This is why it works for digital products—no inventory, no shipping delays, instant settlement.
Real Numbers
- Processing time: 5-30 seconds from scan to confirmation
- Settlement lag: Depends on your bank (most: next business day)
- Fees: Zero from AgentPay VN (you pay only your bank's standard VietQR fees, typically 0-1%)
- Supported products: Ebooks, software licenses, online courses, API credits, NFTs, access tokens
Why This Matters for Digital Product Creators
Let's say you run an online Vietnamese language course platform. Your AI tutor chatbot recommends premium content to learners. Currently:
- You route students to a separate payment page (friction, lost sales)
- You wait 1-3 days for settlement
- You manage refund policies manually
- You comply with payment processor terms (no ebooks in some regions? No problem for VietQR)
With AgentPay VN:
- The chatbot handles the entire flow in-conversation
- Payment settles to your bank account before you grant access
- One Python function confirms payment; unlock the content immediately
- No processor restrictions on digital goods
Setting Up AgentPay VN: Step-by-Step
Step 1: Installation
pip install agentpay-vn
This gives you the SDK. For MCP integration (Claude/other AI agents), also install:
pip install agentpay-mcp
Step 2: Create Your First Payment Request
Here's the canonical flow in Python:
from agentpay_vn import create_payment_request, await_settlement
# Step 1: Generate a payment request
# This creates a unique VietQR tied to your merchant bank account
payment = create_payment_request(
amount=299000, # VND for a $15 ebook
description="Premium JavaScript Course Bundle",
transaction_id="txn_20250115_user42_course",
merchant_account="0123456789", # Your bank account
merchant_bank="970436" # ACB bank code
)
# payment.checkout_url = "https://vietqr.io/..."
# payment.qr_code = <base64 encoded image>
# payment.expires_in = 3600 # seconds
# Step 2: Send the checkout URL to the customer
print(f"Please complete payment: {payment.checkout_url}")
print(f"QR Code expires in {payment.expires_in} seconds")
# Step 3: Wait for settlement confirmation
# This polls your bank feed every 3 seconds for up to 5 minutes
settlement = await_settlement(
transaction_id="txn_20250115_user42_course",
timeout=300 # 5 minute timeout
)
if settlement.confirmed:
print(f"✅ Payment confirmed! Reference: {settlement.bank_reference}")
print(f"Settled amount: {settlement.amount} VND")
# NOW grant access to the digital product
grant_course_access(user_id=42)
else:
print(f"❌ Payment timeout or failed")
# Retry or notify customer
Line-by-line breakdown:
- amount: Price in VND (1 USD ≈ 24,500 VND, adjust as needed)
- transaction_id: Unique identifier. Use
uuid4()in production; tie it to your database - merchant_account: Your bank account number (ACB, VCB, TPB, etc. all supported)
- merchant_bank: 3-digit bank code (970436 = ACB, 970010 = VCB, etc.)
- await_settlement(): Blocks until confirmed or timeout. In async apps, use
await_settlement_async()
Step 3: Integrate with Your AI Chatbot (Claude via MCP)
If you're using Claude or another AI agent, define the MCP server config:
{
"mcpServers": {
"agentpay-vn": {
"command": "agentpay-mcp",
"args": [],
"env": {
"AGENTPAY_MERCHANT_ACCOUNT": "0123456789",
"AGENTPAY_MERCHANT_BANK": "970436",
"AGENTPAY_BANK_FEED_URL": "https://your-bank-api.vn/feeds"
}
}
}
}
Now Claude can call create_payment_request and await_settlement directly from its tools. No code needed—the agent orchestrates the payment flow.
Real-World Walkthrough: Café Subscription Bot
Let's build a concrete example: a coffee subscription chatbot for a Hanoi café.
Scenario: Customer asks for a monthly coffee package. Bot recommends "Premium Bean Box" ($20 USD ≈ 490,000 VND).
The Bot's Conversation Flow
Customer: "I want a coffee subscription."
Bot: "Great! Our Premium Bean Box is 490,000 VND/month. It includes 5 single-origin espresso packs. Ready to pay?"
Customer: "Yes!"
[Bot creates payment request]
Bot: "Perfect! Scan this QR or click: [checkout_url]. You'll get your first shipment this Friday."
[Customer scans, pays from their bank app]
[Bank transfer settles in 8 seconds]
[Bot confirms]
Bot: "✅ Payment confirmed! Your subscription is active. I've sent your first shipment details to your email."
The Backend Code
from agentpay_vn import create_payment_request, await_settlement
import uuid
from datetime import datetime
def handle_subscription_purchase(customer_id, email, subscription_tier="premium"):
"""Handle subscription purchase end-to-end."""
# Define pricing
pricing = {
"standard": 290000, # VND
"premium": 490000,
"elite": 890000
}
amount = pricing[subscription_tier]
transaction_id = f"sub_{customer_id}_{uuid.uuid4().hex[:8]}"
# Create payment
payment = create_payment_request(
amount=amount,
description=f"Coffee Subscription - {subscription_tier.capitalize()}",
transaction_id=transaction_id,
merchant_account="0123456789",
merchant_bank="970436"
)
# Send to customer
print(f"📲 Sent checkout: {payment.checkout_url}")
# Wait for settlement (with timeout)
try:
settlement = await_settlement(transaction_id, timeout=300)
if settlement.confirmed:
# Grant access: activate subscription
activate_subscription(
customer_id=customer_id,
tier=subscription_tier,
bank_ref=settlement.bank_reference,
settled_at=datetime.now()
)
# Send shipment email
send_email(
to=email,
subject="Your Coffee Subscription is Active!",
body=f"Your first shipment will arrive {get_next_friday()}."
)
return {"status": "success", "subscription_id": customer_id}
else:
return {"status": "timeout", "retry_url": payment.checkout_url}
except Exception as e:
print(f"Settlement error: {e}")
return {"status": "error", "message": str(e)}
What's happening:
- Bot generates a unique transaction ID tied to the customer
- Merchant bank account and code are pre-configured
- Payment URL is generated and sent immediately
- Bot waits up to 5 minutes for bank confirmation
- Once confirmed, subscription is activated (no manual intervention)
- Shipment workflow starts automatically
Total time from "yes" to "subscription active": ~30 seconds.
Advanced Tips & Common Pitfalls
✅ Do's
- Use transaction IDs as a ledger key. Store them in your database and tie them to customers/products.
- Set appropriate timeouts. 5 minutes works for digital goods; subscription upgrades might need 30 seconds.
- Log every settlement event. Bank references are your proof of payment for audits.
- Handle async workflows. For high-volume bots, use
await_settlement_async()and don't block the chat. - Test with small amounts first. Use your actual merchant account but with VND values like 1,000 to validate the bank feed.
❌ Don'ts
- Don't hardcode bank details in your bot. Use environment variables or a config service.
- Don't assume instant settlement. Some banks take 2-5 minutes. Set timeout accordingly.
- Don't skip transaction IDs. Without them, you can't reconcile failed payments.
- Don't send digital goods before
settlement.confirmed == True. Wait for the bank feed, not just QR scan. - Don't use this for unregulated activities. VietQR is for legitimate commerce; respect local regulations.
Do's vs. Don'ts Comparison
| Practice | ✅ Do | ❌ Don't |
|---|---|---|
| Bank details | Use env vars or secrets manager | Hardcode in code |
| Settlement confirmation | Poll bank feed; verify confirmed flag |
Trust QR scan alone |
| Transaction tracking | Log every txn_id + bank_reference | Lose track of payments |
| Timeout handling | Retry with exponential backoff | Fail silently |
| Testing | Use real merchant account with small amounts | Use mock payments; skip integration test |
| Error recovery | Send user a new checkout_url if expired | Force manual bank transfer |
Frequently Asked Questions
Q: Does AgentPay VN hold my money?
A: No. AgentPay VN is not a payment processor. It orchestrates VietQR payments that go directly to your merchant bank account. We never touch the funds. Your bank's account agreement applies; AgentPay VN is invisible to the transaction.
Q: What banks are supported?
A: Any bank in Vietnam that supports VietQR (NAPAS standard). This includes ACB, VCB, TPB, MB, Techcombank, OCB, and 50+ others. Check your bank's VietQR documentation for your account's 3-digit code.
Q: Can I use this for subscription billing?
A: AgentPay VN handles individual transactions. For recurring subscriptions, you'd create a new payment_request each cycle (e.g., monthly). Consider a wrapper library that handles schedule automation, or integrate with your own subscription management system.
Q: What if the bank feed is down?
A: await_settlement() will timeout after your specified duration (default: 300 seconds). The QR code remains valid for 1 hour, so users can re-scan or you can retry programmatically. Implement exponential backoff and notify the user if settlement takes longer than expected.
Q: Is this production-ready?
A: Yes. AgentPay VN is MIT-licensed open-source with a live MCP server. It's been tested with real VietQR integrations. Follow the do's/don'ts above and test with your actual merchant account in a staging environment first.
Key Takeaways
- AgentPay VN eliminates intermediaries. Your AI chatbot collects payments; your bank settles them. No escrow, no holding accounts.
- Three-line workflow.
create_payment_request()→ send URL →await_settlement(). That's it. - Instant for digital goods. Since there's no shipping, you can grant access (ebook, API key, course) the moment the bank confirms.
- Zero fees from AgentPay VN. You pay only your bank's standard VietQR processing fees (typically 0-1% in Vietnam).
- MCP integration means your AI does the work. Claude or other agents can orchestrate the entire payment flow without custom code.
- Production-tested. Real-world examples: course platforms, subscription cafés, software license sales, NFT drops.
Get Started Now
You have everything you need to build a payment-aware AI chatbot.
1. Install the SDK:
pip install agentpay-vn
2. Grab your merchant account details from your bank (account number + 3-digit bank code).
3. Run the walkthrough above with a test transaction. Use VND 1,000 or 10,000 first.
4. Deploy to production. Use environment variables for credentials; log every transaction ID and settlement reference.
Need help? - GitHub repo: https://github.com/phuocdu/agentpay-vn - Full docs & API reference: https://agentpay.servicesai.vn/v1/docs - MCP server setup: Check the README for Claude integration examples
Your customers' money goes straight to your bank. Your chatbot handles the orchestration. No intermediaries, no friction, no regulatory grey zones.
That's the AgentPay VN difference.
Have you built a payment-aware AI chatbot? Share your use case in the comments or open an issue on GitHub. We'd love to hear what you're selling.