Note: Select Network first and then Use "Generate Card" button to auto generate card number, expiry month, expiry year & CVV. You can change card holder name."
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Card(BaseModel):
number: str
def luhn_valid(num: str) -> bool:
digits = [int(d) for d in num if d.isdigit()]
total, double = 0, False
for d in reversed(digits):
if double:
d = d * 2 - 9 if d * 2 > 9 else d * 2
total += d
double = not double
return total % 10 == 0
@app.post("/validate_card")
def validate_card(card: Card):
return {"card_number": card.number, "valid": luhn_valid(card.number)}
// server.js
import express from "express";
import bodyParser from "body-parser";
const app = express();
app.use(bodyParser.json());
function luhnValid(num) {
const digits = (num || "").replace(/\D/g, "").split("").map(Number);
let total = 0, double = false;
for (let i = digits.length - 1; i >= 0; i--) {
let d = digits[i];
if (double) { d = d * 2; if (d > 9) d -= 9; }
total += d; double = !double;
}
return total % 10 === 0;
}
app.post("/validate_card", (req,res)=>{
const { number } = req.body;
if(!number) return res.status(400).json({error:"Missing number"});
res.json({card_number:number, valid:luhnValid(number)});
});
app.listen(3000,()=>console.log("✅ Server running on http://localhost:3000"));