/**
  * request driver.
  *
  * @param $inputs
  *
  * @return array
  */
 public function request($inputs)
 {
     $client = new \SoapClient($this->wsdlAddress, ['encoding' => 'UTF-8']);
     $result = $client->PaymentRequest($inputs);
     if ($result->Status == 100) {
         return ['Authority' => $result->Authority];
     } else {
         return ['error' => $result->Status];
     }
 }
Example #2
0
 /**
  * request driver
  *
  * @param $inputs
  * @return array
  */
 public function request($inputs, $debug)
 {
     $this->debug = $debug;
     $client = new \SoapClient($this->setWsdlAddress(), array('encoding' => 'UTF-8'));
     $result = $client->PaymentRequest($inputs);
     if ($result->Status == 100) {
         return ['Authority' => $result->Authority];
     } else {
         return ['error' => $result->Status];
     }
 }
Example #3
0
 public function zarinpal()
 {
     $this->session->unset_userdata('Amount');
     $donate_zarinpal = $this->config->item('donate_zarinpal');
     $Amount = $this->input->post("amount");
     $Description = $this->input->post("item_name");
     $this->session->set_userdata('Amount', $Amount);
     $client = new SoapClient('https://de.zarinpal.com/pg/services/WebGate/wsdl', array('encoding' => 'UTF-8'));
     $result = $client->PaymentRequest(array('MerchantID' => $donate_zarinpal["MerchantID"], 'Amount' => $Amount, 'Description' => $Description, 'Email' => $donate_zarinpal["email"], 'Mobile' => $donate_zarinpal["Mobile"], 'CallbackURL' => $donate_zarinpal["postback_url"]));
     if ($result->Status == 100) {
         @Header('Location: https://www.zarinpal.com/pg/StartPay/' . $result->Authority);
         exit;
     } else {
         echo 'ERR: ' . $result->Status;
         exit;
     }
 }
Example #4
0
 /**
  * Execute and display a template script.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise a Error object.
  */
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $state = $this->get('State');
     $item = $this->get('Item');
     // Get the parameters
     $params = JComponentHelper::getParams('com_sibdiet');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     $this->state =& $state;
     $this->user =& $user;
     $this->item = $item;
     $this->item->Amount = $params->get('diet_price');
     $Authority = $app->input->get('Authority', NULL, 'STRING');
     if (empty($Authority)) {
         $MerchantID = $params->get('zarinpal_merchant_id');
         $Amount = $params->get('diet_price') / 10;
         $Description = JText::sprintf('COM_SIBDIET_ONLINE_PAYMENT_DESCRIPTION', $item->fname . ' ' . $item->lname);
         $Email = $item->email;
         $Mobile = $item->mobile;
         $CallbackURL = JUri::getInstance();
         $vars = array('MerchantID' => $MerchantID, 'Amount' => $Amount, 'Description' => $Description, 'Email' => $Email, 'Mobile' => $Mobile, 'CallbackURL' => $CallbackURL);
         $client = new SoapClient('https://ir.zarinpal.com/pg/services/WebGate/wsdl', array('encoding' => 'UTF-8'));
         $result = $client->PaymentRequest($vars);
         //Redirect to URL You can do it also by creating a form
         if ($result->Status == 100) {
             $object = new stdClass();
             $object->id = $this->item->id;
             $object->authority = $result->Authority;
             $updateResult = JFactory::getDbo()->updateObject('#__sibdiet_setdiets', $object, 'id');
             $this->action = 'https://www.zarinpal.com/pg/StartPay/' . $result->Authority;
             return parent::display($tpl);
         } else {
             //JError::raiseWarning(500, JText::_('COM_SIBDIET_ZARINPAL_ONLINE_PAYMENT_STATUS_' . $result->Status));
             return false;
         }
     }
     return parent::display($tpl);
 }
