-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Payment history] make refund receipts have correct dates when refunded directly via stripe #44127
Comments
Whoops! This issue is 2 days overdue. Let's get this updated quick! |
Eep! 4 days overdue now. Issues have feelings too... |
Still overdue 6 days?! Let's take care of this! |
10 days overdue. Is anyone even seeing these? Hello? |
12 days overdue now... This issue's end is nigh! |
@dangrous huh, not sure! Where did you do the refund from? Was it from supportal or the stripe dashboard? I think the date is only wrong when we refund directly via stripe, which is what the repro steps simulate. But I haven't tried repro-ing since I created this issue so maybe not. Can you try the repro steps and see if it reproduces? |
oh interesting. Yeah it was via supportal. If I have time today I'll try to go fully through the steps! It was giving me a bit of trouble on Friday but I've rebuilt since then so it's maybe better haha |
eyyy finally managed to reproduce. Looking into it now. |
Okay so it's this line: https://github.com/Expensify/Auth/blob/ce419dee8d3327b51569f728ce3da131b90f628b/auth/command/ProcessStripeWebhook.cpp#L198 Basically SComposeTime deals with usecs, not regular seconds, so it's not correctly parsing the date response from Stripe (i.e. it's saying 1000x less time has passed). I just need to figure out the right function to use to parse, I'm sure we have one in there. |
Technically can fix by multiplying the purchase date by |
ugh I would prefer not to have to create a third set of test accounts and real transactions on my real card for this. @trjExpensify any chance you know of a way we could just double check that any real refunds we're already sending out are appropriately timestamped? Check with concierge agents maybe? It should be all set, but I'd like to QA to confirm |
Hm, any manual refund requests should get a GH created to process by Conci. Doesn't look like we've had any new ones since this was deployed: https://github.com/search?q=repo%3AExpensify%2FExpensify+refund+request&type=issues So I think our best bet is to look for refunds in the logs probably, yeah?
Hope that helps! |
Ooh great, that's helpful! But shows that we might be using the wrong date here - the date of the charge, not the date of the refund itself. So, we're close, but no cigar (might not have noticed this testing since the date of the charge and the date of the refund were the same). @blimpich can you chime in on what we intended here? Asking because we specifically use |
Yeah, I think it's inaccurate to say "Refunded on X date" and that date not be the date of refund. So we should change that to the date refunded, as it's in the design doc. 👍 |
Not intentional, very much a mistake 🫠 |
Okay cool I'll see if I can spin up a fix for this shortly! I think we can just use |
I think |
okay that PR is up |
Once that's on prod I'll use your test steps @trjExpensify to see if we're good to go! |
Dope, we're deploying auth now, so shouldn't be too long. 👍 |
Looks like its deployed 🎉 |
doesn't look like we've processed a refund yet if I'm calculating UTC correctly. I believe we're shooting for something after July 18 6:40PM UTC and the last one we have is 2024-07-18 16:20:43. I mean hopefully we never need to refund anyone ever again and we NEVER KNOW semi-related - I would LOVE a toggle in log search to show times in local time. |
Move to the UK man.. for half the year you'll be on UTC. 😂 |
Good/bad news - still no new refunds, so can't confirm nor deny |
Okay so I found one - https://www.expensify.com/_devportal/tools/logSearch/#query=request_id:(%22393Ikb%22)+AND+timestamp:[2024-07-22T16:12:42.041Z+TO+2024-07-22T18:12:42.041Z]&index=logs_expensify-029493 Weirdly, the pdf refund is still saying July 1, which is particularly odd because neither the original charge (July 7) nor the refund (July 22) is on that date. I double checked the code though and there's pretty much no way that should have happened, with what I updated. @blimpich do you happen to know if the pdfs are separate code? Like, did I fix it for the email but not the pdf? I didn't realize that if so. Sorry this is dragging on so much. |
The issue is probably that there are three different ways of creating a receipt, and one of them is probably broken. The three ways are:
#2 & #3 use similar logic, but #1 is almost an entirely separate flow. This issue's reproduction steps focus on #1. I bet that refund was through #2 or #3. We'd need to create a refund locally via supportal or the request refund button to confirm that hypothesis, but that is my guess as to what is going on. And no apologies needed! I'm dealing with the same frustrations over in this PR. Niche billing code + notification QA is a recipe for a bad time 🫠 |
Oh okay I think I've figured it out, mostly - you're right. so for case 1, the notification is sent from from Auth, and we fixed that code. For both 2 (UserAPI::refundUser) and 3 (UserAPI::refundPurchase), the notification is sent from PHP. Both of those call UserAPI::createRefundReceipt which basically makes the same mistake that we did - they pull the created date of the original purchase, NOT the refund, and use that as the refund date. I think this might be an Auth bug - I think it should be sending back the purchase ID of the refund, not the original purchase.... BUT I'm not sure if there's other code relying on it so to be safe I'll see if we're already sending the refund date somewhere else, and use that rather than changing what Auth sends. |
I will have to figure out how to fake those types of refunds on dev though, lemme know if you have tips. |
oh and it's always the first of the month when sent from PHP because for some reason we take the date, convert into just a month and year string (like |
Okay I made a draft PR - https://github.com/Expensify/Web-Expensify/pull/42878 Two questions for the room:
|
I think it'd be fine to create a new issue. Probably help keep us all sane. Maybe reword the issue title of this too to make it clear this is just for stripe refunds. I probably should've done that to begin with. For the second point, hmmmm, that's strange. I'll DM you, maybe we could do some paired programming? I know that I've tested those flows locally before, so I know its possible. |
great, made https://github.com/Expensify/Expensify/issues/415121, we'll continue discussion there As for this, we're still waiting on a Stripe activated refund to QA |
Okay so I've found a Stripe refund, but unfortunately the receipt link in the billing history links to the original receipt, not the refund. Is there another way to look at it? |
Did you look at the expenses view? If the refund went through correctly it should have made an expense with the receipt for the refund attached to it. |
that one looks like it didn't go through. BUT (drumroll please) I did find one that DID go through! Looks like it's working! Closing out. |
Oh yay!!! |
Problem:
Refund date is showing at Jan 1st 1970 on refund receipts.
Reproduction steps:
5
)script/clitools.sh billingrun
php script/notifyall.sh
from inside the VM in Web-Expensifyscript/bwm.sh
is running so that the subsequent BillingReceiptUploader job can completepurchases
table at the most recent purchase (should be the one you just made) and find thetransactionID
value. It'll be a hashed value, not the actualtransactionID
.YOUR_TRANSACTION_ID_HERE
with your actual transaction id that you got from thepurchases
tablenotifyall.sh
again and make sure bwm is still runningSolution
Investigate and fix this.
The text was updated successfully, but these errors were encountered: