yii2 iranian bank mellat gateway extension
By this extension you can add mellat bank gateway to your yii2 project, (*1)
Installation
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist ahmadrezaei/yii2-mellatbank "*"
or add, (*4)
"ahmadrezaei/yii2-mellatbank": "*"
to the require section of your composer.json
file., (*5)
Configuring application
After extension is installed you need to setup auth client collection application component:, (*6)
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
]
// ...
],
// ...
];
If you want to save records in database, create migrations:, (*7)
php yii migrate -p=@vendor/ahmadrezaei/yii2-mellatbank/migrations
Usage
For create a payment request:, (*8)
$amount = 10000; // Rial
$callBackUrl = Url::to(['callback']); // callback url
/* @var $mellatbank \ahmadrezaei\yii\mellatbank\components\Mellatbank */
$mellatbank = Yii::$app->mellatbank;
$mellatbank->createPayment($amount, $callBackUrl);
For verify payment request:, (*9)
/* @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;
}