Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-haiku-4-5-20251001· anthropicHugging Face nlile/misc-merged-claude-code-traces-v1

Explore the hyperswitch codebase to understand how payment links are implemented,…

  1. User

    Explore the hyperswitch codebase to understand how payment links are implemented, focusing on:

    1. Where payment link configurations are defined and stored
    2. How payment link forms are rendered and validated
    3. Where the submit button logic is implemented
    4. Business profile configuration handling
  2. Claude 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.

  3. Claude Assistant

    Now let me look for frontend-related files that might handle payment link forms and rendering:

  4. Claude Assistant

    Let me search for payment link related files in a broader way:

  5. Claude Assistant

    Let me look for any frontend or UI related files that might handle payment links:

  6. Claude Assistant

    Let me search for any references to payment links in the entire codebase to better understand the structure:

  7. Claude Assistant

    Let me examine the core payment link implementation files to understand how payment links are configured and stored:

  8. Claude Assistant

    Now let me examine the payment link configuration validation module:

  9. Claude Assistant

    Let me look at the payment link API types to understand how payment link configurations are defined:

  10. Claude Assistant

    Let me check the API models for payment link configuration definitions:

  11. Claude Assistant

    Let me search for the payment link config definition in the API models:

  12. Claude Assistant

    (no content)

  13. Claude Assistant

    (no content)

  14. Claude Assistant

    Let me search more specifically for the PaymentLinkConfig struct in the admin module:

  15. Claude Assistant

    (no content)

  16. Claude Assistant

    Let me now read the full PaymentLinkConfig struct:

  17. Claude Assistant

    Now let me check the business profile configuration handling to understand how business profiles are involved with payment links:

  18. Claude Assistant

    (no content)

  19. Claude Assistant

    Let me look for the BusinessPaymentLinkConfig definition in the diesel models:

  20. Claude Assistant

    Let me try a broader search to find the definition:

  21. Claude Assistant

    (no content)

  22. Claude Assistant

    Let me search for the structure definitions more directly:

  23. Claude Assistant

    Let me check around the end of the file to see if it's there:

  24. Claude Assistant

    Let me try to find the struct definition using grep with a broader pattern:

  25. Claude Assistant

    (no content)

  26. Claude Assistant

    Now let me look at the route handler to see how payment links are rendered and handled:

  27. Claude Assistant

    Let me check if there are any frontend or UI files related to payment links by looking for template or HTML handling:

  28. Claude Assistant

    Let me also check the database layer for payment links:

  29. Claude 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:

  30. Claude Assistant

    Let me look for any JavaScript/HTML generation code in the payment link handling:

  31. Claude 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.rs defines PaymentLinkConfig struct 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)

    Business Profile Integration

    • diesel_models/src/business_profile.rs contains BusinessPaymentLinkConfig which 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_flow and initiate_payment_link_flow functions 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.rs handles security validation:
      • Validates allowed domains using validate_domain_against_allowed_domains
      • Checks iframe embedding restrictions via sec-fetch-dest header
      • Validates origin/referer domains against configured allowed domains
      • Ensures secure links are properly generated

    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_DETAILS variable
    • 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_priority function:

    1. Payment creation level config (explicitly passed during payment creation)
    2. Business profile level config (from business profile settings)
    3. Default values (fallback configuration)

    Key Functions:

    • get_payment_link_config_value! macro handles configuration merging with priority
    • extract_payment_link_config parses JSON configuration into structured format
    • Business-specific configs are stored in business_specific_configs map

    Storage Location:

    • Stored in the payment_link_config field of the business_profile table
    • Retrieved via find_business_profile_by_profile_id in 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.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.