You are working on the hyperswitch repository (Rust payment processing system).…
- User
You are working on the hyperswitch repository (Rust payment processing system).
REPOSITORY SETUP:
- Repository: juspay/hyperswitch
- Working directory: ./repos/hyperswitch_pool_3 (already cloned)
- Base commit: 40357ae298ac8327b08f6b5c7b1d4f8cfe7c9acb
- Task ID: juspay__hyperswitch-9343
- Version: v1.117.0
TASK DESCRIPTION: Bug: Add invoice table in hyperswitch
DETAILED CONTEXT & HINTS:
Type of Change
- Bugfix
- New feature
- Enhancement
- Refactoring
- Dependency updates
- Documentation
- CI/CD
Description
Description
This PR introduces the
invoicetable along with supporting models, queries, schema definitions, and storage interfaces.
The goal is to enable subscription billing and payment tracking by storing invoices linked to merchants, customers, subscriptions, and connectors.Key Features
- New
Invoicetable with fields for subscription, connector, merchant, customer, amount, currency, status, and metadata. - Added
InvoiceStatusenum to represent invoice lifecycle stages (e.g.,PendingPayment,PaymentSucceeded,InvoicePaid, etc.). - Implemented Diesel models:
InvoiceNew,Invoice,InvoiceUpdate. - Added storage query methods:
- Insert new invoice
- Find invoice by ID
- Find invoice by merchant + invoice ID
- Update invoice entry
- Integrated with router storage interface (
InvoiceInterface). - Added migrations:
up.sql: createsinvoicetable and indexes (payment_intent_id,subscription_id,merchant_id + customer_id).down.sql: drops indexes and table.
Motivation and Context
- Provides a foundation for subscription billing system in Hyperswitch.
- Supports payment reconciliation and invoice lifecycle tracking.
- Enables robust query and update flows for invoices tied to subscriptions.
Schema Details
Table:
invoiceid(PK)subscription_idconnector_subscription_idmerchant_idprofile_idmerchant_connector_idpayment_intent_id(unique)payment_method_idcustomer_idamountcurrencystatusprovider_namemetadatacreated_atmodified_at
Indexes
idx_payment_intent_ididx_subscription_ididx_merchant_customer
How did you test it?
This can't be tested as this is only creation of tables and their respective storage models.
Checklist
- I formatted the code
cargo +nightly fmt --all - I addressed lints thrown by
cargo clippy - I reviewed the submitted code
- I added unit tests for my changes where possible
CRITICAL INSTRUCTIONS - WORK FAST AND EFFICIENTLY:
-
Create DENSE, ACTION-FOCUSED todos IMMEDIATELY
- Make todos specific and actionable
- Focus on HIGH-IMPACT actions only
- 5-8 todos maximum - be surgical, not exhaustive
-
Execute aggressively:
- Use bash commands to search efficiently
- Read multiple related files in quick succession
- Make ALL related changes in one edit
- Skip unnecessary exploration
-
File operations:
- All repo files: './repos/hyperswitch_pool_3/'
- Use targeted edits over whole file rewrites
-
NO TESTING UNLESS CRITICAL:
- Focus on making the actual code changes
- Only test if explicitly required
-
Maximize information density:
- Each turn should accomplish significant work
- Batch file reads when examining related code
- Use search commands to locate code quickly
EFFICIENCY IS CRITICAL. Make substantial progress every turn.
Assistant
I'll help you implement the invoice table feature in the hyperswitch repository. Let me start by creating a plan of action and exploring the codebase to understand the structure.
Assistant
Let me first explore the database structure to understand where to place the invoice table and how the existing schema is organized.
Assistant
Now let me examine the existing schema file to understand the structure better and then check how other tables are defined.
Assistant
Let me also check the enums file to understand the existing enum structures, particularly for statuses:
Assistant
Now I'll examine some existing models to understand the pattern better:
Assistant
Now I need to check how the migrations are handled. Let me look at the migrations folder:
Assistant
Let me look at the current migrations to understand the naming convention and create a new one for invoice:
Assistant
(no content)
Assistant
Let me check what migrations exist in the directory:
Assistant
Now I'll create the migration files for the invoice table. Based on the task description and pattern in the repository, I need to create a new migration with the up.sql and down.sql files.
Assistant
Let me create the migration files for the invoice table:
Assistant
(no content)
Assistant
I'll create the migration files directly. Let me first check the date/time to make an appropriate timestamp:
Assistant
(no content)
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-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →