• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

payment/classes/class.ilPurchasePaypal.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00031 include_once './payment/classes/class.ilPaymentObject.php';
00032 include_once './payment/classes/class.ilPaymentShoppingCart.php';
00033 include_once './payment/classes/class.ilPaypalSettings.php';
00034 include_once './payment/classes/class.ilPaymentCoupons.php';
00035 
00036 define('SUCCESS', 0);
00037 define('ERROR_OPENSOCKET', 1);
00038 define('ERROR_WRONG_CUSTOMER', 2);
00039 define('ERROR_NOT_COMPLETED', 3);
00040 define('ERROR_PREV_TRANS_ID', 4);
00041 define('ERROR_WRONG_VENDOR', 5);
00042 define('ERROR_WRONG_ITEMS', 6);
00043 define('ERROR_FAIL', 7);
00044 
00045 class ilPurchasePaypal
00046 {
00047         /*
00048          * id of vendor, admin or trustee
00049          */
00050         var $psc_obj = null;
00051         var $user_obj = null;
00052         var $db = null;
00053 
00054         var $paypalConfig;
00055 
00056         function ilPurchasePaypal(&$user_obj)
00057         {
00058                 global $ilDB,$lng;
00059 
00060                 $this->user_obj =& $user_obj;
00061                 $this->db =& $ilDB;
00062                 $this->lng =& $lng;
00063                 
00064                 $this->coupon_obj = new ilPaymentCoupons($this->user_obj);
00065 
00066                 $this->__initShoppingCartObject();
00067 
00068                 $ppSet = ilPaypalSettings::getInstance();
00069                 $this->paypalConfig = $ppSet->getAll();
00070 
00071                 $this->lng->loadLanguageModule("payment");
00072                 
00073                 if (!is_array($_SESSION["coupons"]["paypal"]))
00074                 {
00075                         $_SESSION["coupons"]["paypal"] = array();
00076                 }
00077         }
00078 
00079         function openSocket()
00080         {
00081                 // post back to PayPal system to validate
00082                 $fp = @fsockopen ($this->paypalConfig["server_host"], 80, $errno, $errstr, 30);
00083                 return $fp;
00084         }
00085 
00086         function checkData($fp)
00087         {
00088                 global $ilUser;
00089 
00090                 // read the post from PayPal system and add 'cmd'
00091                 $req = 'cmd=_notify-synch';
00092 
00093                 $tx_token = $_REQUEST['tx'];            
00094 
00095                 $auth_token = $this->paypalConfig["auth_token"];
00096 
00097                 $req .= "&tx=$tx_token&at=$auth_token";
00098                 $header .= "POST " . $this->paypalConfig["server_path"] . " HTTP/1.0\r\n";
00099                 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
00100                 $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
00101 
00102                 fputs ($fp, $header . $req);
00103                 // read the body data
00104                 $res = '';
00105                 $headerdone = false;
00106                 while (!feof($fp))
00107                 {
00108                         $line = fgets ($fp, 1024);
00109                         if (strcmp($line, "\r\n") == 0)
00110                         {
00111                                 // read the header
00112                                 $headerdone = true;
00113                         }
00114                         else if ($headerdone)
00115                         {
00116                                 // header has been read. now read the contents
00117                                 $res .= $line;
00118                         }
00119                 }
00120                 // parse the data
00121                 $lines = explode("\n", $res);
00122                 $keyarray = array();
00123                 if (strcmp ($lines[0], "SUCCESS") == 0)
00124                 {
00125                         for ($i=1; $i<count($lines);$i++)
00126                         {
00127                                 list($key,$val) = explode("=", $lines[$i]);
00128                                 $keyarray[urldecode($key)] = urldecode($val);
00129                         }
00130 // check customer
00131                         if ($ilUser->getId() != $keyarray["custom"])
00132                         {
00133 #echo "Wrong customer";
00134                                 return ERROR_WRONG_CUSTOMER;
00135                         }
00136 
00137 // check the payment_status is Completed
00138                         if (!in_array($keyarray["payment_status"], array("Completed", "In-Progress", "Pending", "Processed")))
00139                         {
00140 #echo "Not completed";
00141                                 return ERROR_NOT_COMPLETED;
00142                         }
00143 
00144 // check that txn_id has not been previously processed
00145                         if ($this->__checkTransactionId($keyarray["txn_id"]))
00146                         {
00147 #echo "Prev. processed trans. id";
00148                                 return ERROR_PREV_TRANS_ID;
00149                         }
00150 
00151 // check that receiver_email is your Primary PayPal email
00152                         if ($keyarray["receiver_email"] != $this->paypalConfig["vendor"])
00153                         {
00154 #echo "Wrong vendor";
00155                                 return ERROR_WRONG_VENDOR;
00156                         }
00157 
00158 // check that payment_amount/payment_currency are correct
00159                         if (!$this->__checkItems($keyarray))
00160                         {
00161 #echo "Wrong items";
00162                                 return ERROR_WRONG_ITEMS;
00163                         }
00164 
00165                         $bookings = $this->__saveTransaction($keyarray["txn_id"]);
00166                         $this->__sendBill($bookings, $keyarray);
00167                         $_SESSION["coupons"]["paypal"] = array();
00168 
00169                         return SUCCESS;
00170                 }
00171                 else if (strcmp ($lines[0], "FAIL") == 0)
00172                 {
00173                         return ERROR_FAIL;
00174                 }
00175         }
00176 
00177         function __checkTransactionId($a_id)
00178         {
00179                 $query = "SELECT * FROM payment_statistic ".
00180                         "WHERE transaction_extern = '".$a_id."'";
00181 
00182                 $res = $this->db->query($query);
00183 
00184                 return $res->numRows() ? true : false;
00185         }
00186 
00187         function __checkItems($a_array)
00188         {
00189                 $genSet = new ilGeneralSettings();
00190 
00191                 include_once './payment/classes/class.ilPayMethods.php';
00192 
00193 // Wrong currency
00194                 if ($a_array["mc_currency"] != $genSet->get("currency_unit"))
00195                 {
00196                         return false;
00197                 }
00198                 
00199                 $sc = $this->psc_obj->getShoppingCart(PAY_METHOD_PAYPAL);               
00200                 $this->psc_obj->clearCouponItemsSession();
00201 
00202                 if (is_array($sc) &&
00203                         count($sc) > 0)
00204                 {
00205                         for ($i = 0; $i < count($sc); $i++)
00206                         {
00207                                 $items[$i] = array(
00208                                         "name" => $a_array["item_name".($i+1)],
00209                                         "amount" => $a_array["mc_gross_".($i+1)]
00210                                 );                      
00211 
00212                                 if (!empty($_SESSION["coupons"]["paypal"]))
00213                                 {                                                                                       
00214                                         $sc[$i]["math_price"] = (float) $sc[$i]["betrag"];
00215                                                                 
00216                                         $tmp_pobject =& new ilPaymentObject($this->user_obj, $sc[$i]['pobject_id']);    
00217                                                                                                         
00218                                         foreach ($_SESSION["coupons"]["paypal"] as $key => $coupon)
00219                                         {                                       
00220                                                 $this->coupon_obj->setId($coupon["pc_pk"]);
00221                                                 $this->coupon_obj->setCurrentCoupon($coupon);
00222                                                 
00223                                                 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
00224                                                 {
00225                                                         $_SESSION["coupons"]["paypal"][$key]["total_objects_coupon_price"] += (float) $sc[$i]["betrag"];
00226                                                         $_SESSION["coupons"]["paypal"][$key]["items"][] = $sc[$i];
00227                                                 }                                                               
00228                                         }
00229                                         
00230                                         unset($tmp_pobject);
00231                                 }                               
00232                         }
00233                         
00234                         $coupon_discount_items = $this->psc_obj->calcDiscountPrices($_SESSION["coupons"]["paypal"]);
00235 
00236                         $found = 0;
00237                         $total = 0;
00238                         for ($i = 0; $i < count($sc); $i++)
00239                         {                       
00240                                 if (array_key_exists($sc[$i]["pobject_id"], $coupon_discount_items))
00241                                 {
00242                                         $sc[$i]["betrag"] = round($coupon_discount_items[$sc[$i]["pobject_id"]]["discount_price"], 2);                          
00243                                         if ($sc[$i]["betrag"] < 0) $sc[$i]["betrag"] = 0.0;     
00244                                 }                               
00245 
00246                                 for ($j = 0; $j < count($items); $j++)
00247                                 {
00248                                         if (substr($items[$j]["name"], 0, strlen($sc[$i]["obj_id"])+2) == "[".$sc[$i]["obj_id"]."]" &&
00249                                                 $items[$j]["amount"] == $sc[$i]["betrag"])
00250                                         {
00251                                                 $total += $items[$j]["amount"];
00252                                                 $found++;
00253                                         }
00254                                 }
00255                         }
00256 
00257 // The number of items, the items themselves and their amounts and the total amount correct
00258                         if (number_format($total, 2, ".", "") == $a_array["mc_gross"] &&
00259                                 $found == count($sc))
00260                         {
00261                                 return true;
00262                         }
00263                 }
00264                 
00265                 return false;
00266         }
00267 
00268         function __saveTransaction($a_id)
00269         {
00270                 global $ilias, $ilUser, $ilObjDataCache;
00271                 
00272                 $sc = $this->psc_obj->getShoppingCart(PAY_METHOD_PAYPAL);
00273                 $this->psc_obj->clearCouponItemsSession();              
00274 
00275                 if (is_array($sc) &&
00276                         count($sc) > 0)
00277                 {
00278                         include_once './payment/classes/class.ilPaymentBookings.php';
00279                         $book_obj =& new ilPaymentBookings($this->usr_obj);
00280                         
00281                         for ($i = 0; $i < count($sc); $i++)
00282                         {
00283                                 if (!empty($_SESSION["coupons"]["paypal"]))
00284                                 {                                                                       
00285                                         $sc[$i]["math_price"] = (float) $sc[$i]["betrag"];
00286                                                                 
00287                                         $tmp_pobject =& new ilPaymentObject($this->user_obj, $sc[$i]['pobject_id']);    
00288                                                                                                         
00289                                         foreach ($_SESSION["coupons"]["paypal"] as $key => $coupon)
00290                                         {                                       
00291                                                 $this->coupon_obj->setId($coupon["pc_pk"]);
00292                                                 $this->coupon_obj->setCurrentCoupon($coupon);
00293                                                 
00294                                                 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
00295                                                 {
00296                                                         $_SESSION["coupons"]["paypal"][$key]["total_objects_coupon_price"] += (float) $sc[$i]["betrag"];
00297                                                         $_SESSION["coupons"]["paypal"][$key]["items"][] = $sc[$i];
00298                                                 }                                                               
00299                                         }
00300                                         
00301                                         unset($tmp_pobject);
00302                                 }
00303                         }
00304                         
00305                         $coupon_discount_items = $this->psc_obj->calcDiscountPrices($_SESSION["coupons"]["paypal"]);                    
00306 
00307                         for ($i = 0; $i < count($sc); $i++)
00308                         {
00309                                 $pobjectData = ilPaymentObject::_getObjectData($sc[$i]["pobject_id"]);
00310                                 $pobject =& new ilPaymentObject($this->user_obj,$sc[$i]['pobject_id']);
00311 
00312                                 $inst_id_time = $ilias->getSetting('inst_id').'_'.$ilUser->getId().'_'.substr((string) time(),-3);
00313                                 
00314                                 $price = $sc[$i]["betrag"];
00315                                 $bonus = 0.0;
00316                                 
00317                                 if (array_key_exists($sc[$i]["pobject_id"], $coupon_discount_items))
00318                                 {
00319                                         $bonus = $coupon_discount_items[$sc[$i]["pobject_id"]]["math_price"] - $coupon_discount_items[$sc[$i]["pobject_id"]]["discount_price"]; 
00320                                 }                               
00321 
00322                                 $book_obj->setTransaction($inst_id_time.substr(md5(uniqid(rand(), true)), 0, 4));
00323                                 $book_obj->setPobjectId($sc[$i]["pobject_id"]);
00324                                 $book_obj->setCustomerId($ilUser->getId());
00325                                 $book_obj->setVendorId($pobjectData["vendor_id"]);
00326                                 $book_obj->setPayMethod($pobjectData["pay_method"]);
00327                                 $book_obj->setOrderDate(time());
00328                                 $book_obj->setDuration($sc[$i]["dauer"]);
00329                                 $book_obj->setPrice($sc[$i]["betrag_string"]);
00330                                 $book_obj->setDiscount($bonus > 0 ? ilPaymentPrices::_getPriceStringFromAmount($bonus * (-1)) : "");
00331                                 $book_obj->setPayed(1);
00332                                 $book_obj->setAccess(1);
00333                                 $book_obj->setVoucher('');
00334                                 $book_obj->setTransactionExtern($a_id);
00335                                 
00336                                 $booking_id = $book_obj->add();
00337                                 
00338                                 if (!empty($_SESSION["coupons"]["paypal"]) && $booking_id)
00339                                 {                               
00340                                         foreach ($_SESSION["coupons"]["paypal"] as $coupon)
00341                                         {       
00342                                                 $this->coupon_obj->setId($coupon["pc_pk"]);                             
00343                                                 $this->coupon_obj->setCurrentCoupon($coupon);                                                                                                                           
00344                                                         
00345                                                 if ($this->coupon_obj->isObjectAssignedToCoupon($pobject->getRefId()))
00346                                                 {                                               
00347                                                         $this->coupon_obj->addCouponForBookingId($booking_id);                                                                                                                                                                  
00348                                                 }                               
00349                                         }                       
00350                                 }
00351         
00352                                 unset($booking_id);
00353                                 unset($pobject);                                
00354 
00355                                 $obj_id = $ilObjDataCache->lookupObjId($pobjectData["ref_id"]);
00356                                 $obj_type = $ilObjDataCache->lookupType($obj_id);
00357                                 $obj_title = $ilObjDataCache->lookupTitle($obj_id);
00358 
00359                                 $bookings["list"][] = array(
00360                                         "type" => $obj_type,
00361                                         "title" => "[".$obj_id."]: " . $obj_title,
00362                                         "duration" => $sc[$i]["dauer"],
00363                                         "price" => $sc[$i]["betrag_string"],
00364                                         "betrag" => $sc[$i]["betrag"]
00365                                 );
00366 
00367                                 $total += $sc[$i]["betrag"];
00368 
00369                                 
00370                                 if ($sc[$i]["psc_id"]) $this->psc_obj->delete($sc[$i]["psc_id"]);                               
00371                         }
00372                         
00373                         if (!empty($_SESSION["coupons"]["paypal"]))
00374                         {                               
00375                                 foreach ($_SESSION["coupons"]["paypal"] as $coupon)
00376                                 {       
00377                                         $this->coupon_obj->setId($coupon["pc_pk"]);                             
00378                                         $this->coupon_obj->setCurrentCoupon($coupon);
00379                                         $this->coupon_obj->addTracking();                       
00380                                 }                       
00381                         }
00382                 }
00383 
00384                 $bookings["total"] = $total;
00385                 $bookings["vat"] = $this->psc_obj->getVat($total);
00386 
00387                 return $bookings;
00388         }
00389 
00390         function __sendBill($bookings, $a_array)
00391         {
00392                 global $ilUser, $ilias;
00393 
00394                 $transaction = $a_array["txn_id"];
00395 
00396                 include_once './classes/class.ilTemplate.php';
00397                 include_once "./Services/Utilities/classes/class.ilUtil.php";
00398                 include_once './payment/classes/class.ilGeneralSettings.php';
00399                 include_once './payment/classes/class.ilPaymentShoppingCart.php';
00400                 include_once 'Services/Mail/classes/class.ilMimeMail.php';
00401 
00402                 $genSet = new ilGeneralSettings();
00403 
00404                 $tpl = new ilTemplate("./payment/templates/default/tpl.pay_paypal_bill.html", true, true, true);
00405   
00406                 $tpl->setVariable("VENDOR_ADDRESS", nl2br(utf8_decode($genSet->get("address"))));
00407                 $tpl->setVariable("VENDOR_ADD_INFO", nl2br(utf8_decode($genSet->get("add_info"))));
00408                 $tpl->setVariable("VENDOR_BANK_DATA", nl2br(utf8_decode($genSet->get("bank_data"))));
00409                 $tpl->setVariable("TXT_BANK_DATA", utf8_decode($this->lng->txt("pay_bank_data")));
00410 
00411 #               $tpl->setVariable("CUSTOMER_FIRSTNAME", utf8_decode($ilUser->getFirstname()));
00412 #               $tpl->setVariable("CUSTOMER_LASTNAME", utf8_decode($ilUser->getLastname()));
00413 #               $tpl->setVariable("CUSTOMER_STREET", utf8_decode($ilUser->getStreet()));
00414 #               $tpl->setVariable("CUSTOMER_ZIPCODE", utf8_decode($ilUser->getZipcode()));
00415 #               $tpl->setVariable("CUSTOMER_CITY", utf8_decode($ilUser->getCity()));
00416 #               $tpl->setVariable("CUSTOMER_COUNTRY", utf8_decode($ilUser->getCountry()));
00417                 $tpl->setVariable("CUSTOMER_FIRSTNAME", $a_array["first_name"]);
00418                 $tpl->setVariable("CUSTOMER_LASTNAME", $a_array["last_name"]);
00419                 $tpl->setVariable("CUSTOMER_STREET", $a_array["address_street"]);
00420                 $tpl->setVariable("CUSTOMER_ZIPCODE", $a_array["address_zip"]);
00421                 $tpl->setVariable("CUSTOMER_CITY", $a_array["address_city"]);
00422                 $tpl->setVariable("CUSTOMER_COUNTRY", $a_array["address_country"]);
00423 
00424                 $tpl->setVariable("BILL_NO", $transaction);
00425                 $tpl->setVariable("DATE", date("d.m.Y"));
00426 
00427                 $tpl->setVariable("TXT_BILL", utf8_decode($this->lng->txt("pays_bill")));
00428                 $tpl->setVariable("TXT_BILL_NO", utf8_decode($this->lng->txt("pay_bill_no")));
00429                 $tpl->setVariable("TXT_DATE", utf8_decode($this->lng->txt("date")));
00430 
00431                 $tpl->setVariable("TXT_ARTICLE", utf8_decode($this->lng->txt("pay_article")));
00432                 $tpl->setVariable("TXT_PRICE", utf8_decode($this->lng->txt("price_a")));
00433 
00434                 for ($i = 0; $i < count($bookings["list"]); $i++)
00435                 {
00436                         $tmp_pobject =& new ilPaymentObject($this->user_obj, $bookings["list"][$i]['pobject_id']);
00437                         
00438                         $assigned_coupons = '';                                 
00439                         if (!empty($_SESSION["coupons"]["paypal"]))
00440                         {                                                                                       
00441                                 foreach ($_SESSION["coupons"]["paypal"] as $key => $coupon)
00442                                 {
00443                                         $this->coupon_obj->setId($coupon["pc_pk"]);
00444                                         $this->coupon_obj->setCurrentCoupon($coupon);
00445 
00446                                         if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
00447                                         {
00448                                                 $assigned_coupons .= '<br />' . $this->lng->txt('paya_coupons_coupon') . ': ' . $coupon["pcc_code"];
00449                                         }
00450                                 }
00451                         }
00452                         
00453                         $tpl->setCurrentBlock("loop");
00454                         $tpl->setVariable("LOOP_OBJ_TYPE", utf8_decode($this->lng->txt($bookings["list"][$i]["type"])));
00455                         $tpl->setVariable("LOOP_TITLE", utf8_decode($bookings["list"][$i]["title"]) . $assigned_coupons);
00456                         $tpl->setVariable("LOOP_TXT_ENTITLED_RETRIEVE", utf8_decode($this->lng->txt("pay_entitled_retrieve")));
00457                         $tpl->setVariable("LOOP_DURATION", $bookings["list"][$i]["duration"] . " " . utf8_decode($this->lng->txt("paya_months")));
00458                         $tpl->setVariable("LOOP_PRICE", $bookings["list"][$i]["price"]);
00459                         $tpl->parseCurrentBlock("loop");
00460                         
00461                         unset($tmp_pobject);
00462                 }
00463                 
00464                 if (!empty($_SESSION["coupons"]["paypal"]))
00465                 {
00466                         if (count($items = $bookings["list"]))
00467                         {
00468                                 $sub_total_amount = $bookings["total"];                                                 
00469 
00470                                 foreach ($_SESSION["coupons"]["paypal"] as $coupon)
00471                                 {
00472                                         $this->coupon_obj->setId($coupon["pc_pk"]);
00473                                         $this->coupon_obj->setCurrentCoupon($coupon);                                   
00474                                         
00475                                         $total_object_price = 0.0;
00476                                         $current_coupon_bonus = 0.0;
00477                                         
00478                                         foreach ($bookings["list"] as $item)
00479                                         {
00480                                                 $tmp_pobject =& new ilPaymentObject($this->user_obj, $item['pobject_id']);                                              
00481                                                 
00482                                                 if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId()))
00483                                                 {                                               
00484                                                         $total_object_price += $item["betrag"];                                                                                                                                                                 
00485                                                 }                       
00486                                                 
00487                                                 unset($tmp_pobject);
00488                                         }                                       
00489                                         
00490                                         $current_coupon_bonus = $this->coupon_obj->getCouponBonus($total_object_price); 
00491 
00492                                         $bookings["total"] += $current_coupon_bonus * (-1);
00493                                         
00494                                         $tpl->setCurrentBlock("cloop");
00495                                         $tpl->setVariable("TXT_COUPON", utf8_decode($this->lng->txt("paya_coupons_coupon") . " " . $coupon["pcc_code"]));
00496                                         $tpl->setVariable("BONUS", number_format($current_coupon_bonus * (-1), 2, ',', '.') . " " . $genSet->get("currency_unit"));
00497                                         $tpl->parseCurrentBlock();
00498                                 }
00499                                 
00500                                 $tpl->setVariable("TXT_SUBTOTAL_AMOUNT", utf8_decode($this->lng->txt("pay_bmf_subtotal_amount")));
00501                                 $tpl->setVariable("SUBTOTAL_AMOUNT", number_format($sub_total_amount, 2, ",", ".") . " " . $genSet->get("currency_unit"));
00502                         }
00503                 }
00504                 
00505                 if ($bookings["total"] < 0)
00506                 {                       
00507                         $bookings["total"] = 0.0;
00508                         $bookings["vat"] = 0.0;
00509                 }
00510                 else
00511                 {
00512                         $bookings["vat"] = $this->psc_obj->getVat($bookings["total"]);
00513                 }
00514 
00515                 $tpl->setVariable("TXT_TOTAL_AMOUNT", utf8_decode($this->lng->txt("pay_bmf_total_amount")));
00516                 $tpl->setVariable("TOTAL_AMOUNT", number_format($bookings["total"], 2, ",", ".") . " " . $genSet->get("currency_unit"));
00517                 if ($bookings["vat"] > 0)
00518                 {
00519                         $tpl->setVariable("VAT", number_format($bookings["vat"], 2, ",", ".") . " " . $genSet->get("currency_unit"));
00520                         $tpl->setVariable("TXT_VAT", $genSet->get("vat_rate") . "% " . utf8_decode($this->lng->txt("pay_bmf_vat_included")));
00521                 }
00522 
00523                 $tpl->setVariable("TXT_PAYMENT_TYPE", utf8_decode($this->lng->txt("pay_payed_paypal")));
00524 
00525                 if (!@file_exists($genSet->get("pdf_path")))
00526                 {
00527                         ilUtil::makeDir($genSet->get("pdf_path"));
00528                 }
00529 
00530                 if (@file_exists($genSet->get("pdf_path")))
00531                 {
00532                         ilUtil::html2pdf($tpl->get(), $genSet->get("pdf_path") . "/" . $transaction . ".pdf");
00533                 }
00534 
00535                 if (@file_exists($genSet->get("pdf_path") . "/" . $transaction . ".pdf") &&
00536                         $ilUser->getEmail() != "" &&
00537                         $ilias->getSetting("admin_email") != "")
00538                 {
00539                         $m= new ilMimeMail; // create the mail
00540                         $m->From( $ilias->getSetting("admin_email") );
00541                         $m->To( $ilUser->getEmail() );
00542                         $m->Subject( $this->lng->txt("pay_message_subject") );  
00543                         $message = $this->lng->txt("pay_message_hello") . " " . $ilUser->getFirstname() . " " . $ilUser->getLastname() . ",\n\n";
00544                         $message .= $this->lng->txt("pay_message_thanks") . "\n\n";
00545                         $message .= $this->lng->txt("pay_message_attachment") . "\n\n";
00546                         $message .= $this->lng->txt("pay_message_regards") . "\n\n";
00547                         $message .= strip_tags($genSet->get("address"));
00548                         $m->Body( $message );   // set the body
00549                         $m->Attach( $genSet->get("pdf_path") . "/" . $transaction . ".pdf", "application/pdf" ) ;       // attach a file of type image/gif
00550                         $m->Send();     // send the mail
00551                 }
00552 
00553                 @unlink($genSet->get("pdf_path") . "/" . $transaction . ".html");
00554                 @unlink($genSet->get("pdf_path") . "/" . $transaction . ".pdf");
00555 
00556         }
00557 
00558         function __initShoppingCartObject()
00559         {
00560                 $this->psc_obj =& new ilPaymentShoppingCart($this->user_obj);
00561         }
00562 
00563         function __getCountries()
00564         {
00565                 global $lng;
00566 
00567                 $lng->loadLanguageModule("meta");
00568 
00569                 $cntcodes = array ("DE","ES","FR","GB","AT","CH","AF","AL","DZ","AS","AD","AO",
00570                         "AI","AQ","AG","AR","AM","AW","AU","AT","AZ","BS","BH","BD","BB","BY",
00571                         "BE","BZ","BJ","BM","BT","BO","BA","BW","BV","BR","IO","BN","BG","BF",
00572                         "BI","KH","CM","CA","CV","KY","CF","TD","CL","CN","CX","CC","CO","KM",
00573                         "CG","CK","CR","CI","HR","CU","CY","CZ","DK","DJ","DM","DO","TP","EC",
00574                         "EG","SV","GQ","ER","EE","ET","FK","FO","FJ","FI","FR","FX","GF","PF",
00575                         "TF","GA","GM","GE","DE","GH","GI","GR","GL","GD","GP","GU","GT","GN",
00576                         "GW","GY","HT","HM","HN","HU","IS","IN","ID","IR","IQ","IE","IL","IT",
00577                         "JM","JP","JO","KZ","KE","KI","KP","KR","KW","KG","LA","LV","LB","LS",
00578                         "LR","LY","LI","LT","LU","MO","MK","MG","MW","MY","MV","ML","MT","MH",
00579                         "MQ","MR","MU","YT","MX","FM","MD","MC","MN","MS","MA","MZ","MM","NA",
00580                         "NR","NP","NL","AN","NC","NZ","NI","NE","NG","NU","NF","MP","NO","OM",
00581                         "PK","PW","PA","PG","PY","PE","PH","PN","PL","PT","PR","QA","RE","RO",
00582                         "RU","RW","KN","LC","VC","WS","SM","ST","SA","CH","SN","SC","SL","SG",
00583                         "SK","SI","SB","SO","ZA","GS","ES","LK","SH","PM","SD","SR","SJ","SZ",
00584                         "SE","SY","TW","TJ","TZ","TH","TG","TK","TO","TT","TN","TR","TM","TC",
00585                         "TV","UG","UA","AE","GB","UY","US","UM","UZ","VU","VA","VE","VN","VG",
00586                         "VI","WF","EH","YE","ZR","ZM","ZW");
00587                 $cntrs = array();
00588                 foreach($cntcodes as $cntcode)
00589                 {
00590                         $cntrs[$cntcode] = $lng->txt("meta_c_".$cntcode);
00591                 }
00592                 asort($cntrs);
00593                 return $cntrs;
00594         }
00595 
00596         function __getCountryCode($value = "")
00597         {
00598                 $countries = $this->__getCountries();
00599                 foreach($countries as $code => $text)
00600                 {
00601                         if ($text == $value)
00602                         {
00603                                 return $code;
00604                         }
00605                 }
00606                 return;
00607         }
00608 
00609         function __getCountryName($value = "")
00610         {
00611                 $countries = $this->__getCountries();
00612                 return $countries[$value];
00613         }
00614 
00615 }
00616 ?>

Generated on Fri Dec 13 2013 17:56:55 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1