The Fetch Payment Link API enables you to retrieve detailed information about a specific payment link using its unique identifier. This endpoint provides complete payment link details including products, tax configuration, and custom fields.
Endpoint Details
/api/v0/payment-links/{id}
Authentication : Required (API Key & Secret)
Authentication
All requests require API key authentication using the following headers:
x-client-key
: Your application’s client key
x-client-secret
: Your application’s client secret
Path Parameters
Unique payment link identifier Example : "pl_01HZXK8M9N2P3Q4R5S6T7U8V9W"
Request Examples
Basic Request
JavaScript/TypeScript
Python
PHP
curl -X GET "https://api.devdraft.ai/api/v0/payment-links/pl_01HZXK8M9N2P3Q4R5S6T7U8V9W" \
-H "x-client-key: YOUR_CLIENT_KEY" \
-H "x-client-secret: YOUR_CLIENT_SECRET"
Success Response (200 OK)
{
"id" : "pl_01HZXK8M9N2P3Q4R5S6T7U8V9W" ,
"title" : "Premium Subscription" ,
"url" : "https://checkout.devdraft.ai/premium-subscription" ,
"description" : "Monthly access to all premium features" ,
"coverImage" : "https://example.com/images/premium-subscription.jpg" ,
"linkType" : "PRODUCT" ,
"status" : "ACTIVE" ,
"amount" : 29.99 ,
"paymentForId" : null ,
"currency" : "usdc" ,
"allowQuantityAdjustment" : true ,
"allowMobilePayment" : true ,
"collectTax" : true ,
"collectAddress" : false ,
"limitPayments" : true ,
"maxPayments" : 1000 ,
"customFields" : {
"subscription_tier" : "premium" ,
"billing_cycle" : "monthly"
},
"paymentLinkProducts" : [
{
"id" : "plp_123456789" ,
"productId" : "prod_987654321" ,
"quantity" : 1 ,
"product" : {
"id" : "prod_987654321" ,
"name" : "Premium Subscription" ,
"description" : "Access to all premium features" ,
"price" : 29.99 ,
"currency" : "usdc" ,
"images" : [
"https://example.com/images/premium-product.jpg"
]
}
}
],
"isForAllProduct" : false ,
"appId" : "app_123456789" ,
"customerId" : null ,
"taxId" : "tax_456789123" ,
"tax" : {
"id" : "tax_456789123" ,
"name" : "Sales Tax" ,
"percentage" : 8.5 ,
"description" : "Standard sales tax"
},
"expiration_date" : "2024-12-31T23:59:59.000Z" ,
"createdAt" : "2023-07-01T12:00:00.000Z" ,
"updatedAt" : "2023-07-15T09:30:00.000Z"
}
Response Fields
Unique payment link identifier
Display title of the payment link
Full checkout URL for the payment link
Description of the payment link
Type of payment link (PRODUCT, DONATION, SUBSCRIPTION)
Current status (ACTIVE, INACTIVE, EXPIRED)
Fixed amount (null for flexible amounts)
Payment currency (usdc, eurc)
Whether quantity adjustment is allowed
Whether mobile payments are allowed
Whether tax collection is enabled
Whether address collection is enabled
Whether payment count is limited
Maximum number of payments allowed
Custom fields for data collection
Array of associated products with detailed information
Tax configuration details (when collectTax is true)
Expiration date (ISO 8601)
Creation timestamp (ISO 8601)
Last update timestamp (ISO 8601)
Error Responses
401 Unauthorized
404 Not Found
403 Forbidden
{
"statusCode" : 401 ,
"message" : "Unauthorized - Invalid API credentials" ,
"error" : "Unauthorized"
}
Use Cases
1. Customer Support
Quickly retrieve payment link details when customers have questions or issues with their payments.
2. Status Verification
Check if a payment link is active and available before sharing it with customers or including it in communications.
3. Administrative Interface
Display detailed payment link information in dashboards and management tools.
4. Integration Validation
Verify payment link configuration and settings during integration testing.
5. Audit and Compliance
Retrieve complete payment link records for audit trails and compliance reporting.
Best Practices
Error Handling
Always check for 404 errors when the payment link might not exist
Handle 403 errors gracefully if accessing links from other applications
Implement retry logic for temporary network issues
Data Validation
Verify payment link status before using in production
Check expiration dates to ensure links are still valid
Validate that required fields are present for your use case
Cache payment link data when appropriate to reduce API calls
Use the fetch endpoint sparingly for frequently accessed links
Consider using the list endpoint with filters for bulk operations
Security Considerations
Never expose payment link data to unauthorized users
Validate user permissions before displaying payment link details
Use HTTPS for all API requests
Integration Examples
class PaymentLinkValidator {
constructor ( api ) {
this . api = api ;
}
async validateForCheckout ( linkId ) {
try {
const analytics = await this . api . getPaymentLinkAnalytics ( linkId );
const { link , isExpired , effectiveStatus } = analytics ;
// Check basic availability
if ( effectiveStatus !== 'active' ) {
return {
valid: false ,
reason: `Payment link is ${ effectiveStatus } ` ,
code: `LINK_ ${ effectiveStatus . toUpperCase () } `
};
}
// Check payment limits
if ( link . limitPayments && link . maxPayments <= 0 ) {
return {
valid: false ,
reason: 'Payment limit reached' ,
code: 'LIMIT_REACHED'
};
}
// Check if close to expiration
if ( analytics . daysUntilExpiration <= 1 ) {
return {
valid: true ,
warning: `Payment link expires in ${ analytics . daysUntilExpiration } day(s)` ,
code: 'EXPIRES_SOON'
};
}
return {
valid: true ,
link: link
};
} catch ( error ) {
return {
valid: false ,
reason: error . message ,
code: 'FETCH_ERROR'
};
}
}
async getPublicLinkInfo ( linkId ) {
try {
const link = await this . api . fetchPaymentLink ( linkId );
// Return only public information
return {
title: link . title ,
description: link . description ,
coverImage: link . coverImage ,
amount: link . amount ,
currency: link . currency ,
allowQuantityAdjustment: link . allowQuantityAdjustment ,
collectAddress: link . collectAddress ,
collectTax: link . collectTax ,
customFields: link . customFields
};
} catch ( error ) {
throw new Error ( 'Payment link not available' );
}
}
}
Support
For additional support with the Fetch Payment Link API:
Ensure you’re using the correct payment link ID format
Verify API key permissions for payment link access
Check that the payment link belongs to your application
Handle 404 errors gracefully for non-existent links
For more information, see: