Link Resources
Link Resources
Section titled “Link Resources”Resources define what users access after a successful payment. Gatepay supports several resource types to fit different use cases. All examples use the Gatepay SDK’s createLink
function.
No Resource
Section titled “No Resource”If no resource is defined, the link returns a simple HTTP 200 response after payment. Use this for API integrations or when you only need to trigger actions (e.g., callbacks) without serving content.
const link = await gatepay.createLink({ name: "Simple Payment Confirmation", description: "Basic payment confirmation", // No resource property - returns HTTP 200 after payment toll: { tollPaymentRequirements: [ { assetNetwork: "base", amount: "1000000", // 1 USDC assetAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", destinationAddress: "your-wallet-address", }, ], },})
Static HTML
Section titled “Static HTML”Serve static HTML content directly after payment.
const link = await gatepay.createLink({ name: "Premium Article", description: "Exclusive article content", resource: { type: "html", data: { html: ` <h1>Premium Content</h1> <p>This is exclusive content available after payment.</p> <p>Thank you for your purchase!</p> `, }, }, toll: { tollPaymentRequirements: [ { assetNetwork: "base", amount: "1000000", assetAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", destinationAddress: "your-wallet-address", }, ], },})
Protected Link
Section titled “Protected Link”Provides access to a protected URL after payment. The user receives the URL directly without redirect or proxy.
const link = await gatepay.createLink({ name: "Protected PDF Access", description: "Get access to premium PDF document", resource: { type: "link", data: { url: "https://example.com/protected-document.pdf", }, }, toll: { tollPaymentRequirements: [ { assetNetwork: "base", amount: "5000000", // 5 USDC assetAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", destinationAddress: "your-wallet-address", }, ], },})
Reverse Proxy
Section titled “Reverse Proxy”Gatepay proxies requests to your backend or API, adding payment gating. Useful for protecting APIs or dynamic content.
const link = await gatepay.createLink({ name: "Protected API Access", description: "Access to protected API endpoint", resource: { type: "proxy", data: { url: "https://api.example.com/protected-endpoint", }, }, toll: { tollPaymentRequirements: [ { assetNetwork: "base", amount: "2000000", // 2 USDC assetAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", destinationAddress: "your-wallet-address", }, ], },})
Redirect
Section titled “Redirect”Redirects users to a specific URL after successful payment.
const link = await gatepay.createLink({ name: "Premium Service Access", description: "Redirect to premium service dashboard", resource: { type: "redirect", data: { url: "https://premium.example.com/dashboard", }, }, toll: { tollPaymentRequirements: [ { assetNetwork: "base", amount: "10000000", // 10 USDC assetAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", destinationAddress: "your-wallet-address", }, ], },})
Cloudflare Tunnel
Section titled “Cloudflare Tunnel”For advanced users, you can create tunnels to locally hosted services:
const link = await gatepay.createLink({ name: "Local Service Access", description: "Access to locally hosted service via Cloudflare tunnel", resource: { type: "tunnel", data: { url: "http://localhost:3000", }, }, toll: { tollPaymentRequirements: [ { assetNetwork: "base", amount: "1000000", assetAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", destinationAddress: "your-wallet-address", }, ], },})
Resource Type Summary
Section titled “Resource Type Summary”Resource Type | Description | Use Case |
---|---|---|
None | Returns HTTP 200 | Simple payment confirmation |
html | Static HTML content | Articles, documentation |
link | Protected URL access | Files, external content |
proxy | Reverse proxy | APIs, dynamic content |
redirect | User redirection | Service dashboards |
tunnel | Cloudflare tunnel | Local/private services |
Next Steps
Section titled “Next Steps”- Adding Tolls - Configure payment requirements
- Link Actions - Set up webhooks and callbacks
- Create Your First Link - Complete walkthrough