Example #5
0
function send_to_bank($Amount, $CallbackURL, $Email, $Mobile, $config, $subject, $lang)
{
    $show['massage'] = '';
    $client = new SoapClient('https://de.zarinpal.com/pg/services/WebGate/wsdl', array('encoding' => 'UTF-8'));
    $result = $client->PaymentRequest(array('MerchantID' => $config['merchent_code'], 'Amount' => $Amount / 10, 'Description' => $subject, 'Email' => $Email, 'Mobile' => $Mobile, 'CallbackURL' => $CallbackURL));
    $result1 = $result->Status;
    $resultgo = $result->Authority;
    if ($result1 == 100) {
        $show['Status'] = 1;
        $show['massage'] .= $lang['Successful']['send'];
        $show['Post_url'] = 'https://www.zarinpal.com/pg/StartPay/' . $result->Authority . '/ZarinGate';
        $show['trans_id1'] = '';
        $show['trans_id2'] = $result->Authority;
    } else {
        $show['Status'] = 0;
        $show['massage'] .= $lang['error'][$result1];
    }
    return $show;
}
Example #6
0
 public function doGenerateForm(array $options = array())
 {
     $this->setOptions($options);
     $this->_checkRequiredOptions(array('merchantCode', 'amount', 'reservationNumber', 'redirectAddress', 'description'));
     try {
         $soapClient = new SoapClient($this->getWSDL(), array('encoding' => 'UTF-8'));
         $merchantID = $this->_config['merchantCode'];
         $amount = $this->_config['amount'];
         $callBackUrl = $this->_config['redirectAddress'] . '/in/' . $this->_config['reservationNumber'];
         $description = urlencode($this->_config['description']);
         $res = $soapClient->PaymentRequest($merchantID, $amount, $callBackUrl, $description);
     } catch (SoapFault $e) {
         $this->log($e->getMessage());
         throw new Exception('SOAP Exception: ' . $e->getMessage());
     }
     if (strlen($res) == 36) {
         $view = Zend_Layout::getMvcInstance()->getView();
         $form = '<form id="gotobank-form" method="post" action="' . sprintf($this->getEndPoint(), $res) . '" class="form-horizontal">';
         $label = isset($this->_config['submitlabel']) ? $this->_config['submitlabel'] : '';
         $submit = sprintf('<div class="control-group"><div class="controls"><input type="submit" class="btn btn-success" value="%s"></div></div>', $label);
         $form .= $submit;
         $form .= '</form>';
         return $form;
     } else {
         switch ($res) {
             case "-1":
                 $msg = static::INCOMPLETE_DATA;
                 break;
             case "-2":
                 $msg = static::INVALID_WEBSERVICE;
                 break;
             case "-3":
                 $msg = static::LOW_AMOUNT;
                 break;
             case "-4":
                 $msg = static::NOT_SILVER_USER_LEVEL;
                 break;
             default:
                 $msg = static::UNKNOWN_REQUEST_RESPONSE;
                 break;
         }
         $this->log($e->getMessage());
         throw new Exception($msg, $res);
     }
 }
Example #7
0
 /**
  * Payment Request
  *
  * @return Authority
  */
 public function PaymentRequest($data)
 {
     // Get the parameters
     $params = JComponentHelper::getParams('com_sibdiet');
     $vars = array('MerchantID' => $params->get('zarinpal_merchant_id'), 'Amount' => $data['payment']['diet_price'] / 10, 'Description' => JText::sprintf('COM_SIBDIET_ONLINE_PAYMENT_DESCRIPTION', $data['profile']['fname'] . ' ' . $data['profile']['lname']), 'Email' => JFactory::getUser()->email, 'Mobile' => $data['profile']['mobile'], 'CallbackURL' => JRoute::_('http://sibdiet.com/index.php?&option=com_sibdiet&view=onlinepayment', false));
     $client = new SoapClient('https://ir.zarinpal.com/pg/services/WebGate/wsdl', array('encoding' => 'UTF-8'));
     $result = $client->PaymentRequest($vars);
     if ($result->Status == 100 && strlen($result->Authority) == 36) {
         return $result->Authority;
     }
     $this->setError(JText::_('COM_SIBDIET_ZARINPAL_ONLINE_PAYMENT_STATUS_' . $result->Status));
     return false;
 }