Article Image

MLabs Functional Programmers Help Juspay Secure India Ecommerce

January 14, 2023

Ecommerce in India is growing at lightning speed. As consumers and businesses move online at an impressive rate, streamlined payment services are smoothing the transition to a digital India.

Fintech juggernaut Juspay is a leader in the space and a household name. The payment services provider has championed key innovations, like a payments browser and one-click payments.

In so doing, the company quickly came to a realization. Functional programming languages such as Haskell and PureScript are imperative for robust, secure solutions.

Ecommerce in India

India has long been a cash-driven society. However, in an age of growing smartphone penetration, the government's Unified Payments Interface (UPI) has paved the way for the widespread digitization of the economy.

Briefly, UPI is a real-time payment system for use on mobile platforms. The incorporation of a Virtual Payment Address identifier allows consumers to orchestrate several bank accounts as they organize push-and-pull transactions among merchants.

  • India: historically cash-driven
  • UPI (Unified Payments Interface)
  • RBI: Covid spearheaded electronic payments - "war on cash"
  • Digital payments: 60% CAGR
  • Juspay: simple merchant infrastructure

While UPI implies opportunities, systems are required to maintain consumer privacy and security while avoiding costly downtime.

Cue Juspay

The 2012 startup specializes in the intermediary solutions needed by such a widely-scoped project.

As Juspay CEO Vimal Kumar explains, these types of solutions help consumers realize their 10x potential.

Juspay, Haskell, and PureScript

Naturally, security is paramount for a payment processor like Juspay. Minor mistakes and buggy implementations lead to unduly blocked purchases or, even worse, millions of dollars lost instantly to fraud.

Indeed, bugs can be catastrophically expensive. Complexity is often the source of errors and must therefore be limited. Vimal Kumar explains why PureScript and Haskell were important to Juspay early on:

There are a lot of workflow systems that try to model business logic, but they are not composable across systems like with Haskell. The whole approach of composing your business model from reusable building blocks is not at all solved in our industry. There is a lot of fragmentation across application architectures. Yet, a lot of what we see in terms of frontend, backend, persistence, services integrations, and analytics can be unified with very few primitives.
Vimal Kumar (Founder & CEO, Juspay)

And this is where functional programming — and flow monads* in particular — shine.

*A flow monad is a specific design pattern used to represent control flow in a program. It allows developers to chain a series of steps that need to be executed in a specific order while handling errors and exceptions that may occur in the process.

Gaining 10x with MLabs

In fintech applications, data is often communicated across disparate pieces of infrastructure (website, payment gateway, merchant processor, etc.) using an encoding scheme like JSON. Ergonomic and efficient encoding reduces a system's complexity and helps guarantee safe usage.

With security top of mind, Juspay turned to MLabs to develop its crucial application architecture.

In only two months, the MLabs team was able to specify, design, and implement Medea, a JSON schema language streamlined for payment processing. The simple and efficient library is self-contained. It ensures payment data is correctly typed so that transactions are securely validated and processed.

Yet, a scalable and robust system design is required for Medea to provide real-life results. MLabs also designed a framework for payment gateway provider services. This involved interacting with several data stores (Postgres, Kafka, and more) and transpiring massive amounts of PureScript into Haskell.

Services employed

Database Framework Design — Juspay leveraged MLabs to design crucial architecture and to reimplement numerous services.

Technical Specification — MLabs designed a technical specification for both the Haskell and Purescript implementation of the Medea library.

Product Integration — MLabs integrated Medea and a redesigned architecture into Juspay's services for massive speed improvements.

MLabs and Juspay Partnership Milestone

  • Medea: MVP ~2 months
  • Ported ~65k lines of JS to Haskell
  • Redesigned database framework
  • Dramatic speed and reliability improvements
  • One of the most significant Haskell use cases to date

Juspay Today

Today, Juspay is a crucial payment services provider as India introduces residents to online finance. Juspay processes over 20 million transactions daily on over 250 million mobile devices.

  • 20 million daily transactions
  • 250 million mobile devices
  • Several raises after working with MLabs
  • 2020: $21.6 million Series B
  • 2021: $60 million Series C

Working with MLabs, Juspay secured its position as an industry leader in a rapidly modernizing payments ecosystem. It is trusted by Amazon, Axis Bank, Yes Bank, PharmEasy, and several other major firms.

Connect with MLabs Today and Schedule Your Free Consultation.

3 Wharfside Street

Spaces Level 1 The Mailbox


United Kingdom

Privacy Policy

© Copyright 2022 MLabs