PHP code example of ahmadrezaei / yii2-mellatbank

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

    

ahmadrezaei / yii2-mellatbank example snippets


return [
    'components' => [
        'mellatbank' => [
            'class' => 'ahmadrezaei\yii\mellatbank\components\Mellatbank',
            'username' => 'YOUR-USERNAME',
            'password' => 'YOUR-PASSWORD',
            'terminal' => 'YOUR-TERMINAL-ID',
            'mysql' => true, // If you want to save records in db
        ]
        // ...
    ],
    // ...
];

$amount = 10000; // Rial
$callBackUrl = Url::to(['callback']); // callback url
/* @var $mellatbank \ahmadrezaei\yii\mellatbank\components\Mellatbank */
$mellatbank = Yii::$app->mellatbank;
$mellatbank->createPayment($amount, $callBackUrl);

/* @var $mellatbank \ahmadrezaei\yii\mellatbank\components\Mellatbank */
$mellatbank = Yii::$app->mellatbank;
$result = $mellatbank->verify();
if( $result ) {
    // payment is successfull
    $transactionID = $mellatbank->transactionId;
    $resCode = $mellatbank->resultCode;
} else {
    // payment is unsuccessfull
    $resCode = $mellatbank->resultCode;
}

php composer.phar 

php yii migrate -p=@vendor/ahmadrezaei/yii2-mellatbank/migrations