#dtfk

1 messages ยท Page 1 of 1 (latest)

smoky troutBOT
neon wigeon
#

What kind of transfer specifically are you referring to? A payout from your account balance to your bank account?

silk spire
#

yes a payout to bank account

#

but the thing is this payout contains total of all payments

#

Suppose:

Customer 1 >>makes payment>> 20$
Customer 2 >>makes payment>> 50$
Customer 3>>makes payment>> 70$
Customer 4 >>makes payment>> 1000$

We want webhook notification for all payments separately:
WebNotification for Customer 1 >>>20$>>>>>from stripe to bank account

WebNotification for Customer 2 >>>50$>>>>>from stripe to bank account

WebNotification for Customer 3 >>>70$>>>>>from stripe to bank account

WebNotification for Customer 4 >>>1000$>>>>>from stripe to bank account

neon wigeon
#

Yeah there's unfortunately not a clean way to do this, but I'll describe something that you can do that should work. What you can do is look at the underlying charge on the payment intent. That charge object will have a balance transaction attached to it: https://stripe.com/docs/api/charges/object#charge_object-balance_transaction. You can expand this field and look at the available_on date: https://stripe.com/docs/api/balance_transactions/object#balance_transaction_object-available_on. That's the date funds will be available in your Stripe balance. In almost all cases, the charge would be paid that day. However, this is not always the case. So, you could keep mappings in your database on Charge/Payment Intent object -> Balance Transaction. You can use webhooks to listen to payout.paid events to listen to when payouts are actually paid out: https://stripe.com/docs/api/events/types#event_types-payout.paid. You can then check the balance transaction object on the payout You can then list all balance transactions by payout: https://stripe.com/docs/api/balance_transactions/list#balance_transaction_list-payout and check with your database the charges/payment intents contained in that payout.

#

Sorry 1 slight revision to the above

silk spire
#

Yes please tell the revision

neon wigeon
#

Ok made the edit

silk spire
#

ok please let me check

neon wigeon
#

Only thing was the strikethrough piece

silk spire
#

ok

#

when a charge is created it will always give us the balance transaction id. Right?

neon wigeon
#

That's correct

silk spire
#

we can use Retrieve a balance transaction api with that balance txn id & it will give us the balance txn object

neon wigeon
#

Yes

#

You could also expand it on the charge object

silk spire
#

ok

#

available on date says stripe balance timestamp

#

stripe balance means bank account?

neon wigeon
#

No Stripe balance means your account's money balance (balance on hold that hasn't been paid out to your bank account)

silk spire
#

ohh ok

neon wigeon
silk spire
#

ok

#

so we need to enable payout.paid event webhook

neon wigeon
#

For my above suggestion yeah

#

Because of the payout.paid description:
Occurs whenever a payout is expected to be available in the destination account. If the payout fails, a payout.failed notification is also sent, at a later time.

#

So payout.paid is when we'd expect it to be paid out, but if something goes wrong we'll later send out a payout.failed event for that same payout id, so you may want to listen to both

silk spire
#

ok so we need to implement payout.paid & payout.failed events webhook. And whenever we receive that notification we need to use :

  1. list all balance transactions by payout>>>it will give us all balance transaction id
  2. Run a job that will update the payment status of all those txn id
neon wigeon
#

Not sure I understand 2 above

#

I recommend storing the mapping of Charge -> Balance Transaction in your databse on payment success

#

That way all you need to do is check your databse after listing balance transactions by payout to see which charges are included in that particular payout

silk spire
#

ok

#

If we do list all balances by payout.paid id
all listings will be of payout success only

void forum
#

Hello ๐Ÿ‘‹
Taking over as codename_duchess needs to step away

silk spire
#

Hello

#

if we do list all balances by payout.paid id
all listings will be of payout success only

void forum
#

I believe so, would recommend testing it out to be 100% certain

silk spire
#

what is type property in list all balances api

#

*List all balance transactions

void forum
silk spire
#

is it possible that if we use List all balance transactions api & we receive two different types for same balance txn id

#

like:
txn_1 ---type:charge
txn_1----type:transfer_refund

void forum
#

no, one transaction will only have one type

silk spire
#

tell me something when we list all balances by payout.paid id, it will list all balance transaction id of all types?

void forum
#

Not sure as I haven't tested it myself. Would recommend testing with a payout.id

silk spire
#

if list all balances by payout.paid id & type: charge then we will receive all balance transaction id with respective payment amounts that are transferred to the bank acount

#

correct?

void forum
#

Let's take a step back as I feel like we're going in circles.
What is your end goal? And what have you tried/tested so far?

silk spire
#

my goal is below
to implement a webhook so that whenever the particular transaction amount transfer status (in-transit, pending, success) to the bank account changes, we get notified for that

#

Suppose:

Customer 1 >>makes payment>> 20$
Customer 2 >>makes payment>> 50$
Customer 3>>makes payment>> 70$
Customer 4 >>makes payment>> 1000$

We want webhook notification for all payments separately:
WebNotification for Customer 1 >>>20$>>>>>from stripe to bank account

WebNotification for Customer 2 >>>50$>>>>>from stripe to bank account

WebNotification for Customer 3 >>>70$>>>>>from stripe to bank account

WebNotification for Customer 4 >>>1000$>>>>>from stripe to bank account

void forum
#

So where exactly are you stuck?

silk spire
#

so codename_duchess advised me a workaround

#

below:

"Yeah there's unfortunately not a clean way to do this, but I'll describe something that you can do that should work. What you can do is look at the underlying charge on the payment intent. That charge object will have a balance transaction attached to it: https://stripe.com/docs/api/charges/object#charge_object-balance_transaction. You can expand this field and look at the available_on date: https://stripe.com/docs/api/balance_transactions/object#balance_transaction_object-available_on. That's the date funds will be available in your Stripe balance. In almost all cases, the charge would be paid that day. However, this is not always the case. So, you could keep mappings in your database on Charge/Payment Intent object -> Balance Transaction. You can use webhooks to listen to payout.paid events to listen to when payouts are actually paid out: https://stripe.com/docs/api/events/types#event_types-payout.paid. You can then check the balance transaction object on the payout You can then list all balance transactions by payout: https://stripe.com/docs/api/balance_transactions/list#balance_transaction_list-payout and check with your database the charges/payment intents contained in that payout."

void forum
#

Right, so did you try that out?

silk spire
#

This one looks good & appropriate

#

the only question is mine that when we list all balance transaction by payout.paid id

#

How do we know which type is for success

void forum
silk spire
#

yes i am only looking for the charges we did on customer payment methods

void forum
#

Look at the guide I linked, that should help

silk spire
#

what is 'expand' => ['data.source'] this expand parameter?

void forum
silk spire
#

okkk

#

it will expand the charge object if we pass type:charge & expand:data.source

#

correct?

void forum
#

yes

silk spire
#

so basically list all balance txn by payout.paid id & type : charge will list all the payments that are transferred to bank accounts

void forum
#

Yup

silk spire
#

And list all balance txn by payout.failed id & type : charge will list all the payments that failed to transfer to bank accounts

void forum
#

yes

silk spire
#

ok thank you so much for all the help

#

๐Ÿ™‚

#

just 1 thing more

void forum
#

Sure, what's up?

silk spire
#

in expand parameter we need to mention as it is 'expand' => ['data.source']

#

no need to mention any source id. Correct?

void forum
#

nope

#

just data.source

silk spire
#

ok thanks