This commit is contained in:
boufni95 2024-06-10 22:54:30 +02:00
parent 8832f54a1f
commit d86ee1817c

View file

@ -164,6 +164,10 @@ export default class {
const isAppUserPayment = userId !== linkedApplication.owner.user_id const isAppUserPayment = userId !== linkedApplication.owner.user_id
const serviceFee = this.getServiceFee(Types.UserOperationType.OUTGOING_INVOICE, payAmount, isAppUserPayment) const serviceFee = this.getServiceFee(Types.UserOperationType.OUTGOING_INVOICE, payAmount, isAppUserPayment)
const internalInvoice = await this.storage.paymentStorage.GetInvoiceOwner(req.invoice) const internalInvoice = await this.storage.paymentStorage.GetInvoiceOwner(req.invoice)
const invoiceAlreadyPaid = await this.storage.paymentStorage.GetPaymentOwner(req.invoice)
if (invoiceAlreadyPaid || (internalInvoice && internalInvoice.paid_at_unix > 0)) {
throw new Error("this invoice was already paid")
}
let paymentInfo = { preimage: "", amtPaid: 0, networkFee: 0, serialId: 0 } let paymentInfo = { preimage: "", amtPaid: 0, networkFee: 0, serialId: 0 }
if (internalInvoice) { if (internalInvoice) {
paymentInfo = await this.PayInternalInvoice(userId, internalInvoice, { payAmount, serviceFee }, linkedApplication) paymentInfo = await this.PayInternalInvoice(userId, internalInvoice, { payAmount, serviceFee }, linkedApplication)