#shammah-ach
1 messages · Page 1 of 1 (latest)
heya @paper hedge! I assume you're referring to ACH Direct Debit. You'll need to retrieve the Charge using : https://stripe.com/docs/api/charges/retrieve
and you should be able to view the correspond refund and it's details : https://stripe.com/docs/api/charges/object#charge_object-refunds
This thread has been archived. If you need help with anything else please ask in #dev-help or contact Stripe Support: https://support.stripe.com/contact
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
@paper hedge I've reopened this thread for you!
Thank you
I'm using a destination charge, so there was a transfer and a transfer reverals. I'm trying to figure out where the balance_transaction is for the actual bounced payment.
Refunds list on the original charge that failed is empty:
refunds: {
object: 'list',
data: [],
has_more: false,
total_count: 0,
...
}
It seems like the only way to do this is to get all the balance transactions, look at the sources, if it's a refund, look at the chargeId, make your own map and go from there. But this is not a great solution
Do you happen to have a failling ACH charge handy? I'm not the most familiar with the reversal in this situation, and looking at an example will help
Yes.
This is the API call I'm making:
const transfer = await stripe.transfers.retrieve('tr_3JmgpcAN9UGzw70g0kwwAh0o', {
expand: [
'source_transaction',
'source_transaction.balance_transaction',
'reversals',
'balance_transaction',
'destination_payment',
'destination_payment.balance_transaction',
'destination_payment.refunds',
],
});
And here's the balance_transaction for the failed charge: txn_1JmPHLAN9UGzw70g8aH6t4qT
I'm trying to find the balance_transaction on the subaccount associated with the transfer_reversal for the failed payment
destination charges have been nice, but ensuring money is returned on failed charges and refunds seems rather confusing
@paper hedge so what's blocking you exactly?
Like when you retrieve that Transfer, you should see the reversals collection, and that has the trr_123 with destination_payment_refund in it with all the BTs you want
It shows the subaccount BTs, but not the platform account bts for the charge failure
expand: [
'source_transaction',
'source_transaction.balance_transaction',
'reversals',
'balance_transaction',
'destination_payment',
'destination_payment.balance_transaction',
'destination_payment.refunds',
// Expand the refund info on the connected account for the reversal
'reversals.data.destination_payment_refund'.
],
});```
and then transfer.reversals.data[0].destination_payment_refund.balance_transaction
Let me try it; I don't think that's the balance transaction on the platform account though. I was looking last night at that. Let me double check
I'm sorry, there are 10+ objects involved here, they each have a balance transaction. What BT do you need? If you want the Transfer Reversal's BT (the trr_123) you want transfer.reversal.data[0].balance_transaction in that case
I'm trying to find: txn_1JmPHLAN9UGzw70g8aH6t4qT and map it to the corresponding balance_transaction on the subaccount. It looks like I need to go through destination_payment_refund on transfer reversal
txn_1JmPHLAN9UGzw70g8aH6t4qT is the BT on the connected account already right?
No, it's the platform account
It looks like going through the destination_payment_refund gives txn_1JmPHMCTez1W7Fj0zrbVHukM as the subaccount balance transaction associated with txn_1JmPHLAN9UGzw70g8aH6t4qT But this still has the issue of this how can I be sure that txn_1JmPHLAN9UGzw70g8aH6t4qT (given that there are possibly multiple reversals) that it's the right one.
Does that make sense?
It doesn't really make sense I'm sorry
1 second, let me post the code
Like there are many objects, but every object is liunked to each other
you have to understand each object is like a box with a pointer to another object and some have points back
assert(typeof transaction.source !== 'string');
assert(transaction.source?.object === 'refund');
assert(typeof transaction.source.charge !== 'string');
assert(typeof transaction.source.charge?.transfer !== 'string');
console.log(transaction.source.charge?.transfer);
for (const reversal of transaction.source.charge?.transfer.reversals.data) {
const refund = await stripe.transfers.retrieveReversal(reversal.transfer, reversal.id, {
expand: ['destination_payment_refund'],
});
console.log(refund.balance_transaction);
}
Transfer Reversal trr_123 -> destination_payment_refund -> Refund pyr_123 -> source_transfer_reversal -> Transfer Reversal trr_123
That last refund.balance_transaction (in this case) is the one I want, but if there are multiple transferReversals how can I be sure?
I don't know why you talk about a last one while retrieving the Transfer unfortunately
console.log(refund.balance_transaction);
In the code I posted
There's only one reversal in this case.
Let's pause for a second and take a step back. What are you really trying to achieve? What is causing you to call https://stripe.com/docs/api/transfers/retrieve at that specific point? Why don't you track the BTs when you explicitly reverse things?
I didn't explicitly reverse this transaction afaik
It happened because it was a destination charge*
Okay, so what makes you call https://stripe.com/docs/api/transfers/retrieve exactly? Is it because you get the https://stripe.com/docs/api/events/types#event_types-transfer.reversed event? What's the context? why would you expect multiple reversals in this world?
I am not doing it in a webhook. I'm trying to find the stripe fees and metadata on the platform account that would be associated with the reversal on the subaccount. So I need the associated platform balance_transaction for the a subaccount txn of txn_1JmPHMCTez1W7Fj0zrbVHukM
I'm trying to find the stripe fees and metadata on the platform account that would be associated with the reversal on the subaccoun
I don;t understand those words. What Stripe fees? what metadata?
id: 'txn_1JmPHLAN9UGzw70g8aH6t4qT',
object: 'balance_transaction',
amount: -153500,
available_on: 1634774400,
created: 1634676683,
currency: 'usd',
description: 'REFUND FOR FAILED PAYMENT (Invoice 071E2135-0039)',
exchange_rate: null,
fee: -100,
fee_details: [
This fee
txn_1JmPHMCTez1W7Fj0zrbVHukM has no fees associated with it.
But there seems to be no direct paper trail between txn_1JmPHMCTez1W7Fj0zrbVHukM and txn_1JmPHLAN9UGzw70g8aH6t4qT
sorry it's so hard to follow with just small bits of info like this. Not your fault at all, there are just dozens of objects to keep track of and without seeing what you see it's hard
Maybe if I explain the use case?
What I do, personally, is that I expand every single object in one call and I dump the entire formatted JSON and I cmd+F
Our particular use of stripe connect is a little unusual
which you haven't seemed to have done
But I will just write you an example that will be easier
I did do that. My point is that the association is 1->M even though there is a unique refund on the subaccount
transaction.source.charge?.transfer.reversals is a list
My point is that the association is 1->M even though there is a unique refund on the subaccount
as far as I know that is not the case at all
This is the balance_transaction associated with the transfer_reversal: txn_1JmPHMAN9UGzw70gLJiP9jt1 But there is also another balance transaction that goes back to the customer.
transaction.source.charge?.transfer.reversals this is one transaction, but there are multiple transfer reversals possible
This balance_transaction is also not associated with a specific reversal:
{
id: 'txn_1JmPHMAN9UGzw70gLJiP9jt1',
object: 'balance_transaction',
amount: 153500,
available_on: 1634774400,
created: 1634676684,
currency: 'usd',
description: 'REFUND FOR TRANSFER',
exchange_rate: null,
fee: 0,
fee_details: [],
net: 153500,
reporting_category: 'transfer_reversal',
source: 'tr_3JkrFgAN9UGzw70g2exPLyTp',
status: 'available',
type: 'transfer_refund'
}
Neither of the two platform balance_transactions have a linkage (as far as I can see) to the balance_transaction associated with the reversal on the subaccount (txn_1JmPHMCTez1W7Fj0zrbVHukM)
I'm asking if, and how to find that. I can't see a 1-1 link anywhere.
give me a few minutes please, I'm write code because this is not working
it will take me a while but it should help
Okay, thank you
@paper hedge ```const transfer = await stripe.transfers.retrieve(
'tr_123',
{
expand: [
// Transfer's BT
'balance_transaction',
// Original Charge's BT from what create the Transfer
'source_transaction.balance_transaction',
// Connected account's charge's BT (result of the Transfer)
'destination_payment.balance_transaction',
// Refund's BT associated with that specific transfer reversal
'reversals.data.source_refund.balance_transaction',
// Connected account's refund associated with that specific transfer reversal
'reversals.data.destination_payment_refund.balance_transaction',
],
}
);
console.log('Transfer id: ', transfer.id, ' - BT id: ', transfer.balance_transaction.id);
console.log('Original charge id (source_transaction): ', transfer.source_transaction.id, ' - BT id: ', transfer.source_transaction.balance_transaction.id);
console.log('Connected account's charge id (destination_payment): ', transfer.destination_payment.id, ' - BT id: ', transfer.destination_payment.balance_transaction.id);
var reversals = transfer.reversals.data;
console.log('Now looking at all reversals: ', reversals.length, ' total');
for(i = 0; i < reversals.length; i++){
console.log('Transfer Reversal id: ', reversals[i].id, ' - BT id: ', reversals[i].balance_transaction.id);
console.log(' * Original Refund id (source): ', reversals[i].source_refund.id, ' - BT id: ', reversals[i].source_refund.balance_transaction.id);
console.log(' * Connected account's refund id (destination_payment_refund): ', reversals[i].destination_payment_refund.id, ' - BT id: ', reversals[i].destination_payment_refund.balance_transaction.id);
}```
can you try this ^ ?
Yes, let me look
There is no source_refund on the transfer reversal
This is for an NSF. There's no refund to the customer, but there is a balance_transaction for removing the funds from our account.
Ah, okay, so that seems to be the misunderstanding in that case. You basically have the transfer reversed with no link to the refund. So now, what is missing in the list of things I printed?
you're right that ACH failures are complex unfortunately and this change a few years ago which that change: https://stripe.com/docs/upgrades#2019-05-16
Can you share the whole output of my script as a gist or something? That way I can load it and we keep the real ids out of discord and later you can delete
Yes, give me a bit.
Transfer Reversal id: trr_1JmPHMAN9UGzw70gK7idn25y - BT id: txn_1JmPHMAN9UGzw70gLJiP9jt1
* Original Refund id (source): null - BT id:
* Connected account's refund id (destination_payment_refund): pyr_1JmPHMCTez1W7Fj06OhsbCg5 - BT id: txn_1JmPHMCTez1W7Fj0zrbVHukM
This definitely links txn_1JmPHMCTez1W7Fj0zrbVHukM to txn_1JmPHMAN9UGzw70gLJiP9jt1 which is helpful, but I need to have a way to find this balance_transaction on the platform account: txn_1JmPHLAN9UGzw70g8aH6t4qT
It's related to charge py_3JkrFgAN9UGzw70g2dZij8pW which has no refunds. There are transfer reverals, which is essentially the above information. But again, the reversals is a list with no way to tell which one would be associated with txn_1JmPHLAN9UGzw70g8aH6t4qT aside from the amounts.
I see, yeah it's because of that API version I mentioned, unfortunately in that specific case, it is impossible to link them beyond using the created 😦