PHP code example of azmolla / fraud-checker-bd-courier

1. Go to this page and download the library: Download azmolla/fraud-checker-bd-courier 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/ */

    

azmolla / fraud-checker-bd-courier example snippets


use FraudCheckerBdCourier;

// Input a standard 11-digit Bangladeshi mobile number
$report = FraudCheckerBdCourier::check('01712345678');

dd($report);



use Azmolla\FraudCheckerBdCourier\Config\FraudCheckerConfig;
use Azmolla\FraudCheckerBdCourier\Cache\FileTokenCache;
use Azmolla\FraudCheckerBdCourier\Services\SteadfastService;
use Azmolla\FraudCheckerBdCourier\Services\PathaoService;
use Azmolla\FraudCheckerBdCourier\Services\RedxService;
use Azmolla\FraudCheckerBdCourier\FraudCheckerBdCourierManager;

// 1. Setup Configuration
$config = new FraudCheckerConfig([
    'steadfast' => [
        'user' => '[email protected]',
        'password' => 'your_steadfast_password'
    ],
    'pathao' => [
        'user' => '[email protected]',
        'password' => 'your_pathao_password'
    ],
    'redx' => [
        'phone' => 'your_redx_login_phone_number',
        'password' => 'your_redx_password'
    ]
]);

// 2. Setup Cache for RedX tokens (defaults to sys_get_temp_dir()/fraud_checker_cache)
$cache = new FileTokenCache(__DIR__ . '/cache');

// 3. Initialize Services
$steadfastService = new SteadfastService($config);
$pathaoService = new PathaoService($config);
$redxService = new RedxService($config, $cache);

// 4. Initialize Manager
$fraudChecker = new FraudCheckerBdCourierManager($steadfastService, $pathaoService, $redxService, $config);

// 5. Check Number
$report = $fraudChecker->check('01712345678');
print_r($report);

[
    'steadfast' => ['success' => 3, 'cancel' => 1, 'total' => 4, 'success_ratio' => 75.0],
    'pathao'    => ['success' => 5, 'cancel' => 2, 'total' => 7, 'success_ratio' => 71.43],
    'redx'      => ['success' => 20, 'cancel' => 5, 'total' => 25, 'success_ratio' => 80.0],

    // The summary across all supported couriers
    'aggregate' => [
        'total_success'    => 28,
        'total_cancel'     => 8,
        'total_deliveries' => 36,
        'success_ratio'    => 77.78,
        'cancel_ratio'     => 22.22
    ]
]

use Azmolla\FraudCheckerBdCourier\Services\PathaoService;
use Azmolla\FraudCheckerBdCourier\Services\SteadfastService;
use Azmolla\FraudCheckerBdCourier\Services\RedxService;

$steadfastData = (new SteadfastService())->getDeliveryStats('01712345678');
$redxData      = (new RedxService())->getDeliveryStats('01712345678');
$pathaoData    = (new PathaoService())->getDeliveryStats('01712345678');

use Azmolla\FraudCheckerBdCourier\Helpers\CourierDataValidator;

CourierDataValidator::checkBdMobile('01712345678');
// Throws InvalidArgumentException if formatting fails
bash
php artisan vendor:publish --tag="config"