langchain-paypack: x402 (Coinbase) + AP2 (Google) dual-protocol Agent payments — the world's ONLY middleware supporting Alipay AND WeChat dual-channel. PayPack is neutral, independent, not bound to any tech giant ecosystem. One agent.pay() for USDC/ETH (Base/Ethereum/Polygon/Arbitrum) + Alipay/WeChat CNY. Dify Tool Plugin available.
Project description
langchain-paypack: x402 + AP2 dual-protocol for LangChain Agents
🌐 Dual-channel · Neutral — the only Agent payment middleware supporting Alipay + WeChat Pay.
x402 (Coinbase) + AP2 (Google) dual-protocol. One agent.pay() for USDC/ETH across Base/Ethereum/Polygon/Arbitrum, plus Alipay/WeChat CNY. Dify Tool Plugin also available.
Installation
pip install paypack-langchain
Requires Python 3.10+.
Quick Start
1. Get your API Key
curl -X POST https://rhcjw.com/pay/v1/register \
-H "Content-Type: application/json" \
-d '{"name": "my_agent", "email": "your@email.com"}'
Returns:
{"api_key": "ppk_your_api_key_here"}
Save this key — you'll use it in every call.
2. Create a payment in 3 lines
from paypack_langchain import PayPackTool
tool = PayPackTool(
api_key="ppk_your_api_key_here",
base_url="https://rhcjw.com/pay",
)
result = tool.run(amount=0.01, subject="AI data query")
print(result)
Output:
支付订单已创建
订单号: PP20260710120000ABC12345
金额: ¥0.01
状态: pending
支付链接: https://openapi.alipay.com/...
二维码: https://...
3. Verify it worked
Check order status:
from paypack_langchain import PayPackQueryTool
query = PayPackQueryTool(
api_key="ppk_your_api_key_here",
base_url="https://rhcjw.com/pay",
)
print(query.run(order_id="PP20260710120000ABC12345"))
Use in a LangChain Agent
from langchain.agents import create_react_agent, AgentExecutor
from langchain_openai import ChatOpenAI
from paypack_langchain import PayPackTool, PayPackQueryTool
llm = ChatOpenAI(model="gpt-4")
tools = [
PayPackTool(api_key="ppk_xxx", base_url="https://rhcjw.com/pay"),
PayPackQueryTool(api_key="ppk_xxx", base_url="https://rhcjw.com/pay"),
]
agent = create_react_agent(llm, tools, ...)
agent_executor = AgentExecutor(agent=agent, tools=tools)
# Agent now handles payments and order queries automatically
When your Agent calls a metered API and receives an HTTP 402 response, it can use PayPackTool to settle the payment and retry the request — fully autonomous.
Supported Networks & Currencies
| Type | Networks | Currencies | Status |
|---|---|---|---|
| Crypto (x402/AP2) | Base, Ethereum, Polygon, Arbitrum | USDC, ETH | ✅ Live |
| Alipay | Alipay Open Platform | CNY | ✅ Production (¥0.10 verified) |
| WeChat Pay | WeChat Pay API | CNY | ✅ Production (¥0.05 verified) |
API Reference
PayPackTool
| Parameter | Type | Required | Description |
|---|---|---|---|
api_key |
string | ✅ | Your PayPack Cloud API key (ppk_...) |
base_url |
string | ✅ | PayPack Cloud endpoint: https://rhcjw.com/pay |
amount |
float | ✅ | Amount to charge (e.g. 0.01 for ¥0.01) |
subject |
string | ✅ | Description shown on payment page |
callback_url |
string | ❌ | Webhook URL for payment result notification |
PayPackQueryTool
| Parameter | Type | Required | Description |
|---|---|---|---|
api_key |
string | ✅ | Your PayPack Cloud API key |
base_url |
string | ✅ | PayPack Cloud endpoint |
order_id |
string | ✅ | Order ID from PayPackTool response |
Links
- Cloud API: https://rhcjw.com/pay
- PyPI: https://pypi.org/project/paypack-langchain/
- GitHub: https://github.com/rhcjw/paypack
- Dify Plugin: PR #2693 (in review)
- Issues: https://github.com/rhcjw/paypack/issues
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file paypack_langchain-0.1.3.tar.gz.
File metadata
- Download URL: paypack_langchain-0.1.3.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f1bdff2fa64acad28465060d0ab33101c20276ad5accc37ee6519b165465d83
|
|
| MD5 |
02134b1d550eed3bfe658f270895fca2
|
|
| BLAKE2b-256 |
d397e77bfad7c3ed41d9f65f6b34a12d52e6cecb65d88efb77d7ca0e88dcaa9d
|
File details
Details for the file paypack_langchain-0.1.3-py3-none-any.whl.
File metadata
- Download URL: paypack_langchain-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c28f41d8f748fe350a0b1ab4e4b8c1b1a5722bbe66a5bbeda7691e4323e879b1
|
|
| MD5 |
6cbb769243ae2aa3206b0c18283eb84c
|
|
| BLAKE2b-256 |
c865e3d9d54d91cf1a1a9e6bcaa37b6aa85727e14cecef795acecdf615341f3e
|