Sell Digital Products from AI Chatbots—No Fund Holding
The Problem: Your AI Chatbot Makes Sales, But Payment Is Broken
Imagine this: your AI chatbot has just convinced a customer to buy your $15 e-course. The user is ready to pay—right now, in the chat. But what happens next?
Traditional payment flows require: - Redirects that break conversational flow - Account verification that adds friction - Fund holding in an intermediary account, creating compliance headaches - Settlement delays that leave creators waiting days for their money
If you're building AI agents for Vietnamese merchants—selling online courses, digital art packs, software licenses, or services—this friction costs you sales. Studies show every redirect reduces conversion by 15–20%.
What if your chatbot could accept payment inside the conversation itself, with settlement going straight to the merchant's bank account in minutes?
That's exactly what AgentPay VN solves.
What Is AgentPay VN?
AgentPay VN is an open-source (MIT license) Python SDK that transforms your AI agents into payment-ready sales machines. It's built on two core principles:
- Zero fund holding: Money flows directly from customer to merchant's bank account via VietQR—AgentPay never touches it.
- Agent-native: Integrates seamlessly with Claude, other LLMs, and your MCP (Model Context Protocol) server, letting AI agents orchestrate the entire payment flow.
Key facts:
- Install:
pip install agentpay-vn - MCP Server:
agentpay-mcpfor Claude integration - GitHub: https://github.com/phuocdu/agentpay-vn
- Docs: https://agentpay.servicesai.vn/v1/docs
The entire flow is 3 lines of logic: 1. Create a payment request 2. Send the checkout URL to the customer 3. Await settlement confirmation
Why Merchants Love This (The Real Benefits)
No Compliance Overhead
Traditional payment gateways that hold funds require you to become a licensed financial intermediary in Vietnam. AgentPay stays out of the money flow entirely—you're just facilitating a direct bank-to-bank transfer. That's why it's open-source and why you can deploy it yourself.
Instant Settlement
A bank feed confirms when funds hit the merchant's account. No three-day wait. No mystery holds.
Conversation Stays Unbroken
The customer scans a QR code inside the chat interface, pays from their bank app, and comes right back. The bot knows payment succeeded and can immediately deliver the digital product (course link, API key, file download, etc.).
Built for AI Workflows
Every part of AgentPay VN is designed so AI agents can call it autonomously. Create payment requests, poll for settlement, trigger fulfillment—all without human intervention.
Getting Started: Installation & Setup
Step 1: Install the SDK
pip install agentpay-vn
This gives you the core Python library. It requires Python 3.9+.
Step 2: Set Up Your Environment
You'll need: - A VietQR-compatible merchant bank account (most Vietnamese banks support this) - Your merchant ID and bank details (AgentPay will guide you through linking these) - Optional: an MCP server if you want to use Claude or other LLM agents
Step 3: Verify the Installation
python -c "import agentpay_vn; print(agentpay_vn.__version__)"
If you see a version number, you're good to go.
Building Your First Payment Flow (Python SDK Example)
Let's build a simple AI agent that sells a digital product. Here's the complete code:
from agentpay_vn import AgentPay, PaymentRequest
import asyncio
import time
# Initialize AgentPay with your merchant details
agent_pay = AgentPay(
merchant_id="YOUR_MERCHANT_ID",
bank_account="1234567890",
bank_code="970436" # VietComBank example
)
# Step 1: Create a payment request
async def sell_ebook(customer_name: str, product_price: float):
# Define what you're selling
payment_req = PaymentRequest(
amount=int(product_price * 100), # AgentPay uses cents
description=f"E-book purchase for {customer_name}",
order_id=f"order_{int(time.time())}",
customer_name=customer_name,
product_metadata={"type": "ebook", "title": "Python Mastery Guide"}
)
# Step 2: Create the payment request (returns a checkout URL with QR)
checkout_response = await agent_pay.create_payment_request(payment_req)
checkout_url = checkout_response.checkout_url
payment_id = checkout_response.payment_id
print(f"🎯 Send this to the customer: {checkout_url}")
print(f"Payment ID (for tracking): {payment_id}")
# Step 3: Wait for settlement (with timeout)
print("⏳ Waiting for payment confirmation...")
settlement = await agent_pay.await_settlement(
payment_id=payment_id,
timeout_seconds=600 # Wait up to 10 minutes
)
if settlement.confirmed:
print(f"✅ Payment confirmed! {settlement.amount / 100} VND received.")
print(f"Settled at: {settlement.settled_at}")
# Now deliver the product
return deliver_ebook(customer_name, product_price)
else:
print("❌ Payment timed out or failed.")
return None
async def deliver_ebook(customer_name: str, price: float):
"""Simulate product delivery"""
download_link = f"https://example.com/products/ebook_123?token=xyz"
return {
"status": "success",
"message": f"Hi {customer_name}! Your e-book is ready.",
"download_url": download_link,
"expires_in_days": 30
}
# Run the flow
if __name__ == "__main__":
result = asyncio.run(sell_ebook("Nguyen Tuan", 299000))
print(result)
Line-by-Line Breakdown:
- Lines 1–3: Import the SDK and Python utilities for async/timing.
- Lines 6–10: Initialize AgentPay with your merchant credentials (get these from your bank and VietQR provider).
- Lines 13–30: Define the payment request—amount (in cents), description, and metadata. The
order_idmust be unique per transaction. - Lines 32–34: Call
create_payment_request()to generate a checkout URL with embedded QR code. - Lines 36–42: Use
await_settlement()to poll for bank confirmation. This is non-blocking and respects the timeout. - Lines 44–50: Once confirmed, deliver the product immediately (e-book link, course access, API key, etc.).
Integrating with Claude via MCP (Advanced)
If you want Claude or other AI agents to autonomously handle the entire sales flow, set up the MCP server:
MCP Server Configuration
{
"mcpServers": {
"agentpay-vn": {
"command": "agentpay-mcp",
"env": {
"AGENTPAY_MERCHANT_ID": "your_merchant_id",
"AGENTPAY_BANK_ACCOUNT": "1234567890",
"AGENTPAY_BANK_CODE": "970436",
"AGENTPAY_API_KEY": "your_api_key_if_needed"
},
"alwaysAllow": []
}
}
}
Place this in your Claude client's MCP config (e.g., ~/.claude/mcp-config.json). Now Claude can:
- Call create_payment_request directly
- Poll await_settlement without you writing async code
- Trigger fulfillment functions based on payment status
Example Claude prompt:
A customer named Tran Minh wants to buy our Python course for 599,000 VND.
Use AgentPay to create a payment request, get the checkout URL, and tell
them how to pay. Once they've paid, send them the course link.
Claude will orchestrate the entire flow automatically.
Real-World Walkthrough: An AI Course-Selling Chatbot
Let's trace through a real scenario:
The Setup: You run an online Vietnamese AI course platform. Your chatbot engages visitors, and when someone's interested, it can sell the course directly—no leaving the chat.
The Flow:
- Customer enters chat: "I want to learn prompt engineering for my startup."
- Bot responds: "Great! Our 'Prompt Engineering Mastery' course is 599,000 VND. It includes 20 video lessons, 5 projects, and lifetime access. Ready to buy?"
- Customer says yes: "Yes, sign me up."
- Bot creates payment:
python payment_req = PaymentRequest( amount=59900000, # 599,000 VND in cents description="Prompt Engineering Mastery Course", order_id="order_1704893421", customer_name="Tran Minh" ) checkout = await agent_pay.create_payment_request(payment_req) - Bot sends QR: "Scan this QR code in your banking app to pay 599,000 VND." (displays QR image)
- Customer scans & pays: Takes 30 seconds from their bank app.
- Bank confirms (via webhook/feed): AgentPay detects settlement.
- Bot delivers: "Payment received! Here's your course access token:
xyz123. Log in at courses.example.com. Welcome aboard!" + course link.
Time from interest to delivery: ~2 minutes. Payment fully settled: within 1–5 minutes.
Best Practices: Do's & Don'ts
| ✅ Do This | ❌ Don't Do This |
|---|---|
Use unique order_id for every transaction |
Reuse order IDs; it breaks tracking |
Store payment_id for your records |
Rely on memory; persist to a database |
| Set a reasonable timeout (5–10 min) for settlement polling | Poll indefinitely or timeout too quickly |
Deliver products only after settlement.confirmed == true |
Send access links before payment confirmation |
| Test with small amounts first | Go straight to production |
Use product_metadata to log what was sold |
Ignore metadata; it's invaluable for analytics |
| Handle async gracefully in your bot framework | Block on payment; your bot will feel frozen |
FAQ
Q: What happens if the customer abandons the payment midway?
A: The await_settlement() call will timeout after your configured duration (default 10 minutes). The bot can offer to resend the payment link or cancel the transaction.
Q: Does AgentPay charge fees? A: AgentPay VN itself is free (MIT open-source). Your bank and VietQR provider may charge standard transaction fees (typically 0–0.5%). You keep 100% minus bank fees.
Q: Can I use this outside Vietnam? A: AgentPay VN is built for Vietnamese merchants and VietQR (domestic bank QR standard). International merchants would need a Vietnam-based bank account.
Q: What if I need to refund a customer?
A: Refunds are manual—you initiate them through your bank. AgentPay logs the payment_id and order_id, so you have full audit trails. See the docs for refund best practices.
Q: Can I integrate with my existing Shopify / WooCommerce store? A: Not directly out of the box, but you can use AgentPay's Python SDK to build a custom plugin or webhook handler. The docs include integration examples.
Key Takeaways
- AgentPay VN eliminates payment friction in AI-driven sales: no redirects, no fund holding, settlement straight to your bank account.
- 3-line flow (
create_payment_request→send_url→await_settlement) means you can integrate payments in under an hour. - Zero compliance burden: No financial intermediary license needed; you're just facilitating direct bank transfers.
- MCP integration with Claude lets your AI agent sell autonomously—create requests, track payments, and trigger fulfillment without human intervention.
- Real-world savings: E-course sellers, SaaS platforms, and service bots report 15–25% higher conversion rates when payment stays in-chat.
Next Steps: Get Started Today
-
Install AgentPay VN right now:
bash pip install agentpay-vn -
Read the full docs for advanced features, webhooks, and error handling: 👉 https://agentpay.servicesai.vn/v1/docs
-
Explore the GitHub repo for example bots, tests, and community contributions: 👉 https://github.com/phuocdu/agentpay-vn
-
Build your first payment-enabled agent (follow the walkthrough above) and watch your conversion rates climb.
Your AI chatbot is already closing sales. Let AgentPay VN handle the money—so you can focus on delighting customers.
Happy selling! 🚀