#orange_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/1502258091637346304
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
const { connected_account_id: connectedAccountId } = connection;
const stripeRefund = await stripeSDK.refunds.retrieve(stripeRefundId);
if (!stripeRefund.transfer_reversal) {
return;
}
const balanceTransactions = await stripeSDK.balanceTransactions.list({
limit: 1,
source: stripeRefund.transfer_reversal,
}, {
stripeAccount: connectedAccountId,
});
const balanceTx = balanceTransactions.data[0] ?? null;
if (!balanceTx) {
return;
}
const connectedPayoutId = balanceTx.payout ?? null;
const payoutArrivalAt = balanceTx.available_on
? moment.unix(balanceTx.available_on).format('YYYY-MM-DD HH:mm:ss')
: null;
This is what the code looks like
hey there ๐ just to confirm, are you aiming to get the ID of the payout associated with the original charge which was refunded?
or do you want to get the ID of the payout associated with the refund itself?
the ID of the payout associated with the refund itself
I already have the payoutIDs for payment Intent
ok, and it sounds like you're using destination charges - is that right?
could you share an example of a refunded PaymentIntent so I can check the logs and understand your flow?
you mean like a refundID? Or paymetnINtent
either a refund or payment intent ID would be perfect
For example this one
refundId: re_3TNvjOBaRfwWelZy0kaJVRFt
paymentIntentId: pi_3TNvjOBaRfwWelZy0uFAxaZs
perfect, thanks - taking a look
Thank you
so yeah, as you mentioned, when you call /v1/refunds with reverse_transfer: true, your response will include a transfer_reversal value (trr_xxx)
https://docs.stripe.com/api/refunds/object#refund_object-transfer_reversal
you can get to the associated balance transaction (txn_xxx) by checking the balance_transaction property on the transfer reversal
https://docs.stripe.com/api/transfer_reversals/object#transfer_reversal_object-balance_transaction
from there, linking to the exact payout is a little tricky since there's no payout property on the balance transaction object
but there's a way to achieve it
the balance transaction contains a property called available_on - this is set to 00:00 UTC on the day that the funds are supposed to be attributed to a payout
https://stripe.com/docs/api#balance_transaction_object-available_on
you can then use the List Payouts API to get any payout created for that day, by passing arrival_date[gte] set to the available_on property, and arrival_date[lte] set to the next day
this is easier to do in reverse (i.e. 'check which transactions are included in a specific payout'), by calling List Balance Tranasactions and passing a payout argument
https://docs.stripe.com/api/balance_transactions/list#balance_transaction_list-payout
but unfortunately, this is only possible when starting with the payout ID - there isn't a neat way to go from 'Balance Transaction > Payout'