Skip to content

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.

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",
},
],
},
})

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",
},
],
},
})

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",
},
],
},
})

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",
},
],
},
})

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",
},
],
},
})

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 TypeDescriptionUse Case
NoneReturns HTTP 200Simple payment confirmation
htmlStatic HTML contentArticles, documentation
linkProtected URL accessFiles, external content
proxyReverse proxyAPIs, dynamic content
redirectUser redirectionService dashboards
tunnelCloudflare tunnelLocal/private services