its alot but ok
<?php
class Phpfox_Gateway_Api_zarinpal implements Phpfox_Gateway_Interface
{
private $_aParam = array();
private $_aCurrency = array('IR','USD');
public function set($aSetting)
{
$this->_aParam = $aSetting;
if (Phpfox::getLib('parse.format')->isSerialized($aSetting['setting']))
{
$this->_aParam['setting'] = unserialize($aSetting['setting']);
}
//for set
}
public function __construct()
{
}
public function getEditForm()
{
return array(
'merchantID' => array(
'phrase' => 'زرین پل',
'phrase_info' => 'خرید با زرین پل',
'value' => (isset($this->_aParam['setting']['merchantID']) ? $this->_aParam['setting']['merchantID'] : '')
),
'merchantID' => array(
'phrase' => 'پین فروشنده',
'phrase_info' => 'کد فروشنده که دریافت میکنید را وارد کنید',
'value' => (isset($this->_aParam['setting']['merchantID']) ? $this->_aParam['setting']['merchantID'] : '')
)
);
//for get edit form
}
public function getForm()
{
if ($this->_aParam['recurring'] > 0)
{
return false;
}
if (!in_array($this->_aParam['currency_code'], $this->_aCurrency))
{
if (!empty($this->_aParam['alternative_cost']))
{
$aCosts = unserialize($this->_aParam['alternative_cost']);
if (isset($aCosts['USD']))
{
$this->_aParam['amount'] = $aCosts['USD'];
}
else
{
return false;
}
}
else
{
return false;
}
}
$merchantID = $this->_aParam['setting']['merchantID'];
$amount = $this->_aParam['amount'];
$callBackUrl = "http://royta.ir/index.php?do=/api/gateway/callback/zarinpal/";
$client = new SoapClient('http://www.zarinpal.com/WebserviceGateway/wsdl', array('encoding'=>'UTF-8'));
$res = $client->PaymentRequest($merchantID, $amount, $callBackUrl, urlencode($this->_aParam['item_name']) );
$aForm = array(
'url' => "https://www.zarinpal.com/users/pay_invoice/$res",
'param' => array(
'merchantID' => $this->_aParam['setting']['merchantID'],
'amount' => $this->_aParam['amount'],
'cart_order_id' => $this->_aParam['item_number'],
'merchant_order_id' => $this->_aParam['item_number'],
'c_prod' => $this->_aParam['item_number'],
'id_type' => 'IR',
'c_name' => $this->_aParam['item_name'],
'c_price' => $this->_aParam['amount'],
'desc' => 'خرید از جامعه رویتا'
)
);
return $aForm;
}
//forget form up!
public function callback(){
//$merchantID = $this->_aParam['setting']['merchantID'];
if(isset($this->_aParam['amount'])){ //this IF give Me WE DONT have IT
echo "we have it";
}
else{
echo "we dont have it";
}
$au = $_GET['au'];
$client = new SoapClient('http://www.zarinpal.com/WebserviceGateway/wsdl', array('encoding'=>'UTF-8'));
$res = $client->PaymentVerification($merchantID, $au, $amount);
print $res;
}
}
?>