Skip to content

feat(billing): add billing endpoints#121

Open
Sourav-kashyap wants to merge 6 commits into
masterfrom
GH-120
Open

feat(billing): add billing endpoints#121
Sourav-kashyap wants to merge 6 commits into
masterfrom
GH-120

Conversation

@Sourav-kashyap

Copy link
Copy Markdown
Contributor

Description

This PR adds three new billing endpoints to retrieve detailed payment and invoice information, along with TypeScript type improvements for webhook handling. The new endpoints provide essential functionality for invoice management and payment tracking in SaaS subscription workflows.

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist:

  • Performed a self-review of my own code
  • npm test passes on your machine

@Sourav-kashyap Sourav-kashyap self-assigned this May 19, 2026
@Sourav-kashyap Sourav-kashyap linked an issue May 19, 2026 that may be closed by this pull request
@Sourav-kashyap Sourav-kashyap force-pushed the GH-120 branch 4 times, most recently from 2fe29d0 to 6baedad Compare May 20, 2026 10:21
Comment on lines +76 to +85
process.env.FEATURE_DB_HOST = 'localhost';
process.env.FEATURE_DB_PORT = '5432';
process.env.FEATURE_DB_USER = 'test';
process.env.FEATURE_DB_PASSWORD = 'test';
process.env.FEATURE_DB_DATABASE = 'test';
process.env.FEATURE_DB_SCHEMA = 'public';
// Billing config
process.env.SITE = 'test';
process.env.API_KEY = 'test';
process.env.STRIPE_SECRET = 'test';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why a database setup, cant we use memory store here ?

@Sourav-kashyap Sourav-kashyap May 20, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

@post(`${BASE}/customers`, {
summary: 'Create a new customer',
responses: {
'200': {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

magic number

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

Comment on lines +70 to +86
schema: {
type: 'object',
required: ['firstName', 'lastName', 'email'],
properties: {
firstName: {type: 'string', example: 'John'},
lastName: {type: 'string', example: 'Doe'},
email: {type: 'string', example: 'john.doe@example.com'},
company: {type: 'string', example: 'Acme Inc.'},
phone: {type: 'string', example: '+1234567890'},
billingAddress: {
type: 'object',
properties: {
line1: {type: 'string'},
city: {type: 'string'},
state: {type: 'string'},
zip: {type: 'string'},
country: {type: 'string', example: 'US'},

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use types

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

Comment on lines +140 to +162
'application/json': {
schema: {
type: 'object',
properties: {
firstName: {type: 'string'},
lastName: {type: 'string'},
email: {type: 'string'},
company: {type: 'string'},
phone: {type: 'string'},
billingAddress: {
type: 'object',
properties: {
line1: {type: 'string'},
city: {type: 'string'},
state: {type: 'string'},
zip: {type: 'string'},
country: {type: 'string'},
},
},
},
},
},
},

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

define type

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

Comment on lines +113 to +119
this.application.bind(StripeBindings.config).to({
secretKey: process.env.STRIPE_SECRET ?? '',
});
this.application
.bind(BillingComponentBindings.SDKProvider)
.toProvider(StripeServiceProvider);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be in sandbox

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

// Mount authorization component for default sequence
this.application.bind(AuthorizationBindings.CONFIG).to({
allowAlwaysPaths: ['/explorer'],
allowAlwaysPaths: ['/explorer', '/billing', '/webhooks'],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there was a webhook component right ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes ma'am

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it not added there then ?

Comment on lines +26 to +30
SITE=
API_KEY=
STRIPE_SECRET=
CHARGEBEE_ITEM_FAMILY_ID=
BILLING_PROVIDER=

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no all this will b ein sandbox

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

@Sourav-kashyap Sourav-kashyap force-pushed the GH-120 branch 2 times, most recently from 1841efc to 5673f13 Compare May 20, 2026 13:38
},
})
async createCustomer(
@requestBody({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this create the customer on stripe? if yes, then we alreayd has the apis to create the customer. what is the difference between them

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

},
})
async getCustomer(
@param.path.string('customerId') customerId: string,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these endpoints already exist exist , review pls

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

},
})
paymentDto: BillingPaymentSourceBody,
): Promise<TPaymentSource> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already have the api , then why need to create new

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

},
},
},
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep them seprate , for product , price, keep them separate

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

* interceptor to BILLING_WEBHOOK_VERIFIER in application.ts.
*/
export class BillingWebhookController {
constructor(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already had a controller for ir

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

@sonarqubecloud

Copy link
Copy Markdown

SonarQube reviewer guide

Summary: Dependency updates and billing feature implementation to enable webhook handling for billing services.

Review Focus: Three key areas demand attention: First, the large package-lock.json updates across AWS SDK v3 dependencies and other packages require verification that version changes don't introduce breaking changes or security vulnerabilities. Second, the new billing-related controllers and DTOs represent significant functionality additions that need validation against the loopback4-billing SDK expectations. Third, the authorization configuration change adding /webhooks to allowAlwaysPaths represents a critical security decision that warrants careful review.

Start review at: services/subscription-service/src/component.ts. This file shows the updated authorization configuration allowing unauthenticated access to /webhooks, which is a significant security and architectural decision that impacts how billing webhooks will be processed. Understanding this change provides essential context for evaluating all the new billing-related controllers.

💬 Please send your feedback

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add billing subscription features

3 participants