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

@Sourav-kashyap Sourav-kashyap force-pushed the GH-120 branch 5 times, most recently from cd672ac to 8d49ba4 Compare June 24, 2026 05:42
@sonarqubecloud

Copy link
Copy Markdown

SonarQube reviewer guide

Summary: Add billing service controllers and update configuration for invoice management and subscription operations.

Review Focus:

  • The changes introduce extensive billing service integration with new controllers for invoicing, subscriptions, and payment handling
  • Verify that all authorization checks use correct PermissionKey values
  • Check that the allowAlwaysPaths in component.ts properly exposes /billing and /webhooks endpoints without auth barriers while maintaining security elsewhere
  • Ensure new DTO models align with loopback4-billing package type definitions

Start review at: services/subscription-service/src/component.ts. This file configures the allowAlwaysPaths authorization whitelist, which directly controls which billing endpoints bypass authentication - a critical security boundary. Confirm that /billing exposure is intentional and that sensitive operations like payment processing still have proper downstream authentication checks.

💬 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