#nahinanajahd_api
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1463182945597657304
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Good morning! I'm here whenever you're ready -- not sure how this is supposed to work. ๐
hey there apologies for the delay here
Can you explain what you expect the transfer group to be doing here? I don't really understand the end goal
No worries!
Sure, so I'm building an invoice on behalf of 2 or more workers. When the invoice is paid, I will need to transfer a portion of the payment to each worker.
ok
From the documentation, it looks like I'm supposed to set a "transfer_group" on the payment intent, so the transfers get grouped under the payment intent (basically money in -> money out)
Grouped in what sense?
If you need to split funds with more than one connected account provider, you have to do manual transfers after the payment is collected. The invoice payment would be separate from the transfers.
That I do not know, my guess is for accounting purposes, so there's just not floating transfers of money going out without being connecting to money coming in.
I think it's basically to make sure that any outgoing transfer is connected to an incoming source of money (so like credit/debit transactions)
The whole transaction should be grouped (invoice/payment in then transfers/payouts out)
Yes, I think what you said is the whole point of the transfer_group -- it allows the system to connect the transfers back to the original incoming payment intent.
If it was just one, I could use the builtin payout mechanism to do it automagically.
Gotcha, so for the transfers you set that when the transfers are created: https://docs.stripe.com/connect/separate-charges-and-transfers?platform=web&ui=elements#create-transfer
For the payment intent, you can't set this via the invoice API, you'd need to update the invoice-associated payment intent(s) after the fact
Yes, I know that part. What I don't know is how to set the transfer_group on the payment intent attached to the invoice when the invoice gets created.
Ok, so how do I get it after the invoice is created?
Is there some method by which I can summon the payment intend by using the invoice id or something?
Yes, you can either retrieve the invoice using expansion to get the payments
https://docs.stripe.com/api/invoices/object#invoice_object-payments-data-payment-payment_intent
Or you can list the Invoice Payments by invoice ID: https://docs.stripe.com/api/invoice-payment/list#list_invoice_payments-invoice
Ok, does that work before the invoice has been paid? i.e. it's just payment intents?
so I create the invoice, add all the line items, then get the payments -- and the payment intent will be there?
if i recall, the managed payment intent is created when you finalize the invoice
ok, so after finalization, got it. ok, so the flow is create invoice->add line items->finalize->fetch payments->update transfer group->pay invoice
Yep, though i expect you would also be able to update the payment intent after payment to set that group, but you should verify that
i'll likely just do it before to be safe, but thanks for the extra info
ok, I'll give this a whirl -- how does the chat thing work, can we keep this open for a bit so I can confirm if it works or not before closing?
yep we can keep this open for a bit while you test, keep us updated
will do, appreciate the help
ok, so tried the flow we discussed, got an error:
now I'm trying it before I finalize the invoice
ok, so looks like the payment intent does not exist before you finalize the invoice
hi there, sorry for the delay, looking into this now
no problem, figure you guys are busy
ah, were you able to make it work after you finalized the invoice?
nope, that did not work
got it, one moment
after the invoice is finalized, I get that error, before the payment intent does not exist
unfortunately this does seem like a limitation on Payment Intents created by Invoices
ok, so I was reading through the docs and an alternative might be to use the source_transaction on transfers and just link the transfer back to the payment
so that will likely work fine, weird that the transfer_group thing is limited, but I appreciate your all's help on this.
sure thing. you might also look into setting metadata on the invoice if the goal is to just have some data associating it with subsequent transfers
that's a good idea, thanks