mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
feat: integrate Stripe payment to invoices
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import HasTenancyService from '../Tenancy/TenancyService';
|
||||
import { TransformerInjectable } from '@/lib/Transformer/TransformerInjectable';
|
||||
import { GetPaymentServicesSpecificInvoiceTransformer } from './GetPaymentServicesSpecificInvoiceTransformer';
|
||||
|
||||
@Service()
|
||||
export class GetPaymentServicesSpecificInvoice {
|
||||
@Inject()
|
||||
private tenancy: HasTenancyService;
|
||||
|
||||
@Inject()
|
||||
private transform: TransformerInjectable;
|
||||
|
||||
/**
|
||||
* Retrieves the payment services of the given invoice.
|
||||
* @param {number} tenantId
|
||||
* @param {number} invoiceId
|
||||
* @returns
|
||||
*/
|
||||
async getPaymentServicesInvoice(tenantId: number) {
|
||||
const { PaymentIntegration } = this.tenancy.models(tenantId);
|
||||
|
||||
const paymentGateways = await PaymentIntegration.query()
|
||||
.where('enable', true)
|
||||
.orderBy('name', 'ASC');
|
||||
|
||||
return this.transform.transform(
|
||||
tenantId,
|
||||
paymentGateways,
|
||||
new GetPaymentServicesSpecificInvoiceTransformer()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { Transformer } from '@/lib/Transformer/Transformer';
|
||||
|
||||
export class GetPaymentServicesSpecificInvoiceTransformer extends Transformer {
|
||||
/**
|
||||
* Exclude attributes.
|
||||
* @returns {string[]}
|
||||
*/
|
||||
public excludeAttributes = (): string[] => {
|
||||
return ['accountId'];
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Service, Inject } from 'typedi';
|
||||
import { GetPaymentServicesSpecificInvoice } from './GetPaymentServicesSpecificInvoice';
|
||||
|
||||
@Service()
|
||||
export class PaymentServicesApplication {
|
||||
@Inject()
|
||||
private getPaymentServicesSpecificInvoice: GetPaymentServicesSpecificInvoice;
|
||||
|
||||
/**
|
||||
* Retrieves the payment services for a specific invoice.
|
||||
* @param {number} tenantId - The ID of the tenant.
|
||||
* @param {number} invoiceId - The ID of the invoice.
|
||||
* @returns {Promise<any>} The payment services for the specified invoice.
|
||||
*/
|
||||
async getPaymentServicesForInvoice(tenantId: number): Promise<any> {
|
||||
return this.getPaymentServicesSpecificInvoice.getPaymentServicesInvoice(
|
||||
tenantId
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user