#newtreyes
1 messages ยท Page 1 of 1 (latest)
Hi @eternal egret
HI ๐
Taking a look
Thank you, Sir
The transfer refunded the entire amount. The application fee is deducted from the amount on the Connect Account's end so it's actually in the amount_refunded.
Here's the funds flow for destination charges with application_fee_amount. https://stripe.com/docs/connect/destination-charges#flow-of-funds-app-fee
I think it just doesn't map well to the fields in the Charge
Now, the thing is that I am seeing this behavior "randomly" appearing when refunding
Let me show you another example where we requested the same thing but the application_fee amount_refunded was not 0
Okay
Request: req_nrqxb3dw3Bmy4H
Refund: re_3NqN3sLNS7fsUd0U1zud4trz
Charge: ch_3NqN3sLNS7fsUd0U1cjN17Kt
Again, we are requesting the application fee to be refunded but in this case, amount_refunded is what we were expecting (59)
We noticed because this random behaviour is breaking some integration tests on our side
We have like 2 or 3 tests that are checking for this field and we noticed that they were randomly failing.
Are we missing something silly?
That is interesting. I don't see the application fee refunded in either case
Right, I don't see any difference on my end
Funny thing is that these tests randomly fail when executed from Github Actions but they run fine from my local environment
Hmmm... ๐ค
So you are saying the application_fee property, when expanded, shows a different amount refunded between the two charges?
Yes
And I am seeing this random behaviour consistently
Every time github actions runs those tests, at least one of them fails because the amoun_refunded is 0
which is not what we are expecting since we are requesting the application fee to be refunded in all cases
The application fee is also the same as the Stripe fee. I'm wondering if that has something to do with it
Is there any way to tell if the application fee was refunded other than this field?
This should be the canonical resource on your end. I'm trying to find the right team to ask.
Thank you, Sir
@thick cypress Hello, Sir
Hello! Just getting caught up here. How are things going?
Both of the application fees show as refuned on our end. If you retrieve the Charges in question from the API now do you still see the discrepancy? Wondering if this might be a race condition of some kind where you're refunding and the retrieving before we can reflect the fee on the application_fee you're expanding?
Ah, nope, that's not it. Hang on, still investigating...
This seems like a bug on our end where we're not properly rendering/reflecting the current state of the application fee in the API for some reason. Still investigating though.
Yeah, this seems to be an issue on our end. We're pulling in more people to look now.
Thank you
We're working on this now, but don't have an ETA for resolution yet.
I see
@unreal vortex If you're still around, wondering if this is a recent issue where you're seeing this happen a lot suddenly?
We're trying to determine if this is a rare but longer term issue or if it's a less rare very recent issue?
Give me a min
Mmmm... I don't remember the last time we ran these integration tests but I think it was less than a month ago
Let me check
Nope... it was 2 months ago
Back then, this was working flawlessly
Do you know how many Charges/Refunds/Application Fees had this issue when you most recently ran the tests? Was it just one or several?
Also wondering if you can share your code that produces the issue? We're having trouble reproducing on our end.
We have 2 tests that check this
They have been failing randomly since 4 hours ago
I can share some code, but it's going to be specific to our integration
assert resp is not None
assert 'id' in resp.json
customer_id = resp.json['id']
card_id = resp.json['default_source']
# Creating and capturing payment intent
amount = 1000 # $10 USD
total_fee = round((amount * 0.029) + 30) # 2.9% + 30c = 59c
data = {
"amount": amount,
"currency": "usd",
"capture_method": 'automatic',
"confirm": True,
'customer': customer_id,
'payment_method': card_id
}
resp = client.post('/v1/s/payment_intents', data=data, headers=account_headers)
assert resp is not None
assert 'id' in resp.json
assert 'connected_account_id' in resp.json['metadata']
assert 'status' in resp.json
assert resp.json['status'] == 'succeeded'
charge_id = resp.json['charges']['data'][0]['id']
# Now let's refund the charge
refund_data = {
'charge': charge_id,
'refund_application_fee': 'true'
}
resp = client.post('/v1/s/refunds', data=refund_data, headers=account_headers)
assert resp is not None
assert resp.status_code == 200
assert 'id' in resp.json
refund_id = resp.json['id']
# Let's make sure the refund is on the LinvioPay side
resp = client.get(f'/v1/s/refunds/{refund_id}', data={}, headers=account_headers)
assert resp is not None
assert resp.status_code == 200
assert resp.json['id'] == refund_id
# Assert Application fee refund
resp = client.get(f'/v1/s/charges/{charge_id}', query_string={'expand[]': 'application_fee.refunds'},
headers=account_headers)
assert resp.json['application_fee']['amount_refunded'] > 0```
The last line is where it is failing
This code is using a thin layer on top of the Stripe API which we call the LinvioPay API
To sum it up: we create a charge, we refund it and then we assert that the fee was refunded.
Those steps are executed very fast
so it may very well be a race condition
It's not a race condition. I pulled the fee with the incorrect refunded amount from the API recently and it still shows 0, and still shows as not being refunded.
Thank you for that detail!
Well, I guess it could somehow be a race condition during the refund that gets things in the wrong state at that point. But it's not a race condition on the read part.
Yes, I agree it's not a race condition when reading
Initially, I tried to delay the reading or retry it but then I checked using the API and the value was still 0
So, it's probably something else... maybe a race condition when writing the values
Anyhow, thank you so much for all your help so far
Hi @unreal vortex I'm taking over this thread, let me know if you have any follow-up questions