Metadata-Version: 2.4
Name: paypack-langchain
Version: 0.1.3
Summary: 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-URL: Homepage, https://github.com/yourname/paypack
Author: PayPack
License: MIT
Keywords: agent-pay,alipay,ap2,base,dify,langchain,usdc,wechat,x402
Requires-Python: >=3.10
Requires-Dist: httpx>=0.27.0
Requires-Dist: langchain-core>=0.3.0
Requires-Dist: pydantic>=2.0.0
Description-Content-Type: text/markdown

# 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

```bash
pip install paypack-langchain
```

Requires Python 3.10+.

---

## Quick Start

### 1. Get your API Key

```bash
curl -X POST https://rhcjw.com/pay/v1/register \
  -H "Content-Type: application/json" \
  -d '{"name": "my_agent", "email": "your@email.com"}'
```

Returns:
```json
{"api_key": "ppk_your_api_key_here"}
```

Save this key — you'll use it in every call.

### 2. Create a payment in 3 lines

```python
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:

```python
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

```python
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
