#mattsulima

1 messages ยท Page 1 of 1 (latest)

echo ridgeBOT
fossil sphinx
#

๐Ÿ‘‹ happy to help

#

If you're using Payment Links the webhook events you need to listen to is checkout.session.completed

quick hinge
#

Oh I'll look into it now, thanks!

#

I have another question, someone makes payment, we authorize only. Then I am capturing e.g. half of it (payment 200 gbp, I am capturing 100gbp). Then when I receive webhook and I read transaction balance I only see 200 gbp , and frees and everyting matching to 200 gbp, not 100 gbp

#

How to load real "balance" for this transaction ?

fossil sphinx
#

I'm not sure I follow

quick hinge
#

I need exactly all balance transaction usually has - so amount, net amount, fee

fossil sphinx
#

would you mind sharing the request IDs or Payment Intent Ids?

quick hinge
#

I think that's one of examples : pi_3MZX8mGEyV5mPs8i0JjI5oSy

#

In other words:

  • someone pays (card authorize, not capture) 200 gbp
  • I look into it, I need to capture only 100, not 200.
  • I am doing capture (100 gbp)
  • then webhook appears (charge.captured)
  • charge usually has .BalanceTransaction obejct, this obejct has amount, net and fee
#

and then I am doing this capture (100 gbp) I still see 200 gbp in balance transaction

#

So my db sees we charged user for 200, when we really charged user for 100 only

fossil sphinx
#

ok taking a look

#

give me a minute please

quick hinge
#

Sure, thanks

quick hinge
fossil sphinx
#

would you mind sharing an event id?

quick hinge
#

evt_1MZYedGEyV5mPs8iLhuzwWnc

fossil sphinx
#

yes it's normal because you have a subscription

#

from there you need to look at the subscription's latest_invoice

quick hinge
#

Ok, thanks, I'll check it

fossil sphinx
#

let me know if you need any more help

quick hinge
fossil sphinx
#

oh yes sorry my bad

#

you're looking at the balance_transaction?

#

e.g. txn_3MZX8mGEyV5mPs8i0lSvXxbF ?

quick hinge
#

yeah I need balance transaction, but txn_3MZX8mGEyV5mPs8i0lSvXxbF shows wrond data. It shows 405 gbp, but we really captured 300 only

#

and 105 refunded

fossil sphinx
#

yes I agree, this info is shown on the charge object

#

ch_3MZX8mGEyV5mPs8i06wodqeE

#

I'll try to look into this even more to see whether this is a normal behavior or not

quick hinge
#

yeah, it is, but isn't fee and net wrong then?

#

For each contract we make we track all payments and we collect 3 things:

  • amount
  • net
  • fee
fossil sphinx
#

yes I agree

#

that's why I'm looking into this

quick hinge
#

thanks

#

Fyi
Originally we were importing csv files but now we want to switch to webhooks. Csv is very often incomplete - e.g. dispute ("adjustment") charge don't have metadata. Payment via link too. And we have many types of payments - single payment, recurring payments, payment links ect. So I hoped I need to connect to charge.succeded or charge captured, load contract id from metadata and load balance.
But it looks I can't ๐Ÿ˜„

#

Take your time, I'll wait for response, fingers crossed we have simple solution to achieve it! ๐Ÿ˜„

fossil sphinx
#

basically what happens in a partial capture is that we create 2 balance transactions: 1 for the original amount and 1 for the refunded amount

quick hinge
#

Oh that's good news, is there separate webhook event I need to listed to catch refund part?

fossil sphinx
#

no actually you need to look at the refund which is no longer included by default on that charge

#

you need to expand on refunds to get the list and from there get the balance transaction to have the negative net amount

#

to finally get the correct amount

quick hinge
#

oh

#

It's all quite complicated tbh ๐Ÿ˜‰

fossil sphinx
#

yes but apparently since your webhook is still on a older API version

#

when you listen to charge.captured event you will get a list of refunds

#

which has the balance_transaction that you were missing

#

so you need to just retrieve both balance transactions

#

the one from the charge

#

and the one from the refund

quick hinge
#

Okay, thanks I'll look into it. makes sense now

quick hinge
#

We are still in development stage so we must have all up to date

fossil sphinx
#

your webhook is using the same API version as your account which is 2022-08-01

#

since then we have deployed other API versions

quick hinge
#

ok cool, I'll update it then. Thanks!

warm plover
#

Hey, taking over here. Let me know if there's any follow-up Qs I can answer!