14 include_once 
'./Services/Payment/classes/class.ilInvoiceNumberPlaceholdersPropertyGUI.php';
 
   15 include_once 
'./Services/Payment/classes/class.ilPayMethods.php';
 
   16 include_once 
'./Services/Payment/classes/class.ilPurchaseBaseGUI.php';
 
   19 define(
'ERROR_OPENSOCKET', 1);
 
   20 define(
'ERROR_WRONG_CUSTOMER', 2);
 
   21 define(
'ERROR_NOT_COMPLETED', 3);
 
   22 define(
'ERROR_PREV_TRANS_ID', 4);
 
   23 define(
'ERROR_WRONG_VENDOR', 5);
 
   24 define(
'ERROR_WRONG_ITEMS', 6);
 
   25 define(
'ERROR_FAIL', 7);
 
   45                 $this->paypalConfig = $ppSet->getAll();
 
   53                 $fp = @fsockopen (
$path = $this->paypalConfig[
"server_host"], 80, $errno, $errstr, 30);
 
   62                 $auth_token = $this->paypalConfig[
"auth_token"];
 
   65                 $req = 
'cmd=_notify-synch';
 
   71                 $req .= 
"&tx=$tx_token&at=$auth_token";
 
   75                 $submiturl = 
'https://'.$this->paypalConfig[
"server_host"].$this->paypalConfig[
"server_path"];
 
   78                 curl_setopt($ch, CURLOPT_URL,$submiturl);
 
   79                 curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
 
   80                 curl_setopt($ch, CURLOPT_POST, 1);
 
   81                 curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
 
   82                 curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/x-www-form-urlencoded", 
"Content-Length: " . strlen($req)));
 
   83                 curl_setopt($ch, CURLOPT_HEADER , 0);  
 
   84                 curl_setopt($ch, CURLOPT_VERBOSE, 1);
 
   85                 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
 
   86                 curl_setopt($ch, CURLOPT_TIMEOUT, 30);
 
   94                 $lines = explode(
"\n", 
$result);
 
   97                 $keyarray[0] = $lines[0]; 
 
   99                 if (strcmp ($lines[0], 
"SUCCESS") == 0)
 
  101                         for ($i=1; $i<count($lines);$i++)
 
  103                                 list($key,$val) = explode(
"=", $lines[$i]);
 
  104                                 $keyarray[urldecode($key)] = urldecode($val);
 
  107                         if ($ilUser->getId() != $keyarray[
"custom"]
 
  108                         && 
$_SESSION[
'shop_user_id'] != $keyarray[
'custom'])
 
  110 #echo "Wrong customer"; 
  115                         if (!in_array($keyarray[
"payment_status"], array(
"Completed", 
"In-Progress", 
"Pending", 
"Processed")))
 
  117 #echo "Not completed"; 
  124                                 if(
$_SESSION[
'tmp_transaction'][
'result'] == 
'success' 
  125                                 && 
$_SESSION[
'tmp_transaction'][
'tx_id'] == $keyarray[
"txn_id"])
 
  132 #echo "Prev. processed trans. id"; 
  137                         if ($keyarray[
"receiver_email"] != $this->paypalConfig[
"vendor"])
 
  171                         $external_data = array();
 
  172                         $external_data[
'transaction_extern'] = $keyarray[
"txn_id"];
 
  173                         $external_data[
'street'] = $keyarray[
"address_street"];
 
  174                         $external_data[
'zipcode'] = $keyarray[
"address_zip"];
 
  175                         $external_data[
'city'] = $keyarray[
"address_city"];
 
  176                         $external_data[
'country'] = $keyarray[
"address_country"];
 
  180                         $_SESSION[
"coupons"][
"paypal"] = array();
 
  181                         $_SESSION[
'tmp_transaction'][
'result'] = 
'success';
 
  185                 else if (strcmp ($lines[0], 
"FAIL") == 0)
 
  199                 $res = $ilDB->queryF(
'SELECT * FROM payment_statistic 
  200                         WHERE transaction_extern = %s',
 
  201                         array(
'text'), array($a_id));
 
  203                 return $res->numRows() ? 
true : 
false;
 
  211                 if ($a_array[
"mc_currency"] != $genSet->get(
"currency_unit"))
 
  216                 $sc = $this->psc_obj->getShoppingCart($this->pay_method);               
 
  217                 $this->psc_obj->clearCouponItemsSession();
 
  219                 if (is_array($sc) && count($sc) > 0)
 
  221                         for ($i = 0; $i < count($sc); $i++)
 
  224                                         "name" => $a_array[
"item_name".($i+1)],
 
  225                                         "amount" => $a_array[
"mc_gross_".($i+1)]
 
  228                                 if (!empty(
$_SESSION[
"coupons"][
"paypal"]))
 
  230                                         $sc[$i][
"math_price"] = (float) $sc[$i][
"price"];
 
  232                                         $tmp_pobject = 
new ilPaymentObject($this->user_obj, $sc[$i][
'pobject_id']);             
 
  234                                         foreach (
$_SESSION[
"coupons"][
"paypal"] as $key => $coupon)
 
  236                                                 $this->coupon_obj->setId($coupon[
"pc_pk"]);
 
  237                                                 $this->coupon_obj->setCurrentCoupon($coupon);
 
  239                                                 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
 
  241                                                         $_SESSION[
"coupons"][
"paypal"][$key][
"total_objects_coupon_price"] += (float) $sc[$i][
"price"];
 
  242                                                         $_SESSION[
"coupons"][
"paypal"][$key][
"items"][] = $sc[$i];
 
  249                         $coupon_discount_items = $this->psc_obj->calcDiscountPrices(
$_SESSION[
"coupons"][
"paypal"]);
 
  253                         for ($i = 0; $i < count($sc); $i++)
 
  255                                 if (array_key_exists($sc[$i][
"pobject_id"], $coupon_discount_items))
 
  257                                         $sc[$i][
"price"] = round($coupon_discount_items[$sc[$i][
"pobject_id"]][
"discount_price"], 2);                           
 
  258                                         if ($sc[$i][
"price"] < 0) $sc[$i][
"price"] = 0.0;       
 
  261                                 for ($j = 0; $j < count($items); $j++)
 
  263                                         if (substr($items[$j][
"name"], 0, strlen($sc[$i][
"obj_id"])+2) == 
"[".$sc[$i][
"obj_id"].
"]" &&
 
  264                                                 $items[$j][
"amount"] == $sc[$i][
"price"])
 
  266                                                 $total += $items[$j][
"amount"];
 
  273                         if (number_format(
$total, 2, 
".", 
"") == $a_array[
"mc_gross"] &&
 
  274                                 $found == count($sc))