Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | 8x 8x 8x 8x 8x 5x 5x 5x 3x 3x 62x 23x 23x 22x 22x 22x 22x | import { injectable } from "inversify";
import { injectables } from "../../core/types/injectables";
import ILogger from "../../core/contracts/ILogger";
import ITransactionDataProvider from "../../core/contracts/ITransactionDataProvider";
import PaymentDetailsContext from "../contexts/paymentDetailsContext";
import TransactionFactory from "../factories/transactionFactory";
import { DependencyInjector } from "../../dependencyInjector";
import ITransactionSourceProvider from "../../core/contracts/ITransactionSourceProvider";
import ITransactionProvider from "../../core/contracts/ITransactionProvider";
@injectable()
export default abstract class AbstractTransactionProvider implements ITransactionProvider {
private readonly logger;
private readonly transactionDataProvider;
private readonly paymentDetailsContext;
protected readonly transactionSourceProvider!: ITransactionSourceProvider;
public constructor() {
this.logger = DependencyInjector.Singleton.resolve<ILogger>(injectables.ILogger);
this.transactionDataProvider = DependencyInjector.Singleton.resolve<ITransactionDataProvider>(injectables.ITransactionDataProvider);
this.paymentDetailsContext = DependencyInjector.Singleton.resolve<PaymentDetailsContext>(injectables.PaymentDetailsContext);
}
public async * generateAsync() {
this.logger.log(`Generating transaction IDs...`);
for await (const transactionId of this.transactionSourceProvider.generateTransactionIdsAsync()) {
yield transactionId;
}
return [];
}
public async resolveTransactionAsync(transactionId: string) {
this.logger.log(`Resolving transaction...`, { transactionId: transactionId });
const transactionSource = await this.transactionSourceProvider.getAsync(transactionId);
const transactionData = this.transactionDataProvider.get(transactionSource);
const paymentDetails = this.paymentDetailsContext.resolve(
transactionData.reference,
transactionData.transactionType,
transactionData.paymentDetailsRaw,
transactionData.additionalDetailsRaw);
const transaction = TransactionFactory.create(transactionId, transactionData, paymentDetails);
return transaction;
}
} |