The Problem with eCommerce Templates in Africa
Search "eCommerce template" and you'll find beautiful, polished Stripe integrations, USD pricing, and US-centric tax logic. For South African businesses, these templates require months of adaptation work before a single rand can change hands.
Green Vault was built to flip that assumption: a fully functional eCommerce demo designed for the South African market from line one, with PayFast as the native payment gateway.
The Token Economy Architecture
Green Vault uses an interesting approach to eCommerce: a token-based economy where users purchase tokens (1:1 with ZAR) and redeem them for products. This pattern has interesting real-world applications:
- Gift card systems: Users buy tokens as gifts for others
- Loyalty programs: Bonus tokens for first purchase or referrals
- Budget management: Pre-load a spending limit, stick to it
- Multi-currency abstraction: Tokens decouple the frontend from payment currency
The token balance is maintained in localStorage with a transaction log that preserves full history. This makes the balance sheet auditable without a database.
Zero-Dependency Frontend: A Production Philosophy
Like K53 Drill Master, Green Vault was built with no external JavaScript dependencies. Just HTML5, CSS3, and modern ES2022.
The CSS is where this becomes interesting. The glassmorphism design · that frosted-glass aesthetic · is achieved with:
.card {
background: rgba(255, 255, 255, 0.08);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
border: 1px solid rgba(255, 255, 255, 0.15);
}
No Tailwind required. These are native CSS properties with widespread browser support. The animation system uses CSS keyframes throughout · zero JavaScript animation libraries.
PayFast Integration Architecture
The PayFast integration is sandbox-ready with a clean architecture for production deployment. Key implementation decisions:
Signature generation: PayFast requires MD5 signature of all payment parameters in field-insertion order (not alphabetically · a common mistake that causes 400 errors). The signature includes the merchant passphrase appended after all other fields.
ITN (Instant Transaction Notification) handling: PayFast sends a server-side notification to your notify_url on payment completion. This is how you reliably update your database · not from the client-side return_url, which can be bypassed.
Sandbox vs Production: A single environment variable switches between sandbox.payfast.co.za and www.payfast.co.za. Merchant credentials swap alongside.
AI Chatbot: Command Recognition Without an API
The AI chatbot in Green Vault is implemented without any external API calls · it uses command recognition patterns rather than a language model.
const commands = [
{ patterns: [/balance/i, /how much/i], response: getBalanceResponse },
{ patterns: [/product/i, /show me/i], response: getProductResponse },
{ patterns: [/help/i, /support/i], response: getHelpResponse },
];
function processMessage(input) {
const match = commands.find(cmd =>
cmd.patterns.some(p => p.test(input))
);
return match ? match.response() : getFallbackResponse();
}
For a demo, this provides instant, reliable responses without API costs or latency. For production, the architecture hooks to any LLM API with a single function swap.
The Preference Engine
Users select preferences via chip-based UI on onboarding · categories they're interested in, dietary preferences, style choices. These persist in localStorage and filter the product catalog on every subsequent session.
This is personalisation without a recommendation system. No collaborative filtering. No user tracking. Just: "you said you like X, so we'll show you X first." It's transparent, fast, and privacy-respecting.
What South African Builders Can Take From This
Green Vault answers a specific question: what does a production-ready PayFast integration actually look like?
The answer: careful signature generation (field order matters, passphrase goes last), server-side ITN handling (not client-side), environment-based merchant credential switching, and honest error handling when PayFast rejects a payment.
These aren't documented in any single place. Green Vault is the implementation I wish had existed when I first integrated PayFast.
Built by Nandawula Regine Kabali-Kagwa · AI Engineer & Creative Technologist Tech: Vanilla JS/HTML5/CSS3, PayFast, localStorage, Vercel · zero external dependencies
Reader Insights
0 responses
No insights yet. Be the first!