Yii 1.1: mellatpayment

Rich payment solutions for Yii framework with Mellat Bank
5 followers

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:

<script language="javascript" type="text/javascript">
    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; ?>');
</script>
<!-- and some HTML code for show information -->

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

Total 5 comments

#17594 report it
Mojtaba Rahbari at 2014/07/07 03:48am
Hello everybody

Who knows how can i download the script? Actually i didn't see any link to download. Anyway, I should say many thanks from Mr.Amini for sharing his experience.

#17569 report it
Amini at 2014/07/03 09:38am
Is ready

Extension is now available!

#17560 report it
morteza at 2014/07/02 12:43pm
Thank you for answer

.سلام،من هنوز پروژه فروشگاه رو کلید نزدم

.می خواستم بدونم این اکستنشن کی آماده می شه و چه جوری می تونم دانلودش کنم

مطمئنن ارزش کار شما از نظر ما دور نیست ودر اسرع وقت کمک مالی برابر با کار شما برای شما ارسال خواهد شد

با تشکر

#17557 report it
Amini at 2014/07/02 08:07am
Complete description

Hi Morteza, thank you for Donation.
More complete description is provided in the text above. This component gives you the ability to use it, you can manage user pay practices.

#17556 report it
morteza at 2014/07/02 05:39am
Thank you!

سلام میشه بیشتر توضیح بدین.ممنون
اللحساب:
شناسه پرداخت : 865110635

Leave a comment

Please to leave your comment.

Create extension
Downloads
No downloadable files yet