Fork me on GitHub
#fulcro
<
2022-02-02
>
hadils00:02:23

I need some advice. Working on a vanilla Fulcro app (not RAD). I need to redirect out to a Stripe page and have it redirect back to my app. I am writing a progressive web app (PWA) so the Stripe page replaces my own. The redirect is complex, it requires front-end and back-end parts. I am thinking of using SSR but I need to know if this is the best or only choice I have. I am short on development time so I don’t want to introduce accidental complexity to my system. Any thoughts? Thanks in advance.

Jakub Holý (HolyJak)13:02:32

I would need a more detailed description of the needs. I do not understand how SSR fits into this. Do I understand you do not simply want to redirect the user to stripe servers but want somehow display the stripe UI inside your app? Anyway, when done, cannot stripe redirect back to http://your.app/return-from-stripe which goes to the back, it does its stuff, and then displays the application, which looks and the url and understand it needs some more stuff, and finally the frontend replaces the URL with just / using History API?

hadils15:02:07

Thanks for your reply @U0522TWDA. I don’t really understand the History API. I followed the instructions in the Developer’s Guide (not RAD) and I keep getting a 404 when redirecting. So my URLs are going to the server. How do I get URLs to be interpreted by the client first?

Jakub Holý (HolyJak)15:02:29

Requests always go to the server first

Jakub Holý (HolyJak)15:02:19

This 404 means your server side routes aren't configured correctly

hadils15:02:42

Understood.

Jakub Holý (HolyJak)15:02:19

Why would you want to process the redirect first on free fronted? It doesn't make sense to me.

hadils15:02:16

Ok. So my redirects will come back to the server. How do I get the server to render the correct page on the front-end? This is why I was considering SSR. But I am open to an easier way of doing it. I just don’t know how to get the server to render a page in my client.

hadils15:02:01

After Stripe is done with its page, I need to reload the client with the correct state…

Jakub Holý (HolyJak)17:02:19

Look at https://github.com/fulcrologic/fulcro-rad-demo/blob/develop/src/shared/com/example/components/ring_middleware.clj#L48 - the wrap-html-routes renders the app for ALL uris excluding just a few. Thus it would render the frontend and there you can look at the url to get the state (and later (.pushState js/history nil "" "/index.html") or similar to remove the state from the url.

Mateusz Mazurczak23:02:14

Hi did anyone here tried using fulcro with tdd? I wonder if it makes sense to write front end in this way at all

Piotr Roterski08:02:11

It’s whatever works best for you, but I think strictly followed TDD is IMHO mostly used as a way of getting fast feedback loop and in Clojure REPL-Driven-Development is more commonly used in its place. When programming with REPL you get all the immediate feedback benefits and it’s much easier to explore the problem-solution space with code. I find it much more suited for frontend development than TDD because how would you even test UI behaviour without seeing it first? Potentially you could do it for some parts of frontend (especially those data-defined declarative parts which Fulcro is full of), but it seems a bit backwards and harder than it needs to be. The downside of REPL-Driven-Development is that this exploratory code is often thrown away, but nothing stops you from converting it to tests later on and there’re a few ideas for making it super-easy like https://github.com/hyperfiddle/rcf to get the best out of TDD and RDD combination.

4
Jakub Holý (HolyJak)16:02:03

I was a strong proponent of TDD until I moved over to Clojure. Now I do explorations in the REPL. I still do TDD sometimes, namely when I am going to implement something non-trivial and have already a good idea of the desired behavior.

👍 2