How juspay/hyperswitch-web works
Project Type & Purpose
• Project Type: This is an open-source web unified checkout SDK that enables businesses to accept payments from multiple global payment providers. It’s built using a mix of Rescript (for core SDK components located in the “src” folder) and React (as seen in the “Hyperswitch-React-Demo-App” demo). It integrates with various external payment providers (e.g., Braintree, ApplePay, GooglePay) and incorporates custom logging and error boundary components.
• Purpose: The project provides a highly customizable, unified payment experience that supports a wide range of payment methods with deep theme customization, extensive integration testing (using Cypress), and robust logging for debugging and monitoring.
Analyzing the File Structure
• Top-Level Separation:
– “src”: Contains the core SDK components, utility functions, payment method implementations (Components, Payments, Styles/Themes, LocaleStrings, etc.), and logging/error capturing (hyper-log-catcher, hyper-loader).
– “Hyperswitch-React-Demo-App”: A demo application that illustrates the SDK integration in a React environment. It has its own server.js, build configuration (webpack files), public assets, and a Makefile.
– “aws”: Deployment and cleanup scripts for deploying to AWS.
– “cypress-tests”: Contains end-to-end tests (written in TypeScript/JavaScript) to simulate different payment workflows.
– Root-level configuration files (Dockerfile, .env, Husky hooks, GitHub workflows) show that CI/CD, Docker-based local development, and code quality/language tooling are integral to the project.
• Architectural Hints:
– The use of “src/Payments” with many payment method sub-components implies modular design (each payment method is encapsulated).
– The organized “Components” folder in “src” and “Hooks” indicate a front-end component-based architecture using both React and Rescript.
– The Dockerfiles and AWS scripts indicate readiness for containerized deployment and cloud hosting.
Insights from the README
• The README details integration steps, required environment variables, and emphasizes support for multiple payment methods.
• It instructs on setting up both the demo app and a local backend server. There is explicit mention of customizing themes, logging integration (using the Beacon API), and ensuring compatibility with external services.
• It highlights architectural concerns like modularity (e.g., separation of concerns between the SDK, the server backend, and the demo front-end).