Lifetime Payments

Hi Guys,
I am trying to fetch the lifetime payments for each contact on my account. Currently, I am pulling the numbers from InvoicePayment( table but for some contacts the numbers don’t seem to match. Can anybody help me with what columns and values should I consider to filter out the rows and get the correct numbers? (Match them with Infusionsoft portal)