Automation tools for monitoring and extracting transaction data from the Mandiri QRIS merchant portal using Puppeteer and storing it in Cloudflare D1.
- Automated Login: Handles Mandiri QRIS portal authentication
- Session Management: Maintains persistent browser sessions to avoid repeated logins
- Transaction Monitoring: Continuously polls for new QRIS transactions
- Cloud Storage: Automatically stores transaction data in Cloudflare D1 database
- Configurable: Extensive configuration options via environment variables
- Headless Mode: Can run in headless or visible browser mode for debugging
- Node.js (v16 or higher)
- npm or yarn
- Google Chrome or Chromium browser
- Cloudflare account with D1 database access
- Mandiri QRIS merchant account
- Clone the repository:
git clone <your-repo-url>
cd qriscodex- Install dependencies:
npm install- Set up environment variables:
cp .env.example .env- Edit
.envfile with your credentials (see Configuration section)
Edit the .env file with your credentials and settings:
# Your Mandiri QRIS portal credentials
MANDIRI_USERNAME=your-phone-number
MANDIRI_PASSWORD=your-password
# Cloudflare D1 credentials
CLOUDFLARE_ACCOUNT_ID=your-cloudflare-account-id
CLOUDFLARE_D1_DATABASE_ID=your-d1-database-id
CLOUDFLARE_API_TOKEN=your-cloudflare-api-token# Browser settings
PUPPETEER_HEADLESS=true # Set to false for debugging
MANDIRI_CHROME_PATH=/usr/bin/google-chrome # Custom Chrome path
# Polling interval (in milliseconds)
MANDIRI_POLL_INTERVAL_MS=300000 # Default: 5 minutes
# Form selectors (if portal UI changes)
MANDIRI_USERNAME_LABEL=Nomor Handphone
MANDIRI_PASSWORD_LABEL=Password
MANDIRI_LOGIN_CTA_TEXT=Sudah Punya Akun? Login di Sini- Log in to your Cloudflare Dashboard
- Navigate to Workers & Pages → D1
- Create a new D1 database or use an existing one
- Get your Account ID from the URL or dashboard
- Copy the Database ID from the D1 database details
- Create an API token with D1 permissions in My Profile → API Tokens
Continuously monitors the Mandiri QRIS portal for new transactions:
npm run watch:transactionsThis script will:
- Launch Chrome and log into the Mandiri QRIS portal
- Keep the session alive
- Poll for transactions every 5 minutes (configurable)
- Store transaction details in Cloudflare D1
- Handle session refreshes and re-login if needed
Press Ctrl+C to stop the monitor.
Fetch transactions once without continuous monitoring:
npm run fetch:puppeteerThere's also a Python-based fetcher (requires session cookies):
python3 fetch_transactions.pyThe script automatically creates a transactions table in your D1 database:
CREATE TABLE transactions (
reff_number TEXT PRIMARY KEY,
number TEXT,
is_transfer_to_rek INTEGER,
transfer_amount TEXT,
transfer_amount_number REAL,
fee_amount TEXT,
fee_amount_number REAL,
auth_amount TEXT,
auth_amount_number REAL,
percentage_fee_amount TEXT,
percentage_fee_amount_number REAL,
issuer_name TEXT,
customer_name TEXT,
mpan TEXT,
tid TEXT,
cpan TEXT,
auth_date_time TEXT,
time_data_change TEXT,
settle_date TEXT,
raw_json TEXT,
created_at TEXT DEFAULT CURRENT_TIMESTAMP,
updated_at TEXT DEFAULT CURRENT_TIMESTAMP
);- Verify your
CLOUDFLARE_ACCOUNT_IDandCLOUDFLARE_D1_DATABASE_IDare correct - Ensure your API token has D1 permissions
- Check that the D1 database exists in your Cloudflare account
- Set
PUPPETEER_HEADLESS=falseto watch the browser - Verify your credentials are correct
- Check if the portal UI has changed (may need to update selectors)
- Ensure you have a stable internet connection
- Make sure you have transactions for the current day
- The script only fetches today's transactions by default
- Check the Mandiri QRIS portal manually to confirm transactions exist
# Ubuntu/Debian
sudo apt-get install chromium-browser
# Or specify custom path in .env
MANDIRI_CHROME_PATH=/path/to/your/chrome- Never commit your
.envfile to version control - Keep your Cloudflare API tokens secure
- Use API tokens with minimal required permissions
- Consider using environment-specific credentials for development/production
- The browser runs in non-sandbox mode - ensure you trust the scripts you run
To modify form selectors or add new features, key files:
scripts/watch_transactions.js- Main transaction monitorscripts/fetch_transactions_puppeteer.js- One-time fetch script.env.example- Environment variable template
MIT
This tool is for personal use with your own Mandiri QRIS merchant account. Ensure you comply with Mandiri's terms of service and only access your own account data.