Slave/btc integration #4

Merged
nobswebdev merged 47 commits from slave/btc-integration into master 2026-09-07 11:11:10 +00:00
3 changed files with 16 additions and 7 deletions
Showing only changes of commit 8639176af4 - Show all commits
@@ -260,10 +260,6 @@ export class OrderService {
amountFiat: deliveryCost
});
if (!shippingInvoice) {
throw new InternalServerErrorException('Failed to issue shipping invoice');
}
await this.orderRepo.update(orderId, {
shippingInvoice: { id: shippingInvoice.id },
quotedAt
@@ -1,4 +1,4 @@
import { Logger, ServiceUnavailableException } from '@nestjs/common';
import { Logger, InternalServerErrorException, ServiceUnavailableException } from '@nestjs/common';
import type { ConfigService } from '@nestjs/config';
import type { Repository } from 'typeorm';
import type { ElectrumWalletRpcClient } from '../../bitcoinWallet/services/ElectrumWalletRpcClient';
@@ -301,4 +301,15 @@ describe('InvoiceService', () => {
)
);
});
it('throws for unsupported payment methods', async () => {
await expect(
service.issueInvoice({
paymentMethod: 'eth' as PaymentMethod,
reason: InvoiceReason.Checkout,
contextId: 'session-uuid',
amountFiat: 15
})
).rejects.toThrow(new InternalServerErrorException('Unsupported payment method: eth'));
});
});
@@ -1,4 +1,4 @@
import { Injectable, Logger, ServiceUnavailableException } from '@nestjs/common';
import { Injectable, InternalServerErrorException, Logger, ServiceUnavailableException } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { ConfigService } from '@nestjs/config';
import { Repository } from 'typeorm';
@@ -32,12 +32,14 @@ export class InvoiceService {
private readonly exchangeRateService: ExchangeRateService
) {}
async issueInvoice(data: IssueInvoiceData): Promise<Invoice | undefined> {
async issueInvoice(data: IssueInvoiceData): Promise<Invoice> {
switch (data.paymentMethod) {
case PaymentMethod.Xmr:
return this.issueXmrInvoice(data);
case PaymentMethod.Btc:
return this.issueBtcInvoice(data);
default:
throw new InternalServerErrorException(`Unsupported payment method: ${String(data.paymentMethod)}`);
}
}