How etsms/hosted-payments works
Project type and purpose
• This is a JavaScript/CSS library (“Hosted Payments”) that provides hosted payment UIs (checkout, e-shop, gift card, loyalty, general payments) to be embedded in merchant websites.
• The README shows it’s intended for browser integration via jQuery v3+, loaded from a CDN, then communicates with Elavon’s payment servers.
File structure
• Top‐level configuration:
• package.json, package-lock.json (npm)
• bower.json (Bower)
• gulpfile.js (build tasks)
• config.rb (Compass/SASS)
• Jenkinsfile (CI)
• Source directory:
• src/*.sass (one .sass per plugin flavor)
• Distribution directory:
• dist/*.js, *.css (minified plugins)
• dist/hosted-*.html (demo pages)
• dist/images
• Demo entry point: demo.html
• No backend code—pure client & build assets.
Extract architecture insights from README
• Library is consumed via <script> & <link> tags from jsDelivr CDN.
• Relies on jQuery as a peer dependency.
• On initialization, it renders iframes or fields that POST data directly to the hosted payment gateway.
• Callbacks return JSON success/error objects to the embedding page.
Main components
a. Developer environment (local machine, CI/CD):
• Source code (src/*.sass)
• Build pipeline (gulp, Node.js/npm, Bower, Compass)
• CI server (Jenkins)
• Output artifacts pushed to GitHub and CDN.
b. CDN & Artifact Storage:
• jsDelivr (serving hosted-payments.min.js & .css)
• GitHub Releases (versioned dist directory)
c. Client Browser (merchant site):
• Merchant’s HTML page
• jQuery library
• Hosted Payments JS/CSS assets
• Rendered iframes or input fields
d. External Payment Gateway:
• Elavon Hosted Payments endpoint (HTTPS)
• Processes card/bank data
• Returns callback JSON to the client
e. Developer Application Code:
• Initializes the library
• Listens for callback events (success, error)
• Handles UI updates, business logic, order fulfillment
Relationships & interactions
• Build pipeline compiles SASS → CSS and bundles JS → creates dist.
• CI (Jenkins) runs tests/builds and publishes dist to GitHub and triggers CDN sync.
• Merchant page loads jQuery → then loads hosted-payments.min.js/css from CDN.
• Hosted Payments code injects UI and iframes that POST to Elavon’s servers.
• Elavon gateway processes transaction and responds with JSON callback to browser.
• Hosted-payments.js captures callback and dispatches events to merchant’s code.
Architectural patterns & principles
• Plugin/module pattern: each payment flavor is a separate JS module.
• Build automation: single gulpfile orchestrates SASS compile, JS minification.
• CDN delivery: static assets are decoupled from merchant servers.
• Security by isolation: sensitive entry fields are hosted in iframes on secure gateway.