mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 03:40:56 +00:00
cac payemnt integration and cbe rate exchange webscrabing
This commit is contained in:
@@ -7,7 +7,8 @@ import {
|
||||
} from "@nestjs/common";
|
||||
import { ConfigService } from "@nestjs/config";
|
||||
import { SchedulerRegistry } from "@nestjs/schedule";
|
||||
import { ProviderPaymentStatus } from "@edr/types";
|
||||
import { ProviderPaymentStatus, ProviderMethod } from "@edr/types";
|
||||
import { CacBankProvider } from "@edr/payment-providers";
|
||||
import {
|
||||
PAYMENT_PROVIDER_MAP,
|
||||
PaymentProviderMap,
|
||||
@@ -38,6 +39,7 @@ export class ReconciliationService implements OnModuleInit, OnModuleDestroy {
|
||||
private readonly schedulerRegistry: SchedulerRegistry,
|
||||
@Inject(PAYMENT_PROVIDER_MAP)
|
||||
private readonly providers: PaymentProviderMap,
|
||||
private readonly cacBankProvider: CacBankProvider,
|
||||
) {
|
||||
this.intervalMs =
|
||||
config.get<number>("app.reconciliation.sweepIntervalMs") ?? 60_000;
|
||||
@@ -82,7 +84,13 @@ export class ReconciliationService implements OnModuleInit, OnModuleDestroy {
|
||||
try {
|
||||
const provider = this.providers.get(intent.provider);
|
||||
if (provider) {
|
||||
const status = await provider.queryStatus(intent.merchantOrderId);
|
||||
const status =
|
||||
intent.provider === ProviderMethod.CAC_BANK
|
||||
? await this.cacBankProvider.queryStatus(
|
||||
intent.merchantOrderId,
|
||||
(intent.rawInitiation as { reference?: string })?.reference,
|
||||
)
|
||||
: await provider.queryStatus(intent.merchantOrderId);
|
||||
const result = this.intentsService.fromProviderStatus(status);
|
||||
if (result.status !== intent.status || result.providerTxnId) {
|
||||
await this.intentsService.applyProviderResult(intent.id, result);
|
||||
|
||||
Reference in New Issue
Block a user