Developer Documentation
Integrate PayDirect with x402 and h402 protocols into your applications
Getting Started
Set up your PayDirect integration
1. Get API Access
Sign up for a PayDirect account and get your API key from the developer dashboard.
2. Set Up Your Environment
Configure your environment variables with your API key:
PAYDIRECT_API_KEY=your_api_key_here
3. Choose Your Integration Method
PayDirect supports multiple integration methods:
- REST API - Direct API calls to our endpoints
- Widget - Embed our pre-built payment widget
- Custom UI - Build your own UI using our API
Basic Integration
Example of integrating PayDirect using our REST API
// Create a payment request
const response = await fetch('https://paydirect.com/api/payments', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.PAYDIRECT_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
amount: '0.01',
currency: 'ETH',
description: 'Test payment',
type: 'immediate'
})
});
const payment = await response.json();
// Check payment status
const statusResponse = await fetch(`https://paydirect.com/api/payments/${payment.id}`, {
headers: {
'Authorization': `Bearer ${process.env.PAYDIRECT_API_KEY}`
}
});
const status = await statusResponse.json();