Merchant Demo API

Welcome, Demo Merchant
Your Demo API Key:
demo-api-key-123456
Use the following demo API endpoint to test payments:
POST /api/mpesa/stk-push
{
    "phone": "2547XXXXXXXX",
    "amount": 100,
    "api_key": "demo-api-key-123456"
}
Demo Features:
For production API access, please contact support.
How to Integrate Demo API in Your Website:
  1. Copy your Demo API Key above.
  2. Send a POST request to /api/mpesa/stk-push with these parameters:
  3. {
        "phone": "2547XXXXXXXX",
        "amount": 100,
        "api_key": "demo-api-key-123456"
    }
  4. Use any programming language (PHP, Python, Node.js, etc.) to make the HTTP request.
  5. On success, your phone will receive an M-Pesa STK Push (money goes to site till).
  6. For production API, contact support.
Sample PHP Integration File:
Filename: demo-stk-form.php
<!-- demo-stk-form.php | Version 1.2 | Powered by vbtech.co.ke -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Demo STK Push Payment | Powered by VBTECH</title>
    <style>
        body { background: #181818; color: #fff; font-family: 'Titillium Web', Arial, sans-serif; }
        .container { max-width: 420px; margin: 32px auto; background: #232323; border-radius: 18px; box-shadow: 0 4px 32px #fd90084d; padding: 32px 18px 24px 18px; }
        h2 { color: #fd9008; text-align: center; font-size: 2rem; font-weight: 800; margin-bottom: 18px; }
        label { color: #ffe91d; font-size: 1.08rem; font-weight: 700; margin-top: 16px; display: block; }
        input[type="text"], input[type="number"] { width: 100%; padding: 14px; border-radius: 10px; border: none; background: #181818; color: #fff; margin-bottom: 18px; font-size: 1.08rem; }
        button { background: linear-gradient(90deg,#fd9008,#fa5a26); color: #fff; font-weight: 800; padding: 16px 0; border-radius: 30px; font-size: 1.15rem; box-shadow: 0 2px 12px #fd90084d; border: none; cursor: pointer; width: 100%; margin-top: 12px; transition: background 0.2s; }
        button:hover { background: linear-gradient(90deg,#fa5a26,#fd9008); }
        .api-response { margin-top: 18px; color: #ffe91d; font-weight: 700; background: #181818; border-radius: 10px; padding: 18px; text-align: left; }
        .support { margin-top: 24px; color: #fff; font-size: 1.02rem; text-align: center; }
        .support b { color: #fd9008; }
        .branding { margin-top: 18px; color: #ffe91d; font-size: 1.02rem; text-align: center; }
        .version { color: #aaa; font-size: 0.98rem; text-align: center; margin-top: 8px; }
        @media (max-width: 600px) { .container { max-width: 98vw; padding: 18px 4vw; } h2 { font-size: 1.3rem; } }
    </style>
</head>
<body>
    <div class="container">
        <h2>Demo STK Push Payment</h2>
        <form method="POST" action="demo-stk-form.php" autocomplete="off">
            <label>Phone Number:</label>
            <input type="text" name="phone" placeholder="Enter phone (07..., 01..., 254...)" required>
            <label>Amount:</label>
            <input type="number" name="amount" placeholder="Amount" required min="1">
            <button type="submit">Send STK Push</button>
        </form>
        <?php
        if ($_SERVER['REQUEST_METHOD'] === 'POST') {
            $phone = trim($_POST['phone']);
            $amount = $_POST['amount'];
            $api_key = 'YOUR_DEMO_API_KEY_HERE'; // Replace with your demo API key
            // Format phone number
            if (preg_match('/^0[17][0-9]{8}$/', $phone)) {
                $phone = '254' . substr($phone, 1);
            } elseif (preg_match('/^254[17][0-9]{8}$/', $phone)) {
                $phone = $phone;
            } elseif (preg_match('/^[17][0-9]{8}$/', $phone)) {
                $phone = '254' . $phone;
            }
            $data = [
                'phone' => $phone,
                'amount' => $amount,
                'api_key' => $api_key
            ];
            $ch = curl_init('https://vbtech.co.ke/api/mpesa/stk-push');
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
            curl_setopt($ch, CURLOPT_HTTPHEADER, [
                'Content-Type: application/json'
            ]);
            $response = curl_exec($ch);
            curl_close($ch);
            echo "
API Response:
" . htmlspecialchars($response) . "
"; } ?> <div class="support"> Support: +254 758 654 469 | Telegram </div> <div class="branding">Powered by vbtech.co.ke</div> <div class="version">Demo STK Form v1.2</div> </div> </body> </html>