mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 04:10:32 +00:00
feat: integrate Stripe payment to invoices
This commit is contained in:
@@ -2,12 +2,16 @@ import { NextFunction, Request, Response, Router } from 'express';
|
||||
import { Service, Inject } from 'typedi';
|
||||
import { StripePaymentService } from '@/services/StripePayment/StripePaymentService';
|
||||
import asyncMiddleware from '@/api/middleware/asyncMiddleware';
|
||||
import { StripeIntegrationApplication } from './StripeIntegrationApplication';
|
||||
|
||||
@Service()
|
||||
export class StripeIntegrationController {
|
||||
@Inject()
|
||||
private stripePaymentService: StripePaymentService;
|
||||
|
||||
@Inject()
|
||||
private stripeIntegrationApp: StripeIntegrationApplication;
|
||||
|
||||
router() {
|
||||
const router = Router();
|
||||
|
||||
@@ -20,9 +24,19 @@ export class StripeIntegrationController {
|
||||
}
|
||||
|
||||
public async createAccount(req: Request, res: Response, next: NextFunction) {
|
||||
const { tenantId } = req;
|
||||
|
||||
try {
|
||||
const accountId = await this.stripePaymentService.createAccount();
|
||||
res.status(201).json({ accountId });
|
||||
const accountId = await this.stripeIntegrationApp.createStripeAccount(
|
||||
tenantId
|
||||
);
|
||||
|
||||
res
|
||||
.status(201)
|
||||
.json({
|
||||
accountId,
|
||||
message: 'The Stripe account has been created successfully.',
|
||||
});
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user