پیش فرض کمک و راهنمایی برای درگاه پرداخت پارسیان

  • نویسنده موضوع نویسنده موضوع tehran
  • تاریخ شروع تاریخ شروع

tehran

New member
با سلام
بنده برای راه اندازی درگاه پرداخت اینترنتی پارسیان با مستندات جدید دچار مشکل شدم.
لطفا هر کسی از دوستان میتونه کمک کنه تا این فایل رو با مستندات جدید ویرایش کنم و بر روی سایت نصب کنم.

مستندات جدید درگاه پارسیان به همراه فایل در ادامه به پیوست قرار میدم.باتشکر


PHP:
<?php
require_once 'functions.class.php';
require_once '../funcs/mellat_lib/nusoap.php';

class Parsian{
	private $_pinCode,
			$_client,
			$_gatewayURL,
			$_formURL,
			$_callBackURL,
			$_gatwayName;

	public function __construct(){
		global $options;
		
		$this->_gatwayName = _e('GATEWAY_PARSIAN', true);

		$this->_pinCode 	= $options->PARSIAN_PINCODE;
		$this->_gatewayURL 	= 'https://pec.shaparak.ir/pecpaymentgateway/eshopservice.asmx?wsdl';
		$this->_formURL 	= 'https://pec.shaparak.ir/pecpaymentgateway?au=';
		$this->_callBackURL = usersroot() . 'parsian_callback.php';

		$this->_client = new nusoap_client($this->_gatewayURL, 'wsdl');
	}

	public function send_user_to_parsian($price, $orderId, $userId, $desc = '' ){
		global $db;

		$amount = (int) $price * 10;

    	$parameters = array(
            'pin' 		=> $this->_pinCode,
            'orderId' 	=> $orderId,
            'amount' 	=> $amount,
            'authority' => 0,
            'status' 	=> 1,
            'callbackUrl' => $this->_callBackURL,
        );
    	$params = array($parameters);
    	echo $this->connecting_message();
    	$result = $this->_client->call('PinPaymentRequest', $params);
    	if($this->_client->fault){
    		echo $this->connection_failure_message();
    	} else {
    		$err = $this->_client->getError();
    		if($err){
    			echo $this->connection_failure_message();
    		}else{
    			$authority = $result['authority'];
				$status = $result['status'];

            	if ($authority > 0 && $status == 0 ) 
            	{

            		$pay = $this->insertPayment($orderId, null, $price, $authority, $userId );
	            	if($pay){
	            		$url = $this->_formURL . $authority;
						Functions::redirect($url,1);
	            	}else{
	            		echo $this->connection_failure_message(666);
	            	}
	            }else{
	                echo $this->connection_failure_message($status);
	            }
    		}
    	}

	}

	public function isPaidDone(){
		if( isset($_GET['au']) && isset($_GET['rs']) && !empty($_GET['au']) && trim($_GET['au']))
		{
			if( (int) $_GET['rs'] === 0 ){
				return true;
			}
		}
		return false;
	}

	public function insertPayment($saleOrderId, $saleReferenceId, $price, $refId, $userId, $done = 1, $settled = 1, $kind = 7){
		global $db;
		try
		{
			$sql = " INSERT INTO tbl_online_payments (user_id, price, sale_order_id, sale_refrence_id, ref_id, done, setteled, kind, date_created) 
					 VALUES (:userId, :price ,:saleOrderId, :saleRefrenceId, :refId, :done, :setteled, :kind, :dateCreated)";
			$stmt = $db->prepare($sql);
			$stmt->execute(
				array(
                    ':userId' => $userId,
                    ':price' => $price,
                    ':saleOrderId' => $saleOrderId,
                    ':saleRefrenceId' => $saleReferenceId,
                    ':refId' => $refId,
                    ':done' => $done, 
                    ':setteled' => $settled, 
                    ':kind' => $kind,
                    ':dateCreated' => date("Y-m-d H:i:s")
                )
    		);
    		return true;
		}catch(PDOException $e){
			return false;
		}
	}

	public function findReturnedPayment($refId)
	{
		global $db;
		$sql  = " SELECT * FROM tbl_online_payments WHERE ref_id=:refId AND kind=:kind AND done=1 ORDER BY id DESC LIMIT 1";
		$stmt = $db->prepare($sql);

		$stmt->bindValue(':refId', $refId);
		$stmt->bindValue(':kind', 7);

		$stmt->execute();
		if($stmt->rowCount() > 0)
			return $stmt->fetch(PDO::FETCH_OBJ);
		else
			return false;
	}

