Explore the hyperswitch codebase to understand how payment links are implemented,…
- User
Explore the hyperswitch codebase to understand how payment links are implemented, focusing on:
- Where payment link configurations are defined and stored
- How payment link forms are rendered and validated
- Where the submit button logic is implemented
- Business profile configuration handling
Assistant
I'll explore the hyperswitch codebase to understand how payment links are implemented. Let me start by examining the overall structure and finding relevant files related to payment links.
Assistant
Now let me look for frontend-related files that might handle payment link forms and rendering:
Assistant
Let me search for payment link related files in a broader way:
Assistant
Let me look for any frontend or UI related files that might handle payment links:
Assistant
Let me search for any references to payment links in the entire codebase to better understand the structure:
Assistant
Let me examine the core payment link implementation files to understand how payment links are configured and stored:
Assistant
Now let me examine the payment link configuration validation module:
Assistant
Let me look at the payment link API types to understand how payment link configurations are defined:
Assistant
Let me check the API models for payment link configuration definitions:
Assistant
Let me search for the payment link config definition in the API models:
Assistant
(no content)
Assistant
(no content)
Assistant
Let me search more specifically for the PaymentLinkConfig struct in the admin module:
Assistant
(no content)
Assistant
Let me now read the full PaymentLinkConfig struct:
Assistant
Now let me check the business profile configuration handling to understand how business profiles are involved with payment links:
Assistant
(no content)
Assistant
Let me look for the BusinessPaymentLinkConfig definition in the diesel models:
Assistant
Let me try a broader search to find the definition:
Assistant
(no content)
Assistant
Let me search for the structure definitions more directly:
Assistant
Let me check around the end of the file to see if it's there:
Assistant
Let me try to find the struct definition using grep with a broader pattern:
Assistant
(no content)
Assistant
Now let me look at the route handler to see how payment links are rendered and handled:
Assistant
Let me check if there are any frontend or UI files related to payment links by looking for template or HTML handling:
Assistant
Let me also check the database layer for payment links:
Assistant
Let me examine how payment link forms are actually rendered. Since this seems to be a backend service, let me check if there's a frontend SDK or a template that handles the form rendering:
Assistant
Let me look for any JavaScript/HTML generation code in the payment link handling:
Assistant
Based on my exploration of the hyperswitch codebase, I can now provide you with a comprehensive overview of how payment links are implemented, focusing on the four areas you requested:
1. Payment Link Configuration Storage
Payment link configurations are defined in several locations:
Core Configuration Structure
api_models/src/admin.rsdefinesPaymentLinkConfigstruct which includes:- Theme colors (
theme,background_colour) - Logo and merchant name (
logo,seller_name) - Layout options (
sdk_layout,details_layout) - Display preferences (
display_sdk_only,show_card_form_by_default) - Security settings (
allowed_domains) - Branding controls (
branding_visibility) - Button customization (
payment_button_text,payment_button_colour) - Additional UI rules (
sdk_ui_rules,payment_link_ui_rules)
- Theme colors (
Business Profile Integration
diesel_models/src/business_profile.rscontainsBusinessPaymentLinkConfigwhich holds:- Default configuration templates
- Business-specific configurations
- Allowed domains
- Branding visibility settings
These configurations are stored in the database as part of business profiles and payment link records.
2. Payment Link Form Rendering and Validation
Form Generation
- The core logic is in
crates/router/src/core/payment_link.rs initiate_secure_payment_link_flowandinitiate_payment_link_flowfunctions handle form generation- Forms are rendered as HTML/JavaScript responses that embed payment details in JavaScript variables
Validation Logic
crates/router/src/core/payment_link/validator.rshandles security validation:- Validates allowed domains using
validate_domain_against_allowed_domains - Checks iframe embedding restrictions via
sec-fetch-destheader - Validates origin/referer domains against configured allowed domains
- Ensures secure links are properly generated
- Validates allowed domains using
Data Injection
- Payment details are injected into the form via JavaScript:
window.__PAYMENT_DETAILS = { ... }
3. Submit Button Logic Implementation
The payment link forms are designed to be SDK-driven rather than traditional HTML form submission. Key aspects:
- SDK Integration: Payment forms are loaded via SDK that handles the submit logic
- JavaScript-based: The payment details are embedded in
window.__PAYMENT_DETAILSvariable - Client-side SDK: The actual submit functionality is handled by the external SDK (not in the core hyperswitch code)
- Backend Response: Returns structured data with JavaScript and CSS needed for SDK integration
4. Business Profile Configuration Handling
Configuration Priority System
The system implements a hierarchy for configuration resolution in
get_payment_link_config_based_on_priorityfunction:- Payment creation level config (explicitly passed during payment creation)
- Business profile level config (from business profile settings)
- Default values (fallback configuration)
Key Functions:
get_payment_link_config_value!macro handles configuration merging with priorityextract_payment_link_configparses JSON configuration into structured format- Business-specific configs are stored in
business_specific_configsmap
Storage Location:
- Stored in the
payment_link_configfield of thebusiness_profiletable - Retrieved via
find_business_profile_by_profile_idin the database layer
The implementation follows a flexible configuration model where merchants can define default payment link behaviors at the business profile level, override them per payment, and even define specific configurations for different use cases or customer segments.
The forms themselves are not HTML templates but are dynamically generated server-side and delivered to the client with the appropriate JavaScript to initialize the SDK-based payment interface.
This approach provides a consistent experience while allowing for extensive customization through the configuration system.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-haiku-4-5-20251001Compare side by side →
claude-haiku-4-5-20251001Compare side by side →
claude-haiku-4-5-20251001Compare side by side →
claude-haiku-4-5-20251001Compare side by side →
claude-haiku-4-5-20251001Compare side by side →
claude-haiku-4-5-20251001Compare side by side →
claude-haiku-4-5-20251001Compare side by side →
claude-haiku-4-5-20251001Compare side by side →
claude-haiku-4-5-20251001Compare side by side →
claude-haiku-4-5-20251001Compare side by side →
claude-haiku-4-5-20251001Compare side by side →
claude-haiku-4-5-20251001Compare side by side →