Example #1
0
 /**
 * @param $setParams
 * @return string
 *
     $hipay = new plugins_hipay_public();
     $hipayProcess = $hipay->getData(
    array(
        'plugin'        =>  'cartpay',
        'key'           =>  $session_key,
        'order'         =>  $id_cart,
        'amount'        =>  $amount_pay_with_tax,
        'shipping'      =>  $shipping,
        'locale'        =>  'BE',
        'customerEmail' => $data_cart['email_cart']
    )
     );
 */
 public function getData($setParams)
 {
     try {
         frontend_model_smarty::getInstance()->configLoad($this->modelSystem->base_path() . 'plugins/hipay/i18n/public_local_' . frontend_model_template::current_Language() . '.conf');
         // Chargement des données Hipay en base de données
         $data = $this->setData();
         $collection = $this->about->getData();
         if ($data != null) {
             if ($data['formaction'] === 'test') {
                 $urlOrder = 'https://test-ws.hipay.com/soap/payment-v2?wsdl';
                 $urlCategory = 'https://test-payment.hipay.com/order/list-categories/id/';
             } elseif ($data['formaction'] === 'production') {
                 $urlOrder = 'https://ws.hipay.com/soap/payment-v2?wsdl';
                 $urlCategory = 'https://payment.hipay.com/order/list-categories/id/';
             }
             $getCategory = $this->getCategory(array('url' => $urlCategory . $data['websiteId'], 'debug' => false));
             $urlwebsite = magixcjquery_html_helpersHtml::getUrl() . '/' . $data['iso'] . '/';
             // seturl pour les notifications et process
             $seturl = $this->setUrl();
             if ($getCategory) {
                 // STEP 1 : soap flow options
                 $options = array('compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP, 'cache_wsdl' => WSDL_CACHE_NONE, 'soap_version' => SOAP_1_1, 'encoding' => 'UTF-8', 'exceptions' => true);
                 // STEP 2 : Soap client initialization
                 $client = new SoapClient($urlOrder, $options);
                 //https://test-ws.hipay.com/soap/payment-v2?wsdl
                 // L'interface de paiement sera, par défaut, en français international
                 $setlocal = $data['iso'] . '_' . strtoupper($setParams['locale']);
                 $executionDate = date('c');
                 // STEP 3 : Soap call on confirm method of manual-capture webservice
                 $result = $client->generate(array('parameters' => array('wsLogin' => $data['wsLogin'], 'wsPassword' => $data['wsPassword'], 'websiteId' => $data['websiteId'], 'categoryId' => $getCategory, 'description' => $this->template->getConfigVars('order_on') . ' ' . $collection['name'], 'freeData' => array(array('key' => 'order', 'value' => $setParams['order']), array('key' => 'shipping', 'value' => $setParams['shipping'])), 'currency' => 'EUR', 'amount' => $setParams['amount'], 'rating' => 'ALL', 'locale' => $setlocal, 'customerIpAddress' => $data['customerIpAddress'], 'manualCapture' => '0', 'executionDate' => $executionDate, 'customerEmail' => $setParams['customerEmail'], 'urlCallback' => $urlwebsite . $setParams['plugin'] . $seturl['seturlack'], 'urlAccept' => $urlwebsite . $setParams['plugin'] . $seturl['seturlok'], 'urlCancel' => $urlwebsite . $setParams['plugin'] . $seturl['seturlcancel'], 'urlDecline' => $urlwebsite . $setParams['plugin'] . $seturl['seturlexception'])));
                 //print_r($result);
                 $forms_hipay = '<a href="' . $result->{'generateResult'}->{'redirectUrl'} . '"><img src="https://www.hipaydirect.com/images/i18n/' . $data['iso'] . '/bt_payment_8.png" /></a>';
                 return $forms_hipay;
             }
         }
     } catch (SoapFault $e) {
         magixglobal_model_system::magixlog("SOAP Fault: (faultcode: {$e->faultcode}, faultstring: {$e->faultstring})", $e);
     }
 }