Micro service mã hoá WASM + nhận diện captcha cho MBBank PHP SDK. Deploy miễn phí trên Render/Railway.
- Node.js >= 18
- File
model.onnx(47MB) — copy từresources/model.onnx
- Push
wasm-api/+model.onnxlên GitHub - render.com → New Web Service
- Settings:
- Start Command:
node index.js - Instance Type: Free (512MB RAM)
- Env:
API_KEY=your-secret-key
- Start Command:
- Deploy → Lấy URL
cd wasm-api/
npm install
cp ../resources/model.onnx .
API_KEY=secret PORT=3000 node index.jsuse MBBank\MBBank;
use MBBank\CaptchaOCRApi;
use MBBank\WasmHelper\WasmEncrypt;
$apiUrl = 'https://your-wasm-api.onrender.com';
$apiKey = 'your-secret-key';
WasmEncrypt::setApiUrl($apiUrl);
WasmEncrypt::setApiKey($apiKey);
$mb = new MBBank([
'username' => 'YOUR_USERNAME',
'password' => 'YOUR_PASSWORD',
'captcha_ocr' => new CaptchaOCRApi($apiUrl, $apiKey),
]);| Method | Path | Body | Response |
|---|---|---|---|
| POST | /encrypt |
{data:{...}, apiKey:"..."} |
{encrypted:"..."} |
| POST | /ocr |
{imageBase64:"...", apiKey:"..."} |
{text:"abc123"} |
| GET | /health |
— | {status,wasmReady,ocrReady} |
- Luôn set
API_KEYtrong production - HTTPS tự động bởi Render/Railway