#rohan_code
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/1343996936763609193
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- rohan_api, 50 minutes ago, 17 messages
I also get the following client-side error when running inside a Cypress test: IntegrationError: lightbox Element didn't mount normally. I don't think I see this error outside Cypress
Hi! I don't think that error is a Stripe error.
I don't think that CashApp supports Cyprus?
Customer locations
US customers (excluding accounts in US territories).
Sorry, not Cyprus the country—Cypress the testing framework
Bahahaha
Weeeeeee
That's what I get for switching to farming for a few years. 😂
Unfortunately I'm totally unfamiliar with Cypress the testing framework - I have reasonably good familiarity with the tree though - so I'm not sure I (or my colleagues) will be of much help with this.
Remind me: what's the outcome you're looking for that you're not seeing exactly?
hahaha
I'm trying to get the cashapp flow tested in cypress, but Cypress doesn't handle stuff opening in new tabs well, so I'm trying to simulate the mobile flow, which should open the payment simluator in the same tab
so I'm trying to figure out how to get Stripe to think we're in mobile, so it opens the redirect
That might actually be a different tab on a mobile device - the really really old version of Checkout was.
hm, okay. let me try it on my mobile device, one sec
I've been doing it in the desktop simulator
yeah, it looks like it works on my phone
so how can I mock the user agent to get it to work on desktop inside Cypress?
ok catching up on this thread - it sounds like your question is how do you mock the user agent to mobile for testing purposes?
yes, exactly, within a cypress test specifically
(sorry, I know this is a little outside the usual ambit, just wondering if y'all had seen something like this done before)
hmmmm. yeah, like my colleague suggested earlier i don't know if this is something we'll be able to help you with since it's pretty specific to cypress
do you know how the stripe client detects whether it's on mobile for the app redirect? maybe I can work backwards from t here
i have used cypress as a testing framework (in a past job) but i haven't had to deal with mocking user agents specifically. so the best i could do is co-google with you and go stack overflow spelunking 😛
haha
that is a good question, let me see if i can figure that out
sweet, ty
I'm also getting this weird "lightbox Element didn't mount normally" without any other context, so if you know what that is / where t hat's coming from, that'd be really helpful haha
do you have any example request IDs from this?
let me check
i can try to look some up too. wondering if i can just check what user agent header we're seeing
actually i just realized i don't have your account ID. so yeah a request ID would be helpful
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
ope one sec
let me grab the req id
i can get it from there actually
cool cool
here's the confirm request:
https://dashboard.stripe.com/test/logs/req_2gKnatyO7Lzh2F
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.137 Safari/537.36
so yeah i think the user agent isn't being overwritten. when i was first googling this i read that user agent stuff in cypress can be a little finicky so i bet that's related
do you know how it grabs the user agent? navigator.userAgent is set correctly when I debug
in theory
let me double-check
Mozilla/5.0 (iPhone; CPU iPhone OS 17_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Mobile/15E148 Safari/604.1
^this is from navigator.userAgent
hmm ok
let me see if this is something other people on my team have run into in the past
amazing, thank you so much!
ok no luck so far
have you tried just doing a manual test over-riding the user agent string? e.g.
https://developer.chrome.com/docs/devtools/device-mode/override-user-agent
ok cool
do you have a request ID from that? or a payment intent, either works
just so i can sanity check it
but yeah this is leading me to think that this is a cypress specific question / problem
ok yep! i'm seeing Mozilla/5.0 (iPhone; CPU iPhone OS 18_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3 Mobile/15E148 Safari/604.1 on that one
so the good news is changing the user agent works, the bad news is that means it's something cypress specific that's going on here so we probably can't help you any further
one of my colleagues also just pointed out that we typically recommend mocking when doing client side testing, so that's something to consider here too
https://docs.stripe.com/automated-testing#client-side-testing
hm, okay cool
one more question about this
is there a programmatic way of confirming / capturing an async payment?
👋 solanum had to step away but I can help
is there a programmatic way of confirming / capturing an async payment?
you mean purely server-side?
yeah, exactly
like the programmatic equivalent of clicking "Authorize test payment" in the simulator UX
Unfortunately, no.. I don't believe we have any automated way to simulate redirect based payment methods.
We typically recommend making a test payment in test mode and using that response to mock out your automated tests.
hm, okay. in this case, because I'm using stripe.js, what exactly should I be mocking for an end-to-end test? we have mocks for unit tests, but in this case I'm trying to get as close to real user behavior as possible
Hmm instead of hitting Stripe's API endpoint, you could hit your own endpoint that returns a mocked json?
what endpoint does confirmCashappPayment hit?
hm, okay. the problem is that when I mock that, the confirmCashappPayment function still loads the QR code UX in an iframe, instead of redirecting to the simulator page (like it does on mobile)
can I override that behavior somehow?
Don't think so, I think that's just the default
General recommendation is that you don't really invoke Stripe.js functions in tests
https://docs.stripe.com/automated-testing#:~:text=Modify your tests to return this error object instead of calling Stripe.js functions and the Stripe APIs. You can use different test cards to generate errors with different error codes to make sure your application properly handles each type of error
You esentiall mock the errors and make sure that your code is able to handle it
hmm, okay
one more thing: do you know what this error means? IntegrationError: lightbox Element didn't mount normally.
there doesn't appear to be any additional context, and it only happens inside the cypress runner
Not sure. Possibly some Stripe.js error about it detecting some abnormality with Elements object (given it's running in test suite env)
alright, cool. got it to work, thanks so much!