PHP code example of mak8tech / mobile-wallet-zm

1. Go to this page and download the library: Download mak8tech/mobile-wallet-zm library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mak8tech / mobile-wallet-zm example snippets


return [
    // Default mobile money provider
    'default' => env('MOBILE_WALLET_PROVIDER', 'mtn'),

    // Default currency
    'currency' => env('MOBILE_WALLET_CURRENCY', 'ZMW'),

    // Default country code
    'country_code' => env('MOBILE_WALLET_COUNTRY_CODE', 'ZM'),

    // MTN MoMo Configuration
    'mtn' => [
        'base_url' => env('MTN_API_BASE_URL', 'https://sandbox.momodeveloper.mtn.com'),
        'api_key' => env('MTN_API_KEY'),
        'api_secret' => env('MTN_API_SECRET'),
        'collection_subscription_key' => env('MTN_COLLECTION_SUBSCRIPTION_KEY'),
        'disbursement_subscription_key' => env('MTN_DISBURSEMENT_SUBSCRIPTION_KEY'),
        'environment' => env('MTN_ENVIRONMENT', 'sandbox'),
    ],

    // Airtel Money Configuration
    'airtel' => [
        'base_url' => env('AIRTEL_API_BASE_URL', 'https://openapi.airtel.africa'),
        'api_key' => env('AIRTEL_API_KEY'),
        'api_secret' => env('AIRTEL_API_SECRET'),
        'environment' => env('AIRTEL_ENVIRONMENT', 'sandbox'),
    ],

    // Zamtel Kwacha Configuration
    'zamtel' => [
        'base_url' => env('ZAMTEL_API_BASE_URL', 'https://api.zamtel.com/kwacha'),
        'api_key' => env('ZAMTEL_API_KEY'),
        'api_secret' => env('ZAMTEL_API_SECRET'),
        'environment' => env('ZAMTEL_ENVIRONMENT', 'sandbox'),
    ],

    // Webhook Configuration
    'webhook' => [
        'secret' => env('MOBILE_WALLET_WEBHOOK_SECRET'),
        'url_path' => env('MOBILE_WALLET_WEBHOOK_PATH', 'api/mobile-wallet/webhook'),
    ],
];

use Mak8Tech\MobileWalletZm\Facades\MobileWallet;

// Request a payment
$result = MobileWallet::requestPayment(
    '0977123456',  // Phone number
    100.00,        // Amount
    'REF123',      // Reference (optional)
    'Payment for order #123' // Narration (optional)
);

// Check transaction status
$status = MobileWallet::checkTransactionStatus($transactionId);

// Using a specific provider
$result = MobileWallet::provider('airtel')->requestPayment(
    '0977123456',
    100.00
);
bash
php artisan mobile-wallet:install
bash
php artisan vendor:publish --tag="mobile-wallet-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="mobile-wallet-config"
bash
php artisan vendor:publish --tag="mobile-wallet-assets"