diff --git a/API.md b/API.md index f8a4386..e380e1f 100644 --- a/API.md +++ b/API.md @@ -73,7 +73,7 @@ Create a new payment session for a customer. "amount": 1000, "expired": "2025-10-13T12:00:00Z", "completed": false, - "session_url": "https://zpaynow.com/pay/abc123", + "session_url": "https://zpaynow.com/sessions/abc123", "merchant": "Your Store Name", "chains": [ { @@ -414,5 +414,5 @@ For higher limits, contact support or consider self-hosting. ## Support For questions and issues: -- GitHub: [https://github.com/ZeroPayDev/zeropay/issues](https://github.com/ZeroPayDev/zeropay/issues) +- GitHub: [https://github.com/zpaynow/zeropay/issues](https://github.com/zpaynow/zeropay/issues) - Platform Support: [https://zpaynow.com/support](https://zpaynow.com/support) diff --git a/api/.sqlx/query-ba909ec779e2dbce5a6e3dffe091b8deb0d2687b8d9e8fcba4057af7b002e266.json b/api/.sqlx/query-c778142486f208998e9103df15271bdd2e1e7c5076038b015cdd194b8e435394.json similarity index 90% rename from api/.sqlx/query-ba909ec779e2dbce5a6e3dffe091b8deb0d2687b8d9e8fcba4057af7b002e266.json rename to api/.sqlx/query-c778142486f208998e9103df15271bdd2e1e7c5076038b015cdd194b8e435394.json index 0accdcb..53b85f4 100644 --- a/api/.sqlx/query-ba909ec779e2dbce5a6e3dffe091b8deb0d2687b8d9e8fcba4057af7b002e266.json +++ b/api/.sqlx/query-c778142486f208998e9103df15271bdd2e1e7c5076038b015cdd194b8e435394.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "SELECT * FROM sessions WHERE customer=$1 AND deposit IS NULL", + "query": "SELECT * FROM sessions WHERE customer=$1 AND deposit IS NULL ORDER BY id DESC", "describe": { "columns": [ { @@ -54,5 +54,5 @@ false ] }, - "hash": "ba909ec779e2dbce5a6e3dffe091b8deb0d2687b8d9e8fcba4057af7b002e266" + "hash": "c778142486f208998e9103df15271bdd2e1e7c5076038b015cdd194b8e435394" } diff --git a/api/src/main.rs b/api/src/main.rs index 6e6863b..88ac398 100644 --- a/api/src/main.rs +++ b/api/src/main.rs @@ -156,10 +156,8 @@ async fn main() { .await .unwrap(); for asset in c.assets { - scheme - .asset(&asset.address, &asset.name, &asset.version) - .await - .unwrap(); + // try x402 asset + scheme.asset(&asset.address).await.unwrap(); } facilitator.register(scheme); } diff --git a/api/src/models/session.rs b/api/src/models/session.rs index 9349db3..3989b8a 100644 --- a/api/src/models/session.rs +++ b/api/src/models/session.rs @@ -34,7 +34,7 @@ impl Session { pub async fn list_unused(customer: i32, db: &PgPool) -> Result> { let res = query_as!( Self, - "SELECT * FROM sessions WHERE customer=$1 AND deposit IS NULL", + "SELECT * FROM sessions WHERE customer=$1 AND deposit IS NULL ORDER BY id DESC", customer, ) .fetch_all(db) diff --git a/docs/AI_INTEGRATION_GUIDE.md b/docs/AI_INTEGRATION_GUIDE.md index ac2c4fe..e1ef239 100644 --- a/docs/AI_INTEGRATION_GUIDE.md +++ b/docs/AI_INTEGRATION_GUIDE.md @@ -16,7 +16,7 @@ ZeroPay is a cryptocurrency payment gateway that: ```javascript const ZEROPAY_CONFIG = { - apiUrl: "https://api.zeropay.example.com", // Replace with actual API URL + apiUrl: "https://api.zpaynow.com", // Replace with actual API URL apiKey: "your-api-key-here", // Provided by ZeroPay webhookSecret: "your-api-key-here", // Same as apiKey for HMAC verification }; diff --git a/docs/API_DOCUMENTATION.md b/docs/API_DOCUMENTATION.md index 48417fa..3a66507 100644 --- a/docs/API_DOCUMENTATION.md +++ b/docs/API_DOCUMENTATION.md @@ -36,7 +36,7 @@ ZeroPay is a payment gateway that allows you to accept cryptocurrency payments ( ### Base URL ``` -https://api.zeropay.example.com +https://api.zpaynow.com ``` Replace with your actual ZeroPay API URL provided during onboarding. @@ -78,7 +78,7 @@ Create a new payment session for a customer. **Example Request:** ```bash -curl -X POST "https://api.zeropay.example.com/sessions?apikey=your_api_key" \ +curl -X POST "https://api.zpaynow.com/sessions?apikey=your_api_key" \ -H "Content-Type: application/json" \ -d '{ "customer": "user_12345", @@ -147,7 +147,7 @@ Retrieve details of an existing payment session. **Example Request:** ```bash -curl "https://api.zeropay.example.com/sessions/42?apikey=your_api_key" +curl "https://api.zpaynow.com/sessions/42?apikey=your_api_key" ``` **Success Response (200 OK):** @@ -826,18 +826,6 @@ A: Verify: --- -## Support - -Need help? Contact us: - -- Email: support@zeropay.example.com -- Documentation: https://docs.zeropay.example.com -- Status Page: https://status.zeropay.example.com - -Include your API key (first 8 characters only) and session IDs when reporting issues. - ---- - ## Changelog ### v1.0.0 (Current) diff --git a/scanner/src/lib.rs b/scanner/src/lib.rs index c4985fd..022ee1b 100644 --- a/scanner/src/lib.rs +++ b/scanner/src/lib.rs @@ -155,7 +155,7 @@ impl ScannerService { let mut values = t.split(":"); let name: String = values.next().unwrap_or_default().to_owned(); let token: Address = values.next().unwrap_or_default().parse()?; - let version = values.next().unwrap_or_default().to_owned(); + let version = values.next().unwrap_or_default().to_owned(); // EIP-3009 x402 let decimal = evm::get_token_decimal(token, provider.clone()).await?; let identity = format!("{}:{}", config.chain_name, name); diff --git a/x402.md b/x402.md index 4710bd6..ab91ff7 100644 --- a/x402.md +++ b/x402.md @@ -61,8 +61,8 @@ Submit payment authorization and settle: curl -X POST "http://localhost:9000/x402/payments?apikey=your-api-key" \ -H "Content-Type: application/json" \ -d '{ - "payment_payload": { - "x402_version": 1, + "paymentPayload": { + "x402Version": 1, "scheme": "exact", "network": "base-sepolia", "payload": { @@ -77,7 +77,7 @@ curl -X POST "http://localhost:9000/x402/payments?apikey=your-api-key" \ } } }, - "payment_requirements": {...} + "paymentRequirements": {...} }' ``` @@ -121,12 +121,11 @@ let response = facilitator.pay(&url, payload).await?; ## Additional Resources - **[AI Integration Guide](./docs/AI_INTEGRATION_GUIDE.md)** - Prompt and guide for AI agents to integrate with ZeroPay API -- **[x402 Specification](https://github.com/zeropaydev/x402)** - Official x402 protocol specification +- **[x402 Specification](https://github.com/coinbase/x402)** - Official x402 protocol specification - **[API Documentation](./docs/API_DOCUMENTATION.md)** - Detailed API reference ## Support For x402-specific questions and issues: -- **x402 Protocol Spec**: [https://github.com/zeropaydev/x402](https://github.com/zeropaydev/x402) -- **GitHub Issues**: [https://github.com/ZeroPayDev/zeropay/issues](https://github.com/ZeroPayDev/zeropay/issues) +- **x402 Protocol Spec**: [https://github.com/coinbase/x402](https://github.com/coinbase/x402) - **Platform Support**: hi@zpaynow.com diff --git a/x402/EIP3009.json b/x402/EIP3009.json index d260f34..a85b13c 100644 --- a/x402/EIP3009.json +++ b/x402/EIP3009.json @@ -261,6 +261,19 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [], + "name": "version", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "symbol", diff --git a/x402/src/scheme/evm.rs b/x402/src/scheme/evm.rs index f14f0bd..014bfc9 100644 --- a/x402/src/scheme/evm.rs +++ b/x402/src/scheme/evm.rs @@ -35,8 +35,8 @@ sol! { address from; address to; uint256 value; - uint256 valid_after; - uint256 valid_before; + uint256 validAfter; + uint256 validBefore; bytes32 nonce; } } @@ -54,8 +54,8 @@ impl TransferWithAuthorization { from, to, value, - valid_after, - valid_before, + validAfter: valid_after, + validBefore: valid_before, nonce, }) } @@ -132,13 +132,15 @@ impl EvmScheme { /// /// # Arguments /// * `addr` - The token contract address - /// * `name` - The token name for EIP-712 domain (e.g., "USD Coin") - /// * `version` - The token version for EIP-712 domain (e.g., "2") /// /// # Returns /// * `Ok(())` if the token is valid and supports EIP-3009 /// * `Err` if the token is invalid or doesn't support EIP-3009 - pub async fn asset(&mut self, addr: &str, name: &str, version: &str) -> Result<()> { + /// + /// # Note + /// This function automatically reads the token name and version from the contract + /// to ensure they match the contract's DOMAIN_SEPARATOR for EIP-712 signing + pub async fn asset(&mut self, addr: &str) -> Result<()> { let token_address: Address = addr.parse()?; // Create provider and contract instance @@ -155,18 +157,32 @@ impl EvmScheme { .call() .await?; - // Create EIP-712 domain - let domain = create_eip712_domain( - name.to_string(), - version.to_string(), - self.chain_id, - token_address, - ); + // Read the contract's actual name, version, and DOMAIN_SEPARATOR + let name = contract.name().call().await?; + let version = contract.version().call().await?; + let contract_domain_separator = contract.DOMAIN_SEPARATOR().call().await?; + + // Create EIP-712 domain with contract's actual name/version + let domain = + create_eip712_domain(name.clone(), version.clone(), self.chain_id, token_address); + let computed_domain_separator = domain.hash_struct(); + + // Verify the computed domain matches the contract's DOMAIN_SEPARATOR + if computed_domain_separator != contract_domain_separator { + return Err(anyhow::anyhow!( + "Domain separator mismatch! Contract DOMAIN_SEPARATOR doesn't match computed value. \ + Contract name: '{}', version: '{}', chain ID: {}", + name, + version, + self.chain_id + )); + } - // Create and store the asset + // Create and store the asset with contract's actual parameters let extra = json!({ "name": name, - "version": version + "version": version, + "chainId": self.chain_id, }); let asset = EvmAsset { name: name.to_owned(),