DEV Community

Cover image for Implementing payments on a Monday
Thomas Hansen
Thomas Hansen

Posted on

Implementing payments on a Monday

Some few years ago I worked for an (undisclosed) company in Cyprus. We had a dedicated software developer exclusively working on payments, and I was supposed to take over his job. The payments module contained some 50,000+ lines of code, and was a mess of Biblical proportions. For the record, the thing supported like 20+ different payment providers, and withdrawals in addition to deposits, but it was scattered with things like Sleep(30000) (to wait for the payment provider to invoke our web hook before continuing execution of some endpoint, seriously! I am not kidding!), in addition to God knows what more. In case you missed the point, let me type it out for you in code ...

// Waiting for payment provider to invoke web hook.
System.Threading.Current.Sleep(30000);
Enter fullscreen mode Exit fullscreen mode

Occasionally the thing would even work ^_^

I begged my manager to allow me to rewrite it, without success. Even after I could prove by looking at our logs that 25% of all payments were simply rejected because our web server was too slow because of all the above Sleep invocations, and other weird parts (Microsoft Workflow Foundation anyone? Remember that one?), I still weren't allowed to rewrite it. This was a monster web server, serving about 500-1,000 payments per day, and we had to create a daemon on it to reboot IIS during the night because of all the memory leaks and socket leaks resulting in that once every 24 hours the thing would become completely locked up and dysfunctional.

I replaced him in 10 hours with Hyperlambda today

Today I implemented Stripe subscription payments, and yes, I mean today. I started around lunch time, and it's 11:29PM now where I live, and fundamentally the thing is more or less done. It consists of about 377 lines of code, and besides from one or two nice to have features, such as web hooks, that I'll probably do later, the thing is more or less done.

Of course, I only did the backend integration, and once it is set into production, and you can use it to pay for cloudlets, the only reason why it'll be truly awesome, is because of my amazing team members; Shirin creating the frontend, Mohsen ensuring it runs in a super secure and stable K8s cluster, and Mo having created an amazing flow and design for the thing, and probably Sharvin having had some "marketing objections" towards how the flow ends up I assume.

However, I want to emphasise that the thing we had a dedicated full time software developer for at one of my previous companies, working 40+ hours per week, for 2.5 years (he had been there for 2.5 years), I did on a Monday using Hyperlambda. And before you ask, the guy had 20 years of experience as a software developer, and he could recite every single software development "best practice" by heart, such as SOLID, Design Patterns, Micro Service, DDD, etc, etc, etc ...

Need subscription payments?

Get a (free) cloudlet here, go to the plugins section, and install the "Stripe module". Screenshot below.

Stripe subscription plugin

Yup, not only did I create the thing on a Monday, but I also open source licensed it, and uploaded it as a dynamically installable plugin in Magic. Once installed, it'll create its own database automatically, and you'll have endpoints to both accept credit card information, pass it on to Stripe, for then to process subscription payments - Implying automatic payments deducted from your users accounts' in a recurring fashion. And it doesn't store credit card information locally, so no needs to worry about PCI compliance ...

Why am I writing this?

Because of my favourite word; KISS, and my favourite programming language; Hyperlambda. KISS means "Keep It Stupid Simple", and is an axiom I wish more software developers would follow. However, it's like an evolutionary local optimum, where instead of simplifying stuff, they ask themselves how many useless buzzword technologies can I stuff into this project to ensure my CV becomes more valuable?

And I'm quite frankly tired of this way of creating software. Simply for no other reasons, than the fact of that when sh*t hits the fan, and everything breaks down, they hire somebody like me to try to clean up the mess, and of course at that point the only way to salvage the project is to apply SHIFT+DELETE refactoring on it ...

I love this Erik Naggum rant where he goes all in on Perl, so let me rewrite it slightly to become more modern to prove a point ...

The inexperienced developer had one problem. "I know he said, I'll just use SOLID, OOP, and Design Patterns." The inexperienced software developer now has 4 problems ...

Please, do me a favour use Hyperlambda. I'm the guy who'll inevitably at some point have to clean up your mess ... :/

Discussion (7)

Collapse
maxfindel profile image
Max F. Findel

Thanks for the article Thomas. I also implemented Stripe in a Rails project recently using the official gem and it was a breeze 👌
I'm curious, what do you think about using Supabase + Stripe instead of Aista? And how about Strapi + Stripe plug-in? I was looking at your product and I find it to be a more enterprise level CMS, CRUD generator and integrator of sorts 🤔

Collapse
polterguy profile image
Thomas Hansen Author • Edited on

Thank you Max. It depends upon what you're creating. If you're happy with GraphQL and Postgrest, go for SupaBase by all means, if you need more, such as business logic in your backend (to avoid scattering business logic in your frontend - Sigh!) then SupaBase (and others such as Hasura) can't help you much.

I suspect it's about your requirement for "horizontally integrated solutions" that would be the trigger here in the end. As to your observation about Magic being more enterprise level, I'd have to agree upon that ... ;)

Collapse
maxfindel profile image
Max F. Findel

Thanks for the answer, Thomas. I think I understand the charm of Aista a bit better now 🙂

Collapse
polterguy profile image
Thomas Hansen Author

Psst ... ^_^

Collapse
mshafiey profile image
Mohsen

I always think on it , when an algorithm is x - y - y - z , your code also can be x - y - y - z why people emphasis to do it complex ? I love your method Thomas

Collapse
mshafiey profile image
Mohsen

I always think on it , when an algorithm is x - y - y - z , your code also can be x - y - y - z why people emphasis to do it complex ? I love your method Thomas.

Collapse
polterguy profile image
Thomas Hansen Author

Thank you Mohsen. It's quite sad our profession has turned into a competition of "how to make things complex", when fundamentally it's really quite simple :)