Skip to content
Merged
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
4 changes: 4 additions & 0 deletions src/@types/invoice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export interface Invoice {
verifyURL?: string
}

export interface LnurlInvoice extends Invoice {
verifyURL: string
}

export interface DBInvoice {
id: string
pubkey: Buffer
Expand Down
4 changes: 2 additions & 2 deletions src/payments-processors/lnurl-payments-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -15,7 +15,7 @@ export class LnurlPaymentsProcesor implements IPaymentsProcessor {
private settings: Factory<Settings>
) {}

public async getInvoice(invoice: Invoice): Promise<GetInvoiceResponse> {
public async getInvoice(invoice: LnurlInvoice): Promise<GetInvoiceResponse> {
debug('get invoice: %s', invoice.id)

try {
Expand Down
5 changes: 2 additions & 3 deletions src/services/payments-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ export class PaymentsService implements IPaymentsService {
}
}

public async getInvoiceFromPaymentsProcessor(invoice: Invoice): Promise<Partial<Invoice>> {
debug('get invoice %s from payment processor', invoice.id)
public async getInvoiceFromPaymentsProcessor(invoice: Invoice | string): Promise<Partial<Invoice>> {
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)
Expand Down