	public function updatePayment()
	{
		
	}
	public function verifyRequest($authority){
		$parameters = array(
            'pin' 		=> $this->_pinCode,
            'authority' => $authority,
            'status' => 1
        );
		$params = array($parameters);
        $result = $this->_client->call('PinPaymentEnquiry', $params);
		if($this->_client->fault){
			return false;
		}else{
			$err = $this->_client->getError();
			if($err){
				return false;
			}else{
				return $result;
			}
		}
	}

	public function reversalRequest($saleOrderId){
		$parameters = array(
            'pin' 		=> $this->_pinCode,
            'orderId' 	=> time(),
            'orderToReversal' => $saleOrderId,
        );
		$params = array($parameters);

        $result = $this->_client->call('PinReversal', $params);
		
		if($this->_client->fault){
			return false;
		}else{
			$err = $this->_client->getError();
			if($err){
				return false;
			}else{
				return (int) $result['status'];
			}
		}
	}

	public function settlementRequest($saleOrderId, $saleReferenceId){
		$parameters = array(
            'terminalId' => $this->_terminalId,
            'userName' => $this->_username,
            'userPassword' => $this->_password,
            'orderId' => time(),
	        'saleOrderId' => $saleOrderId,
	        'saleReferenceId' => $saleReferenceId
        );

        $result = $this->_client->call('bpReversalRequest', $parameters, $this->_namespace);
		
		if($this->_client->fault){
			return false;
		}else{
			$err = $this->_client->getError();
			if($err){
				return false;
			}else{
				return $result;
			}
		}
	}

	public function CheckBPMStatus($errCode){
       switch ($errCode) 
	     {
		  case 1:
	        $tmess = _e('UNDEFINED_STATUS', true);
		    break;
		  case 20:
	        $tmess = _e('INVALID_PIN', true);
		    break;
		  case 22:
	        $tmess= _e('INVALID_PIN_IP', true);
		    break;
		  case 30:
	        $tmess= _e('REUSED_TRANSACTION_CODE', true);
		    break;
		  case 34:
	        $tmess= _e('REUSED_TRANSACTION_CODE', true);
		    break;
		  case 666:
	        $tmess= _e('INVALID_TRANSACTION_CODE', true);
		    break;
		  default:
		  	$tmess= _e('UNDEFINED_STATUS', true);
		  	break;
		 }	
		return $tmess;
	}

	private function connecting_message(){
		$output = "

			<div class='payment-return' id='connecting' style='padding-top:50px' >
	            <div class='container-fluid payment-info'>
	                <div class='row'>
	                    <div class='span12 mini-next-line text-center'>
	                        <div class='payment-logo'> <img src='../images/payment-methods/parsian.png' width='120'> </div>
	                        <p class='big-msg'> " . _e('CONNECTING_TO', true, array('{%1%}' => $this->_gatwayName)) . " </p>
	                        <p class='big-msg'> " . _e('PLEASE_WAIT', true) . " </p>
	                    	<img src='../images/ajax-loader2.gif'>
	                    </div>
	                </div>
	            </div>
	        </div>
		";
		return $output;
	}

	private function connection_failure_message($errCode= ''){
		$output = "
			<script language='javascript' type='text/javascript'>
				document.getElementById('connecting').style.display = 'none';
			</script>
			<div class='payment-return' style='padding-top:50px'>
	            <div class='container-fluid payment-fail'>
	                <div class='row'>
	                    <div class='span12 mini-next-line text-center'>
	                        <div class='payment-logo'> <img src='../images/payment-methods/parsian.png' width='120'> </div>
	                        <p class='big-msg'> " . _e('CONNECTION_REFUSED', true) . " </p>
	                        ";
	                        
					        if(!empty($errCode))
					        	$output .= $this->CheckBPMStatus($errCode);

	    $output .= "
	                        <p class='big-msg'> <a class='btn btn-inverse' href=''> <i class='icon-refresh'></i> تلاش مجدد </a><div class='clearfix'></div> </p>
	                    </div>
	                </div>
	            </div>
	        </div>
	        <div class='next-line'></div>
		";
		return $output;

	}

}

?>
 

پیوست‌ها

عقب
بالا