Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable } from '@nestjs/common';
import { ConflictException, Injectable } from '@nestjs/common';
import { Config } from 'src/config/config';
import { TransactionStatus } from 'src/integration/sift/dto/sift.dto';
import { SiftService } from 'src/integration/sift/services/sift.service';
Expand Down Expand Up @@ -210,7 +210,11 @@ export class BuyCryptoPreparationService {
if (entity.amlCheck === CheckStatus.FAIL)
void this.siftService.buyCryptoTransaction(entity, TransactionStatus.FAILURE);
} catch (e) {
this.logger.error(`Error during buy-crypto ${entity.id} AML check:`, e);
if (e instanceof ConflictException) {
this.logger.warn(`Error during buy-crypto ${entity.id} AML check:`, e);
} else {
this.logger.error(`Error during buy-crypto ${entity.id} AML check:`, e);
}
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/subdomains/supporting/realunit/realunit.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import { FeeService } from 'src/subdomains/supporting/payment/services/fee.servi
import { SwissQRService } from 'src/subdomains/supporting/payment/services/swiss-qr.service';
import { TransactionRequestService } from 'src/subdomains/supporting/payment/services/transaction-request.service';
import { TransactionService } from 'src/subdomains/supporting/payment/services/transaction.service';
import { isClientError } from 'src/tracing';
import { transliterate } from 'transliteration';
import { AssetPricesService } from '../pricing/services/asset-prices.service';
import { PriceCurrency, PriceValidity, PricingService } from '../pricing/services/pricing.service';
Expand Down Expand Up @@ -611,10 +612,12 @@ export class RealUnitService {
price: Math.round(request.amount * 100),
});
} catch (error) {
const upstreamStatus = error?.response?.status;
const message = error?.response?.data ? JSON.stringify(error.response.data) : error?.message || error;
this.logger.error(
this.logger.warn(
`Failed to request payment instructions from Aktionariat for request ${requestId} (currency: ${fiat.name}, shares: ${Math.floor(request.estimatedAmount)}, price: ${Math.round(request.amount * 100)}): ${message}`,
);
if (isClientError(upstreamStatus)) throw new BadRequestException(`Aktionariat API error: ${message}`);
throw new ServiceUnavailableException(`Aktionariat API error: ${message}`);
}

Expand Down