Skip to content

Commit ecf0a65

Browse files
committed
fix: getClientPayment
1 parent 23bf29f commit ecf0a65

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

services/chronikService.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -449,14 +449,17 @@ export class ChronikBlockchainClient {
449449
private async handleUpdateClientPaymentStatus (txAmount: string | number | Prisma.Decimal | DecimalJsLike, opReturn: string | undefined, status: ClientPaymentStatus): Promise<void> {
450450
const parsedOpReturn = parseOpReturnData(opReturn ?? '')
451451
const paymentId = parsedOpReturn.paymentId
452-
453-
const clientPayment = await getClientPayment(paymentId)
454-
if (clientPayment.amount !== null) {
455-
if (Number(clientPayment.amount) === Number(txAmount)) {
456-
await updateClientPaymentStatus(paymentId, status)
452+
if (paymentId !== undefined && paymentId !== '') {
453+
const clientPayment = await getClientPayment(paymentId)
454+
if (clientPayment !== null) {
455+
if (clientPayment?.amount !== null) {
456+
if (Number(clientPayment?.amount) === Number(txAmount)) {
457+
await updateClientPaymentStatus(paymentId, status)
458+
}
459+
} else {
460+
await updateClientPaymentStatus(paymentId, status)
461+
}
457462
}
458-
} else {
459-
await updateClientPaymentStatus(paymentId, status)
460463
}
461464
}
462465

services/transactionService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,8 +1009,8 @@ export const updateClientPaymentStatus = async (paymentId: string, status: Clien
10091009
})
10101010
}
10111011

1012-
export const getClientPayment = async (paymentId: string): Promise<Prisma.ClientPaymentGetPayload<{ include: { address: true } }>> => {
1013-
return await prisma.clientPayment.findUniqueOrThrow({
1012+
export const getClientPayment = async (paymentId: string): Promise<Prisma.ClientPaymentGetPayload<{ include: { address: true } }> | null> => {
1013+
return await prisma.clientPayment.findUnique({
10141014
where: { paymentId },
10151015
include: { address: true }
10161016
})

0 commit comments

Comments
 (0)