#πŸ’ͺ🦊

1 messages Β· Page 1 of 1 (latest)

lavish pawnBOT
grim basalt
#

hi! transfer_group is more or less just like metadata, we don't actively track the balance as far as I know. if you use source_transaction then we do, obviously you can't transfer more than is in that transaction. If you want such a limitation it's something you'd have to build yourself by e.g using https://stripe.com/docs/api/transfers/list#list_transfers-transfer_group and summing the results before making a new transfer, to check the amount 'used'

low abyss
#

hm okay, so I can fetch all the transfers within the transfer group and then check how much is left on those transfers?

#
const transfers = await stripe.transfers.list({
  transfer_group: {Whatever Identifier I gave it}
});```
#

so say like this

#

and then whatever transactions I get in that, (should only be 1 in my use case) I just check if the money thats about to be transfered will be available in the source transaction?

grim basalt
#

sorry, kind of lost

#

when you say the transfer group has money, what do you mean by that

low abyss
#

right okay, can I take you through my system steps?

#
  1. A User initiates the payment intent, with the transfer_group as {SOME ID}
#
  1. The system captures the payment intent a bit later
#
  1. So now the transfer group has the amount of money captured assigned to it, right?
grim basalt
#

yes

#

like, on paper

#

we have no concept of that internally. But ok, go on, what happens next?

low abyss
#

so now lets say I we had a $100 on the initial captured payment

#

and I want to transfer $80 to a custom connect account and leave $20 for the platform

#

and that's fine, I know how to do that

#

I basically calculate the price that I need to send just to the user do this

#

where booking.ownerID.customerID is the custom connect account id

grim basalt
#

sure. I mean you can and should just use source_transaction there

low abyss
#

okay there we go

grim basalt
#

https://stripe.com/docs/connect/charges-transfers#transfer-availability

When using this parameter:

  • The amount of the transfer must not exceed the amount of the source charge
  • You may create multiple transfers with the same source_transaction, as long as the sum of the transfers doesn’t exceed the source charge
  • The transfer takes on the pending status of the associated charge: if the funds from the charge become available in N days, the payment that the destination Stripe account receives from the transfer also becomes available in N days
  • Stripe automatically creates a transfer_group for you
  • The currency of the balance transaction associated with the charge must match the currency of the transfer
low abyss
#

so, it will return an error if I use more than the source transaction has?

grim basalt
#

yes

low abyss
grim basalt
#

not sure what you mean

#

I feel like that is the part you missed(how to list the charges that are related to a given transfer_group)

low abyss
#

hm

#

well what I am asking is how would I get the source_transaciton:

#
const charges = await stripe.charges.list({
  transfer_group: {TRANSFER_GROUP_ID}
});
#

like this, correct?

#

one second, capturing the payment intent returns a charge_id somewhere in there, does it not?

#

so I could just record that?

grim basalt
#

you should be saving it in your database really

#

or yes, it's paymentIntent.charges.data[0].id, indeed

low abyss
#

yeah I remember now, thank you:)

low abyss
# low abyss

and now anything that will not be transfered to the user with this will be in the platform account

#

right?

fast plaza
#

Hi! I'm taking over this thread.

#

Yes that's correct, any amount that you don't transfer stay on the platform account.

low abyss
#

just last question

#

I have a use case of when I need to refund 1/2 of the paymentIntent and transfer the other 1/2

#

this should do it right?

fast plaza
#

This should be possible yes! However be careful when doing /2 since the amount needs to be an integer (and not a float).

low abyss
#

ill double check that, thank you:)

#

and also the remaining funds, if there are any (because the initial payment intent was the same price + 10%), should remain on the platform account

#

so basically the 10% minus the stripe commission

fast plaza
#

the code you shared above sends 50% to the connected account and 50% back to the user. So the platform would be left with nothing (actually a negative amount because of the Stripe fee).

low abyss
#

well no, because I create the initial payment intent with amount: price * 1.1

#

so if the price was 100, then the actual captured amount is 110

#

and the amounts transfered to the connected account and refunded would be 100/2

#

so 10 minus the stripe charge left in the account?

#

the maths works out, I'm just wondering if after refunding and transfering I need to do anything to put the remaining "10%" in the platform account

fast plaza
#

Got it, I missed that 1.1. Then yes it works, and there's nothing to do.
By default all the funds go to your platform account. And when you make a transfer you explicitly send some money to a connected account. So after the transfer the money left stays in your platform account.

low abyss
#

okay thank you ^_^

fast plaza
#

Happy to help πŸ™‚