Skip to content

Commit 07d9350

Browse files
authored
v2: Clean up paywall (#710)
* Remove cdpClientKey and sessionTokenEndpoint from PaywallConfig Remove Onramp functionality from EvmPaywall Remove Coinbase fields from paywall template generation * Migrate site to @x402/next with v2 protocol support * Clean up tests * remove CDP onramp from core paywall * Update templates and build process * Format * Lockfile * mock templates for CI * Format * Generate new templates * Format
1 parent d1f0f9c commit 07d9350

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+254
-1860
lines changed

go/http/evm_paywall_template.go

Lines changed: 5 additions & 0 deletions
Large diffs are not rendered by default.

go/http/svm_paywall_template.go

Lines changed: 5 additions & 0 deletions
Large diffs are not rendered by default.

python/x402/src/x402/evm_paywall_template.py

Lines changed: 2 additions & 0 deletions
Large diffs are not rendered by default.

python/x402/src/x402/fastapi/middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def require_payment(
6565
network (str, optional): Ethereum network ID. Defaults to "base-sepolia" (Base Sepolia testnet).
6666
resource (Optional[str], optional): Resource URL. Defaults to None (uses request URL).
6767
paywall_config (Optional[PaywallConfig], optional): Configuration for paywall UI customization.
68-
Includes options like cdp_client_key, app_name, app_logo, session_token_endpoint.
68+
Includes options like app_name, app_logo.
6969
custom_paywall_html (Optional[str], optional): Custom HTML to display for paywall instead of default.
7070
7171
Returns:

python/x402/src/x402/paywall.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33

44
from x402.types import PaymentRequirements, PaywallConfig
55
from x402.common import x402_VERSION
6-
from x402.template import PAYWALL_TEMPLATE
6+
from x402.evm_paywall_template import EVM_PAYWALL_TEMPLATE
7+
from x402.svm_paywall_template import SVM_PAYWALL_TEMPLATE
8+
9+
10+
def get_paywall_template(network: str) -> str:
11+
"""Get the appropriate paywall template for the given network."""
12+
if network.startswith("solana:"):
13+
return SVM_PAYWALL_TEMPLATE
14+
return EVM_PAYWALL_TEMPLATE
715

816

917
def is_browser_request(headers: Dict[str, Any]) -> bool:
@@ -63,10 +71,8 @@ def create_x402_config(
6371
"currentUrl": current_url,
6472
"error": error,
6573
"x402_version": x402_VERSION,
66-
"cdpClientKey": config.get("cdp_client_key", ""),
6774
"appName": config.get("app_name", ""),
6875
"appLogo": config.get("app_logo", ""),
69-
"sessionTokenEndpoint": config.get("session_token_endpoint", ""),
7076
}
7177

7278

@@ -114,6 +120,10 @@ def get_paywall_html(
114120
Returns:
115121
Complete HTML with injected payment data
116122
"""
123+
if not payment_requirements:
124+
raise ValueError("payment_requirements cannot be empty")
125+
network = payment_requirements[0].network
126+
template = get_paywall_template(network)
117127
return inject_payment_data(
118-
PAYWALL_TEMPLATE, error, payment_requirements, paywall_config
128+
template, error, payment_requirements, paywall_config
119129
)

python/x402/src/x402/static/paywall.html

Lines changed: 0 additions & 1355 deletions
This file was deleted.

python/x402/src/x402/svm_paywall_template.py

Lines changed: 2 additions & 0 deletions
Large diffs are not rendered by default.

python/x402/src/x402/template.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

python/x402/src/x402/types.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,8 @@ class UnsupportedSchemeException(Exception):
218218
class PaywallConfig(TypedDict, total=False):
219219
"""Configuration for paywall UI customization"""
220220

221-
cdp_client_key: str
222221
app_name: str
223222
app_logo: str
224-
session_token_endpoint: str
225223

226224

227225
class DiscoveredResource(BaseModel):

python/x402/tests/fastapi_tests/test_middleware.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,8 @@ def test_paywall_config_injection():
379379
"""Test that paywall configuration is properly injected into HTML."""
380380
# Use a plain dict that will be compatible with PaywallConfig
381381
paywall_config = {
382-
"cdp_client_key": "test-key-123",
383382
"app_name": "Test Application",
384383
"app_logo": "https://example.com/logo.png",
385-
"session_token_endpoint": "https://example.com/token",
386384
}
387385

388386
app = FastAPI()
@@ -409,7 +407,6 @@ def test_paywall_config_injection():
409407

410408
html_content = response.text
411409
assert "window.x402" in html_content
412-
assert '"cdpClientKey": "test-key-123"' in html_content
413410
assert '"appName": "Test Application"' in html_content
414411
assert '"appLogo": "https://example.com/logo.png"' in html_content
415412
assert '"amount": 2.5' in html_content

0 commit comments

Comments
 (0)