Skip to main content

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 Alipay/WeChat CNY via Cloud, with USDC/ETH support via local-signer mode. 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
Alipay (Cloud) Alipay Open Platform CNY ✅ Production (¥0.10 verified)
WeChat Pay (Cloud) WeChat Pay API CNY ✅ Production (¥0.05 verified)
USDC / ETH (Cloud) Base, Ethereum, Polygon, Arbitrum USDC, ETH 🔜 SDK ready, Cloud backend pending
USDC / ETH (local-signer) Base, Ethereum, Polygon, Arbitrum USDC, ETH ✅ Via langchain-paypack (legacy)

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
currency string Currency: CNY (default), USDC, ETH
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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

paypack_langchain-0.1.4.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

paypack_langchain-0.1.4-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file paypack_langchain-0.1.4.tar.gz.

File metadata

  • Download URL: paypack_langchain-0.1.4.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for paypack_langchain-0.1.4.tar.gz
Algorithm Hash digest
SHA256 b28bce13bd53e914d22f786a1e43fba585cb0bd92d4d8dea2946df0e4ce27354
MD5 990788487bd28b28eacd8b20ad6ebb8c
BLAKE2b-256 80eb2d23fe56ac2b04dac527631515a31ebc0a354dbaf8751528355107951523

See more details on using hashes here.

File details

Details for the file paypack_langchain-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for paypack_langchain-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a506cd5b9b9f1d399b2293c33399196ae37edb3177a2067dd2ab611e915e0881
MD5 17db69704c68d19619ba51149af4ac87
BLAKE2b-256 a5c73a72eed439c1e3e6b49ba6c8b1770b696e378f8b3029da9b058dd32ff1fa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page