Skip to content

feat: add invoice table#9348

Merged
Gnanasundari24 merged 20 commits intomainfrom
create-invoice-table
Sep 23, 2025
Merged

feat: add invoice table#9348
Gnanasundari24 merged 20 commits intomainfrom
create-invoice-table

Conversation

@prajjwalkumar17
Copy link
Member

@prajjwalkumar17 prajjwalkumar17 commented Sep 10, 2025

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

Screenshot 2025-09-18 at 22 35 30

Description

This PR introduces the invoice table 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 Invoice table with fields for subscription, connector, merchant, customer, amount, currency, status, and metadata.
  • Added InvoiceStatus enum 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: creates invoice table 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: invoice

  • id (PK)
  • subscription_id
  • connector_subscription_id
  • merchant_id
  • profile_id
  • merchant_connector_id
  • payment_intent_id (unique)
  • payment_method_id
  • customer_id
  • amount
  • currency
  • status
  • provider_name
  • metadata
  • created_at
  • modified_at

Indexes

  • idx_payment_intent_id
  • idx_subscription_id
  • idx_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

@prajjwalkumar17 prajjwalkumar17 self-assigned this Sep 10, 2025
@prajjwalkumar17 prajjwalkumar17 requested a review from a team as a code owner September 10, 2025 10:35
@semanticdiff-com
Copy link

semanticdiff-com bot commented Sep 10, 2025

@hyperswitch-bot hyperswitch-bot bot added the M-database-changes Metadata: This PR involves database schema changes label Sep 10, 2025
@jagan-jaya jagan-jaya linked an issue Sep 10, 2025 that may be closed by this pull request
@prajjwalkumar17 prajjwalkumar17 requested a review from a team as a code owner September 11, 2025 08:39
jagan-jaya
jagan-jaya previously approved these changes Sep 11, 2025
@Sarthak1799
Copy link
Contributor

We need an update interface for payment_intent_id as well @prajjwalkumar17

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Sep 23, 2025
Merged via the queue into main with commit 61949c5 Sep 23, 2025
20 of 26 checks passed
@Gnanasundari24 Gnanasundari24 deleted the create-invoice-table branch September 23, 2025 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

M-database-changes Metadata: This PR involves database schema changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add invoice table in hyperswitch

5 participants