<?php

require_once ROOT_PATH.'/zipmarket/apps/payments/models/payments_abstract.class.php';

class parspal extends payments_abstract {
	
	public function generateForm($order_data = array()) {
		global $langArray, $currency, $config, $languageURL;
require_once ROOT_PATH.'/zipmarket/apps/payments/nusoap.php';
		$ParspalPin 	= trim($this->getMeta('parspal_merchant'));
		$pass			= trim($this->getMeta('parspal_pass'));
		$amount 		= round($order_data['price']);
		$invoice_id		= $order_data['id'];
		$callBackUrl 	= 'http://' . $config['domain'] . '/' . $languageURL . 'payments/parspal/?oID='.(int)$order_data['id'];
		$soapclient = new nusoap_client('http://merchant.parspal.com/WebService.asmx?wsdl','wsdl');
		 $params = array(
						"MerchantID" =>$ParspalPin,
						"Password"=>$pass,
		                "Price" => $amount,
						"ReturnPath" => $callBackUrl,
						"ResNumber" => $invoice_id,
						"Description"=>urlencode($this->getMeta('parspal_title')),
						"Paymenter"=>$this->getUserData('firstname').$this->getUserData('lastname'),
						"Email"=>$this->getUserData('email'),
						"Mobile"=>'0930'
		              );
		$res = $soapclient->call('RequestPayment', $params);
		$PayPath = $res['RequestPaymentResult']['PaymentPath'];
		$Status = $res['RequestPaymentResult']['ResultStatus'];
	  if(strtolower($Status) == 'succeed')
		{

		$form  = '<form class="form-for-pay" action="'.$PayPath.'" method="post" id="parspal_form_submit">'."\n";
		$form .= '<button id="parspal-purchase-button" class="btn-icon purchase" type="submit">خرید کنید</button>'."\n";
		$form .= '</form>'."\n";
		}
		else
		{
			$form = '<font color="red">در اتصال به درگاه پارس پال مشکلی پیش آمد دوباره امتحان کنید و یا به پشتیبانی خبر دهید</font>'.$Status.'<br />';

		}
		return $form;
	}

	public function generateDepositForm($order_data = array()) {
		global $langArray, $currency, $config, $languageURL;
require_once ROOT_PATH.'/zipmarket/apps/payments/nusoap.php';
		$ParspalPin 	= trim($this->getMeta('parspal_merchant'));
		$pass			= trim($this->getMeta('parspal_pass'));
		$amount 		= round($order_data['deposit']);
		$invoice_id		= $order_data['id'];
		$callBackUrl 	= 'http://' . $config['domain'] . '/' . $languageURL . 'payments/deposit_parspal/?oID='.(int)$order_data['id'];
		$soapclient = new nusoap_client('http://merchant.parspal.com/WebService.asmx?wsdl','wsdl');
		 $params = array(
						"MerchantID" =>$ParspalPin,
						"Password"=>$pass,
		                "Price" => $amount,
						"ReturnPath" => $callBackUrl,
						"ResNumber" => $invoice_id,
						"Description"=>urlencode($this->getMeta('parspal_title')),
						"Paymenter"=>$this->getUserData('firstname').$this->getUserData('lastname'),
						"Email"=>$this->getUserData('email'),
						"Mobile"=>'0930'
		              );
		$res = $soapclient->call('RequestPayment', $params);
		$PayPath = $res['RequestPaymentResult']['PaymentPath'];
		$Status = $res['RequestPaymentResult']['ResultStatus'];
	  if(strtolower($Status) == 'succeed')
		{

		$form  = '<form class="form-for-pay" action="'.$PayPath.'" method="post" id="parspal_form_submit">'."\n";
		$form .= '<button id="parspal-purchase-button" class="btn-icon purchase" type="submit">خرید کنید</button>'."\n";
		$form .= '</form>'."\n";
		}
		else
		{
			$form = '<font color="red">در اتصال به درگاه پارس پال مشکلی پیش آمد دوباره امتحان کنید و یا به پشتیبانی خبر دهید</font>'.$Status.'<br />';

		}
		return $form;
	}
	
}

?>