mellatpayment Rich payment solutions for Yii framework with Mellat Bank

  1. Requirements
  2. Installation
  3. Usage
  4. Resources
  5. Donate

Mellat-Payment Yii Extension

Mellat-Payment is a Online Payment Component used for online shoping or donate.

Requirements

requirements of using this extension (e.g. Yii 1.1 or above)...

Installation

  • Extract the release file under protected/extensions
  • After place this code within your configuration file (main.php) inside the 'components' section
'Payment' => array(
	'class'=> 'ext.RezvanPayment.RezvanPayment',
	'terminalId' => 'portal_terminal_number',
	'userName' => 'portal_username',
	'userPassword' => 'portal_password',
),

Usage

See the following code example:
On your controller action:

$order_Id = rand(); // This variables must be uniquely
$result = Yii::app()->Payment->PayRequest( 'your_amount', $order_Id, 'callback_page');
if(!is_array($result)){
	/* 
	*  Save Result And Redirect to bank
	*  if set return variable in component you can directly redirect to bank site
	*/
	$this->render('_redirect',array('ReferenceId'=>$result));
}

And redirect page: ~~~ [html]

function postRefId (refIdValue) {
	var form = document.createElement("form");
	form.setAttribute("method", "POST");
	form.setAttribute("action", "https://bpm.shaparak.ir/pgwchannel/startpay.mellat");
	form.setAttribute("target", "_self");
	var hiddenField = document.createElement("input");
	hiddenField.setAttribute("name", "RefId");
	hiddenField.setAttribute("value", refIdValue);
	form.appendChild(hiddenField);

	document.body.appendChild(form);
	form.submit();
	document.body.removeChild(form);
}
postRefId('<?php echo $ReferenceId; ?>');

~~~ Users are directed to the website of the bank for payment. After payment by user, bank returns the user to the previously announced CallBack Address. return address, which is an action in the controller. In this action you can with parameters that come from the bank, send verifying deposit to bank.
CallBack action:

$model=$this->loadModelByReference($_POST['RefId']);
if($_POST['ResCode'] == 0){
	$result = Yii::app()->Payment->VerifyRequest( $model->orderId, $_POST['SaleOrderId'], $_POST['SaleReferenceId']);
}
if($result != NULL){
	$RecourceCode = (!is_array($result) ? $result :  $result[0]);
}
else
	$RecourceCode = $_POST['ResCode'];

$model->resCode=($model->resCode == NULL ? $RecourceCode : $model->resCode);
$model->saleReferenceId=$_POST['SaleReferenceId'];

$model->save();
$this->render('_notif',array(
	'model'=>$model,
));

And other function:

  • Settle Request:
    Using this method, the operation will be paid, in fact, the final method of payment operations Is used. Bank transactions approved by this method, the contract will be credited to the recipient's account. The return value of "0" means receiving a payment request is successful.
# **Settle Request:**
Yii::app()->Payment->SettleRequest( $order_Id, $SaleOrderId, $SaleReferenceId);
  • Inquiry Request:
    This method is applicable when the recipient for any reason, the result is returned VerifyRequest not know at the time of transaction. The uncertain status confirming the purchase, by this method of inquiry is. After calling this method, the payment transaction will be clear to the recipient.
# **Inquiry Request:**
Yii::app()->Payment->InquiryRequest( $order_Id, $SaleOrderId, $SaleReferenceId);

Resources

Donate

Want to say thanks for the time and efforts put on this project?
Donate

1 0
5 followers
142 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Others
Developed by: Amini
Created on: Jun 30, 2014
Last updated: 8 years ago

Downloads

show all

Related Extensions