diff --git a/src/@types/invoice.ts b/src/@types/invoice.ts index ce889bf5..1644bcf2 100644 --- a/src/@types/invoice.ts +++ b/src/@types/invoice.ts @@ -28,6 +28,10 @@ export interface Invoice { verifyURL?: string } +export interface LnurlInvoice extends Invoice { + verifyURL: string +} + export interface DBInvoice { id: string pubkey: Buffer diff --git a/src/payments-processors/lnurl-payments-processor.ts b/src/payments-processors/lnurl-payments-processor.ts index 30b412e3..ed95e1c0 100644 --- a/src/payments-processors/lnurl-payments-processor.ts +++ b/src/payments-processors/lnurl-payments-processor.ts @@ -2,7 +2,7 @@ import { AxiosInstance } from 'axios' import { Factory } from '../@types/base' import { CreateInvoiceRequest, GetInvoiceResponse, IPaymentsProcessor } from '../@types/clients' -import { Invoice, InvoiceStatus, InvoiceUnit } from '../@types/invoice' +import { InvoiceStatus, InvoiceUnit, LnurlInvoice } from '../@types/invoice' import { createLogger } from '../factories/logger-factory' import { randomUUID } from 'crypto' import { Settings } from '../@types/settings' @@ -15,7 +15,7 @@ export class LnurlPaymentsProcesor implements IPaymentsProcessor { private settings: Factory ) {} - public async getInvoice(invoice: Invoice): Promise { + public async getInvoice(invoice: LnurlInvoice): Promise { debug('get invoice: %s', invoice.id) try { diff --git a/src/services/payments-service.ts b/src/services/payments-service.ts index 32c140fc..40cef860 100644 --- a/src/services/payments-service.ts +++ b/src/services/payments-service.ts @@ -35,11 +35,10 @@ export class PaymentsService implements IPaymentsService { } } - public async getInvoiceFromPaymentsProcessor(invoice: Invoice): Promise> { - debug('get invoice %s from payment processor', invoice.id) + public async getInvoiceFromPaymentsProcessor(invoice: Invoice | string): Promise> { try { return await this.paymentsProcessor.getInvoice( - this.settings().payments?.processor === 'lnurl' ? invoice : invoice.id + typeof invoice === 'string' ? invoice : invoice.id ) } catch (error) { console.log('Unable to get invoice from payments processor. Reason:', error)