PHP code example of taitech / azampay

1. Go to this page and download the library: Download taitech/azampay 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/ */

    

taitech / azampay example snippets


use Taitech\Azampay\AzampayService;

// Initialize the service
$azampay = new AzampayService(
    appName: 'YOUR_APP_NAME',
    clientId: 'YOUR_CLIENT_ID',
    secret: 'YOUR_CLIENT_SECRET',
    env: 'SANDBOX', // or 'PRODUCTION'
    service: 'MNO' // or 'BANK' or 'MERCHANT'
);

$azampay = new AzampayService(
    appName: 'YOUR_APP_NAME',
    clientId: 'YOUR_CLIENT_ID',
    secret: 'YOUR_CLIENT_SECRET',
    env: 'SANDBOX', // or 'PRODUCTION'
    service: 'MNO'
);

$azampay = new AzampayService(
    appName: 'YOUR_APP_NAME',
    clientId: 'YOUR_CLIENT_ID',
    secret: 'YOUR_CLIENT_SECRET',
    env: 'SANDBOX', // or 'PRODUCTION'
    service: 'BANK'
);

$azampay = new AzampayService(
    appName: 'YOUR_APP_NAME',
    clientId: 'YOUR_CLIENT_ID',
    secret: 'YOUR_CLIENT_SECRET',
    env: 'SANDBOX', // or 'PRODUCTION'
    service: 'MERCHANT'
);

// vendor credentials
$app = 'YOUR_APP_NAME';
$clientId = 'YOUR_CLIENT_ID';
$secret = 'YOUR_SECRET_KEY';


try {
     $azampay = new AzampayService(
        $app, // App Name
        $clientId, // Client ID
        $secret, // Client Secret
        'SANDBOX', // Environment (SANDBOX/PRODUCTION)
        'MNO', // Service (MNO, BANK, MERCHANT)
    );

    // Example of calling the checkout method for MNO [MOBILE PAYMENT]
    $payload = [
        'amount' => 5000,
        'accountNumber' => '255713295803',
        'provider' => 'Tigo',
        'additionalProperties' => [
                'router' => "Home",
                'mac' => "A6:47:F6:52:38:D5",
            ],
    ];

    $response = $azampay->checkout($payload);

    // Output the final JSON response
    header('Content-Type: application/json');
    echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);

} